Search in sources :

Example 66 with TEST_PACKAGE

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

the class LauncherUIScrollTest method testFolderPageScroll.

@Test
public void testFolderPageScroll() throws Exception {
    // Add a folder with multiple icons
    FolderBuilder fb = mLayoutBuilder.atWorkspace(mIdp.numColumns / 2, mIdp.numRows / 2, 0).putFolder(0);
    for (int i = 0; i < 100; i++) {
        fb.addApp(TEST_PACKAGE, TEST_PACKAGE);
    }
    // Bind and open folder
    Launcher launcher = loadLauncher();
    doLayout(launcher);
    launcher.getWorkspace().getFirstMatch((i, v) -> v instanceof FolderIcon).performClick();
    ShadowLooper.idleMainLooper();
    doLayout(launcher);
    FolderPagedView folderPages = Folder.getOpen(launcher).getContent();
    assertEquals(0, folderPages.getNextPage());
    launcher.dispatchGenericMotionEvent(createScrollEvent(-1));
    assertNotEquals("Folder page was not scrolled", 0, folderPages.getNextPage());
    assertEquals("Workspace was scrolled", 0, launcher.getWorkspace().getNextPage());
}
Also used : Folder(com.android.launcher3.folder.Folder) Context(android.content.Context) PointerProperties(android.view.MotionEvent.PointerProperties) LauncherLayoutBuilder(com.android.launcher3.util.LauncherLayoutBuilder) FolderIcon(com.android.launcher3.folder.FolderIcon) RunWith(org.junit.runner.RunWith) LauncherUIHelper.buildAndBindLauncher(com.android.launcher3.util.LauncherUIHelper.buildAndBindLauncher) UserEventDispatcher(com.android.launcher3.logging.UserEventDispatcher) SystemClock(android.os.SystemClock) ShadowOverrides(com.android.launcher3.shadows.ShadowOverrides) Mode(org.robolectric.annotation.LooperMode.Mode) WidgetsFullSheet(com.android.launcher3.widget.WidgetsFullSheet) InputDevice(android.view.InputDevice) MotionEvent(android.view.MotionEvent) TEST_PACKAGE(com.android.launcher3.util.LauncherModelHelper.TEST_PACKAGE) Settings(android.provider.Settings) FolderPagedView(com.android.launcher3.folder.FolderPagedView) Before(org.junit.Before) Launcher(com.android.launcher3.Launcher) LauncherModelHelper(com.android.launcher3.util.LauncherModelHelper) ShadowLooper(org.robolectric.shadows.ShadowLooper) Test(org.junit.Test) LooperMode(org.robolectric.annotation.LooperMode) RuntimeEnvironment(org.robolectric.RuntimeEnvironment) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) DeviceProfile(com.android.launcher3.DeviceProfile) LauncherState(com.android.launcher3.LauncherState) FolderBuilder(com.android.launcher3.util.LauncherLayoutBuilder.FolderBuilder) RobolectricTestRunner(org.robolectric.RobolectricTestRunner) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) LauncherUIHelper.doLayout(com.android.launcher3.util.LauncherUIHelper.doLayout) Assert.assertEquals(org.junit.Assert.assertEquals) Mockito.mock(org.mockito.Mockito.mock) FolderPagedView(com.android.launcher3.folder.FolderPagedView) FolderBuilder(com.android.launcher3.util.LauncherLayoutBuilder.FolderBuilder) FolderIcon(com.android.launcher3.folder.FolderIcon) LauncherUIHelper.buildAndBindLauncher(com.android.launcher3.util.LauncherUIHelper.buildAndBindLauncher) Launcher(com.android.launcher3.Launcher) Test(org.junit.Test)

Example 67 with TEST_PACKAGE

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

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_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());
    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) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 68 with TEST_PACKAGE

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

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 69 with TEST_PACKAGE

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

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_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());
    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) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 70 with TEST_PACKAGE

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

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)

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