diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java index bb19515dd0..4243ed041f 100644 --- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java +++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java @@ -122,10 +122,6 @@ public abstract class AbstractLauncherUiTest { protected final LauncherActivityRule mActivityMonitor = new LauncherActivityRule(); - @Rule - public ShellCommandRule mDefaultLauncherRule = - TestHelpers.isInLauncherProcess() ? ShellCommandRule.setDefaultLauncher() : null; - @Rule public ShellCommandRule mDisableHeadsUpNotification = ShellCommandRule.disableHeadsUpNotification(); @@ -154,9 +150,13 @@ public abstract class AbstractLauncherUiTest { } protected TestRule getRulesInsideActivityMonitor() { - return RuleChain. - outerRule(new PortraitLandscapeRunner(this)). - around(new FailureWatcher(mDevice)); + final RuleChain inner = RuleChain.outerRule(new PortraitLandscapeRunner(this)) + .around(new FailureWatcher(mDevice)); + + return TestHelpers.isInLauncherProcess() + ? RuleChain.outerRule(ShellCommandRule.setDefaultLauncher()) + .around(inner) : + inner; } @Rule