summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2017-01-06 16:32:57 -0800
committerSunny Goyal <sunnygoyal@google.com>2017-01-10 23:42:49 -0800
commit1cc1c9ad83014ec8af54a44112138339c52795b0 (patch)
treec1b92a862d86a9c99ff06925861cd8f58da8ab75 /tests
parent19ea5cc0c853d48db59363f763d9a06c8691e00d (diff)
downloadandroid_packages_apps_Trebuchet-1cc1c9ad83014ec8af54a44112138339c52795b0.tar.gz
android_packages_apps_Trebuchet-1cc1c9ad83014ec8af54a44112138339c52795b0.tar.bz2
android_packages_apps_Trebuchet-1cc1c9ad83014ec8af54a44112138339c52795b0.zip
Enforcing background thread when accessing iconCacheDb.
> Moving any icon cache access to background thread > Updating Apps list to avoid loading icons for ignored apps Bug: 21325319 Change-Id: Id72755100f1176ccfcc99249c5e02873cc249a13
Diffstat (limited to 'tests')
-rw-r--r--tests/res/raw/cache_data_updated_task_data.txt8
-rw-r--r--tests/src/com/android/launcher3/model/BaseModelUpdateTaskTestCase.java10
-rw-r--r--tests/src/com/android/launcher3/model/CacheDataUpdatedTaskTest.java5
3 files changed, 17 insertions, 6 deletions
diff --git a/tests/res/raw/cache_data_updated_task_data.txt b/tests/res/raw/cache_data_updated_task_data.txt
index 9095476f6..819968709 100644
--- a/tests/res/raw/cache_data_updated_task_data.txt
+++ b/tests/res/raw/cache_data_updated_task_data.txt
@@ -22,7 +22,7 @@ bgItem s itemType=1 title=app4-shrt intent=component=app4/class1 id=8
bgItem s itemType=1 status=1 title=app3-shrt intent=component=app3/class3 id=9
bgItem s itemType=1 status=1 title=app5-shrt intent=component=app5/class1 id=10
-allApps componentName=app1/class1
-allApps componentName=app1/class2
-allApps componentName=app2/class1
-allApps componentName=app2/class2 \ No newline at end of file
+allApps componentName=app1/class1 intent=component=app1/class1
+allApps componentName=app1/class2 intent=component=app1/class2
+allApps componentName=app2/class1 intent=component=app2/class1
+allApps componentName=app2/class2 intent=component=app2/class2 \ No newline at end of file
diff --git a/tests/src/com/android/launcher3/model/BaseModelUpdateTaskTestCase.java b/tests/src/com/android/launcher3/model/BaseModelUpdateTaskTestCase.java
index 1d092ab04..3a27d0dbf 100644
--- a/tests/src/com/android/launcher3/model/BaseModelUpdateTaskTestCase.java
+++ b/tests/src/com/android/launcher3/model/BaseModelUpdateTaskTestCase.java
@@ -13,6 +13,7 @@ import android.support.test.InstrumentationRegistry;
import android.test.ProviderTestCase2;
import com.android.launcher3.AllAppsList;
+import com.android.launcher3.AppFilter;
import com.android.launcher3.AppInfo;
import com.android.launcher3.DeferredHandler;
import com.android.launcher3.IconCache;
@@ -76,7 +77,7 @@ public class BaseModelUpdateTaskTestCase extends ProviderTestCase2<TestLauncherP
idp = new InvariantDeviceProfile();
iconCache = new MyIconCache(targetContext, idp);
- allAppsList = new AllAppsList(iconCache, null);
+ allAppsList = new AllAppsList(iconCache, new AppFilter());
when(appState.getIconCache()).thenReturn(iconCache);
when(appState.getInvariantDeviceProfile()).thenReturn(idp);
@@ -131,7 +132,7 @@ public class BaseModelUpdateTaskTestCase extends ProviderTestCase2<TestLauncherP
(ItemInfo) initItem(classMap.get(commands[1]), commands, 2), false);
break;
case "allApps":
- allAppsList.add((AppInfo) initItem(AppInfo.class, commands, 1));
+ allAppsList.add((AppInfo) initItem(AppInfo.class, commands, 1), null);
break;
}
}
@@ -208,5 +209,10 @@ public class BaseModelUpdateTaskTestCase extends ProviderTestCase2<TestLauncherP
public Bitmap newIcon() {
return Bitmap.createBitmap(1, 1, Config.ARGB_8888);
}
+
+ @Override
+ protected Bitmap makeDefaultIcon(UserHandle user) {
+ return newIcon();
+ }
}
}
diff --git a/tests/src/com/android/launcher3/model/CacheDataUpdatedTaskTest.java b/tests/src/com/android/launcher3/model/CacheDataUpdatedTaskTest.java
index 646ef2794..d595e6cf1 100644
--- a/tests/src/com/android/launcher3/model/CacheDataUpdatedTaskTest.java
+++ b/tests/src/com/android/launcher3/model/CacheDataUpdatedTaskTest.java
@@ -30,6 +30,11 @@ public class CacheDataUpdatedTaskTest extends BaseModelUpdateTaskTestCase {
}
public void testCacheUpdate_update_apps() throws Exception {
+ // Clear all icons from apps list so that its easy to check what was updated
+ for (AppInfo info : allAppsList.data) {
+ info.iconBitmap = null;
+ }
+
executeTaskForTest(newTask(CacheDataUpdatedTask.OP_CACHE_UPDATE, "app1"));
// Verify that only the app icons of app1 (id 1 & 2) are updated. Custom shortcut (id 7)