Update AbstractLauncherUiTest to use recents window when possible
Flag: com.android.launcher3.enable_launcher_overview_in_window Bug: 377678992 Test: pre/postsubmit Change-Id: Id3ddc11aa9163df3f2914edba66e1db36fdde63b
This commit is contained in:
1 parent
7103e478b3
commit
b8440b75ef
16 files changed
+182
-131
No files matched your search
@@ -22,6 +22,7 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
import android.os.SystemProperties;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.test.uiautomator.By;
|
||||
import androidx.test.uiautomator.Until;
|
||||
|
||||
@@ -46,7 +47,8 @@ import java.util.function.Supplier;
|
||||
/**
|
||||
* Base class for all instrumentation tests that deal with Quickstep.
|
||||
*/
|
||||
public abstract class AbstractQuickStepTest extends AbstractLauncherUiTest<QuickstepLauncher> {
|
||||
public abstract class AbstractQuickStepTest
|
||||
extends AbstractLauncherUiTest<QuickstepLauncher, RecentsView<?, ?>> {
|
||||
public static final boolean ENABLE_SHELL_TRANSITIONS =
|
||||
SystemProperties.getBoolean("persist.wm.debug.shell_transit", true);
|
||||
@Override
|
||||
@@ -59,9 +61,9 @@ public abstract class AbstractQuickStepTest extends AbstractLauncherUiTest<Quick
|
||||
|
||||
@Override
|
||||
protected void onLauncherActivityClose(QuickstepLauncher launcher) {
|
||||
super.onLauncherActivityClose(launcher);
|
||||
if (RecentsWindowFlags.enableLauncherOverviewInWindow.isTrue()) {
|
||||
executeOnRecentsWindow(RecentsWindowManager::cleanupRecentsWindow);
|
||||
return;
|
||||
executeOnRecentsWindowIfPresent(RecentsWindowManager::cleanupRecentsWindow);
|
||||
}
|
||||
RecentsView recentsView = launcher.getOverviewPanel();
|
||||
if (recentsView != null) {
|
||||
@@ -69,14 +71,6 @@ public abstract class AbstractQuickStepTest extends AbstractLauncherUiTest<Quick
|
||||
}
|
||||
}
|
||||
|
||||
// Cannot be used in TaplTests between a Tapl call injecting a gesture and a tapl call
|
||||
// expecting the results of that gesture because the wait can hide flakeness.
|
||||
protected void waitForRecentsWindowState(String message, Supplier<LauncherState> state) {
|
||||
waitForRecentsWindowCondition(message, recentsWindow ->
|
||||
state.get() == toLauncherState(
|
||||
recentsWindow.getStateManager().getCurrentStableState()));
|
||||
}
|
||||
|
||||
// Cannot be used in TaplTests after injecting any gesture using Tapl because this can hide
|
||||
// flakiness.
|
||||
protected void waitForRecentsWindowCondition(String
|
||||
@@ -84,23 +78,6 @@ public abstract class AbstractQuickStepTest extends AbstractLauncherUiTest<Quick
|
||||
waitForRecentsWindowCondition(message, condition, TestUtil.DEFAULT_UI_TIMEOUT);
|
||||
}
|
||||
|
||||
protected <T> T getFromRecentsWindow(Function<RecentsWindowManager, T> f) {
|
||||
if (!TestHelpers.isInLauncherProcess()) return null;
|
||||
return getOnUiThread(() -> {
|
||||
RecentsWindowManager recentsWindowManager =
|
||||
RecentsWindowManager.getRecentsWindowTracker().getCreatedContext();
|
||||
return recentsWindowManager != null ? f.apply(recentsWindowManager) : null;
|
||||
});
|
||||
}
|
||||
|
||||
protected void executeOnRecentsWindow(Consumer<RecentsWindowManager> f) {
|
||||
if (!TestHelpers.isInLauncherProcess()) return;
|
||||
getFromRecentsWindow(recentsWindowManager -> {
|
||||
f.accept(recentsWindowManager);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
// Cannot be used in TaplTests after injecting any gesture using Tapl because this can hide
|
||||
// flakiness.
|
||||
protected void waitForRecentsWindowCondition(
|
||||
@@ -110,10 +87,66 @@ public abstract class AbstractQuickStepTest extends AbstractLauncherUiTest<Quick
|
||||
Wait.atMost(message, () -> getFromRecentsWindow(condition), mLauncher, timeout);
|
||||
}
|
||||
|
||||
protected boolean isInRecentsWindowState(Supplier<LauncherState> state) {
|
||||
protected <T> T getFromRecentsWindowIfPresent(Function<RecentsWindowManager, T> f) {
|
||||
if (!TestHelpers.isInLauncherProcess()) return null;
|
||||
return getFromRecentsWindow(recentsWindowManager ->
|
||||
recentsWindowManager == null ? null : f.apply(recentsWindowManager));
|
||||
}
|
||||
|
||||
protected <T> T getFromRecentsWindow(Function<RecentsWindowManager, T> f) {
|
||||
if (!TestHelpers.isInLauncherProcess()) return null;
|
||||
return getOnUiThread(() ->
|
||||
f.apply(RecentsWindowManager.getRecentsWindowTracker().getCreatedContext()));
|
||||
}
|
||||
|
||||
protected void executeOnRecentsWindowIfPresent(Consumer<RecentsWindowManager> f) {
|
||||
if (!TestHelpers.isInLauncherProcess()) return;
|
||||
getFromRecentsWindowIfPresent(recentsWindowManager -> {
|
||||
f.accept(recentsWindowManager);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isInState(Supplier<LauncherState> state) {
|
||||
if (!TestHelpers.isInLauncherProcess()) return true;
|
||||
return getFromRecentsWindow(recentsWindow ->
|
||||
state.get() == toLauncherState(recentsWindow.getStateManager().getState()));
|
||||
if (!RecentsWindowFlags.enableLauncherOverviewInWindow.isTrue()) {
|
||||
return super.isInState(state);
|
||||
}
|
||||
return getFromRecentsWindow(recentsWindowManager ->
|
||||
recentsWindowManager != null && toLauncherState(
|
||||
recentsWindowManager.getStateManager().getState()) == state.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void waitForState(
|
||||
boolean forInitialization, String message, Supplier<LauncherState> state) {
|
||||
if (!TestHelpers.isInLauncherProcess()) return;
|
||||
if (!RecentsWindowFlags.enableLauncherOverviewInWindow.isTrue()
|
||||
|| (forInitialization
|
||||
&& RecentsWindowManager.getRecentsWindowTracker().getCreatedContext() == null)) {
|
||||
super.waitForState(forInitialization, message, state);
|
||||
return;
|
||||
}
|
||||
waitForRecentsWindowCondition(message, recentsWindowManager ->
|
||||
recentsWindowManager != null && toLauncherState(
|
||||
recentsWindowManager.getStateManager().getState()) == state.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected RecentsView getOverviewPanel() {
|
||||
if (!TestHelpers.isInLauncherProcess()) return null;
|
||||
if (!RecentsWindowFlags.enableLauncherOverviewInWindow.isTrue()) {
|
||||
return super.getOverviewPanel();
|
||||
}
|
||||
return getFromRecentsWindowIfPresent(RecentsWindowManager::getOverviewPanel);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean useNullOverview() {
|
||||
return super.useNullOverview()
|
||||
&& !RecentsWindowFlags.enableLauncherOverviewInWindow.isTrue();
|
||||
}
|
||||
|
||||
protected void assertTestActivityIsRunning(int activityNumber, String message) {
|
||||
|
||||
@@ -20,7 +20,6 @@ import static android.view.Display.DEFAULT_DISPLAY;
|
||||
|
||||
import static androidx.test.InstrumentationRegistry.getInstrumentation;
|
||||
|
||||
import static com.android.launcher3.Flags.enableFallbackOverviewInWindow;
|
||||
import static com.android.launcher3.tapl.LauncherInstrumentation.WAIT_TIME_MS;
|
||||
import static com.android.launcher3.tapl.TestHelpers.getHomeIntentInPackage;
|
||||
import static com.android.launcher3.tapl.TestHelpers.getLauncherInMyProcess;
|
||||
@@ -67,6 +66,7 @@ import com.android.launcher3.util.rule.TestIsolationRule;
|
||||
import com.android.launcher3.util.rule.TestStabilityRule;
|
||||
import com.android.launcher3.util.rule.ViewCaptureRule;
|
||||
import com.android.quickstep.OverviewComponentObserver.OverviewChangeListener;
|
||||
import com.android.quickstep.fallback.window.RecentsWindowFlags;
|
||||
import com.android.quickstep.fallback.window.RecentsWindowManager;
|
||||
import com.android.quickstep.views.RecentsView;
|
||||
import com.android.quickstep.views.RecentsViewContainer;
|
||||
@@ -216,9 +216,10 @@ public class FallbackRecentsTest {
|
||||
if (!TestHelpers.isInLauncherProcess()) return null;
|
||||
Object[] result = new Object[1];
|
||||
Wait.atMost("Failed to get from recents", () -> MAIN_EXECUTOR.submit(() -> {
|
||||
RecentsViewContainer recentsViewContainer = enableFallbackOverviewInWindow()
|
||||
? RecentsWindowManager.getRecentsWindowTracker().getCreatedContext()
|
||||
: RecentsActivity.ACTIVITY_TRACKER.getCreatedContext();
|
||||
RecentsViewContainer recentsViewContainer =
|
||||
RecentsWindowFlags.enableFallbackOverviewInWindow.isTrue()
|
||||
? RecentsWindowManager.getRecentsWindowTracker().getCreatedContext()
|
||||
: RecentsActivity.ACTIVITY_TRACKER.getCreatedContext();
|
||||
if (recentsViewContainer == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -241,9 +242,10 @@ public class FallbackRecentsTest {
|
||||
private void waitForRecentsClosed() {
|
||||
try {
|
||||
final boolean isRecentsContainerNUll = MAIN_EXECUTOR.submit(() -> {
|
||||
RecentsViewContainer recentsViewContainer = enableFallbackOverviewInWindow()
|
||||
? RecentsWindowManager.getRecentsWindowTracker().getCreatedContext()
|
||||
: RecentsActivity.ACTIVITY_TRACKER.getCreatedContext();
|
||||
RecentsViewContainer recentsViewContainer =
|
||||
RecentsWindowFlags.enableFallbackOverviewInWindow.isTrue()
|
||||
? RecentsWindowManager.getRecentsWindowTracker().getCreatedContext()
|
||||
: RecentsActivity.ACTIVITY_TRACKER.getCreatedContext();
|
||||
|
||||
return recentsViewContainer == null;
|
||||
}).get();
|
||||
|
||||
@@ -24,8 +24,6 @@ import android.platform.test.annotations.PlatinumTest;
|
||||
import com.android.launcher3.tapl.Overview;
|
||||
import com.android.launcher3.tapl.OverviewTask.OverviewTaskContainer;
|
||||
import com.android.launcher3.tapl.OverviewTaskMenu;
|
||||
import com.android.launcher3.ui.AbstractLauncherUiTest;
|
||||
import com.android.launcher3.uioverrides.QuickstepLauncher;
|
||||
import com.android.quickstep.util.SplitScreenTestUtils;
|
||||
|
||||
import org.junit.Test;
|
||||
@@ -34,7 +32,7 @@ import org.junit.Test;
|
||||
* This test run in both Out of process (Oop) and in-process (Ipc).
|
||||
* Tests the app Icon in overview.
|
||||
*/
|
||||
public class TaplOverviewIconTest extends AbstractLauncherUiTest<QuickstepLauncher> {
|
||||
public class TaplOverviewIconTest extends AbstractQuickStepTest {
|
||||
|
||||
private static final String CALCULATOR_APP_PACKAGE =
|
||||
resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR);
|
||||
|
||||
@@ -23,9 +23,7 @@ import androidx.test.uiautomator.Until
|
||||
import com.android.launcher3.BuildConfig
|
||||
import com.android.launcher3.tapl.LaunchedAppState
|
||||
import com.android.launcher3.tapl.OverviewTask
|
||||
import com.android.launcher3.ui.AbstractLauncherUiTest
|
||||
import com.android.launcher3.ui.PortraitLandscapeRunner.PortraitLandscape
|
||||
import com.android.launcher3.uioverrides.QuickstepLauncher
|
||||
import com.android.launcher3.util.TestUtil
|
||||
import com.google.common.truth.Truth.assertWithMessage
|
||||
import org.junit.Before
|
||||
@@ -34,7 +32,7 @@ import org.junit.Test
|
||||
/** Test Desktop windowing in Overview. */
|
||||
@AllowedDevices(allowed = [DeviceProduct.CF_TABLET, DeviceProduct.TANGORPRO])
|
||||
@IgnoreLimit(ignoreLimit = BuildConfig.IS_STUDIO_BUILD)
|
||||
class TaplTestsOverviewDesktop : AbstractLauncherUiTest<QuickstepLauncher?>() {
|
||||
class TaplTestsOverviewDesktop : AbstractQuickStepTest() {
|
||||
@Before
|
||||
fun setup() {
|
||||
val overview = mLauncher.goHome().switchToOverview()
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.android.quickstep;
|
||||
|
||||
import static com.android.launcher3.Flags.enableLauncherOverviewInWindow;
|
||||
import static com.android.quickstep.TaskbarModeSwitchRule.Mode.TRANSIENT;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -64,8 +63,6 @@ import org.junit.runner.RunWith;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
@LargeTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@@ -79,15 +76,14 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
runOnRecentsView(recentsView ->
|
||||
executeOnOverview(recentsView ->
|
||||
recentsView.getPagedViewOrientedState().forceAllowRotationForTesting(true));
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
runOnRecentsView(recentsView ->
|
||||
recentsView.getPagedViewOrientedState().forceAllowRotationForTesting(false),
|
||||
/* forTearDown= */ true);
|
||||
executeOnOverview(/* forTearDown= */ true, recentsView ->
|
||||
recentsView.getPagedViewOrientedState().forceAllowRotationForTesting(false));
|
||||
}
|
||||
|
||||
public static void startTestApps() throws Exception {
|
||||
@@ -114,23 +110,25 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
Overview overview = mLauncher.goHome().switchToOverview();
|
||||
assertIsInState(
|
||||
"Launcher internal state didn't switch to Overview", LauncherState.OVERVIEW);
|
||||
runOnRecentsView(recentsView -> assertTrue("Don't have at least 3 tasks",
|
||||
executeOnOverview(recentsView -> assertTrue("Don't have at least 3 tasks",
|
||||
recentsView.getTaskViewCount() >= 3));
|
||||
|
||||
// Test flinging forward and backward.
|
||||
runOnRecentsView(recentsView -> assertEquals("Current task in Overview is not first",
|
||||
recentsView.getFirstTaskViewIndex(), recentsView.getCurrentPage()));
|
||||
executeOnOverview(recentsView -> assertEquals("Current task in Overview is not first",
|
||||
recentsView.indexOfChild(recentsView.getFirstTaskView()),
|
||||
recentsView.getCurrentPage()));
|
||||
|
||||
overview.flingForward();
|
||||
assertIsInState("Launcher internal state is not Overview", LauncherState.OVERVIEW);
|
||||
final Integer currentTaskAfterFlingForward =
|
||||
getFromRecentsView(RecentsView::getCurrentPage);
|
||||
runOnRecentsView(recentsView -> assertTrue("Current task in Overview is still first",
|
||||
currentTaskAfterFlingForward > recentsView.getFirstTaskViewIndex()));
|
||||
getFromOverview(RecentsView::getCurrentPage);
|
||||
executeOnOverview(recentsView -> assertTrue("Current task in Overview is still 0",
|
||||
currentTaskAfterFlingForward > recentsView.indexOfChild(
|
||||
recentsView.getFirstTaskView())));
|
||||
|
||||
overview.flingBackward();
|
||||
assertIsInState("Launcher internal state is not Overview", LauncherState.OVERVIEW);
|
||||
runOnRecentsView(recentsView -> assertTrue("Flinging back in Overview did nothing",
|
||||
executeOnOverview(recentsView -> assertTrue("Flinging back in Overview did nothing",
|
||||
recentsView.getCurrentPage() < currentTaskAfterFlingForward));
|
||||
|
||||
// Test opening a task.
|
||||
@@ -146,18 +144,18 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
overview = mLauncher.goHome().switchToOverview();
|
||||
assertIsInState("Launcher internal state didn't switch to Overview",
|
||||
LauncherState.OVERVIEW);
|
||||
final Integer numTasks = getFromRecentsView(RecentsView::getTaskViewCount);
|
||||
final Integer numTasks = getFromOverview(RecentsView::getTaskViewCount);
|
||||
task = overview.getCurrentTask();
|
||||
assertNotNull("overview.getCurrentTask() returned null (2)", task);
|
||||
task.dismiss();
|
||||
runOnRecentsView(recentsView -> assertEquals(
|
||||
executeOnOverview(recentsView -> assertEquals(
|
||||
"Dismissing a task didn't remove 1 task from Overview",
|
||||
numTasks - 1, recentsView.getTaskViewCount()));
|
||||
|
||||
// Test dismissing all tasks.
|
||||
mLauncher.goHome().switchToOverview().dismissAllTasks();
|
||||
assertIsInState("Launcher internal state is not Home", LauncherState.NORMAL);
|
||||
runOnRecentsView(recentsView -> assertEquals("Still have tasks after dismissing all",
|
||||
executeOnOverview(recentsView -> assertEquals("Still have tasks after dismissing all",
|
||||
0, recentsView.getTaskViewCount()));
|
||||
}
|
||||
|
||||
@@ -381,14 +379,15 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
}
|
||||
|
||||
Overview overview = mLauncher.goHome().switchToOverview();
|
||||
runOnRecentsView(recentsView -> assertTrue("Don't have at least 13 tasks",
|
||||
executeOnOverview(recentsView -> assertTrue("Don't have at least 13 tasks",
|
||||
recentsView.getTaskViewCount() >= 13));
|
||||
|
||||
// Test scroll the first task off screen
|
||||
overview.scrollCurrentTaskOffScreen();
|
||||
assertIsInState("Launcher internal state is not Overview", LauncherState.OVERVIEW);
|
||||
runOnRecentsView(recentsView -> assertTrue("Current task in Overview is still first",
|
||||
recentsView.getCurrentPage() > recentsView.getFirstTaskViewIndex()));
|
||||
executeOnOverview(recentsView -> assertTrue("Current task in Overview is still first",
|
||||
recentsView.getCurrentPage() > recentsView.indexOfChild(
|
||||
recentsView.getFirstTaskView())));
|
||||
|
||||
// Test opening the task.
|
||||
overview.getCurrentTask().open();
|
||||
@@ -403,16 +402,17 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
overview.scrollCurrentTaskOffScreen();
|
||||
assertIsInState(
|
||||
"Launcher internal state is not Overview", LauncherState.OVERVIEW);
|
||||
runOnRecentsView(recentsView -> assertTrue("Current task in Overview is still first",
|
||||
recentsView.getCurrentPage() > recentsView.getFirstTaskViewIndex()));
|
||||
executeOnOverview(recentsView -> assertTrue("Current task in Overview is still first",
|
||||
recentsView.getCurrentPage() > recentsView.indexOfChild(
|
||||
recentsView.getFirstTaskView())));
|
||||
|
||||
// Test dismissing the later task.
|
||||
final Integer numTasks = getFromRecentsView(RecentsView::getTaskViewCount);
|
||||
final Integer numTasks = getFromOverview(RecentsView::getTaskViewCount);
|
||||
overview.getCurrentTask().dismiss();
|
||||
runOnRecentsView(recentsView -> assertEquals(
|
||||
executeOnOverview(recentsView -> assertEquals(
|
||||
"Dismissing a task didn't remove 1 task from Overview",
|
||||
numTasks - 1, recentsView.getTaskViewCount()));
|
||||
runOnRecentsView(recentsView -> assertTrue("Grid did not rebalance after dismissal",
|
||||
executeOnOverview(recentsView -> assertTrue("Grid did not rebalance after dismissal",
|
||||
(Math.abs(recentsView.getTopRowTaskCountForTablet()
|
||||
- recentsView.getBottomRowTaskCountForTablet()) <= 1)));
|
||||
|
||||
@@ -423,7 +423,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
assertIsInState(
|
||||
"Launcher internal state didn't remain in Overview", LauncherState.OVERVIEW);
|
||||
overview.getCurrentTask().dismiss();
|
||||
runOnRecentsView(recentsView -> assertTrue(
|
||||
executeOnOverview(recentsView -> assertTrue(
|
||||
"Grid did not rebalance after multiple dismissals",
|
||||
(Math.abs(recentsView.getTopRowTaskCountForTablet()
|
||||
- recentsView.getBottomRowTaskCountForTablet()) <= 1)));
|
||||
@@ -431,7 +431,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
// Test dismissing all tasks.
|
||||
mLauncher.goHome().switchToOverview().dismissAllTasks();
|
||||
assertIsInState("Launcher internal state is not Home", LauncherState.NORMAL);
|
||||
runOnRecentsView(recentsView -> assertEquals("Still have tasks after dismissing all",
|
||||
executeOnOverview(recentsView -> assertEquals("Still have tasks after dismissing all",
|
||||
0, recentsView.getTaskViewCount()));
|
||||
}
|
||||
|
||||
@@ -442,7 +442,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
|
||||
Overview overview = mLauncher.goHome().switchToOverview();
|
||||
assertIsInState("Launcher internal state should be Overview", LauncherState.OVERVIEW);
|
||||
runOnRecentsView(recentsView -> assertTrue("Should have at least 3 tasks",
|
||||
executeOnOverview(recentsView -> assertTrue("Should have at least 3 tasks",
|
||||
recentsView.getTaskViewCount() >= 3));
|
||||
|
||||
// It should not dismiss overview when tapping between tasks
|
||||
@@ -465,7 +465,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
|
||||
Overview overview = mLauncher.goHome().switchToOverview();
|
||||
assertIsInState("Launcher internal state should be Overview", LauncherState.OVERVIEW);
|
||||
runOnRecentsView(recentsView -> assertTrue("Should have at least 3 tasks",
|
||||
executeOnOverview(recentsView -> assertTrue("Should have at least 3 tasks",
|
||||
recentsView.getTaskViewCount() >= 3));
|
||||
|
||||
if (mLauncher.isTransientTaskbar()) {
|
||||
@@ -532,13 +532,13 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
Overview overview = mLauncher.goHome().switchToOverview();
|
||||
assertIsInState("Launcher internal state didn't switch to Overview",
|
||||
LauncherState.OVERVIEW);
|
||||
final Integer numTasks = getFromRecentsView(RecentsView::getTaskViewCount);
|
||||
final Integer numTasks = getFromOverview(RecentsView::getTaskViewCount);
|
||||
OverviewTask task = overview.getCurrentTask();
|
||||
assertNotNull("overview.getCurrentTask() returned null (2)", task);
|
||||
|
||||
task.dismissCancel();
|
||||
|
||||
runOnRecentsView(recentsView -> assertEquals(
|
||||
executeOnOverview(recentsView -> assertEquals(
|
||||
"Canceling dismissing a task removed a task from Overview",
|
||||
numTasks == null ? 0 : numTasks, recentsView.getTaskViewCount()));
|
||||
}
|
||||
@@ -554,13 +554,13 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
Overview overview = mLauncher.goHome().switchToOverview();
|
||||
assertIsInState("Launcher internal state didn't switch to Overview",
|
||||
LauncherState.OVERVIEW);
|
||||
final Integer numTasks = getFromRecentsView(RecentsView::getTaskViewCount);
|
||||
final Integer numTasks = getFromOverview(RecentsView::getTaskViewCount);
|
||||
Optional<OverviewTask> bottomTask = overview.getCurrentTasksForTablet().stream().max(
|
||||
Comparator.comparingInt(OverviewTask::getTaskCenterY));
|
||||
assertTrue("bottomTask null", bottomTask.isPresent());
|
||||
|
||||
bottomTask.get().dismiss();
|
||||
runOnRecentsView(recentsView -> assertEquals(
|
||||
executeOnOverview(recentsView -> assertEquals(
|
||||
"Dismissing a bottomTask didn't remove 1 bottomTask from Overview",
|
||||
numTasks - 1, recentsView.getTaskViewCount()));
|
||||
}
|
||||
@@ -574,7 +574,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
startTestAppsWithCheck();
|
||||
startTestActivity(3);
|
||||
startTestActivity(4);
|
||||
runOnRecentsView(recentsView -> assertNotEquals(
|
||||
executeOnOverview(recentsView -> assertNotEquals(
|
||||
"Grid overview should have unequal row counts",
|
||||
recentsView.getTopRowTaskCountForTablet(),
|
||||
recentsView.getBottomRowTaskCountForTablet()));
|
||||
@@ -584,13 +584,13 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
|
||||
overview.flingForwardUntilClearAllVisible();
|
||||
assertTrue("Clear All not visible.", overview.isClearAllVisible());
|
||||
final Integer numTasks = getFromRecentsView(RecentsView::getTaskViewCount);
|
||||
final Integer numTasks = getFromOverview(RecentsView::getTaskViewCount);
|
||||
Optional<OverviewTask> lastGridTask = overview.getCurrentTasksForTablet().stream().min(
|
||||
Comparator.comparingInt(OverviewTask::getTaskCenterX));
|
||||
assertTrue("lastGridTask null.", lastGridTask.isPresent());
|
||||
|
||||
lastGridTask.get().dismiss();
|
||||
runOnRecentsView(recentsView -> {
|
||||
executeOnOverview(recentsView -> {
|
||||
assertEquals(
|
||||
"Dismissing a lastGridTask didn't remove 1 lastGridTask from Overview",
|
||||
numTasks - 1, recentsView.getTaskViewCount());
|
||||
@@ -627,18 +627,12 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
|
||||
private void assertIsInState(
|
||||
@NonNull String failureMessage, @NonNull LauncherState expectedState) {
|
||||
assertTrue(failureMessage, enableLauncherOverviewInWindow()
|
||||
? isInRecentsWindowState(() -> expectedState)
|
||||
: isInState(() -> expectedState));
|
||||
assertTrue(failureMessage, isInState(() -> expectedState));
|
||||
}
|
||||
|
||||
private void waitForState(
|
||||
@NonNull String failureMessage, @NonNull LauncherState expectedState) {
|
||||
if (enableLauncherOverviewInWindow()) {
|
||||
waitForRecentsWindowState(failureMessage, () -> expectedState);
|
||||
} else {
|
||||
waitForState(failureMessage, () -> expectedState);
|
||||
}
|
||||
waitForState(failureMessage, () -> expectedState);
|
||||
}
|
||||
|
||||
private void expectLaunchedAppState() {
|
||||
@@ -647,33 +641,4 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
+ "one",
|
||||
isInLaunchedApp(launcher)));
|
||||
}
|
||||
|
||||
private <T> T getFromRecentsView(Function<RecentsView, T> f) {
|
||||
return getFromRecentsView(f, false);
|
||||
}
|
||||
|
||||
private <T> T getFromRecentsView(Function<RecentsView, T> f, boolean forTearDown) {
|
||||
if (enableLauncherOverviewInWindow()) {
|
||||
return getFromRecentsWindow(recentsWindowManager ->
|
||||
(forTearDown && recentsWindowManager == null)
|
||||
? null : f.apply(recentsWindowManager.getOverviewPanel()));
|
||||
} else {
|
||||
return getFromLauncher(launcher -> (forTearDown && launcher == null)
|
||||
? null : f.apply(launcher.getOverviewPanel()));
|
||||
}
|
||||
}
|
||||
|
||||
private void runOnRecentsView(Consumer<RecentsView> f) {
|
||||
runOnRecentsView(f, false);
|
||||
}
|
||||
|
||||
private void runOnRecentsView(Consumer<RecentsView> f, boolean forTearDown) {
|
||||
getFromRecentsView(recentsView -> {
|
||||
if (forTearDown && recentsView == null) {
|
||||
return null;
|
||||
}
|
||||
f.accept(recentsView);
|
||||
return null;
|
||||
}, forTearDown);
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,8 @@ package com.android.launcher3.allapps;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.LauncherState;
|
||||
import com.android.launcher3.tapl.AppIcon;
|
||||
@@ -31,7 +33,7 @@ import org.junit.Test;
|
||||
* The test runs in Out of process (Oop) and in process.
|
||||
* Makes sure the basic behaviors of Icons on AllApps are working.
|
||||
*/
|
||||
public class TaplAllAppsIconsWorkingTest extends AbstractLauncherUiTest<Launcher> {
|
||||
public class TaplAllAppsIconsWorkingTest extends AbstractLauncherUiTest<Launcher, View> {
|
||||
|
||||
/**
|
||||
* Makes sure we can launch an icon from All apps
|
||||
|
||||
@@ -24,6 +24,7 @@ import static org.junit.Assume.assumeTrue;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.platform.test.annotations.PlatinumTest;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
|
||||
@@ -39,7 +40,7 @@ import org.junit.Test;
|
||||
* Test that we can open and close the all apps in multiple situations.
|
||||
* The test runs in Out of process (Oop) and in process.
|
||||
*/
|
||||
public class TaplOpenCloseAllAppsTest extends AbstractLauncherUiTest<Launcher> {
|
||||
public class TaplOpenCloseAllAppsTest extends AbstractLauncherUiTest<Launcher, View> {
|
||||
|
||||
public static final String READ_DEVICE_CONFIG_PERMISSION =
|
||||
"android.permission.READ_DEVICE_CONFIG";
|
||||
|
||||
@@ -21,6 +21,7 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import android.platform.test.annotations.PlatinumTest;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.popup.ArrowPopup;
|
||||
@@ -38,7 +39,7 @@ import org.junit.Test;
|
||||
* Tests the AppIconMenu (the menu that appears when you long press an app icon) and also make sure
|
||||
* we can launch a shortcut from it.
|
||||
*/
|
||||
public class TaplAppIconMenuTest extends AbstractLauncherUiTest<Launcher> {
|
||||
public class TaplAppIconMenuTest extends AbstractLauncherUiTest<Launcher, View> {
|
||||
|
||||
private boolean isOptionsPopupVisible(Launcher launcher) {
|
||||
final ArrowPopup<?> popup = launcher.getOptionsPopup();
|
||||
|
||||
@@ -29,6 +29,7 @@ import android.graphics.Point;
|
||||
import android.os.SystemClock;
|
||||
import android.platform.test.annotations.PlatinumTest;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.tapl.Folder;
|
||||
@@ -54,7 +55,7 @@ import org.junit.Test;
|
||||
* * Can drag an icon from AllApps into the workspace
|
||||
* * Can drag an icon on the Workspace to other positions of the Workspace.
|
||||
*/
|
||||
public class TaplDragTest extends AbstractLauncherUiTest<Launcher> {
|
||||
public class TaplDragTest extends AbstractLauncherUiTest<Launcher, View> {
|
||||
|
||||
/**
|
||||
* Adds two icons to the Workspace and combines them into a folder, then makes sure the icons
|
||||
|
||||
@@ -28,6 +28,7 @@ import android.graphics.Point;
|
||||
import android.platform.test.annotations.PlatinumTest;
|
||||
import android.platform.test.rule.ScreenRecordRule;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.tapl.HomeAllApps;
|
||||
@@ -47,7 +48,7 @@ import java.util.Arrays;
|
||||
* Test runs in Out of process (Oop) and In process (Ipc)
|
||||
* Test the behaviour of uninstalling and removing apps both from AllApps, Workspace and Hotseat.
|
||||
*/
|
||||
public class TaplUninstallRemoveTest extends AbstractLauncherUiTest<Launcher> {
|
||||
public class TaplUninstallRemoveTest extends AbstractLauncherUiTest<Launcher, View> {
|
||||
|
||||
/**
|
||||
* Deletes app both built-in and user-installed from the Workspace and makes sure it's no longer
|
||||
|
||||
@@ -26,7 +26,9 @@ import android.content.Intent;
|
||||
import android.os.Process;
|
||||
import android.system.OsConstants;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.test.uiautomator.By;
|
||||
import androidx.test.uiautomator.BySelector;
|
||||
import androidx.test.uiautomator.Until;
|
||||
@@ -59,7 +61,8 @@ import java.util.function.Supplier;
|
||||
/**
|
||||
* Base class for all instrumentation tests providing various utility methods.
|
||||
*/
|
||||
public abstract class AbstractLauncherUiTest<LAUNCHER_TYPE extends Launcher>
|
||||
public abstract class AbstractLauncherUiTest<LAUNCHER_TYPE extends Launcher,
|
||||
OVERVIEW_TYPE extends View>
|
||||
extends BaseLauncherTaplTest {
|
||||
|
||||
private static final String TAG = "AbstractLauncherUiTest";
|
||||
@@ -91,7 +94,9 @@ public abstract class AbstractLauncherUiTest<LAUNCHER_TYPE extends Launcher>
|
||||
mLauncher.getWorkspace();
|
||||
|
||||
waitForLauncherCondition("Launcher didn't start", Objects::nonNull);
|
||||
waitForState("Launcher internal state didn't switch to Home",
|
||||
waitForState(
|
||||
/* forInitialization= */ true,
|
||||
/* message= */ "Launcher internal state didn't switch to Home",
|
||||
() -> LauncherState.NORMAL);
|
||||
waitForResumed("Launcher internal state is still Background");
|
||||
|
||||
@@ -150,9 +155,44 @@ public abstract class AbstractLauncherUiTest<LAUNCHER_TYPE extends Launcher>
|
||||
});
|
||||
}
|
||||
|
||||
protected void executeOnOverview(Consumer<OVERVIEW_TYPE> f) {
|
||||
executeOnOverview(false, f);
|
||||
}
|
||||
|
||||
protected void executeOnOverview(boolean forTearDown, Consumer<OVERVIEW_TYPE> f) {
|
||||
if (!TestHelpers.isInLauncherProcess()) return;
|
||||
getFromOverview(overview -> {
|
||||
if (overview != null || (!forTearDown && useNullOverview())) {
|
||||
f.accept(overview);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
protected <T> T getFromOverview(Function<OVERVIEW_TYPE, T> f) {
|
||||
if (!TestHelpers.isInLauncherProcess()) return null;
|
||||
return getOnUiThread(() -> f.apply(getOverviewPanel()));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected OVERVIEW_TYPE getOverviewPanel() {
|
||||
return getFromLauncher(Launcher::getOverviewPanel);
|
||||
}
|
||||
|
||||
protected boolean useNullOverview() {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Cannot be used in TaplTests between a Tapl call injecting a gesture and a tapl call
|
||||
// expecting the results of that gesture because the wait can hide flakeness.
|
||||
protected void waitForState(String message, Supplier<LauncherState> state) {
|
||||
waitForState(/* forInitialization= */ false, message, state);
|
||||
}
|
||||
|
||||
// Cannot be used in TaplTests between a Tapl call injecting a gesture and a tapl call
|
||||
// expecting the results of that gesture because the wait can hide flakeness.
|
||||
protected void waitForState(
|
||||
boolean forInitialization, String message, Supplier<LauncherState> state) {
|
||||
waitForLauncherCondition(message,
|
||||
launcher -> launcher.getStateManager().getCurrentStableState() == state.get());
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import static com.android.launcher3.LauncherPrefs.FIXED_LANDSCAPE_MODE;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.Surface;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.launcher3.Flags;
|
||||
import com.android.launcher3.Launcher;
|
||||
@@ -22,9 +23,10 @@ import java.lang.annotation.Target;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class PortraitLandscapeRunner<LAUNCHER_TYPE extends Launcher> implements TestRule {
|
||||
public class PortraitLandscapeRunner<LAUNCHER_TYPE extends Launcher, OVERVIEW_TYPE extends View>
|
||||
implements TestRule {
|
||||
private static final String TAG = "PortraitLandscapeRunner";
|
||||
private AbstractLauncherUiTest<LAUNCHER_TYPE> mTest;
|
||||
private AbstractLauncherUiTest<LAUNCHER_TYPE, OVERVIEW_TYPE> mTest;
|
||||
|
||||
// Annotation for tests that need to be run in portrait and landscape modes.
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@@ -32,7 +34,7 @@ public class PortraitLandscapeRunner<LAUNCHER_TYPE extends Launcher> implements
|
||||
public @interface PortraitLandscape {
|
||||
}
|
||||
|
||||
public PortraitLandscapeRunner(AbstractLauncherUiTest<LAUNCHER_TYPE> test) {
|
||||
public PortraitLandscapeRunner(AbstractLauncherUiTest<LAUNCHER_TYPE, OVERVIEW_TYPE> test) {
|
||||
mTest = test;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@ package com.android.launcher3.ui;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import androidx.test.filters.LargeTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
@@ -28,7 +30,7 @@ import org.junit.runner.RunWith;
|
||||
|
||||
@LargeTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class TaplTestsLauncher3Test extends AbstractLauncherUiTest<Launcher> {
|
||||
public class TaplTestsLauncher3Test extends AbstractLauncherUiTest<Launcher, View> {
|
||||
|
||||
@Test
|
||||
public void testDevicePressMenu() {
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.android.launcher3.ui.widget;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import android.platform.test.annotations.PlatinumTest;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import androidx.test.filters.LargeTest;
|
||||
@@ -43,7 +44,7 @@ import org.junit.runner.RunWith;
|
||||
*/
|
||||
@LargeTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class TaplAddWidgetTest extends AbstractLauncherUiTest<Launcher> {
|
||||
public class TaplAddWidgetTest extends AbstractLauncherUiTest<Launcher, View> {
|
||||
|
||||
@Rule
|
||||
public ShellCommandRule mGrantWidgetRule = ShellCommandRule.grantWidgetBind();
|
||||
|
||||
@@ -26,6 +26,8 @@ import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import androidx.test.filters.LargeTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
@@ -54,7 +56,7 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
@LargeTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class TaplTwoPanelWorkspaceTest extends AbstractLauncherUiTest<Launcher> {
|
||||
public class TaplTwoPanelWorkspaceTest extends AbstractLauncherUiTest<Launcher, View> {
|
||||
|
||||
private AutoCloseable mLauncherLayout;
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@ import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.LauncherState;
|
||||
import com.android.launcher3.tapl.HomeAppIcon;
|
||||
@@ -37,7 +39,7 @@ import org.junit.Test;
|
||||
/**
|
||||
* Test the basic interactions of the Workspace, adding pages, moving the pages and removing pages.
|
||||
*/
|
||||
public class TaplWorkspaceTest extends AbstractLauncherUiTest<Launcher> {
|
||||
public class TaplWorkspaceTest extends AbstractLauncherUiTest<Launcher, View> {
|
||||
|
||||
private AutoCloseable mLauncherLayout;
|
||||
|
||||
|
||||
Reference in new issue
Block a user