Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6941f122 authored by Wilson Wu's avatar Wilson Wu
Browse files

Attempt to fix testShowImeCold flake

The IME animation may fail to start during
the test flow. Have a retry mechanism when
it happened to prevent the test failure.

Bug: 253363101
Test: atest ImePerfTest#testShowImeCold
Change-Id: Iec28c897e70e37d6ad3a682e4e564b8b8040bf3d
parent 38838912
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -245,7 +245,9 @@ public class ImePerfTest extends ImePerfTestBase
        }

        long measuredTimeNs = 0;
        while (state.keepRunning(measuredTimeNs)) {
        boolean shouldRetry = false;
        while (shouldRetry || state.keepRunning(measuredTimeNs)) {
            shouldRetry = false;
            killBaselineIme();
            try (ImeSession imeSession = new ImeSession(BaselineIme.getName(
                    getInstrumentation().getContext()))) {
@@ -268,6 +270,14 @@ public class ImePerfTest extends ImePerfTestBase
                });

                measuredTimeNs = waitForAnimationStart(latchStart, startTime);

                if (measuredTimeNs == ANIMATION_NOT_STARTED) {
                    // Animation didn't start within timeout,
                    // retry for more samples.
                    // TODO(b/264722663): Investigate the animation start failure reason.
                    shouldRetry = true;
                    Log.w(TAG, "Insets animation didn't start within timeout.");
                }
                mActivityRule.finishActivity();
            }
        }