Correctly restarting Launcher from OOP tests

Waiting for touch interaction service; waiting for package-restart
events.

Bug: 136215685
Change-Id: I0c31c09fe3a58b898168dfdb4e4d23757b94a47c
This commit is contained in:
vadimt 2019-06-28 12:04:36 -07:00
parent f11dd8e107
commit 853852351f
6 changed files with 39 additions and 1 deletions

View File

@ -185,4 +185,8 @@ public class TouchInteractionService extends Service {
}
return mMyBinder;
}
public static boolean isInputMonitorInitialized() {
return true;
}
}

View File

@ -226,12 +226,17 @@ public class TouchInteractionService extends Service implements
};
private static boolean sConnected = false;
private static boolean sInputMonitorInitialized = false;
private static final SwipeSharedState sSwipeSharedState = new SwipeSharedState();
public static boolean isConnected() {
return sConnected;
}
public static boolean isInputMonitorInitialized() {
return sInputMonitorInitialized;
}
public static SwipeSharedState getSwipeSharedState() {
return sSwipeSharedState;
}
@ -325,6 +330,7 @@ public class TouchInteractionService extends Service implements
mInputMonitorCompat.dispose();
mInputMonitorCompat = null;
}
sInputMonitorInitialized = false;
}
private void initInputMonitor() {
@ -342,6 +348,7 @@ public class TouchInteractionService extends Service implements
Log.e(TAG, "Unable to create input monitor", e);
}
initTouchBounds();
sInputMonitorInitialized = true;
}
private int getNavbarSize(String resName) {

View File

@ -10,7 +10,8 @@ import com.android.quickstep.util.LayoutUtils;
public class QuickstepTestInformationHandler extends TestInformationHandler {
public QuickstepTestInformationHandler(Context context) { }
public QuickstepTestInformationHandler(Context context) {
}
@Override
public Bundle call(String method) {
@ -29,6 +30,12 @@ public class QuickstepTestInformationHandler extends TestInformationHandler {
response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, (int) swipeHeight);
return response;
}
case TestProtocol.REQUEST_IS_LAUNCHER_INITIALIZED: {
response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD,
TouchInteractionService.isInputMonitorInitialized());
break;
}
}
return super.call(method);

View File

@ -74,6 +74,11 @@ public class TestInformationHandler implements ResourceBasedOverride {
break;
}
case TestProtocol.REQUEST_IS_LAUNCHER_INITIALIZED: {
response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD, true);
break;
}
case TestProtocol.REQUEST_ENABLE_DEBUG_TRACING:
TestProtocol.sDebugTracing = true;
break;

View File

@ -66,6 +66,7 @@ public final class TestProtocol {
"all-apps-to-overview-swipe-height";
public static final String REQUEST_HOME_TO_ALL_APPS_SWIPE_HEIGHT =
"home-to-all-apps-swipe-height";
public static final String REQUEST_IS_LAUNCHER_INITIALIZED = "is-launcher-initialized";
public static final String REQUEST_FREEZE_APP_LIST = "freeze-app-list";
public static final String REQUEST_UNFREEZE_APP_LIST = "unfreeze-app-list";
public static final String REQUEST_APP_LIST_FREEZE_FLAGS = "app-list-freeze-flags";

View File

@ -444,6 +444,8 @@ public final class LauncherInstrumentation {
}
private UiObject2 verifyContainerType(ContainerType containerType) {
waitForTouchInteractionService();
assertEquals("Unexpected display rotation",
mExpectedRotation, mDevice.getDisplayRotation());
@ -514,6 +516,18 @@ public final class LauncherInstrumentation {
}
}
private void waitForTouchInteractionService() {
for (int i = 0; i < 100; ++i) {
if (getTestInfo(
TestProtocol.REQUEST_IS_LAUNCHER_INITIALIZED).
getBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD)) {
return;
}
SystemClock.sleep(100);
}
fail("TouchInteractionService didn't connect");
}
Parcelable executeAndWaitForEvent(Runnable command,
UiAutomation.AccessibilityEventFilter eventFilter, String message) {
try {