Merge "Update TestProtocol.REQUEST_CLEAR_DATA to properly clear the workspace" into udc-qpr-dev am: 720d0cf4c4
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/23835672 Change-Id: I392b76e7b4263d1ca33fc33dac3ecf20660795d8 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
committed by
Automerger Merge Worker
commit
045f9cf583
@@ -188,12 +188,27 @@ public class DebugTestInformationHandler extends TestInformationHandler {
|
||||
return response;
|
||||
}
|
||||
|
||||
case TestProtocol.REQUEST_REINITIALIZE_DATA: {
|
||||
final long identity = Binder.clearCallingIdentity();
|
||||
try {
|
||||
MODEL_EXECUTOR.execute(() -> {
|
||||
LauncherModel model = LauncherAppState.getInstance(mContext).getModel();
|
||||
model.getModelDbController().createEmptyDB();
|
||||
MAIN_EXECUTOR.execute(model::forceReload);
|
||||
});
|
||||
return response;
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(identity);
|
||||
}
|
||||
}
|
||||
|
||||
case TestProtocol.REQUEST_CLEAR_DATA: {
|
||||
final long identity = Binder.clearCallingIdentity();
|
||||
try {
|
||||
MODEL_EXECUTOR.execute(() -> {
|
||||
LauncherModel model = LauncherAppState.getInstance(mContext).getModel();
|
||||
model.getModelDbController().createEmptyDB();
|
||||
model.getModelDbController().clearEmptyDbFlag();
|
||||
MAIN_EXECUTOR.execute(model::forceReload);
|
||||
});
|
||||
return response;
|
||||
|
||||
@@ -110,6 +110,7 @@ public final class TestProtocol {
|
||||
public static final String REQUEST_GET_TEST_EVENTS = "get-test-events";
|
||||
public static final String REQUEST_GET_HAD_NONTEST_EVENTS = "get-had-nontest-events";
|
||||
public static final String REQUEST_STOP_EVENT_LOGGING = "stop-event-logging";
|
||||
public static final String REQUEST_REINITIALIZE_DATA = "reinitialize-data";
|
||||
public static final String REQUEST_CLEAR_DATA = "clear-data";
|
||||
public static final String REQUEST_HOTSEAT_ICON_NAMES = "get-hotseat-icon-names";
|
||||
public static final String REQUEST_IS_TABLET = "is-tablet";
|
||||
|
||||
@@ -291,8 +291,16 @@ public abstract class AbstractLauncherUiTest {
|
||||
}
|
||||
}
|
||||
|
||||
protected void clearLauncherData() {
|
||||
mLauncher.clearLauncherData();
|
||||
protected void reinitializeLauncherData() {
|
||||
reinitializeLauncherData(false);
|
||||
}
|
||||
|
||||
protected void reinitializeLauncherData(boolean clearWorkspace) {
|
||||
if (clearWorkspace) {
|
||||
mLauncher.clearLauncherData();
|
||||
} else {
|
||||
mLauncher.reinitializeLauncherData();
|
||||
}
|
||||
mLauncher.waitForLauncherInitialized();
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +97,12 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest {
|
||||
}
|
||||
|
||||
public static void initialize(AbstractLauncherUiTest test) throws Exception {
|
||||
test.clearLauncherData();
|
||||
initialize(test, false);
|
||||
}
|
||||
|
||||
public static void initialize(
|
||||
AbstractLauncherUiTest test, boolean clearWorkspace) throws Exception {
|
||||
test.reinitializeLauncherData(clearWorkspace);
|
||||
test.mDevice.pressHome();
|
||||
test.waitForLauncherCondition("Launcher didn't start", launcher -> launcher != null);
|
||||
test.waitForState("Launcher internal state didn't switch to Home",
|
||||
@@ -248,7 +253,7 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest {
|
||||
LauncherLayoutBuilder builder = new LauncherLayoutBuilder()
|
||||
.atHotseat(0).putApp("com.android.chrome", "com.google.android.apps.chrome.Main");
|
||||
mLauncherLayout = TestUtil.setLauncherDefaultLayout(mTargetContext, builder);
|
||||
clearLauncherData();
|
||||
reinitializeLauncherData();
|
||||
|
||||
final Workspace workspace = mLauncher.getWorkspace();
|
||||
|
||||
@@ -557,7 +562,7 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest {
|
||||
allApps.unfreeze();
|
||||
}
|
||||
// Reset the workspace for the next shortcut creation.
|
||||
initialize(this);
|
||||
initialize(this, true);
|
||||
endTime = SystemClock.uptimeMillis();
|
||||
elapsedTime = endTime - startTime;
|
||||
Log.d("testDragAppIconToWorkspaceCellTime",
|
||||
|
||||
@@ -1855,6 +1855,12 @@ public final class LauncherInstrumentation {
|
||||
return tasks;
|
||||
}
|
||||
|
||||
/** Reinitializes the workspace to its default layout. */
|
||||
public void reinitializeLauncherData() {
|
||||
getTestInfo(TestProtocol.REQUEST_REINITIALIZE_DATA);
|
||||
}
|
||||
|
||||
/** Clears the workspace, leaving it empty. */
|
||||
public void clearLauncherData() {
|
||||
getTestInfo(TestProtocol.REQUEST_CLEAR_DATA);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user