Not checking for some anomalies when switching nav modes
Test: presubmit
Bug: 196820244
Change-Id: I3e9554d3deb453625cde5003ccf132f21253f58a
diff --git a/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java b/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java
index bc8602c..416c193 100644
--- a/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java
+++ b/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java
@@ -30,7 +30,6 @@
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;
@@ -217,12 +216,7 @@
private static void assertTrue(LauncherInstrumentation launcher, String message,
boolean condition, Description description) {
- if (launcher.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.
- launcher.checkForAnomaly();
- }
+ launcher.checkForAnomaly(true);
if (!condition) {
final AssertionError assertionError = new AssertionError(message);
if (description != null) {
diff --git a/tests/src/com/android/launcher3/util/Wait.java b/tests/src/com/android/launcher3/util/Wait.java
index fe6143c..8b5e197 100644
--- a/tests/src/com/android/launcher3/util/Wait.java
+++ b/tests/src/com/android/launcher3/util/Wait.java
@@ -52,7 +52,7 @@
throw new RuntimeException(t);
}
Log.d("Wait", "atMost: timed out: " + SystemClock.uptimeMillis());
- launcher.checkForAnomaly();
+ launcher.checkForAnomaly(false);
Assert.fail(message.get());
}
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 2ca40d8..f273d6f 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -305,7 +305,7 @@
public boolean isTwoPanels() {
return getTestInfo(TestProtocol.REQUEST_IS_TWO_PANELS)
- .getBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD);
+ .getBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD);
}
private void setForcePauseTimeout(long timeout) {
@@ -379,7 +379,7 @@
}
}
- private String getSystemAnomalyMessage() {
+ private String getSystemAnomalyMessage(boolean ignoreNavmodeChangeStates) {
try {
{
final StringBuilder sb = new StringBuilder();
@@ -402,16 +402,18 @@
if (hasSystemUiObject("keyguard_status_view")) return "Phone is locked";
- final String visibleApps = mDevice.findObjects(getAnyObjectSelector())
- .stream()
- .map(LauncherInstrumentation::getApplicationPackageSafe)
- .distinct()
- .filter(pkg -> pkg != null)
- .collect(Collectors.joining(","));
- if (SYSTEMUI_PACKAGE.equals(visibleApps)) return "Only System UI views are visible";
+ if (!ignoreNavmodeChangeStates) {
+ final String visibleApps = mDevice.findObjects(getAnyObjectSelector())
+ .stream()
+ .map(LauncherInstrumentation::getApplicationPackageSafe)
+ .distinct()
+ .filter(pkg -> pkg != null)
+ .collect(Collectors.joining(","));
+ if (SYSTEMUI_PACKAGE.equals(visibleApps)) return "Only System UI views are visible";
- if (!mDevice.wait(Until.hasObject(getAnyObjectSelector()), WAIT_TIME_MS)) {
- return "Screen is empty";
+ if (!mDevice.wait(Until.hasObject(getAnyObjectSelector()), WAIT_TIME_MS)) {
+ return "Screen is empty";
+ }
}
final String navigationModeError = getNavigationModeMismatchError(true);
@@ -423,8 +425,12 @@
return null;
}
- public void checkForAnomaly() {
- final String systemAnomalyMessage = getSystemAnomalyMessage();
+ private void checkForAnomaly() {
+ checkForAnomaly(false);
+ }
+
+ public void checkForAnomaly(boolean ignoreNavmodeChangeStates) {
+ final String systemAnomalyMessage = getSystemAnomalyMessage(ignoreNavmodeChangeStates);
if (systemAnomalyMessage != null) {
Assert.fail(formatSystemHealthMessage(formatErrorWithEvents(
"http://go/tapl : Tests are broken by a non-Launcher system error: "
@@ -756,7 +762,7 @@
if (hasLauncherObject(CONTEXT_MENU_RES_ID)) {
GestureScope gestureScope = gestureStartFromLauncher
- ? (isTablet()? GestureScope.INSIDE : GestureScope.INSIDE_TO_OUTSIDE)
+ ? (isTablet() ? GestureScope.INSIDE : GestureScope.INSIDE_TO_OUTSIDE)
: GestureScope.OUTSIDE_WITH_PILFER;
linearGesture(
displaySize.x / 2, displaySize.y - 1,