Search in sources :

Example 1 with LauncherModelHelper

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

the class WidgetsPredicationUpdateTaskTest method setup.

@Before
public void setup() throws Exception {
    MockitoAnnotations.initMocks(this);
    doAnswer(invocation -> {
        ComponentWithLabel componentWithLabel = invocation.getArgument(0);
        return componentWithLabel.getComponent().getShortClassName();
    }).when(mIconCache).getTitleNoCache(any());
    mContext = RuntimeEnvironment.application;
    mModelHelper = new LauncherModelHelper();
    mUserHandle = Process.myUserHandle();
    mTestProfile = new InvariantDeviceProfile();
    // 2 widgets, app4/provider1 & app5/provider1, have already been added to the workspace.
    mModelHelper.initializeData("/widgets_predication_update_task_data.txt");
    ShadowPackageManager packageManager = shadowOf(mContext.getPackageManager());
    mApp1Provider1.provider = ComponentName.createRelative("app1", "provider1");
    ReflectionHelpers.setField(mApp1Provider1, "providerInfo", packageManager.addReceiverIfNotPresent(mApp1Provider1.provider));
    mApp1Provider2.provider = ComponentName.createRelative("app1", "provider2");
    ReflectionHelpers.setField(mApp1Provider2, "providerInfo", packageManager.addReceiverIfNotPresent(mApp1Provider2.provider));
    mApp2Provider1.provider = ComponentName.createRelative("app2", "provider1");
    ReflectionHelpers.setField(mApp2Provider1, "providerInfo", packageManager.addReceiverIfNotPresent(mApp2Provider1.provider));
    mApp4Provider1.provider = ComponentName.createRelative("app4", "provider1");
    ReflectionHelpers.setField(mApp4Provider1, "providerInfo", packageManager.addReceiverIfNotPresent(mApp4Provider1.provider));
    mApp4Provider2.provider = ComponentName.createRelative("app4", ".provider2");
    ReflectionHelpers.setField(mApp4Provider2, "providerInfo", packageManager.addReceiverIfNotPresent(mApp4Provider2.provider));
    mApp5Provider1.provider = ComponentName.createRelative("app5", "provider1");
    ReflectionHelpers.setField(mApp5Provider1, "providerInfo", packageManager.addReceiverIfNotPresent(mApp5Provider1.provider));
    ShadowAppWidgetManager shadowAppWidgetManager = shadowOf(mContext.getSystemService(AppWidgetManager.class));
    shadowAppWidgetManager.addInstalledProvider(mApp1Provider1);
    shadowAppWidgetManager.addInstalledProvider(mApp1Provider2);
    shadowAppWidgetManager.addInstalledProvider(mApp2Provider1);
    shadowAppWidgetManager.addInstalledProvider(mApp4Provider1);
    shadowAppWidgetManager.addInstalledProvider(mApp4Provider2);
    shadowAppWidgetManager.addInstalledProvider(mApp5Provider1);
    mModelHelper.getModel().addCallbacks(mCallback);
    MODEL_EXECUTOR.post(() -> mModelHelper.getBgDataModel().widgetsModel.update(LauncherAppState.getInstance(mContext), /* packageUser= */
    null));
    waitUntilIdle();
}
Also used : ShadowPackageManager(org.robolectric.shadows.ShadowPackageManager) LauncherModelHelper(com.android.launcher3.util.LauncherModelHelper) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) ShadowAppWidgetManager(org.robolectric.shadows.ShadowAppWidgetManager) AppWidgetManager(android.appwidget.AppWidgetManager) ComponentWithLabel(com.android.launcher3.icons.ComponentWithLabel) ShadowAppWidgetManager(org.robolectric.shadows.ShadowAppWidgetManager) Before(org.junit.Before)

Example 2 with LauncherModelHelper

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

the class AddWorkspaceItemsTaskTest method setup.

@Before
public void setup() {
    mModelHelper = new LauncherModelHelper();
    mTargetContext = RuntimeEnvironment.application;
    mIdp = InvariantDeviceProfile.INSTANCE.get(mTargetContext);
    mIdp.numColumns = mIdp.numRows = 5;
    mAppState = LauncherAppState.getInstance(mTargetContext);
    mExistingScreens = new IntArray();
    mScreenOccupancy = new IntSparseArrayMap<>();
    mNewScreens = new IntArray();
}
Also used : IntArray(com.android.launcher3.util.IntArray) LauncherModelHelper(com.android.launcher3.util.LauncherModelHelper) Before(org.junit.Before)

