I have a method along the lines of
volatile boolean mIsDoingStuff = false;
void doStuff() {
Choreographer.getInstance().postFrameCallback(this);
mIsDoingStuff = true;
}
@Override
public void doFrame(long frameTimeNanos) {
...
...
Choreographer.getInstance().postFrameCallback(this);
}
Now, I want to write a test along the lines of
@Test
public void testDoingStuff() {
object.doStuff()
assertThat(object.isDoingStuff()).isTrue();
}
This never works in the test because the postFrameCallback
executes sequentially calling doFrame()
over and over again, never hitting mIsDoingStuff = true
. After the doFrame()
calls end is when mIsDoingStuff
gets set to true.
I'd like to test this so that I can call doStuff()
, verify mIsDoingStuff = true
, then call stopDoingStuff()
and verify that mIsDoingStuff = false
, which means I'd like to verify values when all the postFrameCallbacks are executing. How do I do this?
Aucun commentaire:
Enregistrer un commentaire