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

Commit 658058b9 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Adding some widget addition flow tests

> Added two dummy widget providers: with config and without config
> Added tests for verify widget config flow

Change-Id: I4577f085abe8f8b82047b644c71cc9065358153a
parent 76891df7
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -46,12 +46,16 @@ android {
        androidTest {
            java.srcDirs = ['tests/src']
            res.srcDirs = ['tests/res']
            manifest.srcFile "tests/AndroidManifest.xml"
            manifest.srcFile "tests/AndroidManifest-common.xml"
        }

        aosp {
            manifest.srcFile "AndroidManifest.xml"
        }

        aospAndroidTest {
            manifest.srcFile "tests/AndroidManifest.xml"
        }
    }
}

+1 −1
Original line number Diff line number Diff line
@@ -93,7 +93,7 @@ public class FolderInfo extends ItemInfo {
    }

    @Override
    void onAddToDatabase(ContentWriter writer) {
    public void onAddToDatabase(ContentWriter writer) {
        super.onAddToDatabase(writer);
        writer.put(LauncherSettings.Favorites.TITLE, title)
                .put(LauncherSettings.Favorites.OPTIONS, options);
+1 −1
Original line number Diff line number Diff line
@@ -166,7 +166,7 @@ public class ItemInfo {
    /**
     * Write the fields of this item to the DB
     */
    void onAddToDatabase(ContentWriter writer) {
    public void onAddToDatabase(ContentWriter writer) {
        if (screenId == Workspace.EXTRA_EMPTY_SCREEN_ID) {
            // We should never persist an item on the extra empty screen.
            throw new RuntimeException("Screen id should not be EXTRA_EMPTY_SCREEN_ID");
+2 −2
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ public class LauncherAppWidgetInfo extends ItemInfo {
    /**
     * Indicates that the widget hasn't been instantiated yet.
     */
    static final int NO_ID = -1;
    public static final int NO_ID = -1;

    /**
     * Indicates that this is a locally defined widget and hence has no system allocated id.
@@ -126,7 +126,7 @@ public class LauncherAppWidgetInfo extends ItemInfo {
    }

    @Override
    void onAddToDatabase(ContentWriter writer) {
    public void onAddToDatabase(ContentWriter writer) {
        super.onAddToDatabase(writer);
        writer.put(LauncherSettings.Favorites.APPWIDGET_ID, appWidgetId)
                .put(LauncherSettings.Favorites.APPWIDGET_PROVIDER, providerName.flattenToString())
+4 −51
Original line number Diff line number Diff line
@@ -16,65 +16,18 @@

package com.android.launcher3;

import android.os.Handler;
import android.os.Looper;

import java.util.List;
import java.util.concurrent.AbstractExecutorService;
import java.util.concurrent.TimeUnit;
import com.android.launcher3.util.LooperExecuter;

/**
 * An executor service that executes its tasks on the main thread.
 *
 * Shutting down this executor is not supported.
 */
public class MainThreadExecutor extends AbstractExecutorService {
public class MainThreadExecutor extends LooperExecuter {

    private Handler mHandler = new Handler(Looper.getMainLooper());

    @Override
    public void execute(Runnable runnable) {
        if (Looper.getMainLooper() == Looper.myLooper()) {
            runnable.run();
        } else {
            mHandler.post(runnable);
        }
    }

    /**
     * Not supported and throws an exception when used.
     */
    @Override
    @Deprecated
    public void shutdown() {
        throw new UnsupportedOperationException();
    }

    /**
     * Not supported and throws an exception when used.
     */
    @Override
    @Deprecated
    public List<Runnable> shutdownNow() {
        throw new UnsupportedOperationException();
    }

    @Override
    public boolean isShutdown() {
        return false;
    }

    @Override
    public boolean isTerminated() {
        return false;
    }

    /**
     * Not supported and throws an exception when used.
     */
    @Override
    @Deprecated
    public boolean awaitTermination(long l, TimeUnit timeUnit) throws InterruptedException {
        throw new UnsupportedOperationException();
    public MainThreadExecutor() {
        super(Looper.getMainLooper());
    }
}
Loading