Search in sources :

Example 31 with TEST_PACKAGE

use of com.android.launcher3.util.LauncherModelHelper.TEST_PACKAGE in project android_packages_apps_Launcher3 by ProtonAOSP.

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_ACTIVITY).addApp(TEST_PACKAGE, TEST_ACTIVITY).addApp(TEST_PACKAGE, TEST_ACTIVITY).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) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 32 with TEST_PACKAGE

use of com.android.launcher3.util.LauncherModelHelper.TEST_PACKAGE in project android_packages_apps_Launcher3 by ProtonAOSP.

the class GridSizeMigrationTaskV2Test method setUp.

@Before
public void setUp() {
    mModelHelper = new LauncherModelHelper();
    mContext = mModelHelper.sandboxContext;
    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 33 with TEST_PACKAGE

use of com.android.launcher3.util.LauncherModelHelper.TEST_PACKAGE in project android_packages_apps_Launcher3 by ProtonAOSP.

the class ModelMultiCallbacksTest method setupWorkspacePages.

private void setupWorkspacePages(int pageCount) throws Exception {
    // Create a layout with 3 pages
    LauncherLayoutBuilder builder = new LauncherLayoutBuilder();
    for (int i = 0; i < pageCount; i++) {
        builder.atWorkspace(1, 1, i).putApp(TEST_PACKAGE, TEST_PACKAGE);
    }
    mModelHelper.setupDefaultLayoutProvider(builder);
}
Also used : LauncherLayoutBuilder(com.android.launcher3.util.LauncherLayoutBuilder)

Example 34 with TEST_PACKAGE

use of com.android.launcher3.util.LauncherModelHelper.TEST_PACKAGE in project android_packages_apps_Launcher3 by ProtonAOSP.

the class WidgetsTableUtilsTest method initTestWidgets.

private void initTestWidgets() {
    List<Point> widgetSizes = List.of(new Point(1, 1), new Point(2, 2), new Point(2, 3), new Point(2, 4), new Point(4, 4));
    ArrayList<WidgetItem> widgetItems = new ArrayList<>();
    widgetSizes.stream().forEach(widgetSize -> {
        AppWidgetProviderInfo info = createAppWidgetProviderInfo(ComponentName.createRelative(TEST_PACKAGE, ".WidgetProvider_" + widgetSize.x + "x" + widgetSize.y));
        LauncherAppWidgetProviderInfo widgetInfo = LauncherAppWidgetProviderInfo.fromProviderInfo(mContext, info);
        widgetInfo.spanX = widgetSize.x;
        widgetInfo.spanY = widgetSize.y;
        widgetItems.add(new WidgetItem(widgetInfo, mTestProfile, mIconCache));
    });
    mWidget1x1 = widgetItems.get(0);
    mWidget2x2 = widgetItems.get(1);
    mWidget2x3 = widgetItems.get(2);
    mWidget2x4 = widgetItems.get(3);
    mWidget4x4 = widgetItems.get(4);
}
Also used : LauncherAppWidgetProviderInfo(com.android.launcher3.widget.LauncherAppWidgetProviderInfo) ArrayList(java.util.ArrayList) AppWidgetProviderInfo(android.appwidget.AppWidgetProviderInfo) WidgetUtils.createAppWidgetProviderInfo(com.android.launcher3.util.WidgetUtils.createAppWidgetProviderInfo) LauncherAppWidgetProviderInfo(com.android.launcher3.widget.LauncherAppWidgetProviderInfo) WidgetItem(com.android.launcher3.model.WidgetItem) Point(android.graphics.Point)

Example 35 with TEST_PACKAGE

use of com.android.launcher3.util.LauncherModelHelper.TEST_PACKAGE in project android_packages_apps_Launcher3 by ProtonAOSP.

the class WidgetsListSearchHeaderViewHolderBinderTest method bindViewHolder_appWith3Widgets_shouldShowTheCorrectAppNameAndSubtitle.

@Test
public void bindViewHolder_appWith3Widgets_shouldShowTheCorrectAppNameAndSubtitle() {
    WidgetsListSearchHeaderHolder viewHolder = mViewHolderBinder.newViewHolder(new FrameLayout(mContext));
    WidgetsListHeader widgetsListHeader = viewHolder.mWidgetsListHeader;
    WidgetsListSearchHeaderEntry entry = generateSampleSearchHeader(APP_NAME, TEST_PACKAGE, /* numOfWidgets= */
    3);
    mViewHolderBinder.bindViewHolder(viewHolder, entry, /* position= */
    0, EMPTY_LIST);
    TextView appTitle = widgetsListHeader.findViewById(R.id.app_title);
    TextView appSubtitle = widgetsListHeader.findViewById(R.id.app_subtitle);
    assertThat(appTitle.getText()).isEqualTo(APP_NAME);
    assertThat(appSubtitle.getText()).isEqualTo(".SampleWidget0, .SampleWidget1, .SampleWidget2");
}
Also used : FrameLayout(android.widget.FrameLayout) TextView(android.widget.TextView) WidgetsListSearchHeaderEntry(com.android.launcher3.widget.model.WidgetsListSearchHeaderEntry) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

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