Not checking for some anomalies when switching nav modes
Test: presubmit Bug: 196820244 Change-Id: I3e9554d3deb453625cde5003ccf132f21253f58a
This commit is contained in:
parent
b29f63af3c
commit
51ae38304b
|
@ -30,7 +30,6 @@ import android.content.Context;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.test.uiautomator.By;
|
|
||||||
import androidx.test.uiautomator.UiDevice;
|
import androidx.test.uiautomator.UiDevice;
|
||||||
|
|
||||||
import com.android.launcher3.tapl.LauncherInstrumentation;
|
import com.android.launcher3.tapl.LauncherInstrumentation;
|
||||||
|
@ -217,12 +216,7 @@ public class NavigationModeSwitchRule implements TestRule {
|
||||||
|
|
||||||
private static void assertTrue(LauncherInstrumentation launcher, String message,
|
private static void assertTrue(LauncherInstrumentation launcher, String message,
|
||||||
boolean condition, Description description) {
|
boolean condition, Description description) {
|
||||||
if (launcher.getDevice().hasObject(By.textStartsWith(""))) {
|
launcher.checkForAnomaly(true);
|
||||||
// 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();
|
|
||||||
}
|
|
||||||
if (!condition) {
|
if (!condition) {
|
||||||
final AssertionError assertionError = new AssertionError(message);
|
final AssertionError assertionError = new AssertionError(message);
|
||||||
if (description != null) {
|
if (description != null) {
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class Wait {
|
||||||
throw new RuntimeException(t);
|
throw new RuntimeException(t);
|
||||||
}
|
}
|
||||||
Log.d("Wait", "atMost: timed out: " + SystemClock.uptimeMillis());
|
Log.d("Wait", "atMost: timed out: " + SystemClock.uptimeMillis());
|
||||||
launcher.checkForAnomaly();
|
launcher.checkForAnomaly(false);
|
||||||
Assert.fail(message.get());
|
Assert.fail(message.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -379,7 +379,7 @@ public final class LauncherInstrumentation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getSystemAnomalyMessage() {
|
private String getSystemAnomalyMessage(boolean ignoreNavmodeChangeStates) {
|
||||||
try {
|
try {
|
||||||
{
|
{
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
@ -402,6 +402,7 @@ public final class LauncherInstrumentation {
|
||||||
|
|
||||||
if (hasSystemUiObject("keyguard_status_view")) return "Phone is locked";
|
if (hasSystemUiObject("keyguard_status_view")) return "Phone is locked";
|
||||||
|
|
||||||
|
if (!ignoreNavmodeChangeStates) {
|
||||||
final String visibleApps = mDevice.findObjects(getAnyObjectSelector())
|
final String visibleApps = mDevice.findObjects(getAnyObjectSelector())
|
||||||
.stream()
|
.stream()
|
||||||
.map(LauncherInstrumentation::getApplicationPackageSafe)
|
.map(LauncherInstrumentation::getApplicationPackageSafe)
|
||||||
|
@ -413,6 +414,7 @@ public final class LauncherInstrumentation {
|
||||||
if (!mDevice.wait(Until.hasObject(getAnyObjectSelector()), WAIT_TIME_MS)) {
|
if (!mDevice.wait(Until.hasObject(getAnyObjectSelector()), WAIT_TIME_MS)) {
|
||||||
return "Screen is empty";
|
return "Screen is empty";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final String navigationModeError = getNavigationModeMismatchError(true);
|
final String navigationModeError = getNavigationModeMismatchError(true);
|
||||||
if (navigationModeError != null) return navigationModeError;
|
if (navigationModeError != null) return navigationModeError;
|
||||||
|
@ -423,8 +425,12 @@ public final class LauncherInstrumentation {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkForAnomaly() {
|
private void checkForAnomaly() {
|
||||||
final String systemAnomalyMessage = getSystemAnomalyMessage();
|
checkForAnomaly(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkForAnomaly(boolean ignoreNavmodeChangeStates) {
|
||||||
|
final String systemAnomalyMessage = getSystemAnomalyMessage(ignoreNavmodeChangeStates);
|
||||||
if (systemAnomalyMessage != null) {
|
if (systemAnomalyMessage != null) {
|
||||||
Assert.fail(formatSystemHealthMessage(formatErrorWithEvents(
|
Assert.fail(formatSystemHealthMessage(formatErrorWithEvents(
|
||||||
"http://go/tapl : Tests are broken by a non-Launcher system error: "
|
"http://go/tapl : Tests are broken by a non-Launcher system error: "
|
||||||
|
|
Loading…
Reference in New Issue