feat: Add option to clear home screen in settings (#6125)
Signed-off-by: abhixv <abhi.sharma1@hotmail.com>
This commit is contained in:
1 parent
9898749619
commit
5f3a03f4fb
1577 files changed
+112559
-80244
No files matched your search
@@ -24,22 +24,13 @@ import androidx.test.uiautomator.By;
|
||||
import androidx.test.uiautomator.Until;
|
||||
|
||||
import com.android.launcher3.tapl.LaunchedAppState;
|
||||
import com.android.launcher3.tapl.TestHelpers;
|
||||
import com.android.launcher3.ui.AbstractLauncherUiTest;
|
||||
import com.android.launcher3.uioverrides.QuickstepLauncher;
|
||||
import com.android.launcher3.util.TestUtil;
|
||||
import com.android.launcher3.util.Wait;
|
||||
import com.android.quickstep.fallback.RecentsState;
|
||||
import com.android.quickstep.fallback.window.RecentsWindowManager;
|
||||
import com.android.quickstep.views.RecentsView;
|
||||
|
||||
import org.junit.rules.RuleChain;
|
||||
import org.junit.rules.TestRule;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Base class for all instrumentation tests that deal with Quickstep.
|
||||
*/
|
||||
@@ -62,48 +53,10 @@ 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<RecentsState> state) {
|
||||
waitForRecentsWindowCondition(message, recentsWindow ->
|
||||
recentsWindow.getStateManager().getCurrentStableState() == state.get());
|
||||
}
|
||||
|
||||
// Cannot be used in TaplTests after injecting any gesture using Tapl because this can hide
|
||||
// flakiness.
|
||||
protected void waitForRecentsWindowCondition(String
|
||||
message, Function<RecentsWindowManager, Boolean> condition) {
|
||||
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;
|
||||
});
|
||||
}
|
||||
|
||||
// Cannot be used in TaplTests after injecting any gesture using Tapl because this can hide
|
||||
// flakiness.
|
||||
protected void waitForRecentsWindowCondition(
|
||||
String message, Function<RecentsWindowManager, Boolean> condition, long timeout) {
|
||||
verifyKeyguardInvisible();
|
||||
if (!TestHelpers.isInLauncherProcess()) return;
|
||||
Wait.atMost(message, () -> getFromRecentsWindow(condition), mLauncher, timeout);
|
||||
}
|
||||
|
||||
protected boolean isInRecentsWindowState(Supplier<RecentsState> state) {
|
||||
if (!TestHelpers.isInLauncherProcess()) return true;
|
||||
return getFromRecentsWindow(
|
||||
recentsWindow -> recentsWindow.getStateManager().getState() == state.get());
|
||||
}
|
||||
|
||||
protected void assertTestActivityIsRunning(int activityNumber, String message) {
|
||||
assertTrue(message, mDevice.wait(
|
||||
Until.hasObject(By.pkg(getAppPackageName()).text("TestActivity" + activityNumber)),
|
||||
TestUtil.DEFAULT_UI_TIMEOUT));
|
||||
DEFAULT_UI_TIMEOUT));
|
||||
}
|
||||
|
||||
protected LaunchedAppState getAndAssertLaunchedApp() {
|
||||
|
||||
@@ -55,9 +55,7 @@ public class AbstractTaplTestsTaskbar extends AbstractQuickStepTest {
|
||||
"com.android.launcher3.testcomponent.BaseTestingActivity");
|
||||
mLauncherLayout = TestUtil.setLauncherDefaultLayout(mTargetContext, layoutBuilder);
|
||||
AbstractLauncherUiTest.initialize(this);
|
||||
if (startCalendarAppDuringSetup()) {
|
||||
startAppFast(CALCULATOR_APP_PACKAGE);
|
||||
}
|
||||
startAppFast(CALCULATOR_APP_PACKAGE);
|
||||
mLauncher.enableBlockTimeout(true);
|
||||
mLauncher.showTaskbarIfHidden();
|
||||
}
|
||||
@@ -74,20 +72,8 @@ public class AbstractTaplTestsTaskbar extends AbstractQuickStepTest {
|
||||
return DisplayController.isTransientTaskbar(context);
|
||||
}
|
||||
|
||||
protected boolean startCalendarAppDuringSetup() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean expectTaskbarIconsMatchHotseat() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected Taskbar getTaskbar() {
|
||||
Taskbar taskbar = mLauncher.getLaunchedAppState().getTaskbar();
|
||||
if (!expectTaskbarIconsMatchHotseat()) {
|
||||
return taskbar;
|
||||
}
|
||||
|
||||
List<String> taskbarIconNames = taskbar.getIconNames();
|
||||
List<String> hotseatIconNames = mLauncher.getHotseatIconNames();
|
||||
|
||||
|
||||
@@ -16,50 +16,35 @@
|
||||
|
||||
package com.android.quickstep
|
||||
|
||||
import android.Manifest.permission.SYSTEM_ALERT_WINDOW
|
||||
import android.content.ComponentName
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageInfo
|
||||
import android.content.pm.PackageManager
|
||||
import android.platform.test.annotations.DisableFlags
|
||||
import android.platform.test.annotations.EnableFlags
|
||||
import android.platform.test.flag.junit.SetFlagsRule
|
||||
import android.view.Display.DEFAULT_DISPLAY
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import com.android.dx.mockito.inline.extended.ExtendedMockito
|
||||
import com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession
|
||||
import com.android.dx.mockito.inline.extended.StaticMockitoSession
|
||||
import com.android.internal.R
|
||||
import com.android.launcher3.AbstractFloatingView
|
||||
import com.android.launcher3.AbstractFloatingViewHelper
|
||||
import com.android.launcher3.Flags.enableRefactorTaskThumbnail
|
||||
import com.android.launcher3.logging.StatsLogManager
|
||||
import com.android.launcher3.logging.StatsLogManager.LauncherEvent
|
||||
import com.android.launcher3.model.data.TaskViewItemInfo
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo
|
||||
import com.android.launcher3.uioverrides.QuickstepLauncher
|
||||
import com.android.launcher3.util.SplitConfigurationOptions
|
||||
import com.android.launcher3.util.TransformingTouchDelegate
|
||||
import com.android.quickstep.TaskOverlayFactory.TaskOverlay
|
||||
import com.android.quickstep.task.thumbnail.TaskThumbnailView
|
||||
import com.android.quickstep.views.LauncherRecentsView
|
||||
import com.android.quickstep.views.RecentsViewContainer
|
||||
import com.android.quickstep.views.TaskContainer
|
||||
import com.android.quickstep.views.TaskThumbnailViewDeprecated
|
||||
import com.android.quickstep.views.TaskView
|
||||
import com.android.quickstep.views.TaskViewIcon
|
||||
import com.android.quickstep.views.TaskViewType
|
||||
import com.android.systemui.shared.recents.model.Task
|
||||
import com.android.systemui.shared.recents.model.Task.TaskKey
|
||||
import com.android.window.flags.Flags
|
||||
import com.android.wm.shell.shared.desktopmode.DesktopModeStatus
|
||||
import com.android.wm.shell.shared.desktopmode.DesktopModeTransitionSource
|
||||
import com.android.wm.shell.common.desktopmode.DesktopModeTransitionSource
|
||||
import com.android.wm.shell.shared.DesktopModeStatus
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.mockito.ArgumentMatchers.anyInt
|
||||
import org.mockito.ArgumentMatchers.anyString
|
||||
import org.mockito.Mockito.`when`
|
||||
import org.mockito.kotlin.any
|
||||
import org.mockito.kotlin.doReturn
|
||||
import org.mockito.kotlin.eq
|
||||
@@ -69,22 +54,25 @@ import org.mockito.kotlin.verify
|
||||
import org.mockito.kotlin.whenever
|
||||
import org.mockito.quality.Strictness
|
||||
|
||||
/** Test for [DesktopSystemShortcut] */
|
||||
// TODO(b/403558856): Improve test coverage for DesktopModeCompatPolicy integration.
|
||||
/** Test for DesktopSystemShortcut */
|
||||
class DesktopSystemShortcutTest {
|
||||
|
||||
@get:Rule val setFlagsRule = SetFlagsRule(SetFlagsRule.DefaultInitValueType.DEVICE_DEFAULT)
|
||||
|
||||
private val launcher: RecentsViewContainer = mock()
|
||||
private val launcher: QuickstepLauncher = mock()
|
||||
private val statsLogManager: StatsLogManager = mock()
|
||||
private val statsLogger: StatsLogManager.StatsLogger = mock()
|
||||
private val recentsView: LauncherRecentsView = mock()
|
||||
private val taskView: TaskView = mock()
|
||||
private val workspaceItemInfo: WorkspaceItemInfo = mock()
|
||||
private val abstractFloatingViewHelper: AbstractFloatingViewHelper = mock()
|
||||
private val overlayFactory: TaskOverlayFactory = mock()
|
||||
private val thumbnailViewDeprecated: TaskThumbnailViewDeprecated = mock()
|
||||
private val iconView: TaskViewIcon = mock()
|
||||
private val transformingTouchDelegate: TransformingTouchDelegate = mock()
|
||||
private val factory: TaskShortcutFactory =
|
||||
DesktopSystemShortcut.createFactory(abstractFloatingViewHelper)
|
||||
private val context: Context = spy(InstrumentationRegistry.getInstrumentation().targetContext)
|
||||
private val taskView: TaskView = createTaskViewMock()
|
||||
private val overlayFactory: TaskOverlayFactory = mock()
|
||||
private val overlay: TaskOverlay<*> = mock()
|
||||
|
||||
private lateinit var mockitoSession: StaticMockitoSession
|
||||
|
||||
@@ -93,11 +81,11 @@ class DesktopSystemShortcutTest {
|
||||
mockitoSession =
|
||||
mockitoSession()
|
||||
.strictness(Strictness.LENIENT)
|
||||
.mockStatic(DesktopModeStatus::class.java)
|
||||
.spyStatic(DesktopModeStatus::class.java)
|
||||
.startMocking()
|
||||
whenever(DesktopModeStatus.canEnterDesktopMode(any())).thenReturn(true)
|
||||
whenever(overlayFactory.createOverlay(any())).thenReturn(mock<TaskOverlay<*>>())
|
||||
whenever(launcher.asContext()).thenReturn(context)
|
||||
ExtendedMockito.doReturn(true).`when` { DesktopModeStatus.enforceDeviceRestrictions() }
|
||||
ExtendedMockito.doReturn(true).`when` { DesktopModeStatus.isDesktopModeSupported(any()) }
|
||||
whenever(overlayFactory.createOverlay(any())).thenReturn(overlay)
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -107,7 +95,22 @@ class DesktopSystemShortcutTest {
|
||||
|
||||
@Test
|
||||
fun createDesktopTaskShortcutFactory_desktopModeDisabled() {
|
||||
`when`(DesktopModeStatus.canEnterDesktopMode(any())).thenReturn(false)
|
||||
setFlagsRule.disableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE)
|
||||
|
||||
val task =
|
||||
Task(TaskKey(1, 0, Intent(), ComponentName("", ""), 0, 2000)).apply {
|
||||
isDockable = true
|
||||
}
|
||||
val taskContainer = createTaskContainer(task)
|
||||
|
||||
val shortcuts = factory.getShortcuts(launcher, taskContainer)
|
||||
assertThat(shortcuts).isNull()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun createDesktopTaskShortcutFactory_desktopModeEnabled_DeviceNotSupported() {
|
||||
setFlagsRule.enableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE)
|
||||
ExtendedMockito.doReturn(false).`when` { DesktopModeStatus.isDesktopModeSupported(any()) }
|
||||
|
||||
val taskContainer = createTaskContainer(createTask())
|
||||
|
||||
@@ -116,139 +119,22 @@ class DesktopSystemShortcutTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODALS_POLICY)
|
||||
@DisableFlags(Flags.FLAG_ENABLE_MODALS_FULLSCREEN_WITH_PERMISSION)
|
||||
fun createDesktopTaskShortcutFactory_transparentTask() {
|
||||
val baseComponent = ComponentName("", /* class */ "")
|
||||
val taskKey =
|
||||
TaskKey(
|
||||
/* id */ 1,
|
||||
/* windowingMode */ 0,
|
||||
Intent(),
|
||||
baseComponent,
|
||||
/* userId */ 0,
|
||||
/* lastActiveTime */ 2000,
|
||||
DEFAULT_DISPLAY,
|
||||
baseComponent,
|
||||
/* numActivities */ 1,
|
||||
/* isTopActivityNoDisplay */ false,
|
||||
/* isActivityStackTransparent */ true,
|
||||
)
|
||||
val taskContainer = createTaskContainer(Task(taskKey))
|
||||
val shortcuts = factory.getShortcuts(launcher, taskContainer)
|
||||
assertThat(shortcuts).isNull()
|
||||
}
|
||||
fun createDesktopTaskShortcutFactory_desktopModeEnabled_DeviceNotSupported_OverrideEnabled() {
|
||||
setFlagsRule.enableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE)
|
||||
ExtendedMockito.doReturn(false).`when` { DesktopModeStatus.isDesktopModeSupported(any()) }
|
||||
ExtendedMockito.doReturn(false).`when` { DesktopModeStatus.enforceDeviceRestrictions() }
|
||||
|
||||
@Test
|
||||
@EnableFlags(
|
||||
Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODALS_POLICY,
|
||||
Flags.FLAG_ENABLE_MODALS_FULLSCREEN_WITH_PERMISSION,
|
||||
)
|
||||
fun createDesktopTaskShortcutFactoryPermissionEnabledAllowed_transparentTask() {
|
||||
val packageManager: PackageManager = mock()
|
||||
setUpTransparentPermission(packageManager, isAllowed = true)
|
||||
val baseComponent = ComponentName("", /* class */ "")
|
||||
val taskKey =
|
||||
TaskKey(
|
||||
/* id */ 1,
|
||||
/* windowingMode */ 0,
|
||||
Intent(),
|
||||
baseComponent,
|
||||
/* userId */ 0,
|
||||
/* lastActiveTime */ 2000,
|
||||
DEFAULT_DISPLAY,
|
||||
baseComponent,
|
||||
/* numActivities */ 1,
|
||||
/* isTopActivityNoDisplay */ false,
|
||||
/* isActivityStackTransparent */ true,
|
||||
)
|
||||
val taskContainer = createTaskContainer(Task(taskKey))
|
||||
val shortcuts = factory.getShortcuts(launcher, taskContainer)
|
||||
assertThat(shortcuts).isNull()
|
||||
}
|
||||
val taskContainer = spy(createTaskContainer(createTask()))
|
||||
doReturn(workspaceItemInfo).whenever(taskContainer).itemInfo
|
||||
|
||||
@Test
|
||||
@EnableFlags(
|
||||
Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODALS_POLICY,
|
||||
Flags.FLAG_ENABLE_MODALS_FULLSCREEN_WITH_PERMISSION,
|
||||
)
|
||||
fun createDesktopTaskShortcutFactoryPermissionEnabledNotAllowed_transparentTask() {
|
||||
val packageManager: PackageManager = mock()
|
||||
setUpTransparentPermission(packageManager, isAllowed = false)
|
||||
val baseComponent = ComponentName("", /* class */ "")
|
||||
val homeActivities = ComponentName("defaultHomePackage", /* class */ "")
|
||||
whenever(packageManager.getHomeActivities(any())).thenReturn(homeActivities)
|
||||
val taskKey =
|
||||
TaskKey(
|
||||
/* id */ 1,
|
||||
/* windowingMode */ 0,
|
||||
Intent(),
|
||||
baseComponent,
|
||||
/* userId */ 0,
|
||||
/* lastActiveTime */ 2000,
|
||||
DEFAULT_DISPLAY,
|
||||
baseComponent,
|
||||
/* numActivities */ 1,
|
||||
/* isTopActivityNoDisplay */ false,
|
||||
/* isActivityStackTransparent */ true,
|
||||
)
|
||||
val taskContainer = createTaskContainer(Task(taskKey).apply { isDockable = true })
|
||||
val shortcuts = factory.getShortcuts(launcher, taskContainer)
|
||||
assertThat(shortcuts).isNotEmpty()
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODALS_POLICY)
|
||||
fun createDesktopTaskShortcutFactory_systemUiTask() {
|
||||
val sysUiPackageName: String = context.resources.getString(R.string.config_systemUi)
|
||||
val baseComponent = ComponentName(sysUiPackageName, /* class */ "")
|
||||
val taskKey =
|
||||
TaskKey(
|
||||
/* id */ 1,
|
||||
/* windowingMode */ 0,
|
||||
Intent(),
|
||||
baseComponent,
|
||||
/* userId */ 0,
|
||||
/* lastActiveTime */ 2000,
|
||||
DEFAULT_DISPLAY,
|
||||
baseComponent,
|
||||
/* numActivities */ 1,
|
||||
/* isTopActivityNoDisplay */ false,
|
||||
/* isActivityStackTransparent */ false,
|
||||
)
|
||||
val taskContainer = createTaskContainer(Task(taskKey))
|
||||
val shortcuts = factory.getShortcuts(launcher, taskContainer)
|
||||
assertThat(shortcuts).isNull()
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODALS_POLICY)
|
||||
fun createDesktopTaskShortcutFactory_defaultHomeTask() {
|
||||
val packageManager: PackageManager = mock()
|
||||
whenever(context.packageManager).thenReturn(packageManager)
|
||||
val homeActivities = ComponentName("defaultHomePackage", /* class */ "")
|
||||
whenever(packageManager.getHomeActivities(any())).thenReturn(homeActivities)
|
||||
val taskKey =
|
||||
TaskKey(
|
||||
/* id */ 1,
|
||||
/* windowingMode */ 0,
|
||||
Intent(),
|
||||
homeActivities,
|
||||
/* userId */ 0,
|
||||
/* lastActiveTime */ 2000,
|
||||
DEFAULT_DISPLAY,
|
||||
homeActivities,
|
||||
/* numActivities */ 1,
|
||||
/* isTopActivityNoDisplay */ false,
|
||||
/* isActivityStackTransparent */ false,
|
||||
)
|
||||
val taskContainer = createTaskContainer(Task(taskKey).apply { isDockable = true })
|
||||
val shortcuts = factory.getShortcuts(launcher, taskContainer)
|
||||
assertThat(shortcuts).isNull()
|
||||
assertThat(shortcuts).isNotNull()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun createDesktopTaskShortcutFactory_undockable() {
|
||||
setFlagsRule.enableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE)
|
||||
|
||||
val unDockableTask = createTask().apply { isDockable = false }
|
||||
val taskContainer = createTaskContainer(unDockableTask)
|
||||
|
||||
@@ -258,6 +144,8 @@ class DesktopSystemShortcutTest {
|
||||
|
||||
@Test
|
||||
fun desktopSystemShortcutClicked() {
|
||||
setFlagsRule.enableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE)
|
||||
|
||||
val task = createTask()
|
||||
val taskContainer = spy(createTaskContainer(task))
|
||||
|
||||
@@ -265,19 +153,17 @@ class DesktopSystemShortcutTest {
|
||||
whenever(launcher.statsLogManager).thenReturn(statsLogManager)
|
||||
whenever(statsLogManager.logger()).thenReturn(statsLogger)
|
||||
whenever(statsLogger.withItemInfo(any())).thenReturn(statsLogger)
|
||||
whenever(taskView.context).thenReturn(context)
|
||||
whenever(recentsView.moveTaskToDesktop(any(), any(), any())).thenAnswer {
|
||||
val successCallback = it.getArgument<Runnable>(2)
|
||||
successCallback.run()
|
||||
}
|
||||
val taskViewItemInfo = mock<TaskViewItemInfo>()
|
||||
doReturn(taskViewItemInfo).whenever(taskContainer).itemInfo
|
||||
doReturn(workspaceItemInfo).whenever(taskContainer).itemInfo
|
||||
|
||||
val shortcuts = factory.getShortcuts(launcher, taskContainer)
|
||||
assertThat(shortcuts).isNotNull()
|
||||
assertThat(shortcuts!!.single()).isInstanceOf(DesktopSystemShortcut::class.java)
|
||||
assertThat(shortcuts).hasSize(1)
|
||||
assertThat(shortcuts!!.first()).isInstanceOf(DesktopSystemShortcut::class.java)
|
||||
|
||||
val desktopShortcut = shortcuts.single() as DesktopSystemShortcut
|
||||
val desktopShortcut = shortcuts.first() as DesktopSystemShortcut
|
||||
|
||||
desktopShortcut.onClick(taskView)
|
||||
|
||||
@@ -288,64 +174,29 @@ class DesktopSystemShortcutTest {
|
||||
.moveTaskToDesktop(
|
||||
eq(taskContainer),
|
||||
eq(DesktopModeTransitionSource.APP_FROM_OVERVIEW),
|
||||
any(),
|
||||
any()
|
||||
)
|
||||
verify(statsLogger).withItemInfo(taskViewItemInfo)
|
||||
verify(statsLogger).withItemInfo(workspaceItemInfo)
|
||||
verify(statsLogger).log(LauncherEvent.LAUNCHER_SYSTEM_SHORTCUT_DESKTOP_TAP)
|
||||
}
|
||||
|
||||
private fun createTask() =
|
||||
Task(
|
||||
TaskKey(
|
||||
/* id */ 1,
|
||||
/* windowingMode */ 0,
|
||||
Intent(),
|
||||
ComponentName("", ""),
|
||||
/* userId */ 0,
|
||||
/* lastActiveTime */ 2000,
|
||||
DEFAULT_DISPLAY,
|
||||
ComponentName("", ""),
|
||||
/* numActivities */ 1,
|
||||
/* isTopActivityNoDisplay */ false,
|
||||
/* isActivityStackTransparent */ false,
|
||||
)
|
||||
)
|
||||
.apply { isDockable = true }
|
||||
private fun createTask(): Task {
|
||||
return Task(TaskKey(1, 0, Intent(), ComponentName("", ""), 0, 2000)).apply {
|
||||
isDockable = true
|
||||
}
|
||||
}
|
||||
|
||||
private fun createTaskContainer(task: Task) =
|
||||
TaskContainer(
|
||||
taskView,
|
||||
private fun createTaskContainer(task: Task): TaskView.TaskContainer {
|
||||
return taskView.TaskContainer(
|
||||
task,
|
||||
if (enableRefactorTaskThumbnail()) mock<TaskThumbnailView>()
|
||||
else mock<TaskThumbnailViewDeprecated>(),
|
||||
mock<TaskViewIcon>(),
|
||||
mock<TransformingTouchDelegate>(),
|
||||
thumbnailView = null,
|
||||
thumbnailViewDeprecated,
|
||||
iconView,
|
||||
transformingTouchDelegate,
|
||||
SplitConfigurationOptions.STAGE_POSITION_UNDEFINED,
|
||||
digitalWellBeingToast = null,
|
||||
showWindowsView = null,
|
||||
overlayFactory,
|
||||
overlayFactory
|
||||
)
|
||||
|
||||
private fun setUpTransparentPermission(packageManager: PackageManager, isAllowed: Boolean) {
|
||||
val packageInfo: PackageInfo = mock()
|
||||
if (isAllowed) {
|
||||
packageInfo.requestedPermissions = arrayOf(SYSTEM_ALERT_WINDOW)
|
||||
}
|
||||
whenever(context.packageManager).thenReturn(packageManager)
|
||||
whenever(
|
||||
packageManager.getPackageInfoAsUser(
|
||||
anyString(),
|
||||
eq(PackageManager.GET_PERMISSIONS),
|
||||
anyInt(),
|
||||
)
|
||||
)
|
||||
.thenReturn(packageInfo)
|
||||
}
|
||||
|
||||
private fun createTaskViewMock(): TaskView {
|
||||
val taskView: TaskView = mock()
|
||||
whenever(taskView.type).thenReturn(TaskViewType.SINGLE)
|
||||
whenever(taskView.context).thenReturn(context)
|
||||
return taskView
|
||||
}
|
||||
}
|
||||
@@ -19,11 +19,12 @@ import static android.content.pm.PackageManager.MATCH_DISABLED_COMPONENTS;
|
||||
|
||||
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;
|
||||
import static com.android.launcher3.ui.AbstractLauncherUiTest.DEFAULT_ACTIVITY_TIMEOUT;
|
||||
import static com.android.launcher3.ui.AbstractLauncherUiTest.DEFAULT_BROADCAST_TIMEOUT_SECS;
|
||||
import static com.android.launcher3.ui.AbstractLauncherUiTest.DEFAULT_UI_TIMEOUT;
|
||||
import static com.android.launcher3.ui.AbstractLauncherUiTest.resolveSystemApp;
|
||||
import static com.android.launcher3.ui.AbstractLauncherUiTest.startAppFast;
|
||||
import static com.android.launcher3.ui.AbstractLauncherUiTest.startTestActivity;
|
||||
@@ -55,7 +56,6 @@ import com.android.launcher3.tapl.OverviewTask;
|
||||
import com.android.launcher3.tapl.TestHelpers;
|
||||
import com.android.launcher3.testcomponent.TestCommandReceiver;
|
||||
import com.android.launcher3.ui.AbstractLauncherUiTest;
|
||||
import com.android.launcher3.util.TestUtil;
|
||||
import com.android.launcher3.util.Wait;
|
||||
import com.android.launcher3.util.rule.ExtendedLongPressTimeoutRule;
|
||||
import com.android.launcher3.util.rule.FailureWatcher;
|
||||
@@ -64,10 +64,7 @@ import com.android.launcher3.util.rule.ScreenRecordRule;
|
||||
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.RecentsWindowManager;
|
||||
import com.android.quickstep.views.RecentsView;
|
||||
import com.android.quickstep.views.RecentsViewContainer;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
@@ -145,7 +142,7 @@ public class FallbackRecentsTest {
|
||||
};
|
||||
|
||||
final ViewCaptureRule viewCaptureRule = new ViewCaptureRule(
|
||||
RecentsActivity.ACTIVITY_TRACKER::getCreatedContext);
|
||||
RecentsActivity.ACTIVITY_TRACKER::getCreatedActivity);
|
||||
mOrderSensitiveRules = RuleChain
|
||||
.outerRule(new SamplerRule())
|
||||
.around(new TestStabilityRule())
|
||||
@@ -195,31 +192,29 @@ public class FallbackRecentsTest {
|
||||
@Test
|
||||
public void goToOverviewFromApp() {
|
||||
startAppFast(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR));
|
||||
waitForRecentsClosed();
|
||||
waitForRecentsActivityStop();
|
||||
|
||||
mLauncher.getLaunchedAppState().switchToOverview();
|
||||
}
|
||||
|
||||
protected void executeOnRecents(Consumer<RecentsViewContainer> f) {
|
||||
protected void executeOnRecents(Consumer<RecentsActivity> f) {
|
||||
getFromRecents(r -> {
|
||||
f.accept(r);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
protected <T> T getFromRecents(Function<RecentsViewContainer, T> f) {
|
||||
protected <T> T getFromRecents(Function<RecentsActivity, T> f) {
|
||||
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();
|
||||
if (recentsViewContainer == null) {
|
||||
RecentsActivity activity = RecentsActivity.ACTIVITY_TRACKER.getCreatedActivity();
|
||||
if (activity == null) {
|
||||
return false;
|
||||
}
|
||||
result[0] = f.apply(recentsViewContainer);
|
||||
result[0] = f.apply(activity);
|
||||
return true;
|
||||
}).get(), mLauncher);
|
||||
}).get(), DEFAULT_UI_TIMEOUT, mLauncher);
|
||||
return (T) result[0];
|
||||
}
|
||||
|
||||
@@ -230,19 +225,14 @@ public class FallbackRecentsTest {
|
||||
|
||||
private void pressHomeAndWaitForOverviewClose() {
|
||||
mDevice.pressHome();
|
||||
waitForRecentsClosed();
|
||||
waitForRecentsActivityStop();
|
||||
}
|
||||
|
||||
private void waitForRecentsClosed() {
|
||||
private void waitForRecentsActivityStop() {
|
||||
try {
|
||||
final boolean isRecentsContainerNUll = MAIN_EXECUTOR.submit(() -> {
|
||||
RecentsViewContainer recentsViewContainer = enableFallbackOverviewInWindow()
|
||||
? RecentsWindowManager.getRecentsWindowTracker().getCreatedContext()
|
||||
: RecentsActivity.ACTIVITY_TRACKER.getCreatedContext();
|
||||
|
||||
return recentsViewContainer == null;
|
||||
}).get();
|
||||
if (isRecentsContainerNUll) {
|
||||
final boolean recentsActivityIsNull = MAIN_EXECUTOR.submit(
|
||||
() -> RecentsActivity.ACTIVITY_TRACKER.getCreatedActivity() == null).get();
|
||||
if (recentsActivityIsNull) {
|
||||
// Null activity counts as a "stopped" one.
|
||||
return;
|
||||
}
|
||||
@@ -252,9 +242,9 @@ public class FallbackRecentsTest {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
Wait.atMost("Recents view container didn't close",
|
||||
Wait.atMost("Recents activity didn't stop",
|
||||
() -> getFromRecents(recents -> !recents.isStarted()),
|
||||
mLauncher);
|
||||
DEFAULT_UI_TIMEOUT, mLauncher);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -262,10 +252,9 @@ public class FallbackRecentsTest {
|
||||
startAppFast(getAppPackageName());
|
||||
startAppFast(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR));
|
||||
startTestActivity(2);
|
||||
waitForRecentsClosed();
|
||||
waitForRecentsActivityStop();
|
||||
Wait.atMost("Expected three apps in the task list",
|
||||
() -> mLauncher.getRecentTasks().size() >= 3,
|
||||
mLauncher);
|
||||
() -> mLauncher.getRecentTasks().size() >= 3, DEFAULT_ACTIVITY_TIMEOUT, mLauncher);
|
||||
|
||||
checkTestLauncher();
|
||||
BaseOverview overview = mLauncher.getLaunchedAppState().switchToOverview();
|
||||
@@ -293,7 +282,7 @@ public class FallbackRecentsTest {
|
||||
assertNotNull("OverviewTask.open returned null", task.open());
|
||||
assertTrue("Test activity didn't open from Overview", TestHelpers.wait(Until.hasObject(
|
||||
By.pkg(getAppPackageName()).text("TestActivity2")),
|
||||
TestUtil.DEFAULT_UI_TIMEOUT));
|
||||
DEFAULT_UI_TIMEOUT));
|
||||
|
||||
|
||||
// Test dismissing a task.
|
||||
@@ -323,39 +312,37 @@ public class FallbackRecentsTest {
|
||||
);
|
||||
}
|
||||
|
||||
private int getCurrentOverviewPage(RecentsViewContainer recentsViewContainer) {
|
||||
return recentsViewContainer.<RecentsView>getOverviewPanel().getCurrentPage();
|
||||
private int getCurrentOverviewPage(RecentsActivity recents) {
|
||||
return recents.<RecentsView>getOverviewPanel().getCurrentPage();
|
||||
}
|
||||
|
||||
private int getTaskCount(RecentsViewContainer recentsViewContainer) {
|
||||
return recentsViewContainer.<RecentsView>getOverviewPanel().getTaskViewCount();
|
||||
private int getTaskCount(RecentsActivity recents) {
|
||||
return recents.<RecentsView>getOverviewPanel().getTaskViewCount();
|
||||
}
|
||||
|
||||
private class OverviewUpdateHandler implements OverviewChangeListener {
|
||||
private class OverviewUpdateHandler {
|
||||
|
||||
final RecentsAnimationDeviceState mRads;
|
||||
final OverviewComponentObserver mObserver;
|
||||
final CountDownLatch mChangeCounter;
|
||||
|
||||
OverviewUpdateHandler() {
|
||||
Context ctx = getInstrumentation().getTargetContext();
|
||||
mObserver = OverviewComponentObserver.INSTANCE.get(ctx);
|
||||
mRads = new RecentsAnimationDeviceState(ctx);
|
||||
mObserver = new OverviewComponentObserver(ctx, mRads);
|
||||
mChangeCounter = new CountDownLatch(1);
|
||||
if (mObserver.getHomeIntent().getComponent()
|
||||
.getPackageName().equals(mOtherLauncherActivity.packageName)) {
|
||||
// Home already same
|
||||
mChangeCounter.countDown();
|
||||
} else {
|
||||
mObserver.addOverviewChangeListener(this);
|
||||
mObserver.setOverviewChangeListener(b -> mChangeCounter.countDown());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOverviewTargetChange(boolean isHomeAndOverviewSame) {
|
||||
mChangeCounter.countDown();
|
||||
}
|
||||
|
||||
void destroy() {
|
||||
mObserver.removeOverviewChangeListener(this);
|
||||
mObserver.onDestroy();
|
||||
mRads.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.android.quickstep;
|
||||
|
||||
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
|
||||
import static androidx.test.InstrumentationRegistry.getInstrumentation;
|
||||
|
||||
import static com.android.quickstep.NavigationModeSwitchRule.Mode.ALL;
|
||||
import static com.android.quickstep.NavigationModeSwitchRule.Mode.THREE_BUTTON;
|
||||
@@ -26,7 +26,6 @@ import static com.android.systemui.shared.system.QuickStepContract.NAV_BAR_MODE_
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Process;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.test.uiautomator.UiDevice;
|
||||
@@ -58,6 +57,8 @@ public class NavigationModeSwitchRule implements TestRule {
|
||||
|
||||
static final String TAG = "QuickStepOnOffRule";
|
||||
|
||||
public static final int WAIT_TIME_MS = 10000;
|
||||
|
||||
public enum Mode {
|
||||
THREE_BUTTON, ZERO_BUTTON, ALL
|
||||
}
|
||||
@@ -154,9 +155,7 @@ public class NavigationModeSwitchRule implements TestRule {
|
||||
|
||||
Log.d(TAG, "setActiveOverlay: " + overlayPackage + "...");
|
||||
UiDevice.getInstance(getInstrumentation()).executeShellCommand(
|
||||
String.format("cmd overlay enable-exclusive --user %d --category %s",
|
||||
Process.myUserHandle().getIdentifier(),
|
||||
overlayPackage));
|
||||
"cmd overlay enable-exclusive --category " + overlayPackage);
|
||||
|
||||
if (currentSysUiNavigationMode() != expectedMode) {
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
@@ -180,13 +179,12 @@ public class NavigationModeSwitchRule implements TestRule {
|
||||
}
|
||||
|
||||
Wait.atMost("Couldn't switch to " + overlayPackage,
|
||||
() -> launcher.getNavigationModel() == expectedMode,
|
||||
launcher);
|
||||
() -> launcher.getNavigationModel() == expectedMode, WAIT_TIME_MS, launcher);
|
||||
|
||||
Wait.atMost(() -> "Switching nav mode: "
|
||||
+ launcher.getNavigationModeMismatchError(false),
|
||||
() -> launcher.getNavigationModeMismatchError(false) == null,
|
||||
launcher);
|
||||
WAIT_TIME_MS, launcher);
|
||||
AbstractLauncherUiTest.checkDetectedLeaks(launcher, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
|
||||
|
||||
import static com.android.launcher3.util.NavigationMode.NO_BUTTON;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
@@ -42,8 +41,6 @@ import android.view.Surface;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.launcher3.testing.shared.ResourceUtils;
|
||||
import com.android.launcher3.util.DaggerSingletonTracker;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
import com.android.launcher3.util.RotationUtils;
|
||||
import com.android.launcher3.util.WindowBounds;
|
||||
@@ -91,7 +88,7 @@ public class OrientationTouchTransformerTest {
|
||||
float landscapeRegionY =
|
||||
generateTouchRegionHeight(NORMAL_SCREEN_SIZE, Surface.ROTATION_90) + 1;
|
||||
|
||||
mTouchTransformer.createOrAddTouchRegion(mInfo, "test");
|
||||
mTouchTransformer.createOrAddTouchRegion(mInfo);
|
||||
tapAndAssertTrue(100, portraitRegionY,
|
||||
event -> mTouchTransformer.touchInValidSwipeRegions(event.getX(), event.getY()));
|
||||
tapAndAssertFalse(100, landscapeRegionY,
|
||||
@@ -103,8 +100,7 @@ public class OrientationTouchTransformerTest {
|
||||
|
||||
// Override region
|
||||
mTouchTransformer
|
||||
.createOrAddTouchRegion(createDisplayInfo(NORMAL_SCREEN_SIZE, Surface.ROTATION_90),
|
||||
"test");
|
||||
.createOrAddTouchRegion(createDisplayInfo(NORMAL_SCREEN_SIZE, Surface.ROTATION_90));
|
||||
tapAndAssertFalse(100, portraitRegionY,
|
||||
event -> mTouchTransformer.touchInValidSwipeRegions(event.getX(), event.getY()));
|
||||
tapAndAssertTrue(100, landscapeRegionY,
|
||||
@@ -115,7 +111,7 @@ public class OrientationTouchTransformerTest {
|
||||
event -> mTouchTransformer.touchInAssistantRegion(event));
|
||||
|
||||
// Override region again
|
||||
mTouchTransformer.createOrAddTouchRegion(mInfo, "test");
|
||||
mTouchTransformer.createOrAddTouchRegion(mInfo);
|
||||
tapAndAssertTrue(100, portraitRegionY,
|
||||
event -> mTouchTransformer.touchInValidSwipeRegions(event.getX(), event.getY()));
|
||||
tapAndAssertFalse(100, landscapeRegionY,
|
||||
@@ -134,8 +130,7 @@ public class OrientationTouchTransformerTest {
|
||||
generateTouchRegionHeight(NORMAL_SCREEN_SIZE, Surface.ROTATION_90) + 1;
|
||||
|
||||
mTouchTransformer
|
||||
.createOrAddTouchRegion(createDisplayInfo(NORMAL_SCREEN_SIZE, Surface.ROTATION_90),
|
||||
"test");
|
||||
.createOrAddTouchRegion(createDisplayInfo(NORMAL_SCREEN_SIZE, Surface.ROTATION_90));
|
||||
tapAndAssertFalse(100, portraitRegionY,
|
||||
event -> mTouchTransformer.touchInValidSwipeRegions(event.getX(), event.getY()));
|
||||
tapAndAssertTrue(100, landscapeRegionY,
|
||||
@@ -147,7 +142,7 @@ public class OrientationTouchTransformerTest {
|
||||
// We have to add 0 rotation second so that gets set as the current rotation, otherwise
|
||||
// matrix transform will fail (tests only work in Portrait at the moment)
|
||||
mTouchTransformer.enableMultipleRegions(true, mInfo);
|
||||
mTouchTransformer.createOrAddTouchRegion(mInfo, "test");
|
||||
mTouchTransformer.createOrAddTouchRegion(mInfo);
|
||||
|
||||
tapAndAssertTrue(100, portraitRegionY,
|
||||
event -> mTouchTransformer.touchInValidSwipeRegions(event.getX(), event.getY()));
|
||||
@@ -168,9 +163,8 @@ public class OrientationTouchTransformerTest {
|
||||
|
||||
mTouchTransformer.enableMultipleRegions(true, mInfo);
|
||||
mTouchTransformer
|
||||
.createOrAddTouchRegion(createDisplayInfo(NORMAL_SCREEN_SIZE, Surface.ROTATION_90),
|
||||
"test");
|
||||
mTouchTransformer.createOrAddTouchRegion(mInfo, "test");
|
||||
.createOrAddTouchRegion(createDisplayInfo(NORMAL_SCREEN_SIZE, Surface.ROTATION_90));
|
||||
mTouchTransformer.createOrAddTouchRegion(mInfo);
|
||||
tapAndAssertTrue(0, portraitRegionY,
|
||||
event -> mTouchTransformer.touchInAssistantRegion(event));
|
||||
tapAndAssertFalse(0, landscapeRegionY,
|
||||
@@ -185,10 +179,9 @@ public class OrientationTouchTransformerTest {
|
||||
generateTouchRegionHeight(NORMAL_SCREEN_SIZE, Surface.ROTATION_90) + 1;
|
||||
|
||||
mTouchTransformer.enableMultipleRegions(true, mInfo);
|
||||
mTouchTransformer.createOrAddTouchRegion(mInfo, "test");
|
||||
mTouchTransformer.createOrAddTouchRegion(mInfo);
|
||||
mTouchTransformer
|
||||
.createOrAddTouchRegion(createDisplayInfo(NORMAL_SCREEN_SIZE, Surface.ROTATION_90),
|
||||
"test");
|
||||
.createOrAddTouchRegion(createDisplayInfo(NORMAL_SCREEN_SIZE, Surface.ROTATION_90));
|
||||
mTouchTransformer.enableMultipleRegions(false, mInfo);
|
||||
tapAndAssertTrue(0, portraitRegionY,
|
||||
event -> mTouchTransformer.touchInAssistantRegion(event));
|
||||
@@ -218,14 +211,14 @@ public class OrientationTouchTransformerTest {
|
||||
|
||||
@Test
|
||||
public void applyTransform_taskNotFrozen_notInRegion() {
|
||||
mTouchTransformer.createOrAddTouchRegion(mInfo, "test");
|
||||
mTouchTransformer.createOrAddTouchRegion(mInfo);
|
||||
tapAndAssertFalse(100, 100,
|
||||
event -> mTouchTransformer.touchInValidSwipeRegions(event.getX(), event.getY()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void applyTransform_taskFrozen_noRotate_outOfRegion() {
|
||||
mTouchTransformer.createOrAddTouchRegion(mInfo, "test");
|
||||
mTouchTransformer.createOrAddTouchRegion(mInfo);
|
||||
mTouchTransformer.enableMultipleRegions(true, mInfo);
|
||||
tapAndAssertFalse(100, 100,
|
||||
event -> mTouchTransformer.touchInValidSwipeRegions(event.getX(), event.getY()));
|
||||
@@ -233,7 +226,7 @@ public class OrientationTouchTransformerTest {
|
||||
|
||||
@Test
|
||||
public void applyTransform_taskFrozen_noRotate_inRegion() {
|
||||
mTouchTransformer.createOrAddTouchRegion(mInfo, "test");
|
||||
mTouchTransformer.createOrAddTouchRegion(mInfo);
|
||||
mTouchTransformer.enableMultipleRegions(true, mInfo);
|
||||
float y = generateTouchRegionHeight(NORMAL_SCREEN_SIZE, Surface.ROTATION_0) + 1;
|
||||
tapAndAssertTrue(100, y,
|
||||
@@ -242,7 +235,7 @@ public class OrientationTouchTransformerTest {
|
||||
|
||||
@Test
|
||||
public void applyTransform_taskNotFrozen_noRotate_inDefaultRegion() {
|
||||
mTouchTransformer.createOrAddTouchRegion(mInfo, "test");
|
||||
mTouchTransformer.createOrAddTouchRegion(mInfo);
|
||||
float y = generateTouchRegionHeight(NORMAL_SCREEN_SIZE, Surface.ROTATION_0) + 1;
|
||||
tapAndAssertTrue(100, y,
|
||||
event -> mTouchTransformer.touchInValidSwipeRegions(event.getX(), event.getY()));
|
||||
@@ -251,8 +244,7 @@ public class OrientationTouchTransformerTest {
|
||||
@Test
|
||||
public void applyTransform_taskNotFrozen_90Rotate_inRegion() {
|
||||
mTouchTransformer
|
||||
.createOrAddTouchRegion(createDisplayInfo(NORMAL_SCREEN_SIZE, Surface.ROTATION_90),
|
||||
"test");
|
||||
.createOrAddTouchRegion(createDisplayInfo(NORMAL_SCREEN_SIZE, Surface.ROTATION_90));
|
||||
float y = generateTouchRegionHeight(NORMAL_SCREEN_SIZE, Surface.ROTATION_90) + 1;
|
||||
tapAndAssertTrue(100, y,
|
||||
event -> mTouchTransformer.touchInValidSwipeRegions(event.getX(), event.getY()));
|
||||
@@ -260,11 +252,10 @@ public class OrientationTouchTransformerTest {
|
||||
|
||||
@Test
|
||||
public void applyTransform_taskNotFrozen_90Rotate_withTwoRegions() {
|
||||
mTouchTransformer.createOrAddTouchRegion(mInfo, "test");
|
||||
mTouchTransformer.createOrAddTouchRegion(mInfo);
|
||||
mTouchTransformer.enableMultipleRegions(true, mInfo);
|
||||
mTouchTransformer
|
||||
.createOrAddTouchRegion(createDisplayInfo(NORMAL_SCREEN_SIZE, Surface.ROTATION_90),
|
||||
"test");
|
||||
.createOrAddTouchRegion(createDisplayInfo(NORMAL_SCREEN_SIZE, Surface.ROTATION_90));
|
||||
// Landscape point
|
||||
float y1 = generateTouchRegionHeight(NORMAL_SCREEN_SIZE, Surface.ROTATION_90) + 1;
|
||||
MotionEvent inRegion1_down = generateMotionEvent(MotionEvent.ACTION_DOWN, 10, y1);
|
||||
@@ -285,11 +276,10 @@ public class OrientationTouchTransformerTest {
|
||||
@Test
|
||||
public void applyTransform_90Rotate_inRotatedRegion() {
|
||||
// Create regions for both 0 Rotation and 90 Rotation
|
||||
mTouchTransformer.createOrAddTouchRegion(mInfo, "test");
|
||||
mTouchTransformer.createOrAddTouchRegion(mInfo);
|
||||
mTouchTransformer.enableMultipleRegions(true, mInfo);
|
||||
mTouchTransformer
|
||||
.createOrAddTouchRegion(createDisplayInfo(NORMAL_SCREEN_SIZE, Surface.ROTATION_90),
|
||||
"test");
|
||||
.createOrAddTouchRegion(createDisplayInfo(NORMAL_SCREEN_SIZE, Surface.ROTATION_90));
|
||||
// Portrait point in landscape orientation axis
|
||||
float x1 = generateTouchRegionHeight(NORMAL_SCREEN_SIZE, Surface.ROTATION_0);
|
||||
// bottom of screen, from landscape perspective right side of screen
|
||||
@@ -297,35 +287,6 @@ public class OrientationTouchTransformerTest {
|
||||
assertTrue(mTouchTransformer.touchInValidSwipeRegions(inRegion2.getX(), inRegion2.getY()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleOrientationTouchTransformer() {
|
||||
final DisplayController displayController = mock(DisplayController.class);
|
||||
doReturn(mInfo).when(displayController).getInfoForDisplay(anyInt());
|
||||
final SimpleOrientationTouchTransformer transformer =
|
||||
new SimpleOrientationTouchTransformer(getApplicationContext(), displayController,
|
||||
mock(DaggerSingletonTracker.class));
|
||||
final MotionEvent move1 = generateMotionEvent(MotionEvent.ACTION_MOVE, 100, 10);
|
||||
transformer.transform(move1, Surface.ROTATION_90);
|
||||
// The position is transformed to 90 degree.
|
||||
assertEquals(10, move1.getX(), 0f /* delta */);
|
||||
assertEquals(NORMAL_SCREEN_SIZE.getWidth() - 100, move1.getY(), 0f /* delta */);
|
||||
|
||||
// If the touching state is specified, the position is still transformed to 90 degree even
|
||||
// if the given rotation is changed.
|
||||
final MotionEvent move2 = generateMotionEvent(MotionEvent.ACTION_MOVE, 100, 10);
|
||||
transformer.updateTouchingOrientation(Surface.ROTATION_90);
|
||||
transformer.transform(move2, Surface.ROTATION_0);
|
||||
assertEquals(move1.getX(), move2.getX(), 0f /* delta */);
|
||||
assertEquals(move1.getY(), move2.getY(), 0f /* delta */);
|
||||
|
||||
// If the touching state is cleared, it restores to use the given rotation.
|
||||
final MotionEvent move3 = generateMotionEvent(MotionEvent.ACTION_MOVE, 100, 10);
|
||||
transformer.clearTouchingOrientation();
|
||||
transformer.transform(move3, Surface.ROTATION_0);
|
||||
assertEquals(100, move3.getX(), 0f /* delta */);
|
||||
assertEquals(10, move3.getY(), 0f /* delta */);
|
||||
}
|
||||
|
||||
private DisplayController.Info createDisplayInfo(Size screenSize, int rotation) {
|
||||
Point displaySize = new Point(screenSize.getWidth(), screenSize.getHeight());
|
||||
RotationUtils.rotateSize(displaySize, rotation);
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.quickstep;
|
||||
|
||||
import static junit.framework.TestCase.assertNull;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.KeyguardManager;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.launcher3.util.LooperExecutor;
|
||||
import com.android.quickstep.util.GroupTask;
|
||||
import com.android.wm.shell.util.GroupedRecentTaskInfo;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@SmallTest
|
||||
public class RecentTasksListTest {
|
||||
|
||||
@Mock
|
||||
private SystemUiProxy mockSystemUiProxy;
|
||||
@Mock
|
||||
private TopTaskTracker mTopTaskTracker;
|
||||
|
||||
// Class under test
|
||||
private RecentTasksList mRecentTasksList;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
LooperExecutor mockMainThreadExecutor = mock(LooperExecutor.class);
|
||||
KeyguardManager mockKeyguardManager = mock(KeyguardManager.class);
|
||||
mRecentTasksList = new RecentTasksList(mockMainThreadExecutor, mockKeyguardManager,
|
||||
mockSystemUiProxy, mTopTaskTracker);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onRecentTasksChanged_doesNotFetchTasks() {
|
||||
mRecentTasksList.onRecentTasksChanged();
|
||||
verify(mockSystemUiProxy, times(0))
|
||||
.getRecentTasks(anyInt(), anyInt());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loadTasksInBackground_onlyKeys_noValidTaskDescription() {
|
||||
GroupedRecentTaskInfo recentTaskInfos = GroupedRecentTaskInfo.forSplitTasks(
|
||||
new ActivityManager.RecentTaskInfo(), new ActivityManager.RecentTaskInfo(), null);
|
||||
when(mockSystemUiProxy.getRecentTasks(anyInt(), anyInt()))
|
||||
.thenReturn(new ArrayList<>(Collections.singletonList(recentTaskInfos)));
|
||||
|
||||
List<GroupTask> taskList = mRecentTasksList.loadTasksInBackground(Integer.MAX_VALUE, -1,
|
||||
true);
|
||||
|
||||
assertEquals(1, taskList.size());
|
||||
assertNull(taskList.get(0).task1.taskDescription.getLabel());
|
||||
assertNull(taskList.get(0).task2.taskDescription.getLabel());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loadTasksInBackground_moreThanKeys_hasValidTaskDescription() {
|
||||
String taskDescription = "Wheeee!";
|
||||
ActivityManager.RecentTaskInfo task1 = new ActivityManager.RecentTaskInfo();
|
||||
task1.taskDescription = new ActivityManager.TaskDescription(taskDescription);
|
||||
ActivityManager.RecentTaskInfo task2 = new ActivityManager.RecentTaskInfo();
|
||||
task2.taskDescription = new ActivityManager.TaskDescription();
|
||||
GroupedRecentTaskInfo recentTaskInfos = GroupedRecentTaskInfo.forSplitTasks(task1, task2,
|
||||
null);
|
||||
when(mockSystemUiProxy.getRecentTasks(anyInt(), anyInt()))
|
||||
.thenReturn(new ArrayList<>(Collections.singletonList(recentTaskInfos)));
|
||||
|
||||
List<GroupTask> taskList = mRecentTasksList.loadTasksInBackground(Integer.MAX_VALUE, -1,
|
||||
false);
|
||||
|
||||
assertEquals(1, taskList.size());
|
||||
assertEquals(taskDescription, taskList.get(0).task1.taskDescription.getLabel());
|
||||
assertNull(taskList.get(0).task2.taskDescription.getLabel());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
package com.android.quickstep
|
||||
|
||||
import android.content.Context
|
||||
import android.testing.AndroidTestingRunner
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import androidx.test.filters.SmallTest
|
||||
import com.android.launcher3.util.DisplayController.CHANGE_DENSITY
|
||||
import com.android.launcher3.util.DisplayController.CHANGE_NAVIGATION_MODE
|
||||
import com.android.launcher3.util.DisplayController.CHANGE_ROTATION
|
||||
import com.android.launcher3.util.DisplayController.Info
|
||||
import com.android.launcher3.util.NavigationMode
|
||||
import com.android.quickstep.util.GestureExclusionManager
|
||||
import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_ALLOW_GESTURE_IGNORING_BAR_VISIBILITY
|
||||
import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_DEVICE_DREAMING
|
||||
import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_DISABLE_GESTURE_SPLIT_INVOCATION
|
||||
import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_HOME_DISABLED
|
||||
import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_MAGNIFICATION_OVERLAP
|
||||
import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NAV_BAR_HIDDEN
|
||||
import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED
|
||||
import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_OVERVIEW_DISABLED
|
||||
import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_QUICK_SETTINGS_EXPANDED
|
||||
import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING
|
||||
import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_TOUCHPAD_GESTURES_DISABLED
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.reset
|
||||
import org.mockito.Mockito.verify
|
||||
import org.mockito.MockitoAnnotations
|
||||
import org.mockito.kotlin.doReturn
|
||||
import org.mockito.kotlin.verifyZeroInteractions
|
||||
import org.mockito.kotlin.whenever
|
||||
|
||||
/** Unit test for [RecentsAnimationDeviceState]. */
|
||||
@SmallTest
|
||||
@RunWith(AndroidTestingRunner::class)
|
||||
class RecentsAnimationDeviceStateTest {
|
||||
|
||||
@Mock private lateinit var exclusionManager: GestureExclusionManager
|
||||
@Mock private lateinit var info: Info
|
||||
|
||||
private val context = ApplicationProvider.getApplicationContext() as Context
|
||||
private lateinit var underTest: RecentsAnimationDeviceState
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
underTest = RecentsAnimationDeviceState(context, exclusionManager)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun registerExclusionListener_success() {
|
||||
underTest.registerExclusionListener()
|
||||
|
||||
verify(exclusionManager).addListener(underTest)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun registerExclusionListener_again_fail() {
|
||||
underTest.registerExclusionListener()
|
||||
reset(exclusionManager)
|
||||
|
||||
underTest.registerExclusionListener()
|
||||
|
||||
verifyZeroInteractions(exclusionManager)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun unregisterExclusionListener_success() {
|
||||
underTest.registerExclusionListener()
|
||||
reset(exclusionManager)
|
||||
|
||||
underTest.unregisterExclusionListener()
|
||||
|
||||
verify(exclusionManager).removeListener(underTest)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun unregisterExclusionListener_again_fail() {
|
||||
underTest.registerExclusionListener()
|
||||
underTest.unregisterExclusionListener()
|
||||
reset(exclusionManager)
|
||||
|
||||
underTest.unregisterExclusionListener()
|
||||
|
||||
verifyZeroInteractions(exclusionManager)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun onDisplayInfoChanged_noButton_registerExclusionListener() {
|
||||
doReturn(NavigationMode.NO_BUTTON).whenever(info).getNavigationMode()
|
||||
|
||||
underTest.onDisplayInfoChanged(context, info, CHANGE_ROTATION or CHANGE_NAVIGATION_MODE)
|
||||
|
||||
verify(exclusionManager).addListener(underTest)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun onDisplayInfoChanged_twoButton_unregisterExclusionListener() {
|
||||
underTest.registerExclusionListener()
|
||||
whenever(info.getNavigationMode()).thenReturn(NavigationMode.TWO_BUTTONS)
|
||||
reset(exclusionManager)
|
||||
|
||||
underTest.onDisplayInfoChanged(context, info, CHANGE_ROTATION or CHANGE_NAVIGATION_MODE)
|
||||
|
||||
verify(exclusionManager).removeListener(underTest)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun onDisplayInfoChanged_changeDensity_noOp() {
|
||||
underTest.registerExclusionListener()
|
||||
whenever(info.getNavigationMode()).thenReturn(NavigationMode.NO_BUTTON)
|
||||
reset(exclusionManager)
|
||||
|
||||
underTest.onDisplayInfoChanged(context, info, CHANGE_DENSITY)
|
||||
|
||||
verifyZeroInteractions(exclusionManager)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun trackpadGesturesNotAllowedForSelectedStates() {
|
||||
val disablingStates = GESTURE_DISABLING_SYSUI_STATES +
|
||||
SYSUI_STATE_TOUCHPAD_GESTURES_DISABLED
|
||||
|
||||
allSysUiStates().forEach { state ->
|
||||
val canStartGesture = !disablingStates.contains(state)
|
||||
underTest.setSystemUiFlags(state)
|
||||
assertThat(underTest.canStartTrackpadGesture()).isEqualTo(canStartGesture)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun trackpadGesturesNotAllowedIfHomeAndOverviewIsDisabled() {
|
||||
val stateToExpectedResult = mapOf(
|
||||
SYSUI_STATE_HOME_DISABLED to true,
|
||||
SYSUI_STATE_OVERVIEW_DISABLED to true,
|
||||
DEFAULT_STATE
|
||||
.enable(SYSUI_STATE_OVERVIEW_DISABLED)
|
||||
.enable(SYSUI_STATE_HOME_DISABLED) to false
|
||||
)
|
||||
|
||||
stateToExpectedResult.forEach { (state, allowed) ->
|
||||
underTest.setSystemUiFlags(state)
|
||||
assertThat(underTest.canStartTrackpadGesture()).isEqualTo(allowed)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun systemGesturesNotAllowedForSelectedStates() {
|
||||
val disablingStates = GESTURE_DISABLING_SYSUI_STATES + SYSUI_STATE_NAV_BAR_HIDDEN
|
||||
|
||||
allSysUiStates().forEach { state ->
|
||||
val canStartGesture = !disablingStates.contains(state)
|
||||
underTest.setSystemUiFlags(state)
|
||||
assertThat(underTest.canStartSystemGesture()).isEqualTo(canStartGesture)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun systemGesturesNotAllowedWhenGestureStateDisabledAndNavBarVisible() {
|
||||
val stateToExpectedResult = mapOf(
|
||||
DEFAULT_STATE
|
||||
.enable(SYSUI_STATE_ALLOW_GESTURE_IGNORING_BAR_VISIBILITY)
|
||||
.disable(SYSUI_STATE_NAV_BAR_HIDDEN) to true,
|
||||
DEFAULT_STATE
|
||||
.enable(SYSUI_STATE_ALLOW_GESTURE_IGNORING_BAR_VISIBILITY)
|
||||
.enable(SYSUI_STATE_NAV_BAR_HIDDEN) to true,
|
||||
DEFAULT_STATE
|
||||
.disable(SYSUI_STATE_ALLOW_GESTURE_IGNORING_BAR_VISIBILITY)
|
||||
.disable(SYSUI_STATE_NAV_BAR_HIDDEN) to true,
|
||||
DEFAULT_STATE
|
||||
.disable(SYSUI_STATE_ALLOW_GESTURE_IGNORING_BAR_VISIBILITY)
|
||||
.enable(SYSUI_STATE_NAV_BAR_HIDDEN) to false,
|
||||
)
|
||||
|
||||
stateToExpectedResult.forEach {(state, gestureAllowed) ->
|
||||
underTest.setSystemUiFlags(state)
|
||||
assertThat(underTest.canStartSystemGesture()).isEqualTo(gestureAllowed)
|
||||
}
|
||||
}
|
||||
|
||||
private fun allSysUiStates(): List<Long> {
|
||||
// SYSUI_STATES_* are binary flags
|
||||
return (0..SYSUI_STATES_COUNT).map { 1L shl it }
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val GESTURE_DISABLING_SYSUI_STATES = listOf(
|
||||
SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED,
|
||||
SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING,
|
||||
SYSUI_STATE_QUICK_SETTINGS_EXPANDED,
|
||||
SYSUI_STATE_MAGNIFICATION_OVERLAP,
|
||||
SYSUI_STATE_DEVICE_DREAMING,
|
||||
SYSUI_STATE_DISABLE_GESTURE_SPLIT_INVOCATION,
|
||||
)
|
||||
private const val SYSUI_STATES_COUNT = 33
|
||||
private const val DEFAULT_STATE = 0L
|
||||
}
|
||||
|
||||
private fun Long.enable(state: Long) = this or state
|
||||
|
||||
private fun Long.disable(state: Long) = this and state.inv()
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.quickstep;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
|
||||
import androidx.test.annotation.UiThreadTest;
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.launcher3.Flags;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.icons.IconProvider;
|
||||
import com.android.quickstep.util.GroupTask;
|
||||
import com.android.systemui.shared.recents.model.Task;
|
||||
import com.android.systemui.shared.system.TaskStackChangeListeners;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@SmallTest
|
||||
public class RecentsModelTest {
|
||||
@Mock
|
||||
private Context mContext;
|
||||
|
||||
@Mock
|
||||
private TaskThumbnailCache mThumbnailCache;
|
||||
|
||||
@Mock
|
||||
private RecentTasksList mTasksList;
|
||||
|
||||
@Mock
|
||||
private TaskThumbnailCache.HighResLoadingState mHighResLoadingState;
|
||||
|
||||
private RecentsModel mRecentsModel;
|
||||
|
||||
private RecentTasksList.TaskLoadResult mTaskResult;
|
||||
|
||||
private Resources mResource;
|
||||
|
||||
@Rule
|
||||
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||
|
||||
@Before
|
||||
public void setup() throws NoSuchFieldException {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_GRID_ONLY_OVERVIEW);
|
||||
mTaskResult = getTaskResult();
|
||||
doAnswer(invocation-> {
|
||||
Consumer<ArrayList<GroupTask>> callback = invocation.getArgument(1);
|
||||
callback.accept(mTaskResult);
|
||||
return null;
|
||||
}).when(mTasksList).getTaskKeys(anyInt(), any());
|
||||
|
||||
when(mHighResLoadingState.isEnabled()).thenReturn(true);
|
||||
when(mThumbnailCache.getHighResLoadingState()).thenReturn(mHighResLoadingState);
|
||||
when(mThumbnailCache.isPreloadingEnabled()).thenReturn(true);
|
||||
|
||||
mRecentsModel = new RecentsModel(mContext, mTasksList, mock(TaskIconCache.class),
|
||||
mThumbnailCache, mock(IconProvider.class), mock(TaskStackChangeListeners.class));
|
||||
|
||||
mResource = mock(Resources.class);
|
||||
when(mResource.getInteger((R.integer.recentsThumbnailCacheSize))).thenReturn(3);
|
||||
when(mContext.getResources()).thenReturn(mResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThreadTest
|
||||
public void preloadOnHighResolutionEnabled() {
|
||||
mRecentsModel.preloadCacheIfNeeded();
|
||||
|
||||
ArgumentCaptor<Task> taskArgs = ArgumentCaptor.forClass(Task.class);
|
||||
verify(mRecentsModel.getThumbnailCache(), times(2))
|
||||
.updateThumbnailInCache(taskArgs.capture(), /* lowResolution= */ eq(false));
|
||||
|
||||
GroupTask expectedGroupTask = mTaskResult.get(0);
|
||||
assertThat(taskArgs.getAllValues().get(0)).isEqualTo(
|
||||
expectedGroupTask.task1);
|
||||
assertThat(taskArgs.getAllValues().get(1)).isEqualTo(
|
||||
expectedGroupTask.task2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notPreloadOnHighResolutionDisabled() {
|
||||
when(mHighResLoadingState.isEnabled()).thenReturn(false);
|
||||
when(mThumbnailCache.isPreloadingEnabled()).thenReturn(true);
|
||||
mRecentsModel.preloadCacheIfNeeded();
|
||||
verify(mRecentsModel.getThumbnailCache(), never())
|
||||
.updateThumbnailInCache(any(), anyBoolean());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notPreloadOnPreloadDisabled() {
|
||||
when(mThumbnailCache.isPreloadingEnabled()).thenReturn(false);
|
||||
mRecentsModel.preloadCacheIfNeeded();
|
||||
verify(mRecentsModel.getThumbnailCache(), never())
|
||||
.updateThumbnailInCache(any(), anyBoolean());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void increaseCacheSizeAndPreload() {
|
||||
// Mock to return preload is needed
|
||||
when(mThumbnailCache.updateCacheSizeAndRemoveExcess()).thenReturn(true);
|
||||
// Update cache size
|
||||
mRecentsModel.updateCacheSizeAndPreloadIfNeeded();
|
||||
// Assert update cache is called
|
||||
verify(mRecentsModel.getThumbnailCache(), times(2))
|
||||
.updateThumbnailInCache(any(), /* lowResolution= */ eq(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decreaseCacheSizeAndNotPreload() {
|
||||
// Mock to return preload is not needed
|
||||
when(mThumbnailCache.updateCacheSizeAndRemoveExcess()).thenReturn(false);
|
||||
// Update cache size
|
||||
mRecentsModel.updateCacheSizeAndPreloadIfNeeded();
|
||||
// Assert update cache is never called
|
||||
verify(mRecentsModel.getThumbnailCache(), never())
|
||||
.updateThumbnailInCache(any(), anyBoolean());
|
||||
}
|
||||
|
||||
private RecentTasksList.TaskLoadResult getTaskResult() {
|
||||
RecentTasksList.TaskLoadResult allTasks = new RecentTasksList.TaskLoadResult(0, false, 1);
|
||||
ActivityManager.RecentTaskInfo taskInfo1 = new ActivityManager.RecentTaskInfo();
|
||||
Task.TaskKey taskKey1 = new Task.TaskKey(taskInfo1);
|
||||
Task task1 = Task.from(taskKey1, taskInfo1, false);
|
||||
|
||||
ActivityManager.RecentTaskInfo taskInfo2 = new ActivityManager.RecentTaskInfo();
|
||||
Task.TaskKey taskKey2 = new Task.TaskKey(taskInfo2);
|
||||
Task task2 = Task.from(taskKey2, taskInfo2, false);
|
||||
|
||||
allTasks.add(new GroupTask(task1, task2, null));
|
||||
return allTasks;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.quickstep;
|
||||
|
||||
import static androidx.test.InstrumentationRegistry.getInstrumentation;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.app.usage.UsageStatsManager;
|
||||
import android.content.Intent;
|
||||
|
||||
import androidx.test.filters.LargeTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.quickstep.views.DigitalWellBeingToast;
|
||||
import com.android.quickstep.views.RecentsView;
|
||||
import com.android.quickstep.views.TaskView;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
@LargeTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class TaplDigitalWellBeingToastTest extends AbstractQuickStepTest {
|
||||
private static final String CALCULATOR_PACKAGE =
|
||||
resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR);
|
||||
|
||||
@Test
|
||||
public void testToast() throws Exception {
|
||||
startAppFast(CALCULATOR_PACKAGE);
|
||||
|
||||
final UsageStatsManager usageStatsManager =
|
||||
mTargetContext.getSystemService(UsageStatsManager.class);
|
||||
final int observerId = 0;
|
||||
|
||||
try {
|
||||
final String[] packages = new String[]{CALCULATOR_PACKAGE};
|
||||
|
||||
// Set time limit for app.
|
||||
runWithShellPermission(() ->
|
||||
usageStatsManager.registerAppUsageLimitObserver(observerId, packages,
|
||||
Duration.ofSeconds(600), Duration.ofSeconds(300),
|
||||
PendingIntent.getActivity(mTargetContext, -1, new Intent()
|
||||
.setPackage(mTargetContext.getPackageName()),
|
||||
PendingIntent.FLAG_MUTABLE)));
|
||||
|
||||
mLauncher.goHome();
|
||||
final DigitalWellBeingToast toast = getToast();
|
||||
|
||||
waitForLauncherCondition("Toast is not visible", launcher -> toast.hasLimit());
|
||||
assertEquals("Toast text: ", "5 minutes left today", toast.getText());
|
||||
|
||||
// Unset time limit for app.
|
||||
runWithShellPermission(
|
||||
() -> usageStatsManager.unregisterAppUsageLimitObserver(observerId));
|
||||
|
||||
mLauncher.goHome();
|
||||
assertFalse("Toast is visible", getToast().hasLimit());
|
||||
} finally {
|
||||
runWithShellPermission(
|
||||
() -> usageStatsManager.unregisterAppUsageLimitObserver(observerId));
|
||||
}
|
||||
}
|
||||
|
||||
private DigitalWellBeingToast getToast() {
|
||||
mLauncher.getWorkspace().switchToOverview();
|
||||
final TaskView task = getOnceNotNull("No latest task", launcher -> getLatestTask(launcher));
|
||||
|
||||
return getFromLauncher(launcher -> {
|
||||
TaskView.TaskContainer taskContainer = task.getTaskContainers().get(0);
|
||||
assertTrue("Latest task is not Calculator", CALCULATOR_PACKAGE.equals(
|
||||
taskContainer.getTask().getTopComponent().getPackageName()));
|
||||
return taskContainer.getDigitalWellBeingToast();
|
||||
});
|
||||
}
|
||||
|
||||
private TaskView getLatestTask(Launcher launcher) {
|
||||
return launcher.<RecentsView>getOverviewPanel().getTaskViewAt(0);
|
||||
}
|
||||
|
||||
private void runWithShellPermission(Runnable action) {
|
||||
getInstrumentation().getUiAutomation().adoptShellPermissionIdentity();
|
||||
try {
|
||||
action.run();
|
||||
} finally {
|
||||
getInstrumentation().getUiAutomation().dropShellPermissionIdentity();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -15,18 +15,20 @@
|
||||
*/
|
||||
package com.android.quickstep;
|
||||
|
||||
import static com.android.launcher3.util.rule.TestStabilityRule.LOCAL;
|
||||
import static com.android.launcher3.util.rule.TestStabilityRule.PLATFORM_POSTSUBMIT;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.platform.test.annotations.PlatinumTest;
|
||||
|
||||
import com.android.launcher3.tapl.Overview;
|
||||
import com.android.launcher3.tapl.OverviewTask.OverviewTaskContainer;
|
||||
import com.android.launcher3.tapl.OverviewTask.OverviewSplitTask;
|
||||
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 com.android.launcher3.util.rule.TestStabilityRule;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -67,18 +69,41 @@ public class TaplOverviewIconTest extends AbstractLauncherUiTest<QuickstepLaunch
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestStabilityRule.Stability(flavors = LOCAL | PLATFORM_POSTSUBMIT) // b/288939273
|
||||
public void testSplitTaskTapBothIconMenus() {
|
||||
Overview overview = SplitScreenTestUtils.createAndLaunchASplitPairInOverview(mLauncher);
|
||||
createAndLaunchASplitPair();
|
||||
|
||||
OverviewTaskMenu taskMenu = overview.getCurrentTask().tapMenu();
|
||||
OverviewTaskMenu taskMenu =
|
||||
mLauncher.goHome().switchToOverview().getCurrentTask().tapMenu();
|
||||
assertTrue("App info item not appearing in expanded task menu.",
|
||||
taskMenu.hasMenuItem("App info"));
|
||||
taskMenu.touchOutsideTaskMenuToDismiss();
|
||||
|
||||
OverviewTaskMenu splitMenu = overview.getCurrentTask().tapMenu(
|
||||
OverviewTaskContainer.SPLIT_BOTTOM_OR_RIGHT);
|
||||
OverviewTaskMenu splitMenu =
|
||||
mLauncher.goHome().switchToOverview().getCurrentTask().tapMenu(
|
||||
OverviewSplitTask.SPLIT_BOTTOM_OR_RIGHT);
|
||||
assertTrue("App info item not appearing in expanded split task's menu.",
|
||||
splitMenu.hasMenuItem("App info"));
|
||||
splitMenu.touchOutsideTaskMenuToDismiss();
|
||||
}
|
||||
}
|
||||
|
||||
private void createAndLaunchASplitPair() {
|
||||
clearAllRecentTasks();
|
||||
|
||||
startTestActivity(2);
|
||||
startTestActivity(3);
|
||||
|
||||
if (mLauncher.isTablet() && !mLauncher.isGridOnlyOverviewEnabled()) {
|
||||
mLauncher.goHome().switchToOverview().getOverviewActions()
|
||||
.clickSplit()
|
||||
.getTestActivityTask(2)
|
||||
.open();
|
||||
} else {
|
||||
mLauncher.goHome().switchToOverview().getCurrentTask()
|
||||
.tapMenu()
|
||||
.tapSplitMenuItem()
|
||||
.getCurrentTask()
|
||||
.open();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,9 +21,7 @@ import static com.android.launcher3.LauncherState.NORMAL;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assume.assumeFalse;
|
||||
|
||||
import android.os.Process;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
@@ -57,6 +55,8 @@ public class TaplPrivateSpaceTest extends AbstractQuickStepTest {
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
initialize(this);
|
||||
|
||||
createAndStartPrivateProfileUser();
|
||||
|
||||
mDevice.pressHome();
|
||||
@@ -75,9 +75,8 @@ public class TaplPrivateSpaceTest extends AbstractQuickStepTest {
|
||||
}
|
||||
|
||||
private void createAndStartPrivateProfileUser() {
|
||||
int myUserId = Process.myUserHandle().getIdentifier();
|
||||
String createUserOutput = executeShellCommand("pm create-user --profileOf " + myUserId
|
||||
+ " --user-type android.os.usertype.profile.PRIVATE " + PRIVATE_PROFILE_NAME);
|
||||
String createUserOutput = executeShellCommand("pm create-user --profileOf 0 --user-type "
|
||||
+ "android.os.usertype.profile.PRIVATE " + PRIVATE_PROFILE_NAME);
|
||||
updatePrivateProfileSetupSuccessful("pm create-user", createUserOutput);
|
||||
String[] tokens = createUserOutput.split("\\s+");
|
||||
mProfileUserId = Integer.parseInt(tokens[tokens.length - 1]);
|
||||
@@ -118,6 +117,7 @@ public class TaplPrivateSpaceTest extends AbstractQuickStepTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenRecordRule.ScreenRecord // b/334946529
|
||||
public void testUserInstalledAppIsShownAboveDivider() throws IOException {
|
||||
// Ensure that the App is not installed in main user otherwise, it may not be found in
|
||||
// PS container.
|
||||
@@ -142,6 +142,7 @@ public class TaplPrivateSpaceTest extends AbstractQuickStepTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenRecordRule.ScreenRecord // b/334946529
|
||||
public void testPrivateSpaceAppLongPressUninstallMenu() throws IOException {
|
||||
// Ensure that the App is not installed in main user otherwise, it may not be found in
|
||||
// PS container.
|
||||
@@ -165,8 +166,8 @@ public class TaplPrivateSpaceTest extends AbstractQuickStepTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenRecordRule.ScreenRecord // b/334946529
|
||||
public void testPrivateSpaceLockingBehaviour() throws IOException {
|
||||
assumeFalse(mLauncher.isTablet()); // b/367258373
|
||||
// Scroll to the bottom of All Apps
|
||||
executeOnLauncher(launcher -> launcher.getAppsView().resetAndScrollToPrivateSpaceHeader());
|
||||
HomeAllApps homeAllApps = mLauncher.getAllApps();
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package com.android.quickstep;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.test.filters.LargeTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
@@ -31,14 +29,8 @@ import org.junit.runner.RunWith;
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class TaplStartLauncherViaGestureTests extends AbstractQuickStepTest {
|
||||
|
||||
public static final String TAG = "TaplStartLauncherViaGestureTests";
|
||||
|
||||
static final int STRESS_REPEAT_COUNT = 10;
|
||||
|
||||
private enum TestCase {
|
||||
TO_HOME, TO_OVERVIEW,
|
||||
}
|
||||
|
||||
@Override
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
@@ -49,60 +41,28 @@ public class TaplStartLauncherViaGestureTests extends AbstractQuickStepTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@NavigationModeSwitch(mode = NavigationModeSwitchRule.Mode.THREE_BUTTON)
|
||||
@NavigationModeSwitch
|
||||
public void testStressPressHome() {
|
||||
runTest(TestCase.TO_HOME);
|
||||
}
|
||||
|
||||
@Test
|
||||
@NavigationModeSwitch(mode = NavigationModeSwitchRule.Mode.ZERO_BUTTON)
|
||||
public void testStressSwipeHome() {
|
||||
runTest(TestCase.TO_HOME);
|
||||
}
|
||||
|
||||
@Test
|
||||
@NavigationModeSwitch(mode = NavigationModeSwitchRule.Mode.THREE_BUTTON)
|
||||
public void testStressPressOverview() {
|
||||
runTest(TestCase.TO_OVERVIEW);
|
||||
}
|
||||
|
||||
@Test
|
||||
@NavigationModeSwitch(mode = NavigationModeSwitchRule.Mode.ZERO_BUTTON)
|
||||
public void testStressSwipeToOverview() {
|
||||
runTest(TestCase.TO_OVERVIEW);
|
||||
}
|
||||
|
||||
private void runTest(TestCase testCase) {
|
||||
long testStartTime = System.currentTimeMillis();
|
||||
for (int i = 0; i < STRESS_REPEAT_COUNT; ++i) {
|
||||
long loopStartTime = System.currentTimeMillis();
|
||||
// Destroy Launcher activity.
|
||||
closeLauncherActivity();
|
||||
|
||||
// The test action.
|
||||
switch (testCase) {
|
||||
case TO_OVERVIEW:
|
||||
mLauncher.getLaunchedAppState().switchToOverview();
|
||||
break;
|
||||
case TO_HOME:
|
||||
mLauncher.goHome();
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Cannot run test case: " + testCase);
|
||||
}
|
||||
Log.d(TAG, "Loop " + (i + 1) + " runtime="
|
||||
+ (System.currentTimeMillis() - loopStartTime) + "ms");
|
||||
}
|
||||
Log.d(TAG, "Test runtime=" + (System.currentTimeMillis() - testStartTime) + "ms");
|
||||
switch (testCase) {
|
||||
case TO_OVERVIEW:
|
||||
closeLauncherActivity();
|
||||
mLauncher.goHome();
|
||||
break;
|
||||
case TO_HOME:
|
||||
default:
|
||||
// No-Op
|
||||
break;
|
||||
mLauncher.goHome();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@NavigationModeSwitch
|
||||
public void testStressSwipeToOverview() {
|
||||
for (int i = 0; i < STRESS_REPEAT_COUNT; ++i) {
|
||||
// Destroy Launcher activity.
|
||||
closeLauncherActivity();
|
||||
|
||||
// The test action.
|
||||
mLauncher.getLaunchedAppState().switchToOverview();
|
||||
}
|
||||
closeLauncherActivity();
|
||||
mLauncher.goHome();
|
||||
}
|
||||
}
|
||||
@@ -49,7 +49,6 @@ public class TaplTestsKeyboardQuickSwitch extends AbstractQuickStepTest {
|
||||
DISMISS(0),
|
||||
LAUNCH_LAST_APP(0),
|
||||
LAUNCH_SELECTED_APP(1),
|
||||
DISMISS_WHEN_GOING_HOME(1),
|
||||
LAUNCH_OVERVIEW(KeyboardQuickSwitchController.MAX_TASKS - 1);
|
||||
|
||||
private final int mNumAdditionalRunningTasks;
|
||||
@@ -157,11 +156,6 @@ public class TaplTestsKeyboardQuickSwitch extends AbstractQuickStepTest {
|
||||
mLauncher.goHome().showQuickSwitchView().launchFocusedAppTask(CALCULATOR_APP_PACKAGE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDismissedWhenGoingHome() {
|
||||
runTest(TestSurface.LAUNCHED_APP, TestCase.DISMISS_WHEN_GOING_HOME);
|
||||
}
|
||||
|
||||
private void runTest(@NonNull TestSurface testSurface, @NonNull TestCase testCase) {
|
||||
for (int i = 0; i < testCase.mNumAdditionalRunningTasks; i++) {
|
||||
startTestActivity(3 + i);
|
||||
@@ -203,9 +197,6 @@ public class TaplTestsKeyboardQuickSwitch extends AbstractQuickStepTest {
|
||||
}
|
||||
kqs.launchFocusedAppTask(CALCULATOR_APP_PACKAGE);
|
||||
break;
|
||||
case DISMISS_WHEN_GOING_HOME:
|
||||
kqs.dismissByGoingHome();
|
||||
break;
|
||||
case LAUNCH_OVERVIEW:
|
||||
kqs.moveFocusBackward();
|
||||
if (!testSurface.mInitialFocusAtZero) {
|
||||
|
||||
@@ -15,12 +15,16 @@
|
||||
*/
|
||||
package com.android.quickstep;
|
||||
|
||||
import static com.android.quickstep.TaskbarModeSwitchRule.Mode.PERSISTENT;
|
||||
|
||||
import android.graphics.Rect;
|
||||
|
||||
import androidx.test.filters.LargeTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.launcher3.ui.PortraitLandscapeRunner.PortraitLandscape;
|
||||
import com.android.quickstep.NavigationModeSwitchRule.NavigationModeSwitch;
|
||||
import com.android.quickstep.TaskbarModeSwitchRule.TaskbarModeSwitch;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
@@ -31,6 +35,8 @@ import org.junit.runner.RunWith;
|
||||
public class TaplTestsPersistentTaskbar extends AbstractTaplTestsTaskbar {
|
||||
|
||||
@Test
|
||||
@TaskbarModeSwitch(mode = PERSISTENT)
|
||||
@PortraitLandscape
|
||||
@NavigationModeSwitch
|
||||
public void testTaskbarFillsWidth() {
|
||||
// Width check is performed inside TAPL whenever getTaskbar() is called.
|
||||
|
||||
@@ -16,14 +16,12 @@
|
||||
|
||||
package com.android.quickstep;
|
||||
|
||||
import static com.android.launcher3.Flags.enableLauncherOverviewInWindow;
|
||||
import static com.android.launcher3.util.rule.TestStabilityRule.LOCAL;
|
||||
import static com.android.launcher3.util.rule.TestStabilityRule.PLATFORM_POSTSUBMIT;
|
||||
import static com.android.quickstep.TaskbarModeSwitchRule.Mode.TRANSIENT;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assume.assumeFalse;
|
||||
@@ -32,13 +30,13 @@ import static org.junit.Assume.assumeTrue;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.test.filters.LargeTest;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
import androidx.test.uiautomator.By;
|
||||
import androidx.test.uiautomator.Until;
|
||||
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.LauncherState;
|
||||
import com.android.launcher3.tapl.BaseOverview;
|
||||
import com.android.launcher3.tapl.LaunchedAppState;
|
||||
@@ -49,13 +47,11 @@ import com.android.launcher3.tapl.OverviewTask;
|
||||
import com.android.launcher3.tapl.SelectModeButtons;
|
||||
import com.android.launcher3.tapl.Workspace;
|
||||
import com.android.launcher3.ui.PortraitLandscapeRunner.PortraitLandscape;
|
||||
import com.android.launcher3.util.TestUtil;
|
||||
import com.android.launcher3.util.Wait;
|
||||
import com.android.launcher3.util.rule.ScreenRecordRule;
|
||||
import com.android.launcher3.util.rule.ScreenRecordRule.ScreenRecord;
|
||||
import com.android.launcher3.util.rule.TestStabilityRule;
|
||||
import com.android.quickstep.NavigationModeSwitchRule.NavigationModeSwitch;
|
||||
import com.android.quickstep.TaskbarModeSwitchRule.TaskbarModeSwitch;
|
||||
import com.android.quickstep.fallback.RecentsState;
|
||||
import com.android.quickstep.views.RecentsView;
|
||||
|
||||
import org.junit.After;
|
||||
@@ -64,10 +60,6 @@ import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
@LargeTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
@@ -77,32 +69,21 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
private static final String READ_DEVICE_CONFIG_PERMISSION =
|
||||
"android.permission.READ_DEVICE_CONFIG";
|
||||
|
||||
private enum ExpectedState {
|
||||
|
||||
HOME(LauncherState.NORMAL, RecentsState.HOME),
|
||||
OVERVIEW(LauncherState.OVERVIEW, RecentsState.DEFAULT);
|
||||
|
||||
private final LauncherState mLauncherState;
|
||||
private final RecentsState mRecentsState;
|
||||
|
||||
ExpectedState(LauncherState launcherState, RecentsState recentsState) {
|
||||
this.mLauncherState = launcherState;
|
||||
this.mRecentsState = recentsState;
|
||||
}
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
runOnRecentsView(recentsView ->
|
||||
recentsView.getPagedViewOrientedState().forceAllowRotationForTesting(true));
|
||||
executeOnLauncher(launcher -> {
|
||||
RecentsView recentsView = launcher.getOverviewPanel();
|
||||
recentsView.getPagedViewOrientedState().forceAllowRotationForTesting(true);
|
||||
});
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
runOnRecentsView(recentsView ->
|
||||
recentsView.getPagedViewOrientedState().forceAllowRotationForTesting(false),
|
||||
/* forTearDown= */ true);
|
||||
executeOnLauncherInTearDown(launcher -> {
|
||||
RecentsView recentsView = launcher.getOverviewPanel();
|
||||
recentsView.getPagedViewOrientedState().forceAllowRotationForTesting(false);
|
||||
});
|
||||
}
|
||||
|
||||
public static void startTestApps() throws Exception {
|
||||
@@ -111,6 +92,14 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
startTestActivity(2);
|
||||
}
|
||||
|
||||
private void startTestAppsWithCheck() throws Exception {
|
||||
startTestApps();
|
||||
executeOnLauncher(launcher -> assertTrue(
|
||||
"Launcher activity is the top activity; expecting another activity to be the top "
|
||||
+ "one",
|
||||
isInLaunchedApp(launcher)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@NavigationModeSwitch
|
||||
@PortraitLandscape
|
||||
@@ -127,26 +116,28 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
startTestAppsWithCheck();
|
||||
// mLauncher.pressHome() also tests an important case of pressing home while in background.
|
||||
Overview overview = mLauncher.goHome().switchToOverview();
|
||||
assertIsInState(
|
||||
"Launcher internal state didn't switch to Overview", ExpectedState.OVERVIEW);
|
||||
runOnRecentsView(recentsView -> assertTrue("Don't have at least 3 tasks",
|
||||
recentsView.getTaskViewCount() >= 3));
|
||||
assertTrue("Launcher internal state didn't switch to Overview",
|
||||
isInState(() -> LauncherState.OVERVIEW));
|
||||
executeOnLauncher(
|
||||
launcher -> assertTrue("Don't have at least 3 tasks", getTaskCount(launcher) >= 3));
|
||||
|
||||
// Test flinging forward and backward.
|
||||
runOnRecentsView(recentsView -> assertEquals("Current task in Overview is not 0",
|
||||
0, recentsView.getCurrentPage()));
|
||||
executeOnLauncher(launcher -> assertEquals("Current task in Overview is not 0",
|
||||
0, getCurrentOverviewPage(launcher)));
|
||||
|
||||
overview.flingForward();
|
||||
assertIsInState("Launcher internal state is not Overview", ExpectedState.OVERVIEW);
|
||||
final Integer currentTaskAfterFlingForward =
|
||||
getFromRecentsView(RecentsView::getCurrentPage);
|
||||
runOnRecentsView(recentsView -> assertTrue("Current task in Overview is still 0",
|
||||
assertTrue("Launcher internal state is not Overview",
|
||||
isInState(() -> LauncherState.OVERVIEW));
|
||||
final Integer currentTaskAfterFlingForward = getFromLauncher(
|
||||
launcher -> getCurrentOverviewPage(launcher));
|
||||
executeOnLauncher(launcher -> assertTrue("Current task in Overview is still 0",
|
||||
currentTaskAfterFlingForward > 0));
|
||||
|
||||
overview.flingBackward();
|
||||
assertIsInState("Launcher internal state is not Overview", ExpectedState.OVERVIEW);
|
||||
runOnRecentsView(recentsView -> assertTrue("Flinging back in Overview did nothing",
|
||||
recentsView.getCurrentPage() < currentTaskAfterFlingForward));
|
||||
assertTrue("Launcher internal state is not Overview",
|
||||
isInState(() -> LauncherState.OVERVIEW));
|
||||
executeOnLauncher(launcher -> assertTrue("Flinging back in Overview did nothing",
|
||||
getCurrentOverviewPage(launcher) < currentTaskAfterFlingForward));
|
||||
|
||||
// Test opening a task.
|
||||
OverviewTask task = mLauncher.goHome().switchToOverview().getCurrentTask();
|
||||
@@ -154,26 +145,31 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
assertNotNull("OverviewTask.open returned null", task.open());
|
||||
assertTrue("Test activity didn't open from Overview", mDevice.wait(Until.hasObject(
|
||||
By.pkg(getAppPackageName()).text("TestActivity2")),
|
||||
TestUtil.DEFAULT_UI_TIMEOUT));
|
||||
expectLaunchedAppState();
|
||||
DEFAULT_UI_TIMEOUT));
|
||||
executeOnLauncher(launcher -> assertTrue(
|
||||
"Launcher activity is the top activity; expecting another activity to be the top "
|
||||
+ "one",
|
||||
isInLaunchedApp(launcher)));
|
||||
|
||||
// Test dismissing a task.
|
||||
overview = mLauncher.goHome().switchToOverview();
|
||||
assertIsInState("Launcher internal state didn't switch to Overview",
|
||||
ExpectedState.OVERVIEW);
|
||||
final Integer numTasks = getFromRecentsView(RecentsView::getTaskViewCount);
|
||||
assertTrue("Launcher internal state didn't switch to Overview",
|
||||
isInState(() -> LauncherState.OVERVIEW));
|
||||
final Integer numTasks = getFromLauncher(launcher -> getTaskCount(launcher));
|
||||
task = overview.getCurrentTask();
|
||||
assertNotNull("overview.getCurrentTask() returned null (2)", task);
|
||||
task.dismiss();
|
||||
runOnRecentsView(recentsView -> assertEquals(
|
||||
"Dismissing a task didn't remove 1 task from Overview",
|
||||
numTasks - 1, recentsView.getTaskViewCount()));
|
||||
executeOnLauncher(
|
||||
launcher -> assertEquals("Dismissing a task didn't remove 1 task from Overview",
|
||||
numTasks - 1, getTaskCount(launcher)));
|
||||
|
||||
// Test dismissing all tasks.
|
||||
mLauncher.goHome().switchToOverview().dismissAllTasks();
|
||||
assertIsInState("Launcher internal state is not Home", ExpectedState.HOME);
|
||||
runOnRecentsView(recentsView -> assertEquals("Still have tasks after dismissing all",
|
||||
0, recentsView.getTaskViewCount()));
|
||||
assertTrue("Launcher internal state is not Home",
|
||||
isInState(() -> LauncherState.NORMAL));
|
||||
executeOnLauncher(
|
||||
launcher -> assertEquals("Still have tasks after dismissing all",
|
||||
0, getTaskCount(launcher)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -195,10 +191,12 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
public void testDismissOverviewWithEscKey() throws Exception {
|
||||
startTestAppsWithCheck();
|
||||
final Overview overview = mLauncher.goHome().switchToOverview();
|
||||
assertIsInState("Launcher internal state is not Overview", ExpectedState.OVERVIEW);
|
||||
assertTrue("Launcher internal state is not Overview",
|
||||
isInState(() -> LauncherState.OVERVIEW));
|
||||
|
||||
overview.dismissByEscKey();
|
||||
assertIsInState("Launcher internal state is not Home", ExpectedState.HOME);
|
||||
assertTrue("Launcher internal state is not Home",
|
||||
isInState(() -> LauncherState.NORMAL));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -219,9 +217,11 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
|
||||
selectModeButtons.dismissByEscKey();
|
||||
|
||||
assertIsInState("Launcher internal state is not Overview", ExpectedState.OVERVIEW);
|
||||
assertTrue("Launcher internal state is not Overview",
|
||||
isInState(() -> LauncherState.OVERVIEW));
|
||||
overview.dismissByEscKey();
|
||||
assertIsInState("Launcher internal state is not Home", ExpectedState.HOME);
|
||||
assertTrue("Launcher internal state is not Home",
|
||||
isInState(() -> LauncherState.NORMAL));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -229,11 +229,11 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
startTestAppsWithCheck();
|
||||
startAppFast(CALCULATOR_APP_PACKAGE); // Ensure Calculator is last opened app.
|
||||
Workspace home = mLauncher.goHome();
|
||||
assertIsInState("Launcher state is not Home", ExpectedState.HOME);
|
||||
assertTrue("Launcher state is not Home", isInState(() -> LauncherState.NORMAL));
|
||||
|
||||
Overview overview = home.openOverviewFromActionPlusTabKeyboardShortcut();
|
||||
|
||||
assertIsInState("Launcher state is not Overview", ExpectedState.OVERVIEW);
|
||||
assertTrue("Launcher state is not Overview", isInState(() -> LauncherState.OVERVIEW));
|
||||
overview.launchFocusedTaskByEnterKey(CALCULATOR_APP_PACKAGE); // Assert app is focused.
|
||||
}
|
||||
|
||||
@@ -242,14 +242,33 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
startTestAppsWithCheck();
|
||||
startAppFast(CALCULATOR_APP_PACKAGE); // Ensure Calculator is last opened app.
|
||||
Workspace home = mLauncher.goHome();
|
||||
assertIsInState("Launcher state is not Home", ExpectedState.HOME);
|
||||
assertTrue("Launcher state is not Home", isInState(() -> LauncherState.NORMAL));
|
||||
|
||||
Overview overview = home.openOverviewFromRecentsKeyboardShortcut();
|
||||
|
||||
assertIsInState("Launcher state is not Overview", ExpectedState.OVERVIEW);
|
||||
assertTrue("Launcher state is not Overview", isInState(() -> LauncherState.OVERVIEW));
|
||||
overview.launchFocusedTaskByEnterKey(CALCULATOR_APP_PACKAGE); // Assert app is focused.
|
||||
}
|
||||
|
||||
private int getCurrentOverviewPage(Launcher launcher) {
|
||||
return launcher.<RecentsView>getOverviewPanel().getCurrentPage();
|
||||
}
|
||||
|
||||
private int getTaskCount(Launcher launcher) {
|
||||
return launcher.<RecentsView>getOverviewPanel().getTaskViewCount();
|
||||
}
|
||||
|
||||
private int getTopRowTaskCountForTablet(Launcher launcher) {
|
||||
return launcher.<RecentsView>getOverviewPanel().getTopRowTaskCountForTablet();
|
||||
}
|
||||
|
||||
private int getBottomRowTaskCountForTablet(Launcher launcher) {
|
||||
return launcher.<RecentsView>getOverviewPanel().getBottomRowTaskCountForTablet();
|
||||
}
|
||||
|
||||
// Staging; will be promoted to presubmit if stable
|
||||
@TestStabilityRule.Stability(flavors = LOCAL | PLATFORM_POSTSUBMIT)
|
||||
|
||||
@Test
|
||||
@NavigationModeSwitch
|
||||
@PortraitLandscape
|
||||
@@ -257,8 +276,8 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
startTestAppsWithCheck();
|
||||
assertNotNull("Workspace.switchToOverview() returned null",
|
||||
mLauncher.goHome().switchToOverview());
|
||||
assertIsInState(
|
||||
"Launcher internal state didn't switch to Overview", ExpectedState.OVERVIEW);
|
||||
assertTrue("Launcher internal state didn't switch to Overview",
|
||||
isInState(() -> LauncherState.OVERVIEW));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -274,6 +293,9 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
}
|
||||
}
|
||||
|
||||
// Staging; will be promoted to presubmit if stable
|
||||
@TestStabilityRule.Stability(flavors = LOCAL | PLATFORM_POSTSUBMIT)
|
||||
|
||||
@Test
|
||||
@NavigationModeSwitch
|
||||
@PortraitLandscape
|
||||
@@ -283,13 +305,27 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
|
||||
assertNotNull("Background.switchToOverview() returned null",
|
||||
launchedAppState.switchToOverview());
|
||||
assertIsInState(
|
||||
"Launcher internal state didn't switch to Overview", ExpectedState.OVERVIEW);
|
||||
assertTrue("Launcher internal state didn't switch to Overview",
|
||||
isInState(() -> LauncherState.OVERVIEW));
|
||||
}
|
||||
|
||||
private void quickSwitchToPreviousAppAndAssert(boolean toRight) {
|
||||
final LaunchedAppState launchedAppState = getAndAssertLaunchedApp();
|
||||
if (toRight) {
|
||||
launchedAppState.quickSwitchToPreviousApp();
|
||||
} else {
|
||||
launchedAppState.quickSwitchToPreviousAppSwipeLeft();
|
||||
}
|
||||
|
||||
// While enable shell transition, Launcher can be resumed due to transient launch.
|
||||
waitForLauncherCondition("Launcher shouldn't stay in resume forever",
|
||||
this::isInLaunchedApp, 3000 /* timeout */);
|
||||
}
|
||||
|
||||
@Test
|
||||
@NavigationModeSwitch
|
||||
@PortraitLandscape
|
||||
@ScreenRecord // b/313464374
|
||||
@TestStabilityRule.Stability(flavors = LOCAL | PLATFORM_POSTSUBMIT) // b/325659406
|
||||
public void testQuickSwitchFromApp() throws Exception {
|
||||
startTestActivity(2);
|
||||
@@ -357,6 +393,11 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isHardwareKeyboard() {
|
||||
return Configuration.KEYBOARD_QWERTY
|
||||
== mTargetContext.getResources().getConfiguration().keyboard;
|
||||
}
|
||||
|
||||
@Test
|
||||
@NavigationModeSwitch
|
||||
@PortraitLandscape
|
||||
@@ -377,11 +418,11 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
// Debug if we need to goHome to prevent wrong previous state b/315525621
|
||||
mLauncher.goHome();
|
||||
mLauncher.getWorkspace().switchToAllApps().pressBackToWorkspace();
|
||||
waitForState("Launcher internal state didn't switch to Home", ExpectedState.HOME);
|
||||
waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL);
|
||||
|
||||
startAppFast(CALCULATOR_APP_PACKAGE);
|
||||
mLauncher.getLaunchedAppState().pressBackToWorkspace();
|
||||
waitForState("Launcher internal state didn't switch to Home", ExpectedState.HOME);
|
||||
waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -396,14 +437,16 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
}
|
||||
|
||||
Overview overview = mLauncher.goHome().switchToOverview();
|
||||
runOnRecentsView(recentsView -> assertTrue("Don't have at least 13 tasks",
|
||||
recentsView.getTaskViewCount() >= 13));
|
||||
executeOnLauncher(
|
||||
launcher -> assertTrue("Don't have at least 13 tasks",
|
||||
getTaskCount(launcher) >= 13));
|
||||
|
||||
// Test scroll the first task off screen
|
||||
overview.scrollCurrentTaskOffScreen();
|
||||
assertIsInState("Launcher internal state is not Overview", ExpectedState.OVERVIEW);
|
||||
runOnRecentsView(recentsView -> assertTrue("Current task in Overview is still 0",
|
||||
recentsView.getCurrentPage() > 0));
|
||||
assertTrue("Launcher internal state is not Overview",
|
||||
isInState(() -> LauncherState.OVERVIEW));
|
||||
executeOnLauncher(launcher -> assertTrue("Current task in Overview is still 0",
|
||||
getCurrentOverviewPage(launcher) > 0));
|
||||
|
||||
// Test opening the task.
|
||||
overview.getCurrentTask().open();
|
||||
@@ -411,43 +454,45 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
mDevice.wait(Until.hasObject(By.pkg(getAppPackageName()).text(
|
||||
mLauncher.isGridOnlyOverviewEnabled() ? "TestActivity12"
|
||||
: "TestActivity13")),
|
||||
TestUtil.DEFAULT_UI_TIMEOUT));
|
||||
DEFAULT_UI_TIMEOUT));
|
||||
|
||||
// Scroll the task offscreen as it is now first
|
||||
overview = mLauncher.goHome().switchToOverview();
|
||||
overview.scrollCurrentTaskOffScreen();
|
||||
assertIsInState(
|
||||
"Launcher internal state is not Overview", ExpectedState.OVERVIEW);
|
||||
runOnRecentsView(recentsView -> assertTrue("Current task in Overview is still 0",
|
||||
recentsView.getCurrentPage() > 0));
|
||||
assertTrue("Launcher internal state is not Overview",
|
||||
isInState(() -> LauncherState.OVERVIEW));
|
||||
executeOnLauncher(launcher -> assertTrue("Current task in Overview is still 0",
|
||||
getCurrentOverviewPage(launcher) > 0));
|
||||
|
||||
// Test dismissing the later task.
|
||||
final Integer numTasks = getFromRecentsView(RecentsView::getTaskViewCount);
|
||||
final Integer numTasks = getFromLauncher(this::getTaskCount);
|
||||
overview.getCurrentTask().dismiss();
|
||||
runOnRecentsView(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",
|
||||
(Math.abs(recentsView.getTopRowTaskCountForTablet()
|
||||
- recentsView.getBottomRowTaskCountForTablet()) <= 1)));
|
||||
executeOnLauncher(
|
||||
launcher -> assertEquals("Dismissing a task didn't remove 1 task from Overview",
|
||||
numTasks - 1, getTaskCount(launcher)));
|
||||
executeOnLauncher(launcher -> assertTrue("Grid did not rebalance after dismissal",
|
||||
(Math.abs(getTopRowTaskCountForTablet(launcher) - getBottomRowTaskCountForTablet(
|
||||
launcher)) <= 1)));
|
||||
|
||||
// Test dismissing more tasks.
|
||||
assertIsInState(
|
||||
"Launcher internal state didn't remain in Overview", ExpectedState.OVERVIEW);
|
||||
overview.getCurrentTask().dismiss();
|
||||
assertIsInState(
|
||||
"Launcher internal state didn't remain in Overview", ExpectedState.OVERVIEW);
|
||||
overview.getCurrentTask().dismiss();
|
||||
runOnRecentsView(recentsView -> assertTrue(
|
||||
"Grid did not rebalance after multiple dismissals",
|
||||
(Math.abs(recentsView.getTopRowTaskCountForTablet()
|
||||
- recentsView.getBottomRowTaskCountForTablet()) <= 1)));
|
||||
// TODO(b/308841019): Re-enable after fixing Overview jank when dismiss
|
||||
// // Test dismissing more tasks.
|
||||
// assertTrue("Launcher internal state didn't remain in Overview",
|
||||
// isInState(() -> LauncherState.OVERVIEW));
|
||||
// overview.getCurrentTask().dismiss();
|
||||
// assertTrue("Launcher internal state didn't remain in Overview",
|
||||
// isInState(() -> LauncherState.OVERVIEW));
|
||||
// overview.getCurrentTask().dismiss();
|
||||
// executeOnLauncher(launcher -> assertTrue("Grid did not rebalance after multiple dismissals",
|
||||
// (Math.abs(getTopRowTaskCountForTablet(launcher) - getBottomRowTaskCountForTablet(
|
||||
// launcher)) <= 1)));
|
||||
|
||||
// Test dismissing all tasks.
|
||||
mLauncher.goHome().switchToOverview().dismissAllTasks();
|
||||
assertIsInState("Launcher internal state is not Home", ExpectedState.HOME);
|
||||
runOnRecentsView(recentsView -> assertEquals("Still have tasks after dismissing all",
|
||||
0, recentsView.getTaskViewCount()));
|
||||
assertTrue("Launcher internal state is not Home",
|
||||
isInState(() -> LauncherState.NORMAL));
|
||||
executeOnLauncher(
|
||||
launcher -> assertEquals("Still have tasks after dismissing all",
|
||||
0, getTaskCount(launcher)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -456,18 +501,22 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
startTestAppsWithCheck();
|
||||
|
||||
Overview overview = mLauncher.goHome().switchToOverview();
|
||||
assertIsInState("Launcher internal state should be Overview", ExpectedState.OVERVIEW);
|
||||
runOnRecentsView(recentsView -> assertTrue("Should have at least 3 tasks",
|
||||
recentsView.getTaskViewCount() >= 3));
|
||||
assertTrue("Launcher internal state should be Overview",
|
||||
isInState(() -> LauncherState.OVERVIEW));
|
||||
executeOnLauncher(
|
||||
launcher -> assertTrue("Should have at least 3 tasks",
|
||||
getTaskCount(launcher) >= 3));
|
||||
|
||||
// It should not dismiss overview when tapping between tasks
|
||||
overview.touchBetweenTasks();
|
||||
overview = mLauncher.getOverview();
|
||||
assertIsInState("Launcher internal state should be Overview", ExpectedState.OVERVIEW);
|
||||
assertTrue("Launcher internal state should be Overview",
|
||||
isInState(() -> LauncherState.OVERVIEW));
|
||||
|
||||
// Dismiss when tapping to the right of the focused task
|
||||
overview.touchOutsideFirstTask();
|
||||
assertIsInState("Launcher internal state should be Home", ExpectedState.HOME);
|
||||
assertTrue("Launcher internal state should be Home",
|
||||
isInState(() -> LauncherState.NORMAL));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -479,28 +528,34 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
startTestAppsWithCheck();
|
||||
|
||||
Overview overview = mLauncher.goHome().switchToOverview();
|
||||
assertIsInState("Launcher internal state should be Overview", ExpectedState.OVERVIEW);
|
||||
runOnRecentsView(recentsView -> assertTrue("Should have at least 3 tasks",
|
||||
recentsView.getTaskViewCount() >= 3));
|
||||
assertTrue("Launcher internal state should be Overview",
|
||||
isInState(() -> LauncherState.OVERVIEW));
|
||||
executeOnLauncher(
|
||||
launcher -> assertTrue("Should have at least 3 tasks",
|
||||
getTaskCount(launcher) >= 3));
|
||||
|
||||
if (mLauncher.isTransientTaskbar()) {
|
||||
// On transient taskbar, it should dismiss when tapping outside taskbar bounds.
|
||||
overview.touchTaskbarBottomCorner(/* tapRight= */ false);
|
||||
assertIsInState("Launcher internal state should be Normal", ExpectedState.HOME);
|
||||
assertTrue("Launcher internal state should be Normal",
|
||||
isInState(() -> LauncherState.NORMAL));
|
||||
|
||||
overview = mLauncher.getWorkspace().switchToOverview();
|
||||
|
||||
// On transient taskbar, it should dismiss when tapping outside taskbar bounds.
|
||||
overview.touchTaskbarBottomCorner(/* tapRight= */ true);
|
||||
assertIsInState("Launcher internal state should be Normal", ExpectedState.HOME);
|
||||
assertTrue("Launcher internal state should be Normal",
|
||||
isInState(() -> LauncherState.NORMAL));
|
||||
} else {
|
||||
// On persistent taskbar, it should not dismiss when tapping the taskbar
|
||||
overview.touchTaskbarBottomCorner(/* tapRight= */ false);
|
||||
assertIsInState("Launcher internal state should be Overview", ExpectedState.OVERVIEW);
|
||||
assertTrue("Launcher internal state should be Overview",
|
||||
isInState(() -> LauncherState.OVERVIEW));
|
||||
|
||||
// On persistent taskbar, it should not dismiss when tapping the taskbar
|
||||
overview.touchTaskbarBottomCorner(/* tapRight= */ true);
|
||||
assertIsInState("Launcher internal state should be Overview", ExpectedState.OVERVIEW);
|
||||
assertTrue("Launcher internal state should be Overview",
|
||||
isInState(() -> LauncherState.OVERVIEW));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -513,7 +568,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
mLauncher.getDevice().setOrientationLeft();
|
||||
startTestActivity(7);
|
||||
Wait.atMost("Device should not be in natural orientation",
|
||||
() -> !mDevice.isNaturalOrientation(), mLauncher);
|
||||
() -> !mDevice.isNaturalOrientation(), DEFAULT_UI_TIMEOUT, mLauncher);
|
||||
mLauncher.goHome();
|
||||
} finally {
|
||||
mLauncher.setExpectedRotationCheckEnabled(true);
|
||||
@@ -526,164 +581,20 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
public void testExcludeFromRecents() throws Exception {
|
||||
startExcludeFromRecentsTestActivity();
|
||||
OverviewTask currentTask = getAndAssertLaunchedApp().switchToOverview().getCurrentTask();
|
||||
// TODO(b/326565120): the expected content description shouldn't be null but for now there
|
||||
// is a bug that causes it to sometimes be for excludeForRecents tasks.
|
||||
assertTrue("Can't find ExcludeFromRecentsTestActivity after entering Overview from it",
|
||||
currentTask.containsContentDescription("ExcludeFromRecents"));
|
||||
currentTask.containsContentDescription("ExcludeFromRecents")
|
||||
|| currentTask.containsContentDescription(null));
|
||||
// Going home should clear out the excludeFromRecents task.
|
||||
BaseOverview overview = mLauncher.goHome().switchToOverview();
|
||||
if (overview.hasTasks()) {
|
||||
currentTask = overview.getCurrentTask();
|
||||
assertFalse("Found ExcludeFromRecentsTestActivity after entering Overview from Home",
|
||||
currentTask.containsContentDescription("ExcludeFromRecents"));
|
||||
currentTask.containsContentDescription("ExcludeFromRecents")
|
||||
|| currentTask.containsContentDescription(null));
|
||||
} else {
|
||||
// Presumably the test started with 0 tasks and remains that way after going home.
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@PortraitLandscape
|
||||
@ScreenRecordRule.ScreenRecord // TODO(b/396447643): Remove screen record.
|
||||
public void testDismissCancel() throws Exception {
|
||||
startTestAppsWithCheck();
|
||||
Overview overview = mLauncher.goHome().switchToOverview();
|
||||
assertIsInState("Launcher internal state didn't switch to Overview",
|
||||
ExpectedState.OVERVIEW);
|
||||
final Integer numTasks = getFromRecentsView(RecentsView::getTaskViewCount);
|
||||
OverviewTask task = overview.getCurrentTask();
|
||||
assertNotNull("overview.getCurrentTask() returned null (2)", task);
|
||||
|
||||
task.dismissCancel();
|
||||
|
||||
runOnRecentsView(recentsView -> assertEquals(
|
||||
"Canceling dismissing a task removed a task from Overview",
|
||||
numTasks == null ? 0 : numTasks, recentsView.getTaskViewCount()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@PortraitLandscape
|
||||
public void testDismissBottomRow() throws Exception {
|
||||
assumeTrue(mLauncher.isTablet());
|
||||
mLauncher.goHome().switchToOverview().dismissAllTasks();
|
||||
startTestAppsWithCheck();
|
||||
Overview overview = mLauncher.goHome().switchToOverview();
|
||||
assertIsInState("Launcher internal state didn't switch to Overview",
|
||||
ExpectedState.OVERVIEW);
|
||||
final Integer numTasks = getFromRecentsView(RecentsView::getTaskViewCount);
|
||||
OverviewTask bottomTask = overview.getCurrentTasksForTablet().stream().max(
|
||||
Comparator.comparingInt(OverviewTask::getTaskCenterY)).get();
|
||||
assertNotNull("bottomTask null", bottomTask);
|
||||
|
||||
bottomTask.dismiss();
|
||||
|
||||
runOnRecentsView(recentsView -> assertEquals(
|
||||
"Dismissing a bottomTask didn't remove 1 bottomTask from Overview",
|
||||
numTasks - 1, recentsView.getTaskViewCount()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@PortraitLandscape
|
||||
public void testDismissLastGridRow() throws Exception {
|
||||
assumeTrue(mLauncher.isTablet());
|
||||
mLauncher.goHome().switchToOverview().dismissAllTasks();
|
||||
startTestAppsWithCheck();
|
||||
startTestActivity(3);
|
||||
startTestActivity(4);
|
||||
runOnRecentsView(
|
||||
recentsView -> assertNotEquals("Grid overview should have unequal row counts",
|
||||
recentsView.getTopRowTaskCountForTablet(),
|
||||
recentsView.getBottomRowTaskCountForTablet()));
|
||||
Overview overview = mLauncher.goHome().switchToOverview();
|
||||
assertIsInState("Launcher internal state didn't switch to Overview",
|
||||
ExpectedState.OVERVIEW);
|
||||
overview.flingForwardUntilClearAllVisible();
|
||||
assertTrue("Clear All not visible.", overview.isClearAllVisible());
|
||||
final Integer numTasks = getFromRecentsView(RecentsView::getTaskViewCount);
|
||||
OverviewTask lastGridTask = overview.getCurrentTasksForTablet().stream().min(
|
||||
Comparator.comparingInt(OverviewTask::getTaskCenterX)).get();
|
||||
assertNotNull("lastGridTask null.", lastGridTask);
|
||||
|
||||
lastGridTask.dismiss();
|
||||
|
||||
runOnRecentsView(recentsView -> assertEquals(
|
||||
"Dismissing a lastGridTask didn't remove 1 lastGridTask from Overview",
|
||||
numTasks - 1, recentsView.getTaskViewCount()));
|
||||
runOnRecentsView(recentsView -> assertEquals("Grid overview should have equal row counts.",
|
||||
recentsView.getTopRowTaskCountForTablet(),
|
||||
recentsView.getBottomRowTaskCountForTablet()));
|
||||
assertTrue("Clear All not visible.", overview.isClearAllVisible());
|
||||
}
|
||||
|
||||
private void startTestAppsWithCheck() throws Exception {
|
||||
startTestApps();
|
||||
expectLaunchedAppState();
|
||||
}
|
||||
|
||||
private void quickSwitchToPreviousAppAndAssert(boolean toRight) {
|
||||
final LaunchedAppState launchedAppState = getAndAssertLaunchedApp();
|
||||
if (toRight) {
|
||||
launchedAppState.quickSwitchToPreviousApp();
|
||||
} else {
|
||||
launchedAppState.quickSwitchToPreviousAppSwipeLeft();
|
||||
}
|
||||
|
||||
// While enable shell transition, Launcher can be resumed due to transient launch.
|
||||
waitForLauncherCondition("Launcher shouldn't stay in resume forever",
|
||||
this::isInLaunchedApp, 3000 /* timeout */);
|
||||
}
|
||||
|
||||
private boolean isHardwareKeyboard() {
|
||||
return Configuration.KEYBOARD_QWERTY
|
||||
== mTargetContext.getResources().getConfiguration().keyboard;
|
||||
}
|
||||
|
||||
private void assertIsInState(
|
||||
@NonNull String failureMessage, @NonNull ExpectedState expectedState) {
|
||||
assertTrue(failureMessage, enableLauncherOverviewInWindow()
|
||||
? isInRecentsWindowState(() -> expectedState.mRecentsState)
|
||||
: isInState(() -> expectedState.mLauncherState));
|
||||
}
|
||||
|
||||
private void waitForState(
|
||||
@NonNull String failureMessage, @NonNull ExpectedState expectedState) {
|
||||
if (enableLauncherOverviewInWindow()) {
|
||||
waitForRecentsWindowState(failureMessage, () -> expectedState.mRecentsState);
|
||||
} else {
|
||||
waitForState(failureMessage, () -> expectedState.mLauncherState);
|
||||
}
|
||||
}
|
||||
|
||||
private void expectLaunchedAppState() {
|
||||
executeOnLauncher(launcher -> assertTrue(
|
||||
"Launcher activity is the top activity; expecting another activity to be the top "
|
||||
+ "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);
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,10 @@
|
||||
package com.android.quickstep;
|
||||
|
||||
|
||||
import static com.android.launcher3.config.FeatureFlags.enableSplitContextually;
|
||||
import static com.android.launcher3.util.rule.TestStabilityRule.LOCAL;
|
||||
import static com.android.launcher3.util.rule.TestStabilityRule.PLATFORM_POSTSUBMIT;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
@@ -29,7 +33,8 @@ import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import com.android.launcher3.tapl.Overview;
|
||||
import com.android.launcher3.tapl.Taskbar;
|
||||
import com.android.launcher3.tapl.TaskbarAppIcon;
|
||||
import com.android.quickstep.util.SplitScreenTestUtils;
|
||||
import com.android.launcher3.util.rule.TestStabilityRule;
|
||||
import com.android.wm.shell.Flags;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
@@ -67,6 +72,7 @@ public class TaplTestsSplitscreen extends AbstractQuickStepTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestStabilityRule.Stability(flavors = PLATFORM_POSTSUBMIT | LOCAL) // b/295225524
|
||||
public void testSplitAppFromHomeWithItself() throws Exception {
|
||||
// Currently only tablets have Taskbar in Overview, so test is only active on tablets
|
||||
assumeTrue(mLauncher.isTablet());
|
||||
@@ -86,16 +92,28 @@ public class TaplTestsSplitscreen extends AbstractQuickStepTest {
|
||||
.getSplitScreenMenuItem()
|
||||
.click();
|
||||
|
||||
// We're staying in all apps, use same instance
|
||||
mLauncher.getAllApps()
|
||||
.getAppIcon(CALCULATOR_APP_NAME)
|
||||
.launchIntoSplitScreen();
|
||||
if (enableSplitContextually()) {
|
||||
// We're staying in all apps, use same instance
|
||||
mLauncher.getAllApps()
|
||||
.getAppIcon(CALCULATOR_APP_NAME)
|
||||
.launchIntoSplitScreen();
|
||||
} else {
|
||||
// We're in overview, use taskbar instance
|
||||
mLauncher.getLaunchedAppState()
|
||||
.getTaskbar()
|
||||
.getAppIcon(CALCULATOR_APP_NAME)
|
||||
.launchIntoSplitScreen();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSaveAppPairMenuItemOrActionExistsOnSplitPair() {
|
||||
Overview overview = SplitScreenTestUtils.createAndLaunchASplitPairInOverview(mLauncher);
|
||||
assumeTrue("App pairs feature is currently not enabled, no test needed",
|
||||
Flags.enableAppPairs());
|
||||
|
||||
createAndLaunchASplitPair();
|
||||
|
||||
Overview overview = mLauncher.goHome().switchToOverview();
|
||||
if (mLauncher.isGridOnlyOverviewEnabled() || !mLauncher.isTablet()) {
|
||||
assertTrue("Save app pair menu item is missing",
|
||||
overview.getCurrentTask()
|
||||
@@ -106,6 +124,9 @@ public class TaplTestsSplitscreen extends AbstractQuickStepTest {
|
||||
|
||||
@Test
|
||||
public void testSaveAppPairMenuItemDoesNotExistOnSingleTask() throws Exception {
|
||||
assumeTrue("App pairs feature is currently not enabled, no test needed",
|
||||
Flags.enableAppPairs());
|
||||
|
||||
startAppFast(CALCULATOR_APP_PACKAGE);
|
||||
|
||||
assertFalse("Save app pair menu item is erroneously appearing on single task",
|
||||
@@ -136,4 +157,24 @@ public class TaplTestsSplitscreen extends AbstractQuickStepTest {
|
||||
TaskbarAppIcon firstApp = taskbar.getAppIcon(firstAppName);
|
||||
firstApp.launchIntoSplitScreen();
|
||||
}
|
||||
|
||||
private void createAndLaunchASplitPair() {
|
||||
clearAllRecentTasks();
|
||||
|
||||
startTestActivity(2);
|
||||
startTestActivity(3);
|
||||
|
||||
if (mLauncher.isTablet() && !mLauncher.isGridOnlyOverviewEnabled()) {
|
||||
mLauncher.goHome().switchToOverview().getOverviewActions()
|
||||
.clickSplit()
|
||||
.getTestActivityTask(2)
|
||||
.open();
|
||||
} else {
|
||||
mLauncher.goHome().switchToOverview().getCurrentTask()
|
||||
.tapMenu()
|
||||
.tapSplitMenuItem()
|
||||
.getCurrentTask()
|
||||
.open();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.quickstep;
|
||||
|
||||
import static com.android.launcher3.util.rule.TestStabilityRule.LOCAL;
|
||||
import static com.android.launcher3.util.rule.TestStabilityRule.PLATFORM_POSTSUBMIT;
|
||||
import static com.android.quickstep.NavigationModeSwitchRule.Mode.ZERO_BUTTON;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
@@ -30,6 +32,8 @@ import androidx.test.runner.AndroidJUnit4;
|
||||
import com.android.launcher3.tapl.LauncherInstrumentation.TrackpadGestureType;
|
||||
import com.android.launcher3.tapl.Workspace;
|
||||
import com.android.launcher3.ui.PortraitLandscapeRunner.PortraitLandscape;
|
||||
import com.android.launcher3.util.rule.ScreenRecordRule;
|
||||
import com.android.launcher3.util.rule.TestStabilityRule;
|
||||
import com.android.quickstep.NavigationModeSwitchRule.NavigationModeSwitch;
|
||||
|
||||
import org.junit.After;
|
||||
@@ -91,6 +95,8 @@ public class TaplTestsTrackpad extends AbstractQuickStepTest {
|
||||
@Test
|
||||
@PortraitLandscape
|
||||
@NavigationModeSwitch
|
||||
@ScreenRecordRule.ScreenRecord // b/336606166
|
||||
@TestStabilityRule.Stability(flavors = LOCAL | PLATFORM_POSTSUBMIT) // b/336606166
|
||||
public void switchToOverview() throws Exception {
|
||||
assumeTrue(mLauncher.isTablet());
|
||||
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.quickstep;
|
||||
|
||||
import static junit.framework.Assert.assertFalse;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.launcher3.R;
|
||||
import com.android.quickstep.util.TaskKeyCache;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@SmallTest
|
||||
public class TaskThumbnailCacheTest {
|
||||
@Mock
|
||||
private Context mContext;
|
||||
|
||||
@Mock
|
||||
private Resources mResource;
|
||||
|
||||
@Mock
|
||||
private TaskKeyCache mTaskKeyCache;
|
||||
|
||||
@Before
|
||||
public void setup() throws NoSuchFieldException {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
when(mContext.getResources()).thenReturn(mResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void increaseCacheSize() {
|
||||
// Mock a cache size increase from 3 to 8
|
||||
when(mTaskKeyCache.getMaxSize()).thenReturn(3);
|
||||
when(mResource.getInteger((R.integer.recentsThumbnailCacheSize))).thenReturn(8);
|
||||
TaskThumbnailCache thumbnailCache = new TaskThumbnailCache(mContext, mock(Executor.class),
|
||||
mTaskKeyCache);
|
||||
|
||||
// Preload is needed when increasing size
|
||||
assertTrue(thumbnailCache.updateCacheSizeAndRemoveExcess());
|
||||
verify(mTaskKeyCache, times(1)).updateCacheSizeAndRemoveExcess(8);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decreaseCacheSize() {
|
||||
// Mock a cache size decrease from 8 to 3
|
||||
when(mTaskKeyCache.getMaxSize()).thenReturn(8);
|
||||
when(mResource.getInteger((R.integer.recentsThumbnailCacheSize))).thenReturn(3);
|
||||
TaskThumbnailCache thumbnailCache = new TaskThumbnailCache(mContext, mock(Executor.class),
|
||||
mTaskKeyCache);
|
||||
// Preload is not needed when decreasing size
|
||||
assertFalse(thumbnailCache.updateCacheSizeAndRemoveExcess());
|
||||
verify(mTaskKeyCache, times(1)).updateCacheSizeAndRemoveExcess(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void keepSameCacheSize() {
|
||||
when(mTaskKeyCache.getMaxSize()).thenReturn(3);
|
||||
when(mResource.getInteger((R.integer.recentsThumbnailCacheSize))).thenReturn(3);
|
||||
TaskThumbnailCache thumbnailCache = new TaskThumbnailCache(mContext, mock(Executor.class),
|
||||
mTaskKeyCache);
|
||||
// Preload is not needed when it has the same cache size
|
||||
assertFalse(thumbnailCache.updateCacheSizeAndRemoveExcess());
|
||||
verify(mTaskKeyCache, never()).updateCacheSizeAndRemoveExcess(anyInt());
|
||||
}
|
||||
}
|
||||
@@ -87,6 +87,18 @@ public class TaskViewTest {
|
||||
true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void showBorderOnHoverEvent() {
|
||||
mTaskView.setBorderEnabled(/* enabled= */ true);
|
||||
MotionEvent event = MotionEvent.obtain(0, 0, MotionEvent.ACTION_HOVER_ENTER, 0.0f, 0.0f, 0);
|
||||
mTaskView.onHoverEvent(MotionEvent.obtain(event));
|
||||
verify(mHoverAnimator, times(1)).setBorderVisibility(/* visible= */ true, /* animated= */
|
||||
true);
|
||||
mTaskView.onFocusChanged(true, 0, new Rect());
|
||||
verify(mFocusAnimator, times(1)).setBorderVisibility(/* visible= */ true, /* animated= */
|
||||
true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void showBorderOnBorderEnabled() {
|
||||
presetBorderStatus(/* enabled= */ false);
|
||||
|
||||
+219
@@ -0,0 +1,219 @@
|
||||
/*
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.quickstep.taskbar.controllers
|
||||
|
||||
import android.animation.AnimatorSet
|
||||
import android.animation.ObjectAnimator
|
||||
import android.view.View
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.SmallTest
|
||||
import com.android.launcher3.LauncherPrefs
|
||||
import com.android.launcher3.LauncherPrefs.Companion.TASKBAR_PINNING
|
||||
import com.android.launcher3.LauncherPrefs.Companion.TASKBAR_PINNING_IN_DESKTOP_MODE
|
||||
import com.android.launcher3.logging.StatsLogManager
|
||||
import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_DIVIDER_MENU_CLOSE
|
||||
import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_DIVIDER_MENU_OPEN
|
||||
import com.android.launcher3.taskbar.TaskbarActivityContext
|
||||
import com.android.launcher3.taskbar.TaskbarBaseTestCase
|
||||
import com.android.launcher3.taskbar.TaskbarDividerPopupView
|
||||
import com.android.launcher3.taskbar.TaskbarDragLayer
|
||||
import com.android.launcher3.taskbar.TaskbarPinningController
|
||||
import com.android.launcher3.taskbar.TaskbarPinningController.Companion.PINNING_PERSISTENT
|
||||
import com.android.launcher3.taskbar.TaskbarPinningController.Companion.PINNING_TRANSIENT
|
||||
import com.android.launcher3.taskbar.TaskbarSharedState
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.kotlin.any
|
||||
import org.mockito.kotlin.argumentCaptor
|
||||
import org.mockito.kotlin.doNothing
|
||||
import org.mockito.kotlin.doReturn
|
||||
import org.mockito.kotlin.mock
|
||||
import org.mockito.kotlin.never
|
||||
import org.mockito.kotlin.spy
|
||||
import org.mockito.kotlin.times
|
||||
import org.mockito.kotlin.verify
|
||||
import org.mockito.kotlin.whenever
|
||||
|
||||
@SmallTest
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class TaskbarPinningControllerTest : TaskbarBaseTestCase() {
|
||||
private val taskbarDragLayer = mock<TaskbarDragLayer>()
|
||||
private val taskbarSharedState = mock<TaskbarSharedState>()
|
||||
private var isInDesktopMode = false
|
||||
private val isInDesktopModeProvider = { isInDesktopMode }
|
||||
private val launcherPrefs =
|
||||
mock<LauncherPrefs> {
|
||||
on { get(TASKBAR_PINNING) } doReturn false
|
||||
on { get(TASKBAR_PINNING_IN_DESKTOP_MODE) } doReturn false
|
||||
}
|
||||
private val statsLogger = mock<StatsLogManager.StatsLogger>()
|
||||
private val statsLogManager = mock<StatsLogManager> { on { logger() } doReturn statsLogger }
|
||||
private lateinit var pinningController: TaskbarPinningController
|
||||
|
||||
@Before
|
||||
override fun setup() {
|
||||
super.setup()
|
||||
whenever(taskbarActivityContext.launcherPrefs).thenReturn(launcherPrefs)
|
||||
whenever(taskbarActivityContext.dragLayer).thenReturn(taskbarDragLayer)
|
||||
whenever(taskbarActivityContext.statsLogManager).thenReturn(statsLogManager)
|
||||
pinningController =
|
||||
spy(TaskbarPinningController(taskbarActivityContext, isInDesktopModeProvider))
|
||||
pinningController.init(taskbarControllers, taskbarSharedState)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testOnCloseCallback_whenClosingPopupView_shouldLogStatsForClosingPopupMenu() {
|
||||
pinningController.onCloseCallback(false)
|
||||
verify(statsLogger, times(1)).log(LAUNCHER_TASKBAR_DIVIDER_MENU_CLOSE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testOnCloseCallback_whenClosingPopupView_shouldPostVisibilityChangedToDragLayer() {
|
||||
val argumentCaptor = argumentCaptor<Runnable>()
|
||||
pinningController.onCloseCallback(false)
|
||||
verify(taskbarDragLayer, times(1)).post(argumentCaptor.capture())
|
||||
|
||||
val runnable = argumentCaptor.lastValue
|
||||
assertThat(runnable).isNotNull()
|
||||
|
||||
runnable.run()
|
||||
verify(taskbarActivityContext, times(1)).onPopupVisibilityChanged(false)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testOnCloseCallback_whenPreferenceUnchanged_shouldNotAnimateTaskbarPinning() {
|
||||
pinningController.onCloseCallback(false)
|
||||
verify(taskbarSharedState, never()).taskbarWasPinned = true
|
||||
verify(pinningController, never()).animateTaskbarPinning(any())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testOnCloseCallback_whenLauncherPreferenceChanged_shouldAnimateToPinnedTaskbar() {
|
||||
whenever(launcherPrefs.get(TASKBAR_PINNING)).thenReturn(false)
|
||||
doNothing().whenever(pinningController).animateTaskbarPinning(any())
|
||||
|
||||
pinningController.onCloseCallback(true)
|
||||
|
||||
verify(taskbarSharedState, times(1)).taskbarWasPinned = false
|
||||
verify(pinningController, times(1)).animateTaskbarPinning(PINNING_PERSISTENT)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testOnCloseCallback_whenLauncherPreferenceChanged_shouldAnimateToTransientTaskbar() {
|
||||
whenever(launcherPrefs.get(TASKBAR_PINNING)).thenReturn(true)
|
||||
doNothing().whenever(pinningController).animateTaskbarPinning(any())
|
||||
|
||||
pinningController.onCloseCallback(true)
|
||||
|
||||
verify(taskbarSharedState, times(1)).taskbarWasPinned = true
|
||||
verify(pinningController, times(1)).animateTaskbarPinning(PINNING_TRANSIENT)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testShowPinningView_whenShowingPinningView_shouldSetTaskbarWindowFullscreenAndPostRunnableToView() {
|
||||
val popupView =
|
||||
mock<TaskbarDividerPopupView<TaskbarActivityContext>> {
|
||||
on { requestFocus() } doReturn true
|
||||
}
|
||||
val view = mock<View>()
|
||||
val argumentCaptor = argumentCaptor<Runnable>()
|
||||
doReturn(popupView).whenever(pinningController).getPopupView(view)
|
||||
|
||||
pinningController.showPinningView(view)
|
||||
|
||||
verify(view, times(1)).post(argumentCaptor.capture())
|
||||
|
||||
val runnable = argumentCaptor.lastValue
|
||||
assertThat(runnable).isNotNull()
|
||||
runnable.run()
|
||||
|
||||
verify(pinningController, times(1)).getPopupView(view)
|
||||
verify(popupView, times(1)).requestFocus()
|
||||
verify(popupView, times(1)).onCloseCallback = any()
|
||||
verify(taskbarActivityContext, times(1)).onPopupVisibilityChanged(true)
|
||||
verify(popupView, times(1)).show()
|
||||
verify(statsLogger, times(1)).log(LAUNCHER_TASKBAR_DIVIDER_MENU_OPEN)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAnimateTaskbarPinning_whenAnimationEnds_shouldInvokeCallbackDoOnEnd() {
|
||||
val animatorSet = spy(AnimatorSet())
|
||||
doReturn(animatorSet)
|
||||
.whenever(pinningController)
|
||||
.getAnimatorSetForTaskbarPinningAnimation(PINNING_PERSISTENT)
|
||||
doNothing().whenever(animatorSet).start()
|
||||
pinningController.animateTaskbarPinning(PINNING_PERSISTENT)
|
||||
animatorSet.listeners[0].onAnimationEnd(ObjectAnimator())
|
||||
verify(pinningController, times(1)).recreateTaskbarAndUpdatePinningValue()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAnimateTaskbarPinning_whenAnimatingToPersistentTaskbar_shouldAnimateToPinnedTaskbar() {
|
||||
val animatorSet = spy(AnimatorSet())
|
||||
doReturn(animatorSet)
|
||||
.whenever(pinningController)
|
||||
.getAnimatorSetForTaskbarPinningAnimation(PINNING_PERSISTENT)
|
||||
doNothing().whenever(animatorSet).start()
|
||||
pinningController.animateTaskbarPinning(PINNING_PERSISTENT)
|
||||
|
||||
verify(taskbarOverlayController, times(1)).hideWindow()
|
||||
verify(pinningController, times(1))
|
||||
.getAnimatorSetForTaskbarPinningAnimation(PINNING_PERSISTENT)
|
||||
verify(taskbarViewController, times(1))
|
||||
.animateAwayNotificationDotsDuringTaskbarPinningAnimation()
|
||||
verify(taskbarDragLayer, times(1)).setAnimatingTaskbarPinning(true)
|
||||
assertThat(pinningController.isAnimatingTaskbarPinning).isTrue()
|
||||
assertThat(animatorSet.listeners).isNotNull()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAnimateTaskbarPinning_whenAnimatingToTransientTaskbar_shouldAnimateToTransientTaskbar() {
|
||||
val animatorSet = spy(AnimatorSet())
|
||||
doReturn(animatorSet)
|
||||
.whenever(pinningController)
|
||||
.getAnimatorSetForTaskbarPinningAnimation(PINNING_TRANSIENT)
|
||||
doNothing().whenever(animatorSet).start()
|
||||
pinningController.animateTaskbarPinning(PINNING_TRANSIENT)
|
||||
|
||||
verify(taskbarOverlayController, times(1)).hideWindow()
|
||||
verify(pinningController, times(1))
|
||||
.getAnimatorSetForTaskbarPinningAnimation(PINNING_TRANSIENT)
|
||||
verify(taskbarDragLayer, times(1)).setAnimatingTaskbarPinning(true)
|
||||
assertThat(pinningController.isAnimatingTaskbarPinning).isTrue()
|
||||
verify(taskbarViewController, times(1))
|
||||
.animateAwayNotificationDotsDuringTaskbarPinningAnimation()
|
||||
assertThat(animatorSet.listeners).isNotNull()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testRecreateTaskbarAndUpdatePinningValue_whenAnimationEnds_shouldUpdateTaskbarPinningLauncherPref() {
|
||||
pinningController.recreateTaskbarAndUpdatePinningValue()
|
||||
verify(taskbarDragLayer, times(1)).setAnimatingTaskbarPinning(false)
|
||||
assertThat(pinningController.isAnimatingTaskbarPinning).isFalse()
|
||||
verify(launcherPrefs, times(1)).put(TASKBAR_PINNING, true)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testRecreateTaskbarAndUpdatePinningValue_whenAnimationEnds_shouldUpdateTaskbarPinningDesktopModePref() {
|
||||
isInDesktopMode = true
|
||||
pinningController.recreateTaskbarAndUpdatePinningValue()
|
||||
verify(taskbarDragLayer, times(1)).setAnimatingTaskbarPinning(false)
|
||||
assertThat(pinningController.isAnimatingTaskbarPinning).isFalse()
|
||||
verify(launcherPrefs, times(1)).put(TASKBAR_PINNING_IN_DESKTOP_MODE, true)
|
||||
}
|
||||
}
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (C) 2024 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.quickstep.taskbar.customization
|
||||
|
||||
import com.android.launcher3.taskbar.customization.TaskbarFeatureEvaluator
|
||||
import com.android.launcher3.taskbar.customization.TaskbarIconSpecs
|
||||
import com.android.launcher3.taskbar.customization.TaskbarSpecsEvaluator
|
||||
import com.android.launcher3.util.LauncherMultivalentJUnit
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.kotlin.doReturn
|
||||
import org.mockito.kotlin.mock
|
||||
import org.mockito.kotlin.spy
|
||||
import org.mockito.kotlin.whenever
|
||||
|
||||
@RunWith(LauncherMultivalentJUnit::class)
|
||||
class TaskbarSpecsEvaluatorTest {
|
||||
|
||||
private val taskbarFeatureEvaluator = mock<TaskbarFeatureEvaluator>()
|
||||
private val taskbarSpecsEvaluator = spy(TaskbarSpecsEvaluator(taskbarFeatureEvaluator))
|
||||
|
||||
@Test
|
||||
fun testGetIconSizeByGrid_whenTaskbarIsTransient_withValidRowAndColumn() {
|
||||
doReturn(true).whenever(taskbarFeatureEvaluator).isTransient
|
||||
assertThat(taskbarSpecsEvaluator.getIconSizeByGrid(6, 5))
|
||||
.isEqualTo(TaskbarIconSpecs.iconSize52dp)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testGetIconSizeByGrid_whenTaskbarIsTransient_withInvalidRowAndColumn() {
|
||||
doReturn(true).whenever(taskbarFeatureEvaluator).isTransient
|
||||
assertThat(taskbarSpecsEvaluator.getIconSizeByGrid(1, 2))
|
||||
.isEqualTo(TaskbarIconSpecs.defaultTransientIconSize)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testGetIconSizeByGrid_whenTaskbarIsPersistent() {
|
||||
doReturn(false).whenever(taskbarFeatureEvaluator).isTransient
|
||||
assertThat(taskbarSpecsEvaluator.getIconSizeByGrid(6, 5))
|
||||
.isEqualTo(TaskbarIconSpecs.defaultPersistentIconSize)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testGetIconSizeStepDown_whenTaskbarIsPersistent() {
|
||||
doReturn(false).whenever(taskbarFeatureEvaluator).isTransient
|
||||
assertThat(taskbarSpecsEvaluator.getIconSizeStepDown(TaskbarIconSpecs.iconSize44dp))
|
||||
.isEqualTo(TaskbarIconSpecs.defaultPersistentIconSize)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testGetIconSizeStepDown_whenTaskbarIsTransientAndIconSizeAreInBound() {
|
||||
doReturn(true).whenever(taskbarFeatureEvaluator).isTransient
|
||||
assertThat(taskbarSpecsEvaluator.getIconSizeStepDown(TaskbarIconSpecs.iconSize52dp))
|
||||
.isEqualTo(TaskbarIconSpecs.iconSize48dp)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testGetIconSizeStepDown_whenTaskbarIsTransientAndIconSizeAreOutOfBound() {
|
||||
doReturn(true).whenever(taskbarFeatureEvaluator).isTransient
|
||||
assertThat(taskbarSpecsEvaluator.getIconSizeStepDown(TaskbarIconSpecs.iconSize44dp))
|
||||
.isEqualTo(TaskbarIconSpecs.iconSize44dp)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testGetIconSizeStepUp_whenTaskbarIsPersistent() {
|
||||
doReturn(false).whenever(taskbarFeatureEvaluator).isTransient
|
||||
assertThat(taskbarSpecsEvaluator.getIconSizeStepUp(TaskbarIconSpecs.iconSize40dp))
|
||||
.isEqualTo(TaskbarIconSpecs.iconSize40dp)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testGetIconSizeStepUp_whenTaskbarIsTransientAndIconSizeAreInBound() {
|
||||
doReturn(true).whenever(taskbarFeatureEvaluator).isTransient
|
||||
assertThat(taskbarSpecsEvaluator.getIconSizeStepUp(TaskbarIconSpecs.iconSize44dp))
|
||||
.isEqualTo(TaskbarIconSpecs.iconSize48dp)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testGetIconSizeStepUp_whenTaskbarIsTransientAndIconSizeAreOutOfBound() {
|
||||
doReturn(true).whenever(taskbarFeatureEvaluator).isTransient
|
||||
assertThat(taskbarSpecsEvaluator.getIconSizeStepUp(TaskbarIconSpecs.iconSize52dp))
|
||||
.isEqualTo(TaskbarIconSpecs.iconSize52dp)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright (C) 2024 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.quickstep.util
|
||||
|
||||
import android.graphics.Rect
|
||||
import android.graphics.Region
|
||||
import android.testing.AndroidTestingRunner
|
||||
import android.view.Display.DEFAULT_DISPLAY
|
||||
import android.view.IWindowManager
|
||||
import androidx.test.filters.SmallTest
|
||||
import com.android.launcher3.util.Executors
|
||||
import com.android.quickstep.util.GestureExclusionManager.ExclusionListener
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mock
|
||||
import org.mockito.MockitoAnnotations
|
||||
import org.mockito.kotlin.reset
|
||||
import org.mockito.kotlin.verify
|
||||
import org.mockito.kotlin.verifyZeroInteractions
|
||||
|
||||
/** Unit test for [GestureExclusionManager]. */
|
||||
@SmallTest
|
||||
@RunWith(AndroidTestingRunner::class)
|
||||
class GestureExclusionManagerTest {
|
||||
|
||||
@Mock private lateinit var windowManager: IWindowManager
|
||||
|
||||
@Mock private lateinit var listener1: ExclusionListener
|
||||
@Mock private lateinit var listener2: ExclusionListener
|
||||
|
||||
private val r1 = Region().apply { union(Rect(0, 0, 100, 200)) }
|
||||
private val r2 = Region().apply { union(Rect(200, 200, 500, 800)) }
|
||||
|
||||
private lateinit var underTest: GestureExclusionManager
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
underTest = GestureExclusionManager(windowManager)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun addListener_registers() {
|
||||
underTest.addListener(listener1)
|
||||
|
||||
awaitTasksCompleted()
|
||||
verify(windowManager)
|
||||
.registerSystemGestureExclusionListener(underTest.exclusionListener, DEFAULT_DISPLAY)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun addListener_again_skips_register() {
|
||||
underTest.addListener(listener1)
|
||||
awaitTasksCompleted()
|
||||
reset(windowManager)
|
||||
|
||||
underTest.addListener(listener2)
|
||||
|
||||
awaitTasksCompleted()
|
||||
verifyZeroInteractions(windowManager)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun removeListener_unregisters() {
|
||||
underTest.addListener(listener1)
|
||||
awaitTasksCompleted()
|
||||
reset(windowManager)
|
||||
|
||||
underTest.removeListener(listener1)
|
||||
|
||||
awaitTasksCompleted()
|
||||
verify(windowManager)
|
||||
.unregisterSystemGestureExclusionListener(underTest.exclusionListener, DEFAULT_DISPLAY)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun removeListener_again_skips_unregister() {
|
||||
underTest.addListener(listener1)
|
||||
underTest.addListener(listener2)
|
||||
awaitTasksCompleted()
|
||||
reset(windowManager)
|
||||
|
||||
underTest.removeListener(listener1)
|
||||
|
||||
awaitTasksCompleted()
|
||||
verifyZeroInteractions(windowManager)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun onSystemGestureExclusionChanged_dispatches_to_listeners() {
|
||||
underTest.addListener(listener1)
|
||||
underTest.addListener(listener2)
|
||||
awaitTasksCompleted()
|
||||
|
||||
underTest.exclusionListener.onSystemGestureExclusionChanged(DEFAULT_DISPLAY, r1, r2)
|
||||
awaitTasksCompleted()
|
||||
verify(listener1).onGestureExclusionChanged(r1, r2)
|
||||
verify(listener2).onGestureExclusionChanged(r1, r2)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun addLister_dispatches_second_time() {
|
||||
underTest.exclusionListener.onSystemGestureExclusionChanged(DEFAULT_DISPLAY, r1, r2)
|
||||
awaitTasksCompleted()
|
||||
underTest.addListener(listener1)
|
||||
awaitTasksCompleted()
|
||||
verifyZeroInteractions(listener1)
|
||||
|
||||
underTest.addListener(listener2)
|
||||
awaitTasksCompleted()
|
||||
|
||||
verifyZeroInteractions(listener1)
|
||||
verify(listener2).onGestureExclusionChanged(r1, r2)
|
||||
}
|
||||
|
||||
private fun awaitTasksCompleted() {
|
||||
Executors.UI_HELPER_EXECUTOR.submit<Any> { null }.get()
|
||||
Executors.MAIN_EXECUTOR.submit<Any> { null }.get()
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user