From 053f5910cb562d55927c2d4a861d545e78c76757 Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Thu, 13 Oct 2022 21:31:06 +0800 Subject: [PATCH] Attempt to reduce flakiness of testDisableRotationCheckForPhone The request setOrientationLeft() is async that puts the target rotation to setting. So the actual display rotation change may happen when executing goHome(). Then the swipe gesture may be interrupted that causes the test to fail. Add a condition to wait for leaving natural orientation change before calling goHome(). Also reorder and simplify the way to start test activity to reduce execution time. Bug: 253290379 Test: TaplTestsQuickstep#testDisableRotationCheckForPhone Change-Id: I881d6f666c98fd3fe601b874adb0d14122bff2b7 --- .../com/android/quickstep/TaplTestsQuickstep.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java index 38007d575c..156ff1a5e5 100644 --- a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java +++ b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java @@ -33,13 +33,13 @@ import androidx.test.uiautomator.Until; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; -import com.android.launcher3.tapl.AllApps; import com.android.launcher3.tapl.LaunchedAppState; import com.android.launcher3.tapl.LauncherInstrumentation.NavigationModel; import com.android.launcher3.tapl.Overview; import com.android.launcher3.tapl.OverviewActions; import com.android.launcher3.tapl.OverviewTask; import com.android.launcher3.ui.TaplTestsLauncher3; +import com.android.launcher3.util.Wait; import com.android.launcher3.util.rule.ScreenRecordRule.ScreenRecord; import com.android.quickstep.NavigationModeSwitchRule.NavigationModeSwitch; import com.android.quickstep.views.RecentsView; @@ -437,14 +437,10 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest { try { mLauncher.setExpectedRotationCheckEnabled(false); mLauncher.setEnableRotation(false); - final AllApps allApps = mLauncher.getWorkspace().switchToAllApps(); - allApps.freeze(); - try { - allApps.getAppIcon("TestActivity7").launch(getAppPackageName()); - } finally { - allApps.unfreeze(); - } mLauncher.getDevice().setOrientationLeft(); + startTestActivity(7); + Wait.atMost("Device should not be in natural orientation", + () -> !mDevice.isNaturalOrientation(), DEFAULT_UI_TIMEOUT, mLauncher); mLauncher.goHome(); } finally { mLauncher.setExpectedRotationCheckEnabled(true);