Removing support for legacy shortcuts from default layouts
Launcher will only allow deep shortcuts to be pinned on homescreen. Bug: 275875209 Test: Updated tests Flag: N/A Change-Id: I4f2674deb9cd81dd07d5d537f35a51b030a183da
This commit is contained in:
@@ -20,8 +20,10 @@ import static com.android.launcher3.util.LauncherModelHelper.TEST_ACTIVITY;
|
||||
import static com.android.launcher3.util.LauncherModelHelper.TEST_PACKAGE;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.LauncherApps;
|
||||
import android.content.pm.PackageInstaller;
|
||||
import android.content.pm.PackageInstaller.SessionParams;
|
||||
|
||||
@@ -127,6 +129,38 @@ public class DefaultLayoutProviderTest {
|
||||
assertEquals(2, info.spanY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomProfileLoaded_with_shortcut_on_hotseat() throws Exception {
|
||||
assumeTrue(mTargetContext.getSystemService(LauncherApps.class).hasShortcutHostPermission());
|
||||
writeLayoutAndLoad(new LauncherLayoutBuilder().atHotseat(0)
|
||||
.putShortcut(TEST_PACKAGE, "shortcut2"));
|
||||
|
||||
// Verify one item in hotseat
|
||||
assertEquals(1, mModelHelper.getBgDataModel().workspaceItems.size());
|
||||
ItemInfo info = mModelHelper.getBgDataModel().workspaceItems.get(0);
|
||||
assertEquals(LauncherSettings.Favorites.CONTAINER_HOTSEAT, info.container);
|
||||
assertEquals(LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT, info.itemType);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomProfileLoaded_with_shortcut_in_folder() throws Exception {
|
||||
assumeTrue(mTargetContext.getSystemService(LauncherApps.class).hasShortcutHostPermission());
|
||||
writeLayoutAndLoad(new LauncherLayoutBuilder().atHotseat(0).putFolder(android.R.string.copy)
|
||||
.addApp(TEST_PACKAGE, TEST_ACTIVITY)
|
||||
.addApp(TEST_PACKAGE, TEST_ACTIVITY)
|
||||
.addShortcut(TEST_PACKAGE, "shortcut2")
|
||||
.build());
|
||||
|
||||
// Verify folder
|
||||
assertEquals(1, mModelHelper.getBgDataModel().workspaceItems.size());
|
||||
FolderInfo info = (FolderInfo) mModelHelper.getBgDataModel().workspaceItems.get(0);
|
||||
assertEquals(3, info.contents.size());
|
||||
|
||||
// Verify last icon
|
||||
assertEquals(LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT,
|
||||
info.contents.get(info.contents.size() - 1).itemType);
|
||||
}
|
||||
|
||||
private void writeLayoutAndLoad(LauncherLayoutBuilder builder) throws Exception {
|
||||
mModelHelper.setupDefaultLayoutProvider(builder).loadModelSync();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user