Search in sources :

Example 51 with LauncherModelHelper

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

the class ModelMultiCallbacksTest method setUp.

@Before
public void setUp() throws Exception {
    mModelHelper = new LauncherModelHelper();
    mModelHelper.installApp(TEST_PACKAGE);
    mSpm = shadowOf(RuntimeEnvironment.application.getPackageManager());
    // Since robolectric tests run on main thread, we run the loader-UI calls on a temp thread,
    // so that we can wait appropriately for the loader to complete.
    mTempMainExecutor = new LooperExecutor(createAndStartNewForegroundLooper("tempMain"));
    ReflectionHelpers.setField(mModelHelper.getModel(), "mMainExecutor", mTempMainExecutor);
}
Also used : LooperExecutor(com.android.launcher3.util.LooperExecutor) LauncherModelHelper(com.android.launcher3.util.LauncherModelHelper) Before(org.junit.Before)

Example 52 with LauncherModelHelper

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

the class PackageInstallStateChangedTaskTest method setup.

@Before
public void setup() throws Exception {
    mModelHelper = new LauncherModelHelper();
    mModelHelper.initializeData("/package_install_state_change_task_data.txt");
}
Also used : LauncherModelHelper(com.android.launcher3.util.LauncherModelHelper) Before(org.junit.Before)

Example 53 with LauncherModelHelper

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

the class LoaderCursorTest method setup.

@Before
public void setup() {
    mModelHelper = new LauncherModelHelper();
    mContext = mModelHelper.sandboxContext;
    mIDP = InvariantDeviceProfile.INSTANCE.get(mContext);
    mApp = LauncherAppState.getInstance(mContext);
    mCursor = new MatrixCursor(new String[] { ICON, ICON_PACKAGE, ICON_RESOURCE, TITLE, _ID, CONTAINER, ITEM_TYPE, PROFILE_ID, SCREEN, CELLX, CELLY, RESTORED, INTENT });
    UserManagerState ums = new UserManagerState();
    mLoaderCursor = new LoaderCursor(mCursor, Favorites.CONTENT_URI, mApp, ums);
    ums.allUsers.put(0, Process.myUserHandle());
}
Also used : LauncherModelHelper(com.android.launcher3.util.LauncherModelHelper) MatrixCursor(android.database.MatrixCursor) Before(org.junit.Before)

Example 54 with LauncherModelHelper

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

the class PackageInstallStateChangedTaskTest method setup.

@Before
public void setup() throws Exception {
    mModelHelper = new LauncherModelHelper();
    mModelHelper.initializeData("package_install_state_change_task_data");
}
Also used : LauncherModelHelper(com.android.launcher3.util.LauncherModelHelper) Before(org.junit.Before)

Example 55 with LauncherModelHelper

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

the class WidgetsPredicationUpdateTaskTest method setup.

@Before
public void setup() throws Exception {
    mModelHelper = new LauncherModelHelper();
    MockitoAnnotations.initMocks(this);
    doAnswer(invocation -> {
        ComponentWithLabel componentWithLabel = invocation.getArgument(0);
        return componentWithLabel.getComponent().getShortClassName();
    }).when(mIconCache).getTitleNoCache(any());
    mUserHandle = myUserHandle();
    mApp1Provider1 = createAppWidgetProviderInfo(ComponentName.createRelative("app1", "provider1"));
    mApp1Provider2 = createAppWidgetProviderInfo(ComponentName.createRelative("app1", "provider2"));
    mApp2Provider1 = createAppWidgetProviderInfo(ComponentName.createRelative("app2", "provider1"));
    mApp4Provider1 = createAppWidgetProviderInfo(ComponentName.createRelative("app4", "provider1"));
    mApp4Provider2 = createAppWidgetProviderInfo(ComponentName.createRelative("app4", ".provider2"));
    mApp5Provider1 = createAppWidgetProviderInfo(ComponentName.createRelative("app5", "provider1"));
    allWidgets = Arrays.asList(mApp1Provider1, mApp1Provider2, mApp2Provider1, mApp4Provider1, mApp4Provider2, mApp5Provider1);
    AppWidgetManager manager = mModelHelper.sandboxContext.spyService(AppWidgetManager.class);
    doReturn(allWidgets).when(manager).getInstalledProviders();
    doReturn(allWidgets).when(manager).getInstalledProvidersForProfile(eq(myUserHandle()));
    doAnswer(i -> {
        String pkg = i.getArgument(0);
        Log.e("Hello", "Getting v " + pkg);
        return TextUtils.isEmpty(pkg) ? allWidgets : allWidgets.stream().filter(a -> pkg.equals(a.provider.getPackageName())).collect(Collectors.toList());
    }).when(manager).getInstalledProvidersForPackage(any(), eq(myUserHandle()));
    // 2 widgets, app4/provider1 & app5/provider1, have already been added to the workspace.
    mModelHelper.initializeData("widgets_predication_update_task_data");
    MAIN_EXECUTOR.submit(() -> mModelHelper.getModel().addCallbacks(mCallback)).get();
    MODEL_EXECUTOR.post(() -> mModelHelper.getBgDataModel().widgetsModel.update(LauncherAppState.getInstance(mModelHelper.sandboxContext), /* packageUser= */
    null));
    MODEL_EXECUTOR.submit(() -> {
    }).get();
    MAIN_EXECUTOR.submit(() -> {
    }).get();
}
Also used : LauncherModelHelper(com.android.launcher3.util.LauncherModelHelper) AppWidgetManager(android.appwidget.AppWidgetManager) ComponentWithLabel(com.android.launcher3.icons.ComponentWithLabel) Before(org.junit.Before)

Aggregations

LauncherModelHelper (com.android.launcher3.util.LauncherModelHelper)55 Before (org.junit.Before)55 Context (android.content.Context)8 InvariantDeviceProfile (com.android.launcher3.InvariantDeviceProfile)7 PackageInfo (android.content.pm.PackageInfo)6 Uri (android.net.Uri)6 UserManager (android.os.UserManager)6 IconCache (com.android.launcher3.icons.IconCache)6 CachingLogic (com.android.launcher3.icons.cache.CachingLogic)6 ItemInfo (com.android.launcher3.model.data.ItemInfo)6 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)6 IntArray (com.android.launcher3.util.IntArray)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 OutputStreamWriter (java.io.OutputStreamWriter)6 AppWidgetManager (android.appwidget.AppWidgetManager)5 ComponentWithLabel (com.android.launcher3.icons.ComponentWithLabel)5 ComponentName (android.content.ComponentName)4 ContentProvider (android.content.ContentProvider)4 MatrixCursor (android.database.MatrixCursor)4 ParcelFileDescriptor (android.os.ParcelFileDescriptor)4