summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorvadimt <vadimt@google.com>2019-06-06 13:40:05 -0700
committervadimt <vadimt@google.com>2019-06-06 14:02:33 -0700
commit44e9a873fcbdfb726eea84d801b708ed8aae860c (patch)
tree476c174bbdceafebdf4d0e707cbe6bc3c6e74607 /tests
parent63013c5e5723117ce7dec97b88cac2abf21f9088 (diff)
downloadandroid_packages_apps_Trebuchet-44e9a873fcbdfb726eea84d801b708ed8aae860c.tar.gz
android_packages_apps_Trebuchet-44e9a873fcbdfb726eea84d801b708ed8aae860c.tar.bz2
android_packages_apps_Trebuchet-44e9a873fcbdfb726eea84d801b708ed8aae860c.zip
Test: using RuleChain to create a correct order of rules.
Change-Id: I2eeb933eab8e5f19b1f80d47566a511ddbdeb28b
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java17
1 files changed, 11 insertions, 6 deletions
diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
index e5cc858bb..64fe2d7d7 100644
--- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
+++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
@@ -65,8 +65,8 @@ import com.android.launcher3.util.rule.ShellCommandRule;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
+import org.junit.rules.RuleChain;
import org.junit.rules.TestRule;
-import org.junit.rules.TestWatcher;
import org.junit.runners.model.Statement;
import java.io.IOException;
@@ -94,7 +94,8 @@ public abstract class AbstractLauncherUiTest {
protected MainThreadExecutor mMainThreadExecutor = new MainThreadExecutor();
protected final UiDevice mDevice = UiDevice.getInstance(getInstrumentation());
- protected final LauncherInstrumentation mLauncher;
+ protected final LauncherInstrumentation mLauncher =
+ new LauncherInstrumentation(getInstrumentation());
protected Context mTargetContext;
protected String mTargetPackage;
@@ -105,11 +106,9 @@ public abstract class AbstractLauncherUiTest {
throw new RuntimeException(e);
}
if (TestHelpers.isInLauncherProcess()) Utilities.enableRunningInTestHarnessForTests();
- mLauncher = new LauncherInstrumentation(getInstrumentation());
}
- @Rule
- public LauncherActivityRule mActivityMonitor = new LauncherActivityRule();
+ protected final LauncherActivityRule mActivityMonitor = new LauncherActivityRule();
@Rule
public ShellCommandRule mDefaultLauncherRule =
@@ -163,8 +162,14 @@ public abstract class AbstractLauncherUiTest {
}
} : base;
+ protected TestRule getRulesInsideActivityMonitor() {
+ return new FailureWatcher(this);
+ }
+
@Rule
- public TestWatcher mFailureWatcher = new FailureWatcher(this);
+ public TestRule mOrderSensitiveRules = RuleChain.
+ outerRule(mActivityMonitor).
+ around(getRulesInsideActivityMonitor());
public UiDevice getDevice() {
return mDevice;