Merge "Fixing alt-tab is properly dispatched to the RecentsView" into ub-launcher3-master
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java
index 43ebbe0..cb6493c 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java
@@ -153,8 +153,7 @@
// Optimization, hide the all apps view to prevent layout while initializing
activity.getAppsView().getContentView().setVisibility(View.GONE);
- AccessibilityManagerCompat.sendEventToTest(
- activity, TestProtocol.SWITCHED_TO_STATE_MESSAGE);
+ AccessibilityManagerCompat.sendStateEventToTest(activity, fromState.ordinal);
} else {
fromState = startState;
}
diff --git a/src/com/android/launcher3/TestProtocol.java b/src/com/android/launcher3/TestProtocol.java
index 0a3b86d..008b624 100644
--- a/src/com/android/launcher3/TestProtocol.java
+++ b/src/com/android/launcher3/TestProtocol.java
@@ -22,6 +22,7 @@
public final class TestProtocol {
public static final String GET_SCROLL_MESSAGE = "TAPL_GET_SCROLL";
public static final String SCROLL_Y_FIELD = "scrollY";
+ public static final String STATE_FIELD = "state";
public static final String SWITCHED_TO_STATE_MESSAGE = "TAPL_SWITCHED_TO_STATE";
public static final String RESPONSE_MESSAGE_POSTFIX = "_RESPONSE";
}
diff --git a/src/com/android/launcher3/compat/AccessibilityManagerCompat.java b/src/com/android/launcher3/compat/AccessibilityManagerCompat.java
index 6feb1e9..51e914c 100644
--- a/src/com/android/launcher3/compat/AccessibilityManagerCompat.java
+++ b/src/com/android/launcher3/compat/AccessibilityManagerCompat.java
@@ -52,11 +52,14 @@
return (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
}
- public static void sendEventToTest(Context context, String eventTag) {
+ public static void sendStateEventToTest(Context context, int stateOrdinal) {
final AccessibilityManager accessibilityManager = getAccessibilityManagerForTest(context);
if (accessibilityManager == null) return;
- sendEventToTest(accessibilityManager, eventTag, null);
+ final Bundle parcel = new Bundle();
+ parcel.putInt(TestProtocol.STATE_FIELD, stateOrdinal);
+
+ sendEventToTest(accessibilityManager, TestProtocol.SWITCHED_TO_STATE_MESSAGE, parcel);
}
private static void sendEventToTest(
diff --git a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
index 0e2ed6c..c125c10 100644
--- a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
+++ b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
@@ -522,8 +522,7 @@
}
mLauncher.getStateManager().goToState(targetState, false /* animated */);
- AccessibilityManagerCompat.sendEventToTest(
- mLauncher, TestProtocol.SWITCHED_TO_STATE_MESSAGE);
+ AccessibilityManagerCompat.sendStateEventToTest(mLauncher, targetState.ordinal);
}
}
diff --git a/tests/src/com/android/launcher3/ui/AllAppsIconToHomeTest.java b/tests/src/com/android/launcher3/ui/AllAppsIconToHomeTest.java
deleted file mode 100644
index fdf87be..0000000
--- a/tests/src/com/android/launcher3/ui/AllAppsIconToHomeTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.android.launcher3.ui;
-
-import android.content.pm.LauncherActivityInfo;
-
-import androidx.test.filters.LargeTest;
-import androidx.test.runner.AndroidJUnit4;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Test for dragging an icon from all-apps to homescreen.
- */
-@LargeTest
-@RunWith(AndroidJUnit4.class)
-public class AllAppsIconToHomeTest extends AbstractLauncherUiTest {
-
- @Test
- @PortraitLandscape
- public void testDragIcon() throws Throwable {
- LauncherActivityInfo settingsApp = getSettingsApp();
-
- clearHomescreen();
-
- final String appName = settingsApp.getLabel().toString();
- // 1. Open all apps and wait for load complete.
- // 2. Drag icon to homescreen.
- // 3. Verify that the icon works on homescreen.
- mLauncher.pressHome().
- switchToAllApps().
- getAppIcon(appName).
- dragToWorkspace().
- getWorkspaceAppIcon(appName).
- launch(settingsApp.getComponentName().getPackageName());
- }
-}
diff --git a/tests/src/com/android/launcher3/ui/ShortcutsLaunchTest.java b/tests/src/com/android/launcher3/ui/ShortcutsLaunchTest.java
deleted file mode 100644
index 1fea4d5..0000000
--- a/tests/src/com/android/launcher3/ui/ShortcutsLaunchTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package com.android.launcher3.ui;
-
-import static org.junit.Assert.assertTrue;
-
-import android.content.pm.LauncherActivityInfo;
-
-import androidx.test.filters.LargeTest;
-import androidx.test.runner.AndroidJUnit4;
-
-import com.android.launcher3.Launcher;
-import com.android.launcher3.popup.ArrowPopup;
-import com.android.launcher3.tapl.AppIconMenu;
-import com.android.launcher3.tapl.AppIconMenuItem;
-import com.android.launcher3.views.OptionsPopupView;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Test for verifying that shortcuts are shown and can be launched after long pressing an app
- */
-@LargeTest
-@RunWith(AndroidJUnit4.class)
-public class ShortcutsLaunchTest extends AbstractLauncherUiTest {
-
- private boolean isOptionsPopupVisible(Launcher launcher) {
- final ArrowPopup popup = OptionsPopupView.getOptionsPopup(launcher);
- return popup != null && popup.isShown();
- }
-
- @Test
- @PortraitLandscape
- public void testAppLauncher() throws Exception {
- mActivityMonitor.startLauncher();
- final LauncherActivityInfo testApp = getSettingsApp();
-
- final AppIconMenu menu = mLauncher.
- pressHome().
- switchToAllApps().
- getAppIcon(testApp.getLabel().toString()).
- openMenu();
-
- executeOnLauncher(
- launcher -> assertTrue("Launcher internal state didn't switch to Showing Menu",
- isOptionsPopupVisible(launcher)));
-
- final AppIconMenuItem menuItem = menu.getMenuItem(1);
- final String itemName = menuItem.getText();
-
- menuItem.launch(testApp.getComponentName().getPackageName(), itemName);
- }
-}
diff --git a/tests/src/com/android/launcher3/ui/ShortcutsToHomeTest.java b/tests/src/com/android/launcher3/ui/ShortcutsToHomeTest.java
deleted file mode 100644
index 4c2c959..0000000
--- a/tests/src/com/android/launcher3/ui/ShortcutsToHomeTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.android.launcher3.ui;
-
-import android.content.pm.LauncherActivityInfo;
-
-import androidx.test.filters.LargeTest;
-import androidx.test.runner.AndroidJUnit4;
-
-import com.android.launcher3.tapl.AppIconMenuItem;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Test for dragging a deep shortcut to the home screen.
- */
-@LargeTest
-@RunWith(AndroidJUnit4.class)
-public class ShortcutsToHomeTest extends AbstractLauncherUiTest {
-
- @Test
- @PortraitLandscape
- public void testDragIcon() throws Throwable {
- clearHomescreen();
- mActivityMonitor.startLauncher();
-
- LauncherActivityInfo testApp = getSettingsApp();
-
- // 1. Open all apps and wait for load complete.
- // 2. Find the app and long press it to show shortcuts.
- // 3. Press icon center until shortcuts appear
- final AppIconMenuItem menuItem = mLauncher.
- getWorkspace().
- switchToAllApps().
- getAppIcon(testApp.getLabel().toString()).
- openMenu().
- getMenuItem(0);
- final String shortcutName = menuItem.getText();
-
- // 4. Drag the first shortcut to the home screen.
- // 5. Verify that the shortcut works on home screen
- // (the app opens and has the same text as the shortcut).
- menuItem.
- dragToWorkspace().
- getWorkspaceAppIcon(shortcutName).
- launch(testApp.getComponentName().getPackageName(), shortcutName);
- }
-}
diff --git a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
index ab5761d..47b98fb 100644
--- a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
+++ b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
@@ -25,6 +25,7 @@
import static org.junit.Assert.assertTrue;
import android.content.Intent;
+import android.content.pm.LauncherActivityInfo;
import android.util.Log;
import androidx.test.filters.LargeTest;
@@ -33,8 +34,11 @@
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
+import com.android.launcher3.popup.ArrowPopup;
import com.android.launcher3.tapl.AllApps;
import com.android.launcher3.tapl.AppIcon;
+import com.android.launcher3.tapl.AppIconMenu;
+import com.android.launcher3.tapl.AppIconMenuItem;
import com.android.launcher3.tapl.Widgets;
import com.android.launcher3.tapl.Workspace;
import com.android.launcher3.views.OptionsPopupView;
@@ -103,7 +107,8 @@
clearLauncherData();
- mLauncher.pressHome();
+ mDevice.pressHome();
+ waitForLauncherCondition("Launcher didn't start", launcher -> launcher != null);
waitForState("Launcher internal state didn't switch to Home", LauncherState.NORMAL);
waitForResumed("Launcher internal state is still Background");
}
@@ -284,4 +289,72 @@
private int getWidgetsScroll(Launcher launcher) {
return getWidgetsView(launcher).getCurrentScrollY();
}
+
+ private boolean isOptionsPopupVisible(Launcher launcher) {
+ final ArrowPopup popup = OptionsPopupView.getOptionsPopup(launcher);
+ return popup != null && popup.isShown();
+ }
+
+ @Test
+ @PortraitLandscape
+ public void testLaunchMenuItem() throws Exception {
+ final LauncherActivityInfo testApp = getSettingsApp();
+
+ final AppIconMenu menu = mLauncher.
+ getWorkspace().
+ switchToAllApps().
+ getAppIcon(testApp.getLabel().toString()).
+ openMenu();
+
+ executeOnLauncher(
+ launcher -> assertTrue("Launcher internal state didn't switch to Showing Menu",
+ isOptionsPopupVisible(launcher)));
+
+ final AppIconMenuItem menuItem = menu.getMenuItem(1);
+ final String itemName = menuItem.getText();
+
+ menuItem.launch(testApp.getComponentName().getPackageName(), itemName);
+ }
+
+ @Test
+ @PortraitLandscape
+ public void testDragAppIcon() throws Throwable {
+ LauncherActivityInfo settingsApp = getSettingsApp();
+
+ final String appName = settingsApp.getLabel().toString();
+ // 1. Open all apps and wait for load complete.
+ // 2. Drag icon to homescreen.
+ // 3. Verify that the icon works on homescreen.
+ mLauncher.getWorkspace().
+ switchToAllApps().
+ getAppIcon(appName).
+ dragToWorkspace().
+ getWorkspaceAppIcon(appName).
+ launch(settingsApp.getComponentName().getPackageName());
+ }
+
+ @Test
+ @PortraitLandscape
+ public void testDragShortcut() throws Throwable {
+ LauncherActivityInfo testApp = getSettingsApp();
+
+ // 1. Open all apps and wait for load complete.
+ // 2. Find the app and long press it to show shortcuts.
+ // 3. Press icon center until shortcuts appear
+ final AppIconMenuItem menuItem = mLauncher.
+ getWorkspace().
+ switchToAllApps().
+ getAppIcon(testApp.getLabel().toString()).
+ openMenu().
+ getMenuItem(0);
+ final String shortcutName = menuItem.getText();
+
+ // 4. Drag the first shortcut to the home screen.
+ // 5. Verify that the shortcut works on home screen
+ // (the app opens and has the same text as the shortcut).
+ menuItem.
+ dragToWorkspace().
+ getWorkspaceAppIcon(shortcutName).
+ launch(testApp.getComponentName().getPackageName(), shortcutName);
+ }
}
diff --git a/tests/tapl/com/android/launcher3/tapl/AllAppsFromOverview.java b/tests/tapl/com/android/launcher3/tapl/AllAppsFromOverview.java
index 42817c1..3e4b1f3 100644
--- a/tests/tapl/com/android/launcher3/tapl/AllAppsFromOverview.java
+++ b/tests/tapl/com/android/launcher3/tapl/AllAppsFromOverview.java
@@ -45,7 +45,8 @@
final Point start = qsb.getVisibleCenter();
final int endY = (int) (mLauncher.getDevice().getDisplayHeight() * 0.6);
LauncherInstrumentation.log("AllAppsFromOverview.switchBackToOverview before swipe");
- mLauncher.swipe(start.x, start.y, start.x, endY);
+ mLauncher.swipe(
+ start.x, start.y, start.x, endY, LauncherInstrumentation.OVERVIEW_STATE_ORDINAL);
return new Overview(mLauncher);
}
diff --git a/tests/tapl/com/android/launcher3/tapl/Background.java b/tests/tapl/com/android/launcher3/tapl/Background.java
index 08d2889..790e938 100644
--- a/tests/tapl/com/android/launcher3/tapl/Background.java
+++ b/tests/tapl/com/android/launcher3/tapl/Background.java
@@ -50,21 +50,22 @@
@NonNull
public BaseOverview switchToOverview() {
verifyActiveContainer();
- goToOverviewUnchecked();
+ goToOverviewUnchecked(LauncherInstrumentation.BACKGROUND_APP_STATE_ORDINAL);
assertTrue("Overview not visible", mLauncher.getDevice().wait(
Until.hasObject(By.pkg(getOverviewPackageName())), WAIT_TIME_MS));
return new BaseOverview(mLauncher);
}
- protected void goToOverviewUnchecked() {
+ protected void goToOverviewUnchecked(int expectedState) {
if (mLauncher.isSwipeUpEnabled()) {
final int height = mLauncher.getDevice().getDisplayHeight();
final UiObject2 navBar = mLauncher.getSystemUiObject("navigation_bar_frame");
mLauncher.swipe(
navBar.getVisibleBounds().centerX(), navBar.getVisibleBounds().centerY(),
- navBar.getVisibleBounds().centerX(), height - 400);
+ navBar.getVisibleBounds().centerX(), height - 400,
+ expectedState);
} else {
mLauncher.getSystemUiObject("recent_apps").click();
}
diff --git a/tests/tapl/com/android/launcher3/tapl/Home.java b/tests/tapl/com/android/launcher3/tapl/Home.java
index 522ce14..bf857f0 100644
--- a/tests/tapl/com/android/launcher3/tapl/Home.java
+++ b/tests/tapl/com/android/launcher3/tapl/Home.java
@@ -47,7 +47,7 @@
@Override
public Overview switchToOverview() {
verifyActiveContainer();
- goToOverviewUnchecked();
+ goToOverviewUnchecked(LauncherInstrumentation.OVERVIEW_STATE_ORDINAL);
return new Overview(mLauncher);
}
}
\ No newline at end of file
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 6b76012..06b9a96 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -54,6 +54,9 @@
public final class LauncherInstrumentation {
private static final String TAG = "Tapl";
+ static final int OVERVIEW_STATE_ORDINAL = 2;
+ static final int APPS_LIST_STATE_ORDINAL = 4;
+ static final int BACKGROUND_APP_STATE_ORDINAL = 5;
// Types for launcher containers that the user is interacting with. "Background" is a
// pseudo-container corresponding to inactive launcher covered by another app.
@@ -154,7 +157,7 @@
fail(message + ". " + "Actual: " + actual);
}
- static public void assertEquals(String message, int expected, int actual) {
+ static private void assertEquals(String message, int expected, int actual) {
if (expected != actual) {
fail(message + " expected: " + expected + " but was: " + actual);
}
@@ -416,12 +419,14 @@
return mDevice;
}
- void swipe(int startX, int startY, int endX, int endY) {
- executeAndWaitForEvent(
+ void swipe(int startX, int startY, int endX, int endY, int expectedState) {
+ final Bundle parcel = (Bundle) executeAndWaitForEvent(
() -> mDevice.swipe(startX, startY, endX, endY, 60),
event -> TestProtocol.SWITCHED_TO_STATE_MESSAGE.equals(event.getClassName()),
"Swipe failed to receive an event for the swipe end: " + startX + ", " + startY
+ ", " + endX + ", " + endY);
+// assertEquals("Swipe switched launcher to a wrong state",
+// expectedState, parcel.getInt(TestProtocol.STATE_FIELD));
}
void waitForIdle() {
diff --git a/tests/tapl/com/android/launcher3/tapl/Overview.java b/tests/tapl/com/android/launcher3/tapl/Overview.java
index 9e0c07f..1f7ed29 100644
--- a/tests/tapl/com/android/launcher3/tapl/Overview.java
+++ b/tests/tapl/com/android/launcher3/tapl/Overview.java
@@ -51,7 +51,8 @@
final UiObject2 navBar = mLauncher.getSystemUiObject("navigation_bar_frame");
final Point start = navBar.getVisibleCenter();
LauncherInstrumentation.log("Overview.switchToAllApps before swipe");
- mLauncher.swipe(start.x, start.y, start.x, 0);
+ mLauncher.swipe(
+ start.x, start.y, start.x, 0, LauncherInstrumentation.APPS_LIST_STATE_ORDINAL);
return new AllAppsFromOverview(mLauncher);
}
diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java
index e10c4fb..4f86603 100644
--- a/tests/tapl/com/android/launcher3/tapl/Workspace.java
+++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java
@@ -55,7 +55,8 @@
start.x,
start.y,
start.x,
- endY
+ endY,
+ LauncherInstrumentation.APPS_LIST_STATE_ORDINAL
);
return new AllApps(mLauncher);