De-flake testSystemDrivenInsetsAnimationLoggingListener_onReady
Test: atest InsetsControllerTest#testSystemDrivenInsetsAnimationLoggingListener_onReady
Fixes: 270547415
Change-Id: Ie72d5b5c538faa038a58033887716bdd870f35fa
Merged-In: Ie72d5b5c538faa038a58033887716bdd870f35fa
(cherry picked from commit 8e011cea51)
This commit is contained in:
committed by
Austin Borger
parent
8064923875
commit
c3dc5d5857
@@ -237,17 +237,22 @@ public class InsetsControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSystemDrivenInsetsAnimationLoggingListener_onReady() {
|
public void testSystemDrivenInsetsAnimationLoggingListener_onReady() {
|
||||||
|
var loggingListener = mock(WindowInsetsAnimationControlListener.class);
|
||||||
|
|
||||||
prepareControls();
|
prepareControls();
|
||||||
// only the original thread that created view hierarchy can touch its views
|
// only the original thread that created view hierarchy can touch its views
|
||||||
InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
|
InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
|
||||||
WindowInsetsAnimationControlListener loggingListener =
|
|
||||||
mock(WindowInsetsAnimationControlListener.class);
|
|
||||||
mController.setSystemDrivenInsetsAnimationLoggingListener(loggingListener);
|
mController.setSystemDrivenInsetsAnimationLoggingListener(loggingListener);
|
||||||
mController.getSourceConsumer(ITYPE_IME).onWindowFocusGained(true);
|
mController.getSourceConsumer(ITYPE_IME).onWindowFocusGained(true);
|
||||||
// since there is no focused view, forcefully make IME visible.
|
// since there is no focused view, forcefully make IME visible.
|
||||||
mController.show(Type.ime(), true /* fromIme */);
|
mController.show(WindowInsets.Type.ime(), true /* fromIme */);
|
||||||
verify(loggingListener).onReady(notNull(), anyInt());
|
// When using the animation thread, this must not invoke onReady()
|
||||||
|
mViewRoot.getView().getViewTreeObserver().dispatchOnPreDraw();
|
||||||
});
|
});
|
||||||
|
// Wait for onReady() being dispatched on the animation thread.
|
||||||
|
InsetsAnimationThread.get().getThreadHandler().runWithScissors(() -> {}, 500);
|
||||||
|
|
||||||
|
verify(loggingListener).onReady(notNull(), anyInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user