diff options
author | Tony Wickham <twickham@google.com> | 2019-10-16 14:31:29 -0700 |
---|---|---|
committer | Tony Wickham <twickham@google.com> | 2019-10-23 23:40:57 +0000 |
commit | 476b7d4378937d0128edf60779cfbdb77aa799ed (patch) | |
tree | c462f539d65f5f9118651fcfc5022b562d9d7ad2 /tests | |
parent | a0f77c4449753490adca6863cbf97c509e70e17a (diff) | |
download | android_packages_apps_Trebuchet-476b7d4378937d0128edf60779cfbdb77aa799ed.tar.gz android_packages_apps_Trebuchet-476b7d4378937d0128edf60779cfbdb77aa799ed.tar.bz2 android_packages_apps_Trebuchet-476b7d4378937d0128edf60779cfbdb77aa799ed.zip |
Fix testQuickSwitchFromApp
Instead of starting getAppPackageName() and relying on it being our Test
Pin Item activity, instead launch our own test activities with the
FLAG_ACTIVITY_MULTIPLE_TASK and FLAG_ACTIVITY_NEW_DOCUMENT flags.
Test:
- Locally run testQuickSwitchFromApp() from Android Studio
- flake -oop -t com.android.quickstep.TaplTestsQuickstep#testQuickSwitchFromApp
Bug: 140252765
Change-Id: Ie137261ce65bfd3dd39df78d57784854a026e967
Merged-In: Ie137261ce65bfd3dd39df78d57784854a026e967
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java index 0f5000944..9a894b1ee 100644 --- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java +++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java @@ -15,8 +15,6 @@ */ package com.android.launcher3.ui; -import static androidx.test.InstrumentationRegistry.getInstrumentation; - import static com.android.launcher3.tapl.LauncherInstrumentation.ContainerType; import static com.android.launcher3.ui.TaplTestsLauncher3.getAppPackageName; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; @@ -25,6 +23,8 @@ import static org.junit.Assert.assertTrue; import static java.lang.System.exit; +import static androidx.test.InstrumentationRegistry.getInstrumentation; + import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; @@ -348,7 +348,8 @@ public abstract class AbstractLauncherUiTest { startIntent( getInstrumentation().getContext().getPackageManager().getLaunchIntentForPackage( packageName), - By.pkg(packageName).depth(0)); + By.pkg(packageName).depth(0), + true /* newTask */); } protected void startTestActivity(int activityNumber) { @@ -357,12 +358,17 @@ public abstract class AbstractLauncherUiTest { getLaunchIntentForPackage(packageName); intent.setComponent(new ComponentName(packageName, "com.android.launcher3.tests.Activity" + activityNumber)); - startIntent(intent, By.pkg(packageName).text("TestActivity" + activityNumber)); + startIntent(intent, By.pkg(packageName).text("TestActivity" + activityNumber), + false /* newTask */); } - private void startIntent(Intent intent, BySelector selector) { + private void startIntent(Intent intent, BySelector selector, boolean newTask) { intent.addCategory(Intent.CATEGORY_LAUNCHER); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); + if (newTask) { + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); + } else { + intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK | Intent.FLAG_ACTIVITY_NEW_DOCUMENT); + } getInstrumentation().getTargetContext().startActivity(intent); assertTrue("App didn't start: " + selector, mDevice.wait(Until.hasObject(selector), DEFAULT_UI_TIMEOUT)); |