Search in sources :

Example 16 with TEST_PACKAGE

use of com.android.launcher3.util.LauncherModelHelper.TEST_PACKAGE in project android_packages_apps_Trebuchet by LineageOS.

the class DefaultLayoutProviderTest method testCustomProfileLoaded_with_folder_custom_title.

@Test
public void testCustomProfileLoaded_with_folder_custom_title() throws Exception {
    writeLayoutAndLoad(new LauncherLayoutBuilder().atHotseat(0).putFolder("CustomFolder").addApp(TEST_PACKAGE, TEST_PACKAGE).addApp(TEST_PACKAGE, TEST_PACKAGE).addApp(TEST_PACKAGE, TEST_PACKAGE).build());
    // Verify folder
    assertEquals(1, mModelHelper.getBgDataModel().workspaceItems.size());
    ItemInfo info = mModelHelper.getBgDataModel().workspaceItems.get(0);
    assertEquals(LauncherSettings.Favorites.ITEM_TYPE_FOLDER, info.itemType);
    assertEquals(3, ((FolderInfo) info).contents.size());
    assertEquals("CustomFolder", info.title.toString());
}
Also used : LauncherLayoutBuilder(com.android.launcher3.util.LauncherLayoutBuilder) ItemInfo(com.android.launcher3.model.data.ItemInfo) FolderInfo(com.android.launcher3.model.data.FolderInfo) Test(org.junit.Test)

Example 17 with TEST_PACKAGE

use of com.android.launcher3.util.LauncherModelHelper.TEST_PACKAGE in project android_packages_apps_Trebuchet by LineageOS.

the class GridSizeMigrationTaskV2Test method setUp.

@Before
public void setUp() {
    mModelHelper = new LauncherModelHelper();
    mContext = RuntimeEnvironment.application;
    mDb = mModelHelper.provider.getDb();
    mValidPackages = new HashSet<>();
    mValidPackages.add(TEST_PACKAGE);
    mValidPackages.add(testPackage1);
    mValidPackages.add(testPackage2);
    mValidPackages.add(testPackage3);
    mValidPackages.add(testPackage4);
    mValidPackages.add(testPackage5);
    mValidPackages.add(testPackage6);
    mValidPackages.add(testPackage7);
    mValidPackages.add(testPackage8);
    mValidPackages.add(testPackage9);
    mValidPackages.add(testPackage10);
    mIdp = InvariantDeviceProfile.INSTANCE.get(mContext);
    long userSerial = UserCache.INSTANCE.get(mContext).getSerialNumberForUser(Process.myUserHandle());
    dropTable(mDb, LauncherSettings.Favorites.TMP_TABLE);
    LauncherSettings.Favorites.addTableToDb(mDb, userSerial, false, LauncherSettings.Favorites.TMP_TABLE);
}
Also used : LauncherModelHelper(com.android.launcher3.util.LauncherModelHelper) Before(org.junit.Before)

Example 18 with TEST_PACKAGE

use of com.android.launcher3.util.LauncherModelHelper.TEST_PACKAGE in project android_packages_apps_Trebuchet by LineageOS.

the class LoaderCursorTest method getAppShortcutInfo_dontAllowMissing_validComponent.

@Test
public void getAppShortcutInfo_dontAllowMissing_validComponent() throws Exception {
    ComponentName cn = new ComponentName(TEST_PACKAGE, TEST_PACKAGE);
    shadowOf(mContext.getPackageManager()).addActivityIfNotPresent(cn);
    initCursor(ITEM_TYPE_APPLICATION, "");
    assertTrue(mLoaderCursor.moveToNext());
    WorkspaceItemInfo info = Executors.MODEL_EXECUTOR.submit(() -> mLoaderCursor.getAppShortcutInfo(new Intent().setComponent(cn), false, /* allowMissingTarget */
    true)).get();
    assertNotNull(info);
    assertTrue(PackageManagerHelper.isLauncherAppTarget(info.getIntent()));
}
Also used : ComponentName(android.content.ComponentName) Intent(android.content.Intent) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) Test(org.junit.Test)

