Search in sources :

Example 21 with TEST_PACKAGE

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

the class LauncherUIScrollTest 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);
    // LayoutBuilder with 3 workspace pages
    mLayoutBuilder = new LauncherLayoutBuilder().atWorkspace(0, mIdp.numRows - 1, 0).putApp(TEST_PACKAGE, TEST_PACKAGE).atWorkspace(0, mIdp.numRows - 1, 1).putApp(TEST_PACKAGE, TEST_PACKAGE).atWorkspace(0, mIdp.numRows - 1, 2).putApp(TEST_PACKAGE, TEST_PACKAGE);
}
Also used : UserEventDispatcher(com.android.launcher3.logging.UserEventDispatcher) LauncherLayoutBuilder(com.android.launcher3.util.LauncherLayoutBuilder) LauncherModelHelper(com.android.launcher3.util.LauncherModelHelper) Before(org.junit.Before)

Example 22 with TEST_PACKAGE

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

the class LauncherUIScrollTest method testWidgetsListScroll.

@Test
public void testWidgetsListScroll() throws Exception {
    // Install 100 widgets
    for (int i = 0; i < 100; i++) {
        mModelHelper.installCustomShortcut(TEST_PACKAGE + i, "shortcutProvider");
    }
    // Bind and open widgets
    Launcher launcher = loadLauncher();
    WidgetsFullSheet widgets = WidgetsFullSheet.show(launcher, false);
    doLayout(launcher);
    int currentScroll = widgets.getRecyclerView().getCurrentScrollY();
    launcher.dispatchGenericMotionEvent(createScrollEvent(-1));
    int newScroll = widgets.getRecyclerView().getCurrentScrollY();
    assertNotEquals("Widgets was not scrolled", currentScroll, newScroll);
    assertEquals("Workspace was scrolled", 0, launcher.getWorkspace().getNextPage());
}
Also used : LauncherUIHelper.buildAndBindLauncher(com.android.launcher3.util.LauncherUIHelper.buildAndBindLauncher) Launcher(com.android.launcher3.Launcher) WidgetsFullSheet(com.android.launcher3.widget.WidgetsFullSheet) Test(org.junit.Test)

Example 23 with TEST_PACKAGE

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

the class LauncherUIScrollTest method testAllAppsScroll.

@Test
public void testAllAppsScroll() throws Exception {
    // Install 100 apps
    for (int i = 0; i < 100; i++) {
        mModelHelper.installApp(TEST_PACKAGE + i);
    }
    // Bind and open all-apps
    Launcher launcher = loadLauncher();
    launcher.getStateManager().goToState(LauncherState.ALL_APPS, false);
    doLayout(launcher);
    int currentScroll = launcher.getAppsView().getActiveRecyclerView().getCurrentScrollY();
    launcher.dispatchGenericMotionEvent(createScrollEvent(-1));
    int newScroll = launcher.getAppsView().getActiveRecyclerView().getCurrentScrollY();
    assertNotEquals("All Apps was not scrolled", currentScroll, newScroll);
    assertEquals("Workspace was scrolled", 0, launcher.getWorkspace().getNextPage());
}
Also used : LauncherUIHelper.buildAndBindLauncher(com.android.launcher3.util.LauncherUIHelper.buildAndBindLauncher) Launcher(com.android.launcher3.Launcher) Test(org.junit.Test)

Example 24 with TEST_PACKAGE

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

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

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

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)

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