summaryrefslogtreecommitdiffstats
path: root/quickstep
diff options
context:
space:
mode:
authorvadimt <vadimt@google.com>2019-08-23 12:11:00 -0700
committervadimt <vadimt@google.com>2019-08-23 14:18:32 -0700
commitf13eaa02427ea536d9a3be077aa267f706f0a5e1 (patch)
tree3a6b513e9e4b5606f4c2d33956c20584d2a58a92 /quickstep
parent197ae725a0c59b56c55be27a82086fd3ad531399 (diff)
downloadandroid_packages_apps_Trebuchet-f13eaa02427ea536d9a3be077aa267f706f0a5e1.tar.gz
android_packages_apps_Trebuchet-f13eaa02427ea536d9a3be077aa267f706f0a5e1.tar.bz2
android_packages_apps_Trebuchet-f13eaa02427ea536d9a3be077aa267f706f0a5e1.zip
Saving screenshots for failures in NavigationModeSwitchRule
Change-Id: I732076a5eb14b181f560024e2780e2012a81fd95
Diffstat (limited to 'quickstep')
-rw-r--r--quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java19
1 files changed, 14 insertions, 5 deletions
diff --git a/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java b/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java
index f27f40088..edd5011f2 100644
--- a/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java
+++ b/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java
@@ -34,9 +34,9 @@ import androidx.test.uiautomator.UiDevice;
import com.android.launcher3.tapl.LauncherInstrumentation;
import com.android.launcher3.tapl.TestHelpers;
+import com.android.launcher3.util.rule.FailureWatcher;
import com.android.systemui.shared.system.QuickStepContract;
-import org.junit.Assert;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
@@ -79,6 +79,14 @@ public class NavigationModeSwitchRule implements TestRule {
description.getAnnotation(NavigationModeSwitch.class) != null) {
Mode mode = description.getAnnotation(NavigationModeSwitch.class).mode();
return new Statement() {
+ private void assertTrue(String message, boolean condition) {
+ if(!condition) {
+ final AssertionError assertionError = new AssertionError(message);
+ FailureWatcher.onError(mLauncher.getDevice(), description, assertionError);
+ throw assertionError;
+ }
+ }
+
@Override
public void evaluate() throws Throwable {
mLauncher.enableDebugTracing();
@@ -107,7 +115,8 @@ public class NavigationModeSwitchRule implements TestRule {
Log.e(TAG, "Exception", e);
throw e;
} finally {
- Assert.assertTrue(setActiveOverlay(prevOverlayPkg, originalMode));
+ assertTrue("Couldn't set overlay",
+ setActiveOverlay(prevOverlayPkg, originalMode));
}
mLauncher.disableDebugTracing();
}
@@ -176,7 +185,7 @@ public class NavigationModeSwitchRule implements TestRule {
latch.await(10, TimeUnit.SECONDS);
targetContext.getMainExecutor().execute(() ->
sysUINavigationMode.removeModeChangeListener(listener));
- Assert.assertTrue("Navigation mode didn't change to " + expectedMode,
+ assertTrue("Navigation mode didn't change to " + expectedMode,
currentSysUiNavigationMode() == expectedMode);
}
@@ -184,7 +193,7 @@ public class NavigationModeSwitchRule implements TestRule {
if (mLauncher.getNavigationModel() == expectedMode) break;
Thread.sleep(100);
}
- Assert.assertTrue("Couldn't switch to " + overlayPackage,
+ assertTrue("Couldn't switch to " + overlayPackage,
mLauncher.getNavigationModel() == expectedMode);
for (int i = 0; i != 100; ++i) {
@@ -192,7 +201,7 @@ public class NavigationModeSwitchRule implements TestRule {
Thread.sleep(100);
}
final String error = mLauncher.getNavigationModeMismatchError();
- Assert.assertTrue("Switching nav mode: " + error, error == null);
+ assertTrue("Switching nav mode: " + error, error == null);
Thread.sleep(5000);
return true;