Search in sources :

Example 36 with TEST_PACKAGE

use of com.android.launcher3.util.LauncherModelHelper.TEST_PACKAGE in project android_packages_apps_404Launcher by P-404.

the class DefaultLayoutProviderTest method testCustomProfileLoaded_with_icon_on_hotseat.

@Test
public void testCustomProfileLoaded_with_icon_on_hotseat() throws Exception {
    writeLayoutAndLoad(new LauncherLayoutBuilder().atHotseat(0).putApp(TEST_PACKAGE, TEST_ACTIVITY));
    // 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_APPLICATION, info.itemType);
}
Also used : LauncherLayoutBuilder(com.android.launcher3.util.LauncherLayoutBuilder) ItemInfo(com.android.launcher3.model.data.ItemInfo) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 37 with TEST_PACKAGE

use of com.android.launcher3.util.LauncherModelHelper.TEST_PACKAGE in project android_packages_apps_404Launcher by P-404.

the class WidgetsListHeaderViewHolderBinderTest method bindViewHolder_appWith3Widgets_shouldShowTheCorrectAppNameAndSubtitle.

@Test
public void bindViewHolder_appWith3Widgets_shouldShowTheCorrectAppNameAndSubtitle() {
    WidgetsListHeaderHolder viewHolder = mViewHolderBinder.newViewHolder(new FrameLayout(mContext));
    WidgetsListHeader widgetsListHeader = viewHolder.mWidgetsListHeader;
    WidgetsListHeaderEntry entry = generateSampleAppHeader(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("3 widgets");
}
Also used : FrameLayout(android.widget.FrameLayout) TextView(android.widget.TextView) WidgetsListHeaderEntry(com.android.launcher3.widget.model.WidgetsListHeaderEntry) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 38 with TEST_PACKAGE

use of com.android.launcher3.util.LauncherModelHelper.TEST_PACKAGE in project android_packages_apps_404Launcher by P-404.

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)

Example 39 with TEST_PACKAGE

use of com.android.launcher3.util.LauncherModelHelper.TEST_PACKAGE in project android_packages_apps_404Launcher by P-404.

the class WidgetsListTableViewHolderBinderTest method bindViewHolder_appWith3Widgets_shouldHave3Widgets.

@Test
public void bindViewHolder_appWith3Widgets_shouldHave3Widgets() throws Exception {
    WidgetsRowViewHolder viewHolder = mViewHolderBinder.newViewHolder(new FrameLayout(mContext));
    WidgetsListContentEntry entry = generateSampleAppWithWidgets(APP_NAME, TEST_PACKAGE, /* numOfWidgets= */
    3);
    mViewHolderBinder.bindViewHolder(viewHolder, entry, /* position= */
    0, EMPTY_LIST);
    Executors.MAIN_EXECUTOR.submit(() -> {
    }).get();
    // THEN the table container has one row, which contains 3 widgets.
    // View:  .SampleWidget0 | .SampleWidget1 | .SampleWidget2
    assertThat(viewHolder.tableContainer.getChildCount()).isEqualTo(1);
    TableRow row = (TableRow) viewHolder.tableContainer.getChildAt(0);
    assertThat(row.getChildCount()).isEqualTo(3);
    // Widget 0 label is .SampleWidget0.
    assertWidgetCellWithLabel(row.getChildAt(0), ".SampleWidget0");
    // Widget 1 label is .SampleWidget1.
    assertWidgetCellWithLabel(row.getChildAt(1), ".SampleWidget1");
    // Widget 2 label is .SampleWidget2.
    assertWidgetCellWithLabel(row.getChildAt(2), ".SampleWidget2");
}
Also used : FrameLayout(android.widget.FrameLayout) TableRow(android.widget.TableRow) WidgetsListContentEntry(com.android.launcher3.widget.model.WidgetsListContentEntry) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 40 with TEST_PACKAGE

use of com.android.launcher3.util.LauncherModelHelper.TEST_PACKAGE in project android_packages_apps_404Launcher by P-404.

the class WidgetsListHeaderViewHolderBinderTest method bindViewHolder_shouldAttachOnHeaderClickListener.

@Test
public void bindViewHolder_shouldAttachOnHeaderClickListener() {
    WidgetsListHeaderHolder viewHolder = mViewHolderBinder.newViewHolder(new FrameLayout(mContext));
    WidgetsListHeader widgetsListHeader = viewHolder.mWidgetsListHeader;
    WidgetsListHeaderEntry entry = generateSampleAppHeader(APP_NAME, TEST_PACKAGE, /* numOfWidgets= */
    3);
    mViewHolderBinder.bindViewHolder(viewHolder, entry, /* position= */
    0, EMPTY_LIST);
    widgetsListHeader.callOnClick();
    verify(mOnHeaderClickListener).onHeaderClicked(eq(true), eq(PackageUserKey.fromPackageItemInfo(entry.mPkgItem)));
}
Also used : FrameLayout(android.widget.FrameLayout) WidgetsListHeaderEntry(com.android.launcher3.widget.model.WidgetsListHeaderEntry) 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