Loading quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java +1 −1 Original line number Diff line number Diff line Loading @@ -208,7 +208,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest { @Test @NavigationModeSwitch @PortraitLandscape // @PortraitLandscape public void testBackground() throws Exception { startAppFast(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR)); final Background background = mLauncher.getBackground(); Loading tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java +3 −41 Original line number Diff line number Diff line Loading @@ -35,7 +35,6 @@ import android.content.pm.PackageManager; import android.os.Process; import android.os.RemoteException; import android.util.Log; import android.view.Surface; import androidx.test.InstrumentationRegistry; import androidx.test.uiautomator.By; Loading Loading @@ -67,7 +66,6 @@ import org.junit.Before; import org.junit.Rule; import org.junit.rules.RuleChain; import org.junit.rules.TestRule; import org.junit.runners.model.Statement; import java.io.IOException; import java.lang.annotation.ElementType; Loading Loading @@ -124,46 +122,10 @@ public abstract class AbstractLauncherUiTest { protected @interface PortraitLandscape { } @Rule public TestRule mPortraitLandscapeExecutor = (base, description) -> false && description.getAnnotation(PortraitLandscape.class) != null ? new Statement() { @Override public void evaluate() throws Throwable { try { // Create launcher activity if necessary and bring it to the front. mLauncher.pressHome(); waitForLauncherCondition("Launcher activity wasn't created", launcher -> launcher != null); executeOnLauncher(launcher -> launcher.getRotationHelper().forceAllowRotationForTesting(true)); evaluateInPortrait(); evaluateInLandscape(); } finally { mDevice.setOrientationNatural(); executeOnLauncher(launcher -> launcher.getRotationHelper().forceAllowRotationForTesting(false)); mLauncher.setExpectedRotation(Surface.ROTATION_0); } } private void evaluateInPortrait() throws Throwable { mDevice.setOrientationNatural(); mLauncher.setExpectedRotation(Surface.ROTATION_0); base.evaluate(); } private void evaluateInLandscape() throws Throwable { mDevice.setOrientationLeft(); mLauncher.setExpectedRotation(Surface.ROTATION_90); base.evaluate(); } } : base; protected TestRule getRulesInsideActivityMonitor() { return new FailureWatcher(this); return RuleChain. outerRule(new PortraitLandscapeRunner(this)). around(new FailureWatcher(this)); } @Rule Loading tests/src/com/android/launcher3/ui/PortraitLandscapeRunner.java 0 → 100644 +63 −0 Original line number Diff line number Diff line package com.android.launcher3.ui; import android.view.Surface; import com.android.launcher3.tapl.TestHelpers; import org.junit.rules.TestRule; import org.junit.runner.Description; import org.junit.runners.model.Statement; class PortraitLandscapeRunner implements TestRule { private AbstractLauncherUiTest mTest; public PortraitLandscapeRunner(AbstractLauncherUiTest test) { mTest = test; } @Override public Statement apply(Statement base, Description description) { if (!TestHelpers.isInLauncherProcess() || description.getAnnotation(AbstractLauncherUiTest.PortraitLandscape.class) == null) { return base; } return new Statement() { @Override public void evaluate() throws Throwable { try { mTest.mDevice.pressHome(); mTest.waitForLauncherCondition("Launcher activity wasn't created", launcher -> launcher != null); mTest.executeOnLauncher(launcher -> launcher.getRotationHelper().forceAllowRotationForTesting( true)); evaluateInPortrait(); evaluateInLandscape(); } finally { mTest.mDevice.setOrientationNatural(); mTest.executeOnLauncher(launcher -> launcher.getRotationHelper().forceAllowRotationForTesting( false)); mTest.mLauncher.setExpectedRotation(Surface.ROTATION_0); } } private void evaluateInPortrait() throws Throwable { mTest.mDevice.setOrientationNatural(); mTest.mLauncher.setExpectedRotation(Surface.ROTATION_0); base.evaluate(); mTest.mLauncher.pressHome(); } private void evaluateInLandscape() throws Throwable { mTest.mDevice.setOrientationLeft(); mTest.mLauncher.setExpectedRotation(Surface.ROTATION_90); base.evaluate(); mTest.mLauncher.pressHome(); } }; } } tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java +1 −5 Original line number Diff line number Diff line Loading @@ -59,11 +59,7 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { public static void initialize(AbstractLauncherUiTest test) throws Exception { test.clearLauncherData(); if (TestHelpers.isInLauncherProcess()) { test.mActivityMonitor.returnToHome(); } else { test.mDevice.pressHome(); } test.waitForLauncherCondition("Launcher didn't start", launcher -> launcher != null); test.waitForState("Launcher internal state didn't switch to Home", LauncherState.NORMAL); test.waitForResumed("Launcher internal state is still Background"); Loading tests/src/com/android/launcher3/ui/widget/RequestPinItemTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -190,7 +190,7 @@ public class RequestPinItemTest extends AbstractLauncherUiTest { } // Go back to home mActivityMonitor.returnToHome(); mLauncher.pressHome(); Wait.atMost(null, new ItemSearchCondition(itemMatcher), DEFAULT_ACTIVITY_TIMEOUT); } Loading Loading
quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java +1 −1 Original line number Diff line number Diff line Loading @@ -208,7 +208,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest { @Test @NavigationModeSwitch @PortraitLandscape // @PortraitLandscape public void testBackground() throws Exception { startAppFast(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR)); final Background background = mLauncher.getBackground(); Loading
tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java +3 −41 Original line number Diff line number Diff line Loading @@ -35,7 +35,6 @@ import android.content.pm.PackageManager; import android.os.Process; import android.os.RemoteException; import android.util.Log; import android.view.Surface; import androidx.test.InstrumentationRegistry; import androidx.test.uiautomator.By; Loading Loading @@ -67,7 +66,6 @@ import org.junit.Before; import org.junit.Rule; import org.junit.rules.RuleChain; import org.junit.rules.TestRule; import org.junit.runners.model.Statement; import java.io.IOException; import java.lang.annotation.ElementType; Loading Loading @@ -124,46 +122,10 @@ public abstract class AbstractLauncherUiTest { protected @interface PortraitLandscape { } @Rule public TestRule mPortraitLandscapeExecutor = (base, description) -> false && description.getAnnotation(PortraitLandscape.class) != null ? new Statement() { @Override public void evaluate() throws Throwable { try { // Create launcher activity if necessary and bring it to the front. mLauncher.pressHome(); waitForLauncherCondition("Launcher activity wasn't created", launcher -> launcher != null); executeOnLauncher(launcher -> launcher.getRotationHelper().forceAllowRotationForTesting(true)); evaluateInPortrait(); evaluateInLandscape(); } finally { mDevice.setOrientationNatural(); executeOnLauncher(launcher -> launcher.getRotationHelper().forceAllowRotationForTesting(false)); mLauncher.setExpectedRotation(Surface.ROTATION_0); } } private void evaluateInPortrait() throws Throwable { mDevice.setOrientationNatural(); mLauncher.setExpectedRotation(Surface.ROTATION_0); base.evaluate(); } private void evaluateInLandscape() throws Throwable { mDevice.setOrientationLeft(); mLauncher.setExpectedRotation(Surface.ROTATION_90); base.evaluate(); } } : base; protected TestRule getRulesInsideActivityMonitor() { return new FailureWatcher(this); return RuleChain. outerRule(new PortraitLandscapeRunner(this)). around(new FailureWatcher(this)); } @Rule Loading
tests/src/com/android/launcher3/ui/PortraitLandscapeRunner.java 0 → 100644 +63 −0 Original line number Diff line number Diff line package com.android.launcher3.ui; import android.view.Surface; import com.android.launcher3.tapl.TestHelpers; import org.junit.rules.TestRule; import org.junit.runner.Description; import org.junit.runners.model.Statement; class PortraitLandscapeRunner implements TestRule { private AbstractLauncherUiTest mTest; public PortraitLandscapeRunner(AbstractLauncherUiTest test) { mTest = test; } @Override public Statement apply(Statement base, Description description) { if (!TestHelpers.isInLauncherProcess() || description.getAnnotation(AbstractLauncherUiTest.PortraitLandscape.class) == null) { return base; } return new Statement() { @Override public void evaluate() throws Throwable { try { mTest.mDevice.pressHome(); mTest.waitForLauncherCondition("Launcher activity wasn't created", launcher -> launcher != null); mTest.executeOnLauncher(launcher -> launcher.getRotationHelper().forceAllowRotationForTesting( true)); evaluateInPortrait(); evaluateInLandscape(); } finally { mTest.mDevice.setOrientationNatural(); mTest.executeOnLauncher(launcher -> launcher.getRotationHelper().forceAllowRotationForTesting( false)); mTest.mLauncher.setExpectedRotation(Surface.ROTATION_0); } } private void evaluateInPortrait() throws Throwable { mTest.mDevice.setOrientationNatural(); mTest.mLauncher.setExpectedRotation(Surface.ROTATION_0); base.evaluate(); mTest.mLauncher.pressHome(); } private void evaluateInLandscape() throws Throwable { mTest.mDevice.setOrientationLeft(); mTest.mLauncher.setExpectedRotation(Surface.ROTATION_90); base.evaluate(); mTest.mLauncher.pressHome(); } }; } }
tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java +1 −5 Original line number Diff line number Diff line Loading @@ -59,11 +59,7 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { public static void initialize(AbstractLauncherUiTest test) throws Exception { test.clearLauncherData(); if (TestHelpers.isInLauncherProcess()) { test.mActivityMonitor.returnToHome(); } else { test.mDevice.pressHome(); } test.waitForLauncherCondition("Launcher didn't start", launcher -> launcher != null); test.waitForState("Launcher internal state didn't switch to Home", LauncherState.NORMAL); test.waitForResumed("Launcher internal state is still Background"); Loading
tests/src/com/android/launcher3/ui/widget/RequestPinItemTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -190,7 +190,7 @@ public class RequestPinItemTest extends AbstractLauncherUiTest { } // Go back to home mActivityMonitor.returnToHome(); mLauncher.pressHome(); Wait.atMost(null, new ItemSearchCondition(itemMatcher), DEFAULT_ACTIVITY_TIMEOUT); } Loading