summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Adrian Roos <roosa@google.com> 2023-02-23 14:22:47 +0000
committer Adrian Roos <roosa@google.com> 2023-02-23 14:28:50 +0000
commit8e011cea5123b36c1e9ea848fdf1c07409fff8fc (patch)
tree93fae080ae35192bbd7e645de99e67d678a99e8e
parent37ea5f6833cce219c3189a19594f7788a6be4a50 (diff)
De-flake testSystemDrivenInsetsAnimationLoggingListener_onReady
Test: atest InsetsControllerTest#testSystemDrivenInsetsAnimationLoggingListener_onReady Fixes: 270547415 Change-Id: Ie72d5b5c538faa038a58033887716bdd870f35fa
-rw-r--r--core/tests/coretests/src/android/view/InsetsControllerTest.java11
1 files changed, 8 insertions, 3 deletions
diff --git a/core/tests/coretests/src/android/view/InsetsControllerTest.java b/core/tests/coretests/src/android/view/InsetsControllerTest.java
index ca1367a710ec..06920524acfc 100644
--- a/core/tests/coretests/src/android/view/InsetsControllerTest.java
+++ b/core/tests/coretests/src/android/view/InsetsControllerTest.java
@@ -248,17 +248,22 @@ public class InsetsControllerTest {
@Test
public void testSystemDrivenInsetsAnimationLoggingListener_onReady() {
+ var loggingListener = mock(WindowInsetsAnimationControlListener.class);
+
prepareControls();
// only the original thread that created view hierarchy can touch its views
InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
- WindowInsetsAnimationControlListener loggingListener =
- mock(WindowInsetsAnimationControlListener.class);
mController.setSystemDrivenInsetsAnimationLoggingListener(loggingListener);
mController.getSourceConsumer(mImeSource).onWindowFocusGained(true);
// since there is no focused view, forcefully make IME visible.
mController.show(WindowInsets.Type.ime(), true /* fromIme */, null /* statsToken */);
- 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