Example 19 with TEST_PACKAGE

use of com.android.launcher3.util.LauncherModelHelper.TEST_PACKAGE in project android_packages_apps_Trebuchet by LineageOS.

the class DefaultLayoutProviderTest method testCustomProfileLoaded_with_folder.

@Test
public void testCustomProfileLoaded_with_folder() throws Exception {
    writeLayoutAndLoad(new LauncherLayoutBuilder().atHotseat(0).putFolder(android.R.string.copy).addApp(TEST_PACKAGE, TEST_PACKAGE).addApp(TEST_PACKAGE, TEST_PACKAGE).addApp(TEST_PACKAGE, TEST_PACKAGE).build());
    // Verify folder
    assertEquals(1, mModelHelper.getBgDataModel().workspaceItems.size());
    ItemInfo info = mModelHelper.getBgDataModel().workspaceItems.get(0);
    assertEquals(LauncherSettings.Favorites.ITEM_TYPE_FOLDER, info.itemType);
    assertEquals(3, ((FolderInfo) info).contents.size());
}
Also used : LauncherLayoutBuilder(com.android.launcher3.util.LauncherLayoutBuilder) ItemInfo(com.android.launcher3.model.data.ItemInfo) FolderInfo(com.android.launcher3.model.data.FolderInfo) Test(org.junit.Test)

Example 20 with TEST_PACKAGE

use of com.android.launcher3.util.LauncherModelHelper.TEST_PACKAGE in project android_packages_apps_Trebuchet by LineageOS.

the class SDWorkModeTest method setup.

@Before
public void setup() throws Exception {
    mModelHelper = new LauncherModelHelper();
    mTargetContext = RuntimeEnvironment.application;
    mIdp = InvariantDeviceProfile.INSTANCE.get(mTargetContext);
    ShadowOverrides.setProvider(UserEventDispatcher.class, c -> mock(UserEventDispatcher.class));
    Settings.Global.putFloat(mTargetContext.getContentResolver(), Settings.Global.WINDOW_ANIMATION_SCALE, 0);
    mModelHelper.installApp(TEST_PACKAGE);
    mLayoutBuilder = new LauncherLayoutBuilder();
}
Also used : UserEventDispatcher(com.android.launcher3.logging.UserEventDispatcher) LauncherLayoutBuilder(com.android.launcher3.util.LauncherLayoutBuilder) LauncherModelHelper(com.android.launcher3.util.LauncherModelHelper) Before(org.junit.Before)

Aggregations

Test (org.junit.Test)55 SmallTest (androidx.test.filters.SmallTest)36 LauncherLayoutBuilder (com.android.launcher3.util.LauncherLayoutBuilder)29 FrameLayout (android.widget.FrameLayout)25 Before (org.junit.Before)19 ItemInfo (com.android.launcher3.model.data.ItemInfo)18 LauncherModelHelper (com.android.launcher3.util.LauncherModelHelper)18 FolderInfo (com.android.launcher3.model.data.FolderInfo)12 TextView (android.widget.TextView)10 WidgetItem (com.android.launcher3.model.WidgetItem)10 WidgetsListHeaderEntry (com.android.launcher3.widget.model.WidgetsListHeaderEntry)10 WidgetsListSearchHeaderEntry (com.android.launcher3.widget.model.WidgetsListSearchHeaderEntry)10 Launcher (com.android.launcher3.Launcher)6 LauncherUIHelper.buildAndBindLauncher (com.android.launcher3.util.LauncherUIHelper.buildAndBindLauncher)6 AppWidgetProviderInfo (android.appwidget.AppWidgetProviderInfo)5 PackageManager (android.content.pm.PackageManager)5 Point (android.graphics.Point)5 TableRow (android.widget.TableRow)5 LauncherAppWidgetProviderInfo (com.android.launcher3.widget.LauncherAppWidgetProviderInfo)5 WidgetsListContentEntry (com.android.launcher3.widget.model.WidgetsListContentEntry)5