Add TaplTestsQuickstep#testExcludeFromRecents
- Add ExcludeFromRecentsTestActivity, and add it to the manifest
with excludeFromRecents="true"
- Add the test to check the current Overview task content
description, ensuring that the excludeFromRecents task is
present directly after a gesture but not after going home.
Bug: 324495241
Flag: None
Test: TaplTestsQuickstep#testExcludeFromRecents
Change-Id: I06be53673f0ac06924f79b44f19744da066cc7ea
diff --git a/quickstep/Android.bp b/quickstep/Android.bp
index a290e84..f14cebd 100644
--- a/quickstep/Android.bp
+++ b/quickstep/Android.bp
@@ -52,5 +52,6 @@
"tests/src/com/android/quickstep/TaplOverviewIconTest.java",
"tests/src/com/android/quickstep/TaplTestsQuickstep.java",
"tests/src/com/android/quickstep/TaplTestsSplitscreen.java",
+ "tests/src/com/android/launcher3/testcomponent/ExcludeFromRecentsTestActivity.java"
],
}
diff --git a/quickstep/tests/src/com/android/launcher3/testcomponent/ExcludeFromRecentsTestActivity.java b/quickstep/tests/src/com/android/launcher3/testcomponent/ExcludeFromRecentsTestActivity.java
new file mode 100644
index 0000000..68ac3d5
--- /dev/null
+++ b/quickstep/tests/src/com/android/launcher3/testcomponent/ExcludeFromRecentsTestActivity.java
@@ -0,0 +1,22 @@
+/*
+ * 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.launcher3.testcomponent;
+
+/**
+ * Extension of BaseTestingActivity to help test excludeFromRecents="true".
+ */
+public class ExcludeFromRecentsTestActivity extends BaseTestingActivity {}
diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java
index 45a9527..ca9d823 100644
--- a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java
+++ b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java
@@ -21,6 +21,7 @@
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.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeFalse;
@@ -38,6 +39,7 @@
import com.android.launcher3.Flags;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
+import com.android.launcher3.tapl.BaseOverview;
import com.android.launcher3.tapl.LaunchedAppState;
import com.android.launcher3.tapl.LauncherInstrumentation.NavigationModel;
import com.android.launcher3.tapl.Overview;
@@ -583,4 +585,25 @@
mLauncher.getDevice().setOrientationNatural();
}
}
+
+ @Test
+ 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(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(null));
+ } else {
+ // Presumably the test started with 0 tasks and remains that way after going home.
+ }
+ }
}