diff options
| author | 2023-02-28 13:03:05 +0000 | |
|---|---|---|
| committer | 2023-02-28 13:03:05 +0000 | |
| commit | b436b2f18361d7bea11de107a0e2d7b26cc8afcb (patch) | |
| tree | 8f5de5525daa33a74a20907aebe9e91d714e5bc3 | |
| parent | 236f36de43d85d03ce0648e70af1ca06373248a6 (diff) | |
| parent | 8e011cea5123b36c1e9ea848fdf1c07409fff8fc (diff) | |
Merge "De-flake testSystemDrivenInsetsAnimationLoggingListener_onReady" into udc-dev
| -rw-r--r-- | core/tests/coretests/src/android/view/InsetsControllerTest.java | 11 |
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 |