From 09ce192b4e87d394a6d47bf486ebe5b4cce31c7c Mon Sep 17 00:00:00 2001 From: vadimt Date: Mon, 4 Nov 2019 18:38:18 -0800 Subject: [PATCH] Not treating "Screen is empty" as an anomaly in NavigationModeSwitchRule It's an acceptable state when Launcher just starts under instrumentation. Change-Id: Ia6eb2550effbd9236bb955e0c0e04416fc5fa506 --- .../com/android/quickstep/NavigationModeSwitchRule.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java b/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java index 5158939383..fa4c7b9fa1 100644 --- a/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java +++ b/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java @@ -30,6 +30,7 @@ import android.content.Context; import android.content.pm.PackageManager; import android.util.Log; +import androidx.test.uiautomator.By; import androidx.test.uiautomator.UiDevice; import com.android.launcher3.tapl.LauncherInstrumentation; @@ -80,7 +81,12 @@ public class NavigationModeSwitchRule implements TestRule { Mode mode = description.getAnnotation(NavigationModeSwitch.class).mode(); return new Statement() { private void assertTrue(String message, boolean condition) { - mLauncher.checkForAnomaly(); + if (mLauncher.getDevice().hasObject(By.textStartsWith(""))) { + // The condition above is "screen is not empty". We are not treating + // "Screen is empty" as an anomaly here. It's an acceptable state when + // Launcher just starts under instrumentation. + mLauncher.checkForAnomaly(); + } if (!condition) { final AssertionError assertionError = new AssertionError(message); FailureWatcher.onError(mLauncher.getDevice(), description, assertionError);