Ensuring that ShortcutInfo always has an icon

> Making iconBitmap public instead of a getter (similar to AppInfo)
> Removing getIcon() which can lead to IO on UI thread
> Removing updateIcon and handling the update at the caller

Bug: 21325319
Change-Id: I6a49b9043f974e9629ea25e77012d97cc04c0594
This commit is contained in:
Sunny Goyal
2016-11-09 10:43:58 -08:00
parent 824c540f19
commit 1cd01b023a
17 changed files with 87 additions and 147 deletions

View File

@@ -1,15 +1,12 @@
package com.android.launcher3.model;
import com.android.launcher3.AppInfo;
import com.android.launcher3.IconCache;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.ShortcutInfo;
import java.util.Arrays;
import java.util.HashSet;
import static org.mockito.Mockito.mock;
/**
* Tests for {@link CacheDataUpdatedTask}
*/
@@ -67,14 +64,13 @@ public class CacheDataUpdatedTaskTest extends BaseModelUpdateTaskTestCase {
private void verifyUpdate(Long... idsUpdated) {
HashSet<Long> updates = new HashSet<>(Arrays.asList(idsUpdated));
IconCache noOpIconCache = mock(IconCache.class);
for (ItemInfo info : bgDataModel.itemsIdMap) {
if (updates.contains(info.id)) {
assertEquals(NEW_LABEL_PREFIX + info.id, info.title);
assertNotNull(((ShortcutInfo) info).getIcon(noOpIconCache));
assertNotNull(((ShortcutInfo) info).iconBitmap);
} else {
assertNotSame(NEW_LABEL_PREFIX + info.id, info.title);
assertNull(((ShortcutInfo) info).getIcon(noOpIconCache));
assertNull(((ShortcutInfo) info).iconBitmap);
}
}
}