diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2017-01-21 01:33:02 -0800 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2017-01-23 15:28:25 -0800 |
commit | 658058b960ef029fc70f0f3e131057a6ba0d10e2 (patch) | |
tree | c8481894d78cbf5070c9d651bf5a979113427259 /src/com/android | |
parent | 76891df785ea18795397528a351a4280f6467e08 (diff) | |
download | android_packages_apps_Trebuchet-658058b960ef029fc70f0f3e131057a6ba0d10e2.tar.gz android_packages_apps_Trebuchet-658058b960ef029fc70f0f3e131057a6ba0d10e2.tar.bz2 android_packages_apps_Trebuchet-658058b960ef029fc70f0f3e131057a6ba0d10e2.zip |
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
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/launcher3/FolderInfo.java | 2 | ||||
-rw-r--r-- | src/com/android/launcher3/ItemInfo.java | 2 | ||||
-rw-r--r-- | src/com/android/launcher3/LauncherAppWidgetInfo.java | 4 | ||||
-rw-r--r-- | src/com/android/launcher3/MainThreadExecutor.java | 55 | ||||
-rw-r--r-- | src/com/android/launcher3/ShortcutInfo.java | 2 | ||||
-rw-r--r-- | src/com/android/launcher3/util/LooperExecuter.java | 81 |
6 files changed, 90 insertions, 56 deletions
diff --git a/src/com/android/launcher3/FolderInfo.java b/src/com/android/launcher3/FolderInfo.java index 4c88e7eea..5fff2e76b 100644 --- a/src/com/android/launcher3/FolderInfo.java +++ b/src/com/android/launcher3/FolderInfo.java @@ -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); diff --git a/src/com/android/launcher3/ItemInfo.java b/src/com/android/launcher3/ItemInfo.java index 82c7ab8de..aec6c7dc2 100644 --- a/src/com/android/launcher3/ItemInfo.java +++ b/src/com/android/launcher3/ItemInfo.java @@ -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"); diff --git a/src/com/android/launcher3/LauncherAppWidgetInfo.java b/src/com/android/launcher3/LauncherAppWidgetInfo.java index 285a93cd7..1e0f28546 100644 --- a/src/com/android/launcher3/LauncherAppWidgetInfo.java +++ b/src/com/android/launcher3/LauncherAppWidgetInfo.java @@ -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()) diff --git a/src/com/android/launcher3/MainThreadExecutor.java b/src/com/android/launcher3/MainThreadExecutor.java index 866b17c71..4ca0a59d8 100644 --- a/src/com/android/launcher3/MainThreadExecutor.java +++ b/src/com/android/launcher3/MainThreadExecutor.java @@ -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()); } } diff --git a/src/com/android/launcher3/ShortcutInfo.java b/src/com/android/launcher3/ShortcutInfo.java index 1a423957a..b35dcb716 100644 --- a/src/com/android/launcher3/ShortcutInfo.java +++ b/src/com/android/launcher3/ShortcutInfo.java @@ -161,7 +161,7 @@ public class ShortcutInfo extends ItemInfoWithIcon { } @Override - void onAddToDatabase(ContentWriter writer) { + public void onAddToDatabase(ContentWriter writer) { super.onAddToDatabase(writer); writer.put(LauncherSettings.BaseLauncherColumns.TITLE, title) .put(LauncherSettings.BaseLauncherColumns.INTENT, getIntent()) diff --git a/src/com/android/launcher3/util/LooperExecuter.java b/src/com/android/launcher3/util/LooperExecuter.java new file mode 100644 index 000000000..4db999bce --- /dev/null +++ b/src/com/android/launcher3/util/LooperExecuter.java @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ +package com.android.launcher3.util; + +import android.os.Handler; +import android.os.Looper; + +import java.util.List; +import java.util.concurrent.AbstractExecutorService; +import java.util.concurrent.TimeUnit; + +/** + * Extension of {@link AbstractExecutorService} which executed on a provided looper. + */ +public class LooperExecuter extends AbstractExecutorService { + + private final Handler mHandler; + + public LooperExecuter(Looper looper) { + mHandler = new Handler(looper); + } + + @Override + public void execute(Runnable runnable) { + if (mHandler.getLooper() == 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(); + } +} |