mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-01 16:26:47 +00:00
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
This commit is contained in:
@@ -26,6 +26,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.ContentResolver;
|
||||
@@ -373,7 +375,8 @@ public abstract class AbstractLauncherUiTest {
|
||||
startIntent(
|
||||
getInstrumentation().getContext().getPackageManager().getLaunchIntentForPackage(
|
||||
packageName),
|
||||
By.pkg(packageName).depth(0));
|
||||
By.pkg(packageName).depth(0),
|
||||
true /* newTask */);
|
||||
}
|
||||
|
||||
public static void startTestActivity(int activityNumber) {
|
||||
@@ -382,12 +385,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 static void startIntent(Intent intent, BySelector selector) {
|
||||
private static 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,
|
||||
UiDevice.getInstance(getInstrumentation())
|
||||
|
||||
Reference in New Issue
Block a user