Merge "Allowing having only SysUI views before pressHome()" into sc-v2-dev

This commit is contained in:
Vadim Tryshev 2021-09-24 18:15:07 +00:00 committed by Android (Google) Code Review
commit fcc51bd1fa
3 changed files with 13 additions and 9 deletions

View File

@ -216,7 +216,7 @@ public class NavigationModeSwitchRule implements TestRule {
private static void assertTrue(LauncherInstrumentation launcher, String message,
boolean condition, Description description) {
launcher.checkForAnomaly(true);
launcher.checkForAnomaly(true, true);
if (!condition) {
final AssertionError assertionError = new AssertionError(message);
if (description != null) {

View File

@ -52,7 +52,7 @@ public class Wait {
throw new RuntimeException(t);
}
Log.d("Wait", "atMost: timed out: " + SystemClock.uptimeMillis());
launcher.checkForAnomaly(false);
launcher.checkForAnomaly(false, false);
Assert.fail(message.get());
}

View File

@ -392,7 +392,8 @@ public final class LauncherInstrumentation {
}
}
private String getSystemAnomalyMessage(boolean ignoreNavmodeChangeStates) {
private String getSystemAnomalyMessage(
boolean ignoreNavmodeChangeStates, boolean ignoreOnlySystemUiViews) {
try {
{
final StringBuilder sb = new StringBuilder();
@ -415,7 +416,7 @@ public final class LauncherInstrumentation {
if (hasSystemUiObject("keyguard_status_view")) return "Phone is locked";
if (!ignoreNavmodeChangeStates) {
if (!ignoreOnlySystemUiViews) {
final String visibleApps = mDevice.findObjects(getAnyObjectSelector())
.stream()
.map(LauncherInstrumentation::getApplicationPackageSafe)
@ -423,7 +424,8 @@ public final class LauncherInstrumentation {
.filter(pkg -> pkg != null)
.collect(Collectors.joining(","));
if (SYSTEMUI_PACKAGE.equals(visibleApps)) return "Only System UI views are visible";
}
if (!ignoreNavmodeChangeStates) {
if (!mDevice.wait(Until.hasObject(getAnyObjectSelector()), WAIT_TIME_MS)) {
return "Screen is empty";
}
@ -439,11 +441,13 @@ public final class LauncherInstrumentation {
}
private void checkForAnomaly() {
checkForAnomaly(false);
checkForAnomaly(false, false);
}
public void checkForAnomaly(boolean ignoreNavmodeChangeStates) {
final String systemAnomalyMessage = getSystemAnomalyMessage(ignoreNavmodeChangeStates);
public void checkForAnomaly(
boolean ignoreNavmodeChangeStates, boolean ignoreOnlySystemUiViews) {
final String systemAnomalyMessage =
getSystemAnomalyMessage(ignoreNavmodeChangeStates, ignoreOnlySystemUiViews);
if (systemAnomalyMessage != null) {
Assert.fail(formatSystemHealthMessage(formatErrorWithEvents(
"http://go/tapl : Tests are broken by a non-Launcher system error: "
@ -765,7 +769,7 @@ public final class LauncherInstrumentation {
// pause in accessibility events prior to pressing Home.
final String action;
if (getNavigationModel() == NavigationModel.ZERO_BUTTON) {
checkForAnomaly();
checkForAnomaly(false, true);
setForcePauseTimeout(FORCE_PAUSE_TIMEOUT_MS);
final Point displaySize = getRealDisplaySize();