Loading tests/tapl/com/android/launcher3/tapl/Background.java +8 −6 Original line number Diff line number Diff line Loading @@ -99,12 +99,12 @@ public class Background extends LauncherInstrumentation.VisibleContainer { end, gestureScope), event -> TestProtocol.PAUSE_DETECTED_MESSAGE.equals(event.getClassName()), () -> "Pause wasn't detected"); () -> "Pause wasn't detected", "swiping and holding"); mLauncher.runToState( () -> mLauncher.sendPointer( downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, end, gestureScope), OVERVIEW_STATE_ORDINAL); OVERVIEW_STATE_ORDINAL, "sending UP event"); break; } Loading Loading @@ -137,7 +137,7 @@ public class Background extends LauncherInstrumentation.VisibleContainer { mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, SQUARE_BUTTON_EVENT); mLauncher.runToState( () -> mLauncher.waitForSystemUiObject("recent_apps").click(), OVERVIEW_STATE_ORDINAL); OVERVIEW_STATE_ORDINAL, "clicking Recents button"); break; } expectSwitchToOverviewEvents(); Loading Loading @@ -218,7 +218,7 @@ public class Background extends LauncherInstrumentation.VisibleContainer { () -> mLauncher.linearGesture( startX, startY, endX, endY, 20, false, gestureScope), event -> event.getEventType() == TYPE_WINDOW_STATE_CHANGED, () -> "Quick switch gesture didn't change window state"); () -> "Quick switch gesture didn't change window state", "swiping"); break; } Loading @@ -226,13 +226,15 @@ public class Background extends LauncherInstrumentation.VisibleContainer { // Double press the recents button. UiObject2 recentsButton = mLauncher.waitForSystemUiObject("recent_apps"); mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, SQUARE_BUTTON_EVENT); mLauncher.runToState(() -> recentsButton.click(), OVERVIEW_STATE_ORDINAL); mLauncher.runToState(() -> recentsButton.click(), OVERVIEW_STATE_ORDINAL, "clicking Recents button for the first time"); mLauncher.getOverview(); mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, SQUARE_BUTTON_EVENT); mLauncher.executeAndWaitForEvent( () -> recentsButton.click(), event -> event.getEventType() == TYPE_WINDOW_STATE_CHANGED, () -> "Pressing recents button didn't change window state"); () -> "Pressing recents button didn't change window state", "clicking Recents button for the second time"); break; } mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, TASK_START_EVENT); Loading tests/tapl/com/android/launcher3/tapl/Launchable.java +18 −20 Original line number Diff line number Diff line Loading @@ -56,8 +56,6 @@ abstract class Launchable { protected abstract String launchableType(); private Background launch(BySelector selector) { try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer( "clicking " + launchableType())) { LauncherInstrumentation.log("Launchable.launch before click " + mObject.getVisibleCenter() + " in " + mLauncher.getVisibleBounds(mObject)); final String label = mObject.getText(); Loading @@ -68,7 +66,8 @@ abstract class Launchable { expectActivityStartEvents(); }, event -> event.getEventType() == TYPE_WINDOW_STATE_CHANGED, () -> "Launching an app didn't open a new window: " + label); () -> "Launching an app didn't open a new window: " + label, "clicking " + launchableType()); mLauncher.assertTrue( "App didn't start: " + label + " (" + selector + ")", Loading @@ -76,7 +75,6 @@ abstract class Launchable { LauncherInstrumentation.WAIT_TIME_MS)); return new Background(mLauncher); } } /** * Drags an object to the center of homescreen. Loading tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +45 −41 Original line number Diff line number Diff line Loading @@ -655,15 +655,18 @@ public final class LauncherInstrumentation { } Parcelable executeAndWaitForLauncherEvent(Runnable command, UiAutomation.AccessibilityEventFilter eventFilter, Supplier<String> message) { UiAutomation.AccessibilityEventFilter eventFilter, Supplier<String> message, String actionName) { return executeAndWaitForEvent( command, e -> mLauncherPackage.equals(e.getPackageName()) && eventFilter.accept(e), message); message, actionName); } Parcelable executeAndWaitForEvent(Runnable command, UiAutomation.AccessibilityEventFilter eventFilter, Supplier<String> message) { UiAutomation.AccessibilityEventFilter eventFilter, Supplier<String> message, String actionName) { try (LauncherInstrumentation.Closable c = addContextLayer(actionName)) { try { final AccessibilityEvent event = mInstrumentation.getUiAutomation().executeAndWaitForEvent( Loading @@ -677,6 +680,7 @@ public final class LauncherInstrumentation { return null; } } } /** * Presses nav bar home button. Loading Loading @@ -720,7 +724,6 @@ public final class LauncherInstrumentation { dumpViewHierarchy(); action = "swiping up to home"; try (LauncherInstrumentation.Closable c = addContextLayer(action)) { swipeToState( displaySize.x / 2, displaySize.y - 1, displaySize.x / 2, 0, Loading @@ -729,12 +732,10 @@ public final class LauncherInstrumentation { ? GestureScope.INSIDE_TO_OUTSIDE : GestureScope.OUTSIDE_WITH_PILFER); } } } else { log("Hierarchy before clicking home:"); dumpViewHierarchy(); action = "clicking home button"; try (LauncherInstrumentation.Closable c = addContextLayer(action)) { if (!isLauncher3() && getNavigationModel() == NavigationModel.TWO_BUTTON) { expectEvent(TestProtocol.SEQUENCE_TIS, EVENT_TOUCH_DOWN_TIS); expectEvent(TestProtocol.SEQUENCE_TIS, EVENT_TOUCH_UP_TIS); Loading @@ -745,8 +746,8 @@ public final class LauncherInstrumentation { NORMAL_STATE_ORDINAL, !hasLauncherObject(WORKSPACE_RES_ID) && (hasLauncherObject(APPS_RES_ID) || hasLauncherObject(OVERVIEW_RES_ID))); } || hasLauncherObject(OVERVIEW_RES_ID)), action); } try (LauncherInstrumentation.Closable c = addContextLayer( "performed action to switch to Home - " + action)) { Loading Loading @@ -1032,22 +1033,23 @@ public final class LauncherInstrumentation { + "]"; } void runToState(Runnable command, int expectedState, boolean requireEvent) { void runToState(Runnable command, int expectedState, boolean requireEvent, String actionName) { if (requireEvent) { runToState(command, expectedState); runToState(command, expectedState, actionName); } else { command.run(); } } void runToState(Runnable command, int expectedState) { void runToState(Runnable command, int expectedState, String actionName) { final List<Integer> actualEvents = new ArrayList<>(); executeAndWaitForLauncherEvent( command, event -> isSwitchToStateEvent(event, expectedState, actualEvents), () -> "Failed to receive an event for the state change: expected [" + TestProtocol.stateOrdinalToString(expectedState) + "], actual: " + eventListToString(actualEvents)); + "], actual: " + eventListToString(actualEvents), actionName); } private boolean isSwitchToStateEvent( Loading @@ -1064,7 +1066,8 @@ public final class LauncherInstrumentation { GestureScope gestureScope) { runToState( () -> linearGesture(startX, startY, endX, endY, steps, false, gestureScope), expectedState); expectedState, "swiping"); } private int getBottomGestureSize() { Loading Loading @@ -1172,7 +1175,8 @@ public final class LauncherInstrumentation { startX, startY, endX, endY, steps, slowDown, GestureScope.INSIDE), event -> TestProtocol.SCROLL_FINISHED_MESSAGE.equals(event.getClassName()), () -> "Didn't receive a scroll end message: " + startX + ", " + startY + ", " + endX + ", " + endY); + ", " + endX + ", " + endY, "scrolling"); } // Inject a swipe gesture. Inject exactly 'steps' motion points, incrementing event time by a Loading tests/tapl/com/android/launcher3/tapl/OverviewTask.java +7 −9 Original line number Diff line number Diff line Loading @@ -71,15 +71,13 @@ public final class OverviewTask { public Background open() { try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) { verifyActiveContainer(); try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer( "clicking an overview task")) { mLauncher.executeAndWaitForEvent( () -> mLauncher.clickLauncherObject(mTask), event -> event.getEventType() == TYPE_WINDOW_STATE_CHANGED, () -> "Launching task didn't open a new window: " + mTask.getParent().getContentDescription()); + mTask.getParent().getContentDescription(), "clicking an overview task"); mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, TASK_START_EVENT); } return new Background(mLauncher); } } Loading tests/tapl/com/android/launcher3/tapl/Workspace.java +4 −2 Original line number Diff line number Diff line Loading @@ -190,13 +190,15 @@ public final class Workspace extends Home { launcher.movePointer(launchableCenter, dest, 10, downTime, true, LauncherInstrumentation.GestureScope.INSIDE); }, SPRING_LOADED_STATE_ORDINAL); SPRING_LOADED_STATE_ORDINAL, "long-pressing and moving"); LauncherInstrumentation.log("dragIconToWorkspace: moved pointer"); launcher.runToState( () -> launcher.sendPointer( downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, dest, LauncherInstrumentation.GestureScope.INSIDE), NORMAL_STATE_ORDINAL); NORMAL_STATE_ORDINAL, "sending UP event"); if (startsActivity || isWidgetShortcut) { launcher.expectEvent(TestProtocol.SEQUENCE_MAIN, LauncherInstrumentation.EVENT_START); } Loading Loading
tests/tapl/com/android/launcher3/tapl/Background.java +8 −6 Original line number Diff line number Diff line Loading @@ -99,12 +99,12 @@ public class Background extends LauncherInstrumentation.VisibleContainer { end, gestureScope), event -> TestProtocol.PAUSE_DETECTED_MESSAGE.equals(event.getClassName()), () -> "Pause wasn't detected"); () -> "Pause wasn't detected", "swiping and holding"); mLauncher.runToState( () -> mLauncher.sendPointer( downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, end, gestureScope), OVERVIEW_STATE_ORDINAL); OVERVIEW_STATE_ORDINAL, "sending UP event"); break; } Loading Loading @@ -137,7 +137,7 @@ public class Background extends LauncherInstrumentation.VisibleContainer { mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, SQUARE_BUTTON_EVENT); mLauncher.runToState( () -> mLauncher.waitForSystemUiObject("recent_apps").click(), OVERVIEW_STATE_ORDINAL); OVERVIEW_STATE_ORDINAL, "clicking Recents button"); break; } expectSwitchToOverviewEvents(); Loading Loading @@ -218,7 +218,7 @@ public class Background extends LauncherInstrumentation.VisibleContainer { () -> mLauncher.linearGesture( startX, startY, endX, endY, 20, false, gestureScope), event -> event.getEventType() == TYPE_WINDOW_STATE_CHANGED, () -> "Quick switch gesture didn't change window state"); () -> "Quick switch gesture didn't change window state", "swiping"); break; } Loading @@ -226,13 +226,15 @@ public class Background extends LauncherInstrumentation.VisibleContainer { // Double press the recents button. UiObject2 recentsButton = mLauncher.waitForSystemUiObject("recent_apps"); mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, SQUARE_BUTTON_EVENT); mLauncher.runToState(() -> recentsButton.click(), OVERVIEW_STATE_ORDINAL); mLauncher.runToState(() -> recentsButton.click(), OVERVIEW_STATE_ORDINAL, "clicking Recents button for the first time"); mLauncher.getOverview(); mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, SQUARE_BUTTON_EVENT); mLauncher.executeAndWaitForEvent( () -> recentsButton.click(), event -> event.getEventType() == TYPE_WINDOW_STATE_CHANGED, () -> "Pressing recents button didn't change window state"); () -> "Pressing recents button didn't change window state", "clicking Recents button for the second time"); break; } mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, TASK_START_EVENT); Loading
tests/tapl/com/android/launcher3/tapl/Launchable.java +18 −20 Original line number Diff line number Diff line Loading @@ -56,8 +56,6 @@ abstract class Launchable { protected abstract String launchableType(); private Background launch(BySelector selector) { try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer( "clicking " + launchableType())) { LauncherInstrumentation.log("Launchable.launch before click " + mObject.getVisibleCenter() + " in " + mLauncher.getVisibleBounds(mObject)); final String label = mObject.getText(); Loading @@ -68,7 +66,8 @@ abstract class Launchable { expectActivityStartEvents(); }, event -> event.getEventType() == TYPE_WINDOW_STATE_CHANGED, () -> "Launching an app didn't open a new window: " + label); () -> "Launching an app didn't open a new window: " + label, "clicking " + launchableType()); mLauncher.assertTrue( "App didn't start: " + label + " (" + selector + ")", Loading @@ -76,7 +75,6 @@ abstract class Launchable { LauncherInstrumentation.WAIT_TIME_MS)); return new Background(mLauncher); } } /** * Drags an object to the center of homescreen. Loading
tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +45 −41 Original line number Diff line number Diff line Loading @@ -655,15 +655,18 @@ public final class LauncherInstrumentation { } Parcelable executeAndWaitForLauncherEvent(Runnable command, UiAutomation.AccessibilityEventFilter eventFilter, Supplier<String> message) { UiAutomation.AccessibilityEventFilter eventFilter, Supplier<String> message, String actionName) { return executeAndWaitForEvent( command, e -> mLauncherPackage.equals(e.getPackageName()) && eventFilter.accept(e), message); message, actionName); } Parcelable executeAndWaitForEvent(Runnable command, UiAutomation.AccessibilityEventFilter eventFilter, Supplier<String> message) { UiAutomation.AccessibilityEventFilter eventFilter, Supplier<String> message, String actionName) { try (LauncherInstrumentation.Closable c = addContextLayer(actionName)) { try { final AccessibilityEvent event = mInstrumentation.getUiAutomation().executeAndWaitForEvent( Loading @@ -677,6 +680,7 @@ public final class LauncherInstrumentation { return null; } } } /** * Presses nav bar home button. Loading Loading @@ -720,7 +724,6 @@ public final class LauncherInstrumentation { dumpViewHierarchy(); action = "swiping up to home"; try (LauncherInstrumentation.Closable c = addContextLayer(action)) { swipeToState( displaySize.x / 2, displaySize.y - 1, displaySize.x / 2, 0, Loading @@ -729,12 +732,10 @@ public final class LauncherInstrumentation { ? GestureScope.INSIDE_TO_OUTSIDE : GestureScope.OUTSIDE_WITH_PILFER); } } } else { log("Hierarchy before clicking home:"); dumpViewHierarchy(); action = "clicking home button"; try (LauncherInstrumentation.Closable c = addContextLayer(action)) { if (!isLauncher3() && getNavigationModel() == NavigationModel.TWO_BUTTON) { expectEvent(TestProtocol.SEQUENCE_TIS, EVENT_TOUCH_DOWN_TIS); expectEvent(TestProtocol.SEQUENCE_TIS, EVENT_TOUCH_UP_TIS); Loading @@ -745,8 +746,8 @@ public final class LauncherInstrumentation { NORMAL_STATE_ORDINAL, !hasLauncherObject(WORKSPACE_RES_ID) && (hasLauncherObject(APPS_RES_ID) || hasLauncherObject(OVERVIEW_RES_ID))); } || hasLauncherObject(OVERVIEW_RES_ID)), action); } try (LauncherInstrumentation.Closable c = addContextLayer( "performed action to switch to Home - " + action)) { Loading Loading @@ -1032,22 +1033,23 @@ public final class LauncherInstrumentation { + "]"; } void runToState(Runnable command, int expectedState, boolean requireEvent) { void runToState(Runnable command, int expectedState, boolean requireEvent, String actionName) { if (requireEvent) { runToState(command, expectedState); runToState(command, expectedState, actionName); } else { command.run(); } } void runToState(Runnable command, int expectedState) { void runToState(Runnable command, int expectedState, String actionName) { final List<Integer> actualEvents = new ArrayList<>(); executeAndWaitForLauncherEvent( command, event -> isSwitchToStateEvent(event, expectedState, actualEvents), () -> "Failed to receive an event for the state change: expected [" + TestProtocol.stateOrdinalToString(expectedState) + "], actual: " + eventListToString(actualEvents)); + "], actual: " + eventListToString(actualEvents), actionName); } private boolean isSwitchToStateEvent( Loading @@ -1064,7 +1066,8 @@ public final class LauncherInstrumentation { GestureScope gestureScope) { runToState( () -> linearGesture(startX, startY, endX, endY, steps, false, gestureScope), expectedState); expectedState, "swiping"); } private int getBottomGestureSize() { Loading Loading @@ -1172,7 +1175,8 @@ public final class LauncherInstrumentation { startX, startY, endX, endY, steps, slowDown, GestureScope.INSIDE), event -> TestProtocol.SCROLL_FINISHED_MESSAGE.equals(event.getClassName()), () -> "Didn't receive a scroll end message: " + startX + ", " + startY + ", " + endX + ", " + endY); + ", " + endX + ", " + endY, "scrolling"); } // Inject a swipe gesture. Inject exactly 'steps' motion points, incrementing event time by a Loading
tests/tapl/com/android/launcher3/tapl/OverviewTask.java +7 −9 Original line number Diff line number Diff line Loading @@ -71,15 +71,13 @@ public final class OverviewTask { public Background open() { try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) { verifyActiveContainer(); try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer( "clicking an overview task")) { mLauncher.executeAndWaitForEvent( () -> mLauncher.clickLauncherObject(mTask), event -> event.getEventType() == TYPE_WINDOW_STATE_CHANGED, () -> "Launching task didn't open a new window: " + mTask.getParent().getContentDescription()); + mTask.getParent().getContentDescription(), "clicking an overview task"); mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, TASK_START_EVENT); } return new Background(mLauncher); } } Loading
tests/tapl/com/android/launcher3/tapl/Workspace.java +4 −2 Original line number Diff line number Diff line Loading @@ -190,13 +190,15 @@ public final class Workspace extends Home { launcher.movePointer(launchableCenter, dest, 10, downTime, true, LauncherInstrumentation.GestureScope.INSIDE); }, SPRING_LOADED_STATE_ORDINAL); SPRING_LOADED_STATE_ORDINAL, "long-pressing and moving"); LauncherInstrumentation.log("dragIconToWorkspace: moved pointer"); launcher.runToState( () -> launcher.sendPointer( downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, dest, LauncherInstrumentation.GestureScope.INSIDE), NORMAL_STATE_ORDINAL); NORMAL_STATE_ORDINAL, "sending UP event"); if (startsActivity || isWidgetShortcut) { launcher.expectEvent(TestProtocol.SEQUENCE_MAIN, LauncherInstrumentation.EVENT_START); } Loading