Loading tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +23 −11 Original line number Original line Diff line number Diff line Loading @@ -562,7 +562,7 @@ public final class LauncherInstrumentation { if (hasLauncherObject(WORKSPACE_RES_ID)) { if (hasLauncherObject(WORKSPACE_RES_ID)) { log(action = "already at home"); log(action = "already at home"); } else { } else { log("Hierarchy before swiping up to home"); log("Hierarchy before swiping up to home:"); dumpViewHierarchy(); dumpViewHierarchy(); log(action = "swiping up to home from " + getVisibleStateMessage()); log(action = "swiping up to home from " + getVisibleStateMessage()); Loading @@ -574,15 +574,19 @@ public final class LauncherInstrumentation { } } } } } else { } else { log(action = "clicking home button"); log("Hierarchy before clicking home:"); executeAndWaitForEvent( dumpViewHierarchy(); () -> { log(action = "clicking home button from " + getVisibleStateMessage()); log("LauncherInstrumentation.pressHome before clicking"); try (LauncherInstrumentation.Closable c = addContextLayer(action)) { waitForSystemUiObject("home").click(); }, event -> true, () -> "Pressing Home didn't produce any events"); mDevice.waitForIdle(); mDevice.waitForIdle(); runToState( () -> waitForSystemUiObject("home").click(), NORMAL_STATE_ORDINAL, !hasLauncherObject(WORKSPACE_RES_ID) && (hasLauncherObject(APPS_RES_ID) || hasLauncherObject(OVERVIEW_RES_ID))); mDevice.waitForIdle(); } } } try (LauncherInstrumentation.Closable c = addContextLayer( try (LauncherInstrumentation.Closable c = addContextLayer( "performed action to switch to Home - " + action)) { "performed action to switch to Home - " + action)) { Loading Loading @@ -786,12 +790,20 @@ public final class LauncherInstrumentation { + "]"; + "]"; } } void runToState(Runnable command, int expectedState, boolean requireEvent) { if (requireEvent) { runToState(command, expectedState); } else { command.run(); } } void runToState(Runnable command, int expectedState) { void runToState(Runnable command, int expectedState) { final List<Integer> actualEvents = new ArrayList<>(); final List<Integer> actualEvents = new ArrayList<>(); executeAndWaitForEvent( executeAndWaitForEvent( command, command, event -> isSwitchToStateEvent(event, expectedState, actualEvents), event -> isSwitchToStateEvent(event, expectedState, actualEvents), () -> "Failed to receive an event for the swipe end: expected " () -> "Failed to receive an event for the stage change: expected " + TestProtocol.stateOrdinalToString(expectedState) + TestProtocol.stateOrdinalToString(expectedState) + ", actual: " + eventListToString(actualEvents)); + ", actual: " + eventListToString(actualEvents)); } } Loading Loading
tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +23 −11 Original line number Original line Diff line number Diff line Loading @@ -562,7 +562,7 @@ public final class LauncherInstrumentation { if (hasLauncherObject(WORKSPACE_RES_ID)) { if (hasLauncherObject(WORKSPACE_RES_ID)) { log(action = "already at home"); log(action = "already at home"); } else { } else { log("Hierarchy before swiping up to home"); log("Hierarchy before swiping up to home:"); dumpViewHierarchy(); dumpViewHierarchy(); log(action = "swiping up to home from " + getVisibleStateMessage()); log(action = "swiping up to home from " + getVisibleStateMessage()); Loading @@ -574,15 +574,19 @@ public final class LauncherInstrumentation { } } } } } else { } else { log(action = "clicking home button"); log("Hierarchy before clicking home:"); executeAndWaitForEvent( dumpViewHierarchy(); () -> { log(action = "clicking home button from " + getVisibleStateMessage()); log("LauncherInstrumentation.pressHome before clicking"); try (LauncherInstrumentation.Closable c = addContextLayer(action)) { waitForSystemUiObject("home").click(); }, event -> true, () -> "Pressing Home didn't produce any events"); mDevice.waitForIdle(); mDevice.waitForIdle(); runToState( () -> waitForSystemUiObject("home").click(), NORMAL_STATE_ORDINAL, !hasLauncherObject(WORKSPACE_RES_ID) && (hasLauncherObject(APPS_RES_ID) || hasLauncherObject(OVERVIEW_RES_ID))); mDevice.waitForIdle(); } } } try (LauncherInstrumentation.Closable c = addContextLayer( try (LauncherInstrumentation.Closable c = addContextLayer( "performed action to switch to Home - " + action)) { "performed action to switch to Home - " + action)) { Loading Loading @@ -786,12 +790,20 @@ public final class LauncherInstrumentation { + "]"; + "]"; } } void runToState(Runnable command, int expectedState, boolean requireEvent) { if (requireEvent) { runToState(command, expectedState); } else { command.run(); } } void runToState(Runnable command, int expectedState) { void runToState(Runnable command, int expectedState) { final List<Integer> actualEvents = new ArrayList<>(); final List<Integer> actualEvents = new ArrayList<>(); executeAndWaitForEvent( executeAndWaitForEvent( command, command, event -> isSwitchToStateEvent(event, expectedState, actualEvents), event -> isSwitchToStateEvent(event, expectedState, actualEvents), () -> "Failed to receive an event for the swipe end: expected " () -> "Failed to receive an event for the stage change: expected " + TestProtocol.stateOrdinalToString(expectedState) + TestProtocol.stateOrdinalToString(expectedState) + ", actual: " + eventListToString(actualEvents)); + ", actual: " + eventListToString(actualEvents)); } } Loading