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

Commit 06146a19 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Revert "Clear only workspace shortcut / widget related tests"" into sc-v2-dev

parents b4307ff8 9b3dd6c0
Loading
Loading
Loading
Loading
+0 −31
Original line number Diff line number Diff line
@@ -461,13 +461,6 @@ public class LauncherProvider extends ContentProvider {
                app.getModel().forceReload();
                return null;
            }
            case LauncherSettings.Settings.METHOD_CLEAR_WORKSPACE:
            {
                Bundle result = new Bundle();
                result.putIntArray(LauncherSettings.Settings.EXTRA_VALUE, clearWorkspace()
                        .toArray());
                return result;
            }
        }
        return null;
    }
@@ -504,30 +497,6 @@ public class LauncherProvider extends ContentProvider {
        }
    }

    /**
     * Deletes any items from the DB apart from hotseat.
     * @return Ids of deleted items.
     */
    private IntArray clearWorkspace() {
        SQLiteDatabase db = mOpenHelper.getWritableDatabase();
        try (SQLiteTransaction t = new SQLiteTransaction(db)) {
            String selection = LauncherSettings.Favorites.CONTAINER + " <> "
                    + LauncherSettings.Favorites.CONTAINER_HOTSEAT;

            IntArray itemIds = LauncherDbUtils.queryIntArray(db, Favorites.TABLE_NAME,
                    Favorites._ID, selection, null, null);
            if (!itemIds.isEmpty()) {
                db.delete(Favorites.TABLE_NAME, Utilities.createDbSelectionQuery(
                        LauncherSettings.Favorites._ID, itemIds), null);
            }
            t.commit();
            return itemIds;
        } catch (SQLException ex) {
            Log.e(TAG, ex.getMessage(), ex);
            return new IntArray();
        }
    }

    @Thunk static void addModifiedTime(ContentValues values) {
        values.put(LauncherSettings.Favorites.MODIFIED, System.currentTimeMillis());
    }
+0 −2
Original line number Diff line number Diff line
@@ -392,8 +392,6 @@ public class LauncherSettings {

        public static final String METHOD_SWITCH_DATABASE = "switch_database";

        public static final String METHOD_CLEAR_WORKSPACE = "clear_workspace";

        public static final String EXTRA_VALUE = "value";

        public static final String EXTRA_DB_NAME = "db_name";
+5 −6
Original line number Diff line number Diff line
@@ -288,14 +288,13 @@ public abstract class AbstractLauncherUiTest {
    }

    /**
     * Removes all items from workspace and populate default hotseat.
     * Removes all icons from homescreen and hotseat.
     */
    public void clearWorkspace() {
        // First clear data to ensure hotseat is populated.
        clearLauncherData();
        // Next make provider call to clear everything apart from hotseat.
    public void clearHomescreen() throws Throwable {
        LauncherSettings.Settings.call(mTargetContext.getContentResolver(),
                LauncherSettings.Settings.METHOD_CLEAR_WORKSPACE);
                LauncherSettings.Settings.METHOD_CREATE_EMPTY_DB);
        LauncherSettings.Settings.call(mTargetContext.getContentResolver(),
                LauncherSettings.Settings.METHOD_CLEAR_EMPTY_DB_FLAG);
        resetLoaderState();
    }

+1 −1
Original line number Diff line number Diff line
@@ -85,7 +85,7 @@ public class AddConfigWidgetTest extends AbstractLauncherUiTest {
     * @param acceptConfig accept the config activity
     */
    private void runTest(boolean acceptConfig) throws Throwable {
        clearWorkspace();
        clearHomescreen();
        mDevice.pressHome();

        final Widgets widgets = mLauncher.getWorkspace().openAllWidgets();
+2 −2
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ public class AddWidgetTest extends AbstractLauncherUiTest {
    @Test
    @PortraitLandscape
    public void testDragIcon() throws Throwable {
        clearWorkspace();
        clearHomescreen();
        mDevice.pressHome();

        final LauncherAppWidgetProviderInfo widgetInfo =
@@ -81,7 +81,7 @@ public class AddWidgetTest extends AbstractLauncherUiTest {
    @Test
    @PortraitLandscape
    public void testDragCustomShortcut() throws Throwable {
        clearWorkspace();
        clearHomescreen();
        mDevice.pressHome();
        mLauncher.getWorkspace().openAllWidgets()
                .getWidget("com.android.launcher3.testcomponent.CustomShortcutConfigActivity")
Loading