Merge "Adding more diags for TAPL actions that change Launcher state" into sc-dev
This commit is contained in:
commit
e5a21905b8
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
|
|
@ -56,26 +56,24 @@ 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();
|
||||
LauncherInstrumentation.log("Launchable.launch before click "
|
||||
+ mObject.getVisibleCenter() + " in " + mLauncher.getVisibleBounds(mObject));
|
||||
final String label = mObject.getText();
|
||||
|
||||
mLauncher.executeAndWaitForEvent(
|
||||
() -> {
|
||||
mLauncher.clickLauncherObject(mObject);
|
||||
expectActivityStartEvents();
|
||||
},
|
||||
event -> event.getEventType() == TYPE_WINDOW_STATE_CHANGED,
|
||||
() -> "Launching an app didn't open a new window: " + label);
|
||||
mLauncher.executeAndWaitForEvent(
|
||||
() -> {
|
||||
mLauncher.clickLauncherObject(mObject);
|
||||
expectActivityStartEvents();
|
||||
},
|
||||
event -> event.getEventType() == TYPE_WINDOW_STATE_CHANGED,
|
||||
() -> "Launching an app didn't open a new window: " + label,
|
||||
"clicking " + launchableType());
|
||||
|
||||
mLauncher.assertTrue(
|
||||
"App didn't start: " + label + " (" + selector + ")",
|
||||
TestHelpers.wait(Until.hasObject(selector),
|
||||
LauncherInstrumentation.WAIT_TIME_MS));
|
||||
return new Background(mLauncher);
|
||||
}
|
||||
mLauncher.assertTrue(
|
||||
"App didn't start: " + label + " (" + selector + ")",
|
||||
TestHelpers.wait(Until.hasObject(selector),
|
||||
LauncherInstrumentation.WAIT_TIME_MS));
|
||||
return new Background(mLauncher);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -655,26 +655,30 @@ 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) {
|
||||
try {
|
||||
final AccessibilityEvent event =
|
||||
mInstrumentation.getUiAutomation().executeAndWaitForEvent(
|
||||
command, eventFilter, WAIT_TIME_MS);
|
||||
assertNotNull("executeAndWaitForEvent returned null (this can't happen)", event);
|
||||
final Parcelable parcelableData = event.getParcelableData();
|
||||
event.recycle();
|
||||
return parcelableData;
|
||||
} catch (TimeoutException e) {
|
||||
fail(message.get());
|
||||
return null;
|
||||
UiAutomation.AccessibilityEventFilter eventFilter, Supplier<String> message,
|
||||
String actionName) {
|
||||
try (LauncherInstrumentation.Closable c = addContextLayer(actionName)) {
|
||||
try {
|
||||
final AccessibilityEvent event =
|
||||
mInstrumentation.getUiAutomation().executeAndWaitForEvent(
|
||||
command, eventFilter, WAIT_TIME_MS);
|
||||
assertNotNull("executeAndWaitForEvent returned null (this can't happen)", event);
|
||||
final Parcelable parcelableData = event.getParcelableData();
|
||||
event.recycle();
|
||||
return parcelableData;
|
||||
} catch (TimeoutException e) {
|
||||
fail(message.get());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -720,33 +724,30 @@ 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,
|
||||
ZERO_BUTTON_STEPS_FROM_BACKGROUND_TO_HOME, NORMAL_STATE_ORDINAL,
|
||||
launcherWasVisible
|
||||
? GestureScope.INSIDE_TO_OUTSIDE
|
||||
: GestureScope.OUTSIDE_WITH_PILFER);
|
||||
}
|
||||
swipeToState(
|
||||
displaySize.x / 2, displaySize.y - 1,
|
||||
displaySize.x / 2, 0,
|
||||
ZERO_BUTTON_STEPS_FROM_BACKGROUND_TO_HOME, NORMAL_STATE_ORDINAL,
|
||||
launcherWasVisible
|
||||
? 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);
|
||||
}
|
||||
|
||||
runToState(
|
||||
waitForSystemUiObject("home")::click,
|
||||
NORMAL_STATE_ORDINAL,
|
||||
!hasLauncherObject(WORKSPACE_RES_ID)
|
||||
&& (hasLauncherObject(APPS_RES_ID)
|
||||
|| hasLauncherObject(OVERVIEW_RES_ID)));
|
||||
if (!isLauncher3() && getNavigationModel() == NavigationModel.TWO_BUTTON) {
|
||||
expectEvent(TestProtocol.SEQUENCE_TIS, EVENT_TOUCH_DOWN_TIS);
|
||||
expectEvent(TestProtocol.SEQUENCE_TIS, EVENT_TOUCH_UP_TIS);
|
||||
}
|
||||
|
||||
runToState(
|
||||
waitForSystemUiObject("home")::click,
|
||||
NORMAL_STATE_ORDINAL,
|
||||
!hasLauncherObject(WORKSPACE_RES_ID)
|
||||
&& (hasLauncherObject(APPS_RES_ID)
|
||||
|| hasLauncherObject(OVERVIEW_RES_ID)),
|
||||
action);
|
||||
}
|
||||
try (LauncherInstrumentation.Closable c = addContextLayer(
|
||||
"performed action to switch to Home - " + action)) {
|
||||
|
@ -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(
|
||||
|
@ -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() {
|
||||
|
@ -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
|
||||
|
|
|
@ -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());
|
||||
mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, TASK_START_EVENT);
|
||||
}
|
||||
mLauncher.executeAndWaitForEvent(
|
||||
() -> mLauncher.clickLauncherObject(mTask),
|
||||
event -> event.getEventType() == TYPE_WINDOW_STATE_CHANGED,
|
||||
() -> "Launching task didn't open a new window: "
|
||||
+ mTask.getParent().getContentDescription(),
|
||||
"clicking an overview task");
|
||||
mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, TASK_START_EVENT);
|
||||
return new Background(mLauncher);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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…
Reference in New Issue