Example 3 with LauncherModelHelper

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

the class BackupRestoreTest method setUp.

@Before
public void setUp() {
    setupUserManager();
    setupBackupManager();
    mModelHelper = new LauncherModelHelper();
    RestoreDbTask.setPending(RuntimeEnvironment.application, true);
    mDb = mModelHelper.provider.getDb();
    mIdp = InvariantDeviceProfile.INSTANCE.get(RuntimeEnvironment.application);
}
Also used : LauncherModelHelper(com.android.launcher3.util.LauncherModelHelper) Before(org.junit.Before)

Example 4 with LauncherModelHelper

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

the class CacheDataUpdatedTaskTest method setup.

@Before
public void setup() throws Exception {
    mModelHelper = new LauncherModelHelper();
    mModelHelper.initializeData("/cache_data_updated_task_data.txt");
    // Add placeholder entries in the cache to simulate update
    Context context = RuntimeEnvironment.application;
    IconCache iconCache = LauncherAppState.getInstance(context).getIconCache();
    CachingLogic<ItemInfo> placeholderLogic = new CachingLogic<ItemInfo>() {

        @Override
        public ComponentName getComponent(ItemInfo info) {
            return info.getTargetComponent();
        }

        @Override
        public UserHandle getUser(ItemInfo info) {
            return info.user;
        }

        @Override
        public CharSequence getLabel(ItemInfo info) {
            return NEW_LABEL_PREFIX + info.id;
        }

        @NonNull
        @Override
        public BitmapInfo loadIcon(Context context, ItemInfo info) {
            return BitmapInfo.of(Bitmap.createBitmap(1, 1, Config.ARGB_8888), Color.RED);
        }
    };
    UserManager um = context.getSystemService(UserManager.class);
    for (ItemInfo info : mModelHelper.getBgDataModel().itemsIdMap) {
        iconCache.addIconToDBAndMemCache(info, placeholderLogic, new PackageInfo(), um.getSerialNumberForUser(info.user), true);
    }
}
Also used : Context(android.content.Context) ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) UserManager(android.os.UserManager) PackageInfo(android.content.pm.PackageInfo) LauncherModelHelper(com.android.launcher3.util.LauncherModelHelper) IconCache(com.android.launcher3.icons.IconCache) CachingLogic(com.android.launcher3.icons.cache.CachingLogic) Before(org.junit.Before)

Example 5 with LauncherModelHelper

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

the class DefaultLayoutProviderTest method setUp.

@Before
public void setUp() {
    mModelHelper = new LauncherModelHelper();
    mTargetContext = RuntimeEnvironment.application;
    shadowOf(mTargetContext.getPackageManager()).addActivityIfNotPresent(new ComponentName(TEST_PACKAGE, TEST_PACKAGE));
}
Also used : LauncherModelHelper(com.android.launcher3.util.LauncherModelHelper) ComponentName(android.content.ComponentName) Before(org.junit.Before)

Aggregations

LauncherModelHelper (com.android.launcher3.util.LauncherModelHelper)12 Before (org.junit.Before)12 ComponentName (android.content.ComponentName)2 Context (android.content.Context)2 InvariantDeviceProfile (com.android.launcher3.InvariantDeviceProfile)2 AppWidgetManager (android.appwidget.AppWidgetManager)1 PackageInfo (android.content.pm.PackageInfo)1 Uri (android.net.Uri)1 UserManager (android.os.UserManager)1 ComponentWithLabel (com.android.launcher3.icons.ComponentWithLabel)1 IconCache (com.android.launcher3.icons.IconCache)1 CachingLogic (com.android.launcher3.icons.cache.CachingLogic)1 ItemInfo (com.android.launcher3.model.data.ItemInfo)1 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)1 ShadowLooperExecutor (com.android.launcher3.shadows.ShadowLooperExecutor)1 IntArray (com.android.launcher3.util.IntArray)1 LauncherLayoutBuilder (com.android.launcher3.util.LauncherLayoutBuilder)1 LooperExecutor (com.android.launcher3.util.LooperExecutor)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1