Loading quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java +49 −0 Original line number Diff line number Diff line Loading @@ -427,6 +427,55 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest { 0, getTaskCount(launcher))); } @Test @PortraitLandscape public void testOverviewDeadzones() throws Exception { startTestAppsWithCheck(); Overview overview = mLauncher.goHome().switchToOverview(); 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(); assertTrue("Launcher internal state should be Overview", isInState(() -> LauncherState.OVERVIEW)); // Dismiss when tapping to the right of the focused task overview.touchOutsideFirstTask(); assertTrue("Launcher internal state should be Home", isInState(() -> LauncherState.NORMAL)); } @Test @PortraitLandscape public void testTaskbarDeadzonesForTablet() throws Exception { assumeTrue(mLauncher.isTablet()); startTestAppsWithCheck(); Overview overview = mLauncher.goHome().switchToOverview(); assertTrue("Launcher internal state should be Overview", isInState(() -> LauncherState.OVERVIEW)); executeOnLauncher( launcher -> assertTrue("Should have at least 3 tasks", getTaskCount(launcher) >= 3)); // On persistent taskbar, it should not dismiss when tapping the taskbar overview.touchTaskbarBottomCorner(/* tapRight= */ false); 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); assertTrue("Launcher internal state should be Overview", isInState(() -> LauncherState.OVERVIEW)); } @Test @ScreenRecord // b/242163205 public void testDisableRotationCheckForPhone() throws Exception { Loading tests/tapl/com/android/launcher3/tapl/BaseOverview.java +86 −14 Original line number Diff line number Diff line Loading @@ -71,6 +71,44 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer { } } /** * Flings backward (right) and waits the fling's end. */ public void flingBackward() { try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) { flingBackwardImpl(); } } private void flingBackwardImpl() { try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer("want to fling backward in overview")) { LauncherInstrumentation.log("Overview.flingBackward before fling"); final UiObject2 overview = verifyActiveContainer(); final int rightMargin = mLauncher.getTargetInsets().right + mLauncher.getEdgeSensitivityWidth(); mLauncher.scroll( overview, Direction.RIGHT, new Rect(0, 0, rightMargin + 1, 0), 20, false); try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer("flung backwards")) { verifyActiveContainer(); verifyActionsViewVisibility(); } } } private OverviewTask flingToFirstTask() { OverviewTask currentTask = getCurrentTask(); while (mLauncher.getRealDisplaySize().x - currentTask.getUiObject().getVisibleBounds().right <= mLauncher.getOverviewPageSpacing()) { flingBackwardImpl(); currentTask = getCurrentTask(); } return currentTask; } /** * Dismissed all tasks by scrolling to Clear-all button and pressing it. */ Loading @@ -94,24 +132,58 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer { } /** * Flings backward (right) and waits the fling's end. * Touch to the right of current task. This should dismiss overview and go back to Workspace. */ public void flingBackward() { public Workspace touchOutsideFirstTask() { try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck(); LauncherInstrumentation.Closable c = mLauncher.addContextLayer("want to fling backward in overview")) { LauncherInstrumentation.log("Overview.flingBackward before fling"); final UiObject2 overview = verifyActiveContainer(); final int rightMargin = mLauncher.getTargetInsets().right + mLauncher.getEdgeSensitivityWidth(); mLauncher.scroll( overview, Direction.RIGHT, new Rect(0, 0, rightMargin + 1, 0), 20, false); try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer("flung backwards")) { verifyActiveContainer(); verifyActionsViewVisibility(); LauncherInstrumentation.Closable c = mLauncher.addContextLayer( "touching outside the focused task")) { if (getTaskCount() < 2) { throw new IllegalStateException( "Need to have at least 2 tasks"); } OverviewTask currentTask = flingToFirstTask(); mLauncher.touchOutsideContainer(currentTask.getUiObject(), /* tapRight= */ true, /* halfwayToEdge= */ false); return new Workspace(mLauncher); } } /** * Touch between two tasks */ public void touchBetweenTasks() { try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck(); LauncherInstrumentation.Closable c = mLauncher.addContextLayer( "touching outside the focused task")) { if (getTaskCount() < 2) { throw new IllegalStateException( "Need to have at least 2 tasks"); } OverviewTask currentTask = flingToFirstTask(); mLauncher.touchOutsideContainer(currentTask.getUiObject(), /* tapRight= */ false, /* halfwayToEdge= */ false); } } /** * Touch either on the right or the left corner of the screen, 1 pixel from the bottom and * from the sides. */ public void touchTaskbarBottomCorner(boolean tapRight) { try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) { Taskbar taskbar = new Taskbar(mLauncher); taskbar.touchBottomCorner(tapRight); verifyActiveContainer(); } } /** Loading tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +26 −6 Original line number Diff line number Diff line Loading @@ -2014,21 +2014,41 @@ public final class LauncherInstrumentation { } /** * Taps outside container to dismiss. * Taps outside container to dismiss, centered vertically and halfway to the edge of the screen. * * @param container container to be dismissed * @param tapRight tap on the right of the container if true, or left otherwise */ void touchOutsideContainer(UiObject2 container, boolean tapRight) { touchOutsideContainer(container, tapRight, true); } /** * Taps outside the container, to the right or left, and centered vertically. * * @param tapRight if true touches to the right of the container, otherwise touches on left * @param halfwayToEdge if true touches halfway to the screen edge, if false touches 1 px from * container */ void touchOutsideContainer(UiObject2 container, boolean tapRight, boolean halfwayToEdge) { try (LauncherInstrumentation.Closable c = addContextLayer( "want to tap outside container on the " + (tapRight ? "right" : "left"))) { Rect containerBounds = getVisibleBounds(container); final long downTime = SystemClock.uptimeMillis(); final Point tapTarget = new Point( tapRight int x; if (halfwayToEdge) { x = tapRight ? (containerBounds.right + getRealDisplaySize().x) / 2 : containerBounds.left / 2, containerBounds.top + 1); : containerBounds.left / 2; } else { x = tapRight ? containerBounds.right + 1 : containerBounds.left - 1; } int y = containerBounds.top + containerBounds.height() / 2; final long downTime = SystemClock.uptimeMillis(); final Point tapTarget = new Point(x, y); sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, tapTarget, LauncherInstrumentation.GestureScope.INSIDE); sendPointer(downTime, downTime, MotionEvent.ACTION_UP, tapTarget, Loading tests/tapl/com/android/launcher3/tapl/OverviewTask.java +4 −0 Original line number Diff line number Diff line Loading @@ -71,6 +71,10 @@ public final class OverviewTask { return mTask.getVisibleBounds().exactCenterX(); } UiObject2 getUiObject() { return mTask; } /** * Dismisses the task by swiping up. */ Loading tests/tapl/com/android/launcher3/tapl/Taskbar.java +30 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static com.android.launcher3.testing.shared.TestProtocol.REQUEST_DISABLE_ import static com.android.launcher3.testing.shared.TestProtocol.REQUEST_ENABLE_MANUAL_TASKBAR_STASHING; import android.graphics.Point; import android.graphics.Rect; import android.os.SystemClock; import android.text.TextUtils; import android.view.MotionEvent; Loading Loading @@ -122,4 +123,33 @@ public final class Taskbar { // Look for an icon with no text return By.clazz(TextView.class).text(""); } private Rect getVisibleBounds() { return mLauncher.waitForSystemLauncherObject(TASKBAR_RES_ID).getVisibleBounds(); } /** * Touch either on the right or the left corner of the screen, 1 pixel from the bottom and * from the sides. */ void touchBottomCorner(boolean tapRight) { try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer( "want to tap bottom corner on the " + (tapRight ? "right" : "left"))) { final long downTime = SystemClock.uptimeMillis(); final Point tapTarget = new Point( tapRight ? getVisibleBounds().right - mLauncher.getTargetInsets().right - 1 : getVisibleBounds().left + 1, mLauncher.getRealDisplaySize().y - 1); mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, tapTarget, LauncherInstrumentation.GestureScope.INSIDE); mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_UP, tapTarget, LauncherInstrumentation.GestureScope.INSIDE); } } } Loading
quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java +49 −0 Original line number Diff line number Diff line Loading @@ -427,6 +427,55 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest { 0, getTaskCount(launcher))); } @Test @PortraitLandscape public void testOverviewDeadzones() throws Exception { startTestAppsWithCheck(); Overview overview = mLauncher.goHome().switchToOverview(); 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(); assertTrue("Launcher internal state should be Overview", isInState(() -> LauncherState.OVERVIEW)); // Dismiss when tapping to the right of the focused task overview.touchOutsideFirstTask(); assertTrue("Launcher internal state should be Home", isInState(() -> LauncherState.NORMAL)); } @Test @PortraitLandscape public void testTaskbarDeadzonesForTablet() throws Exception { assumeTrue(mLauncher.isTablet()); startTestAppsWithCheck(); Overview overview = mLauncher.goHome().switchToOverview(); assertTrue("Launcher internal state should be Overview", isInState(() -> LauncherState.OVERVIEW)); executeOnLauncher( launcher -> assertTrue("Should have at least 3 tasks", getTaskCount(launcher) >= 3)); // On persistent taskbar, it should not dismiss when tapping the taskbar overview.touchTaskbarBottomCorner(/* tapRight= */ false); 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); assertTrue("Launcher internal state should be Overview", isInState(() -> LauncherState.OVERVIEW)); } @Test @ScreenRecord // b/242163205 public void testDisableRotationCheckForPhone() throws Exception { Loading
tests/tapl/com/android/launcher3/tapl/BaseOverview.java +86 −14 Original line number Diff line number Diff line Loading @@ -71,6 +71,44 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer { } } /** * Flings backward (right) and waits the fling's end. */ public void flingBackward() { try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) { flingBackwardImpl(); } } private void flingBackwardImpl() { try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer("want to fling backward in overview")) { LauncherInstrumentation.log("Overview.flingBackward before fling"); final UiObject2 overview = verifyActiveContainer(); final int rightMargin = mLauncher.getTargetInsets().right + mLauncher.getEdgeSensitivityWidth(); mLauncher.scroll( overview, Direction.RIGHT, new Rect(0, 0, rightMargin + 1, 0), 20, false); try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer("flung backwards")) { verifyActiveContainer(); verifyActionsViewVisibility(); } } } private OverviewTask flingToFirstTask() { OverviewTask currentTask = getCurrentTask(); while (mLauncher.getRealDisplaySize().x - currentTask.getUiObject().getVisibleBounds().right <= mLauncher.getOverviewPageSpacing()) { flingBackwardImpl(); currentTask = getCurrentTask(); } return currentTask; } /** * Dismissed all tasks by scrolling to Clear-all button and pressing it. */ Loading @@ -94,24 +132,58 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer { } /** * Flings backward (right) and waits the fling's end. * Touch to the right of current task. This should dismiss overview and go back to Workspace. */ public void flingBackward() { public Workspace touchOutsideFirstTask() { try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck(); LauncherInstrumentation.Closable c = mLauncher.addContextLayer("want to fling backward in overview")) { LauncherInstrumentation.log("Overview.flingBackward before fling"); final UiObject2 overview = verifyActiveContainer(); final int rightMargin = mLauncher.getTargetInsets().right + mLauncher.getEdgeSensitivityWidth(); mLauncher.scroll( overview, Direction.RIGHT, new Rect(0, 0, rightMargin + 1, 0), 20, false); try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer("flung backwards")) { verifyActiveContainer(); verifyActionsViewVisibility(); LauncherInstrumentation.Closable c = mLauncher.addContextLayer( "touching outside the focused task")) { if (getTaskCount() < 2) { throw new IllegalStateException( "Need to have at least 2 tasks"); } OverviewTask currentTask = flingToFirstTask(); mLauncher.touchOutsideContainer(currentTask.getUiObject(), /* tapRight= */ true, /* halfwayToEdge= */ false); return new Workspace(mLauncher); } } /** * Touch between two tasks */ public void touchBetweenTasks() { try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck(); LauncherInstrumentation.Closable c = mLauncher.addContextLayer( "touching outside the focused task")) { if (getTaskCount() < 2) { throw new IllegalStateException( "Need to have at least 2 tasks"); } OverviewTask currentTask = flingToFirstTask(); mLauncher.touchOutsideContainer(currentTask.getUiObject(), /* tapRight= */ false, /* halfwayToEdge= */ false); } } /** * Touch either on the right or the left corner of the screen, 1 pixel from the bottom and * from the sides. */ public void touchTaskbarBottomCorner(boolean tapRight) { try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) { Taskbar taskbar = new Taskbar(mLauncher); taskbar.touchBottomCorner(tapRight); verifyActiveContainer(); } } /** Loading
tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +26 −6 Original line number Diff line number Diff line Loading @@ -2014,21 +2014,41 @@ public final class LauncherInstrumentation { } /** * Taps outside container to dismiss. * Taps outside container to dismiss, centered vertically and halfway to the edge of the screen. * * @param container container to be dismissed * @param tapRight tap on the right of the container if true, or left otherwise */ void touchOutsideContainer(UiObject2 container, boolean tapRight) { touchOutsideContainer(container, tapRight, true); } /** * Taps outside the container, to the right or left, and centered vertically. * * @param tapRight if true touches to the right of the container, otherwise touches on left * @param halfwayToEdge if true touches halfway to the screen edge, if false touches 1 px from * container */ void touchOutsideContainer(UiObject2 container, boolean tapRight, boolean halfwayToEdge) { try (LauncherInstrumentation.Closable c = addContextLayer( "want to tap outside container on the " + (tapRight ? "right" : "left"))) { Rect containerBounds = getVisibleBounds(container); final long downTime = SystemClock.uptimeMillis(); final Point tapTarget = new Point( tapRight int x; if (halfwayToEdge) { x = tapRight ? (containerBounds.right + getRealDisplaySize().x) / 2 : containerBounds.left / 2, containerBounds.top + 1); : containerBounds.left / 2; } else { x = tapRight ? containerBounds.right + 1 : containerBounds.left - 1; } int y = containerBounds.top + containerBounds.height() / 2; final long downTime = SystemClock.uptimeMillis(); final Point tapTarget = new Point(x, y); sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, tapTarget, LauncherInstrumentation.GestureScope.INSIDE); sendPointer(downTime, downTime, MotionEvent.ACTION_UP, tapTarget, Loading
tests/tapl/com/android/launcher3/tapl/OverviewTask.java +4 −0 Original line number Diff line number Diff line Loading @@ -71,6 +71,10 @@ public final class OverviewTask { return mTask.getVisibleBounds().exactCenterX(); } UiObject2 getUiObject() { return mTask; } /** * Dismisses the task by swiping up. */ Loading
tests/tapl/com/android/launcher3/tapl/Taskbar.java +30 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static com.android.launcher3.testing.shared.TestProtocol.REQUEST_DISABLE_ import static com.android.launcher3.testing.shared.TestProtocol.REQUEST_ENABLE_MANUAL_TASKBAR_STASHING; import android.graphics.Point; import android.graphics.Rect; import android.os.SystemClock; import android.text.TextUtils; import android.view.MotionEvent; Loading Loading @@ -122,4 +123,33 @@ public final class Taskbar { // Look for an icon with no text return By.clazz(TextView.class).text(""); } private Rect getVisibleBounds() { return mLauncher.waitForSystemLauncherObject(TASKBAR_RES_ID).getVisibleBounds(); } /** * Touch either on the right or the left corner of the screen, 1 pixel from the bottom and * from the sides. */ void touchBottomCorner(boolean tapRight) { try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer( "want to tap bottom corner on the " + (tapRight ? "right" : "left"))) { final long downTime = SystemClock.uptimeMillis(); final Point tapTarget = new Point( tapRight ? getVisibleBounds().right - mLauncher.getTargetInsets().right - 1 : getVisibleBounds().left + 1, mLauncher.getRealDisplaySize().y - 1); mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, tapTarget, LauncherInstrumentation.GestureScope.INSIDE); mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_UP, tapTarget, LauncherInstrumentation.GestureScope.INSIDE); } } }