Merge "Disable Launcher when starting in a managed profile" into ub-launcher3-master
diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java
index e9d8bce..c60cf45 100644
--- a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java
+++ b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java
@@ -55,12 +55,7 @@
@Before
public void setUp() throws Exception {
super.setUp();
-
- clearLauncherData();
-
- mLauncher.pressHome();
- waitForState("Launcher internal state didn't switch to Home", LauncherState.NORMAL);
- waitForResumed("Launcher internal state is still Background");
+ TaplTestsLauncher3.initialize(this);
}
private void startTestApps() throws Exception {
diff --git a/src/com/android/launcher3/DeleteDropTarget.java b/src/com/android/launcher3/DeleteDropTarget.java
index 70c8aaa..4c6824a 100644
--- a/src/com/android/launcher3/DeleteDropTarget.java
+++ b/src/com/android/launcher3/DeleteDropTarget.java
@@ -91,6 +91,7 @@
mText = getResources().getString(canRemove(item)
? R.string.remove_drop_target_label
: android.R.string.cancel);
+ setContentDescription(mText);
requestLayout();
}
}
diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java
index 899cdd3..6d85612 100644
--- a/src/com/android/launcher3/LauncherState.java
+++ b/src/com/android/launcher3/LauncherState.java
@@ -19,6 +19,11 @@
import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS;
import static android.view.accessibility.AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED;
+import static com.android.launcher3.TestProtocol.ALL_APPS_STATE_ORDINAL;
+import static com.android.launcher3.TestProtocol.BACKGROUND_APP_STATE_ORDINAL;
+import static com.android.launcher3.TestProtocol.NORMAL_STATE_ORDINAL;
+import static com.android.launcher3.TestProtocol.OVERVIEW_STATE_ORDINAL;
+import static com.android.launcher3.TestProtocol.SPRING_LOADED_STATE_ORDINAL;
import static com.android.launcher3.anim.Interpolators.ACCEL_2;
import static com.android.launcher3.states.RotationHelper.REQUEST_NONE;
@@ -77,17 +82,20 @@
/**
* TODO: Create a separate class for NORMAL state.
*/
- public static final LauncherState NORMAL = new LauncherState(0, ContainerType.WORKSPACE, 0,
+ public static final LauncherState NORMAL = new LauncherState(NORMAL_STATE_ORDINAL,
+ ContainerType.WORKSPACE, 0,
FLAG_DISABLE_RESTORE | FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED | FLAG_HIDE_BACK_BUTTON |
FLAG_HAS_SYS_UI_SCRIM);
/**
* Various Launcher states arranged in the increasing order of UI layers
*/
- public static final LauncherState SPRING_LOADED = new SpringLoadedState(1);
- public static final LauncherState OVERVIEW = new OverviewState(2);
- public static final LauncherState ALL_APPS = new AllAppsState(3);
- public static final LauncherState BACKGROUND_APP = new BackgroundAppState(4);
+ public static final LauncherState SPRING_LOADED = new SpringLoadedState(
+ SPRING_LOADED_STATE_ORDINAL);
+ public static final LauncherState OVERVIEW = new OverviewState(OVERVIEW_STATE_ORDINAL);
+ public static final LauncherState ALL_APPS = new AllAppsState(ALL_APPS_STATE_ORDINAL);
+ public static final LauncherState BACKGROUND_APP = new BackgroundAppState(
+ BACKGROUND_APP_STATE_ORDINAL);
public final int ordinal;
diff --git a/src/com/android/launcher3/TestProtocol.java b/src/com/android/launcher3/TestProtocol.java
index 008b624..23df79e 100644
--- a/src/com/android/launcher3/TestProtocol.java
+++ b/src/com/android/launcher3/TestProtocol.java
@@ -25,4 +25,9 @@
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";
+ public static final int NORMAL_STATE_ORDINAL = 0;
+ public static final int SPRING_LOADED_STATE_ORDINAL = 1;
+ public static final int OVERVIEW_STATE_ORDINAL = 2;
+ public static final int ALL_APPS_STATE_ORDINAL = 3;
+ public static final int BACKGROUND_APP_STATE_ORDINAL = 4;
}
diff --git a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
index 47b98fb..33cb5be 100644
--- a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
+++ b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
@@ -39,6 +39,7 @@
import com.android.launcher3.tapl.AppIcon;
import com.android.launcher3.tapl.AppIconMenu;
import com.android.launcher3.tapl.AppIconMenuItem;
+import com.android.launcher3.tapl.TestHelpers;
import com.android.launcher3.tapl.Widgets;
import com.android.launcher3.tapl.Workspace;
import com.android.launcher3.views.OptionsPopupView;
@@ -104,13 +105,15 @@
@Before
public void setUp() throws Exception {
super.setUp();
+ initialize(this);
+ }
- clearLauncherData();
-
- 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");
+ public static void initialize(AbstractLauncherUiTest test) throws Exception {
+ test.clearLauncherData();
+ test.mDevice.pressHome();
+ test.waitForLauncherCondition("Launcher didn't start", launcher -> launcher != null);
+ test.waitForState("Launcher internal state didn't switch to Home", LauncherState.NORMAL);
+ test.waitForResumed("Launcher internal state is still Background");
}
// Please don't add negative test cases for methods that fail only after a long wait.
@@ -298,6 +301,7 @@
@Test
@PortraitLandscape
public void testLaunchMenuItem() throws Exception {
+ if (!TestHelpers.isInLauncherProcess()) return;
final LauncherActivityInfo testApp = getSettingsApp();
final AppIconMenu menu = mLauncher.
@@ -336,6 +340,7 @@
@Test
@PortraitLandscape
public void testDragShortcut() throws Throwable {
+ if (!TestHelpers.isInLauncherProcess()) return;
LauncherActivityInfo testApp = getSettingsApp();
// 1. Open all apps and wait for load complete.
diff --git a/tests/tapl/com/android/launcher3/tapl/AllAppsFromOverview.java b/tests/tapl/com/android/launcher3/tapl/AllAppsFromOverview.java
index 3e4b1f3..2642815 100644
--- a/tests/tapl/com/android/launcher3/tapl/AllAppsFromOverview.java
+++ b/tests/tapl/com/android/launcher3/tapl/AllAppsFromOverview.java
@@ -16,6 +16,8 @@
package com.android.launcher3.tapl;
+import static com.android.launcher3.TestProtocol.OVERVIEW_STATE_ORDINAL;
+
import android.graphics.Point;
import androidx.annotation.NonNull;
@@ -45,8 +47,7 @@
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, LauncherInstrumentation.OVERVIEW_STATE_ORDINAL);
+ mLauncher.swipe(start.x, start.y, start.x, endY, 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 790e938..c54a43f 100644
--- a/tests/tapl/com/android/launcher3/tapl/Background.java
+++ b/tests/tapl/com/android/launcher3/tapl/Background.java
@@ -16,6 +16,7 @@
package com.android.launcher3.tapl;
+import static com.android.launcher3.TestProtocol.BACKGROUND_APP_STATE_ORDINAL;
import static com.android.launcher3.tapl.LauncherInstrumentation.WAIT_TIME_MS;
import static com.android.launcher3.tapl.TestHelpers.getOverviewPackageName;
@@ -50,7 +51,7 @@
@NonNull
public BaseOverview switchToOverview() {
verifyActiveContainer();
- goToOverviewUnchecked(LauncherInstrumentation.BACKGROUND_APP_STATE_ORDINAL);
+ goToOverviewUnchecked(BACKGROUND_APP_STATE_ORDINAL);
assertTrue("Overview not visible", mLauncher.getDevice().wait(
Until.hasObject(By.pkg(getOverviewPackageName())), WAIT_TIME_MS));
return new BaseOverview(mLauncher);
diff --git a/tests/tapl/com/android/launcher3/tapl/Home.java b/tests/tapl/com/android/launcher3/tapl/Home.java
index bf857f0..f8bd85a 100644
--- a/tests/tapl/com/android/launcher3/tapl/Home.java
+++ b/tests/tapl/com/android/launcher3/tapl/Home.java
@@ -16,6 +16,8 @@
package com.android.launcher3.tapl;
+import static com.android.launcher3.TestProtocol.OVERVIEW_STATE_ORDINAL;
+
import androidx.annotation.NonNull;
/**
@@ -47,7 +49,7 @@
@Override
public Overview switchToOverview() {
verifyActiveContainer();
- goToOverviewUnchecked(LauncherInstrumentation.OVERVIEW_STATE_ORDINAL);
+ goToOverviewUnchecked(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 06b9a96..7473189 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -54,9 +54,6 @@
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.
@@ -107,13 +104,13 @@
public LauncherInstrumentation(Instrumentation instrumentation) {
mInstrumentation = instrumentation;
mDevice = UiDevice.getInstance(instrumentation);
- final boolean swipeUpEnabledDefault =
- !SwipeUpSetting.isSwipeUpSettingAvailable() ||
- SwipeUpSetting.isSwipeUpEnabledDefaultValue();
- mSwipeUpEnabled = Settings.Secure.getInt(
- instrumentation.getTargetContext().getContentResolver(),
- SWIPE_UP_SETTING_NAME,
- swipeUpEnabledDefault ? 1 : 0) == 1;
+ final boolean swipeUpEnabledDefaultValue = SwipeUpSetting.isSwipeUpEnabledDefaultValue();
+ mSwipeUpEnabled = SwipeUpSetting.isSwipeUpSettingAvailable() ?
+ Settings.Secure.getInt(
+ instrumentation.getTargetContext().getContentResolver(),
+ SWIPE_UP_SETTING_NAME,
+ swipeUpEnabledDefaultValue ? 1 : 0) == 1 :
+ swipeUpEnabledDefaultValue;
// Launcher should run in test harness so that custom accessibility protocol between
// Launcher and TAPL is enabled. In-process tests enable this protocol with a direct call
@@ -425,8 +422,8 @@
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));
+ 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 1f7ed29..0208144 100644
--- a/tests/tapl/com/android/launcher3/tapl/Overview.java
+++ b/tests/tapl/com/android/launcher3/tapl/Overview.java
@@ -16,6 +16,8 @@
package com.android.launcher3.tapl;
+import static com.android.launcher3.TestProtocol.ALL_APPS_STATE_ORDINAL;
+
import android.graphics.Point;
import com.android.launcher3.tapl.LauncherInstrumentation.ContainerType;
@@ -51,8 +53,7 @@
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, LauncherInstrumentation.APPS_LIST_STATE_ORDINAL);
+ mLauncher.swipe(start.x, start.y, start.x, 0, ALL_APPS_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 4f86603..f597133 100644
--- a/tests/tapl/com/android/launcher3/tapl/Workspace.java
+++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java
@@ -16,6 +16,8 @@
package com.android.launcher3.tapl;
+import static com.android.launcher3.TestProtocol.ALL_APPS_STATE_ORDINAL;
+
import static junit.framework.TestCase.assertTrue;
import android.graphics.Point;
@@ -56,7 +58,7 @@
start.y,
start.x,
endY,
- LauncherInstrumentation.APPS_LIST_STATE_ORDINAL
+ ALL_APPS_STATE_ORDINAL
);
return new AllApps(mLauncher);