Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 67ca5285 authored by Schneider Victor-tulias's avatar Schneider Victor-tulias
Browse files

Update TestProtocol.REQUEST_CLEAR_DATA to properly clear the workspace

Flag: not needed
Fixes: 287097473
Test: TaplTestsLauncher3
Change-Id: I980a68dff8b475ce8f7b86284663f697b7bc2b57
parent d2d1942b
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -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;
+1 −0
Original line number Diff line number Diff line
@@ -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";
+10 −2
Original line number Diff line number Diff line
@@ -293,8 +293,16 @@ public abstract class AbstractLauncherUiTest {
        }
    }

    protected void clearLauncherData() {
    protected void reinitializeLauncherData() {
        reinitializeLauncherData(false);
    }

    protected void reinitializeLauncherData(boolean clearWorkspace) {
        if (clearWorkspace) {
            mLauncher.clearLauncherData();
        } else {
            mLauncher.reinitializeLauncherData();
        }
        mLauncher.waitForLauncherInitialized();
    }

+8 −3
Original line number Diff line number Diff line
@@ -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",
+6 −0
Original line number Diff line number Diff line
@@ -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);
    }