Search in sources :

Example 6 with LauncherModelHelper

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

the class GridBackupTableTest method setUp.

@Before
public void setUp() {
    mModelHelper = new LauncherModelHelper();
    mContext = RuntimeEnvironment.application;
    mDb = mModelHelper.provider.getDb();
    setupGridData();
}
Also used : LauncherModelHelper(com.android.launcher3.util.LauncherModelHelper) Before(org.junit.Before)

Example 7 with LauncherModelHelper

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

the class GridSizeMigrationTaskV2Test method setUp.

@Before
public void setUp() {
    mModelHelper = new LauncherModelHelper();
    mContext = RuntimeEnvironment.application;
    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 8 with LauncherModelHelper

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

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 9 with LauncherModelHelper

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

the class LauncherModelHelper method setupDefaultLayoutProvider.

/**
 * Sets up a mock provider to load the provided layout by default, next time the layout loads
 */
public LauncherModelHelper setupDefaultLayoutProvider(LauncherLayoutBuilder builder) throws Exception {
    Context context = RuntimeEnvironment.application;
    InvariantDeviceProfile idp = InvariantDeviceProfile.INSTANCE.get(context);
    idp.numRows = idp.numColumns = idp.numDatabaseHotseatIcons = DEFAULT_GRID_SIZE;
    idp.iconBitmapSize = DEFAULT_BITMAP_SIZE;
    Settings.Secure.putString(context.getContentResolver(), "launcher3.layout.provider", TEST_PROVIDER_AUTHORITY);
    shadowOf(context.getPackageManager()).addProviderIfNotPresent(new ComponentName("com.test", "Mock")).authority = TEST_PROVIDER_AUTHORITY;
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    builder.build(new OutputStreamWriter(bos));
    Uri layoutUri = LauncherProvider.getLayoutUri(TEST_PROVIDER_AUTHORITY, context);
    shadowOf(context.getContentResolver()).registerInputStream(layoutUri, new ByteArrayInputStream(bos.toByteArray()));
    return this;
}
Also used : Context(android.content.Context) ByteArrayInputStream(java.io.ByteArrayInputStream) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) ComponentName(android.content.ComponentName) OutputStreamWriter(java.io.OutputStreamWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Uri(android.net.Uri)

Example 10 with LauncherModelHelper

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

the class LauncherModelHelper method setupDefaultLayoutProvider.

/**
 * Sets up a mock provider to load the provided layout by default, next time the layout loads
 */
public LauncherModelHelper setupDefaultLayoutProvider(LauncherLayoutBuilder builder) throws Exception {
    InvariantDeviceProfile idp = InvariantDeviceProfile.INSTANCE.get(sandboxContext);
    idp.numRows = idp.numColumns = idp.numDatabaseHotseatIcons = DEFAULT_GRID_SIZE;
    idp.iconBitmapSize = DEFAULT_BITMAP_SIZE;
    UiDevice.getInstance(getInstrumentation()).executeShellCommand("settings put secure launcher3.layout.provider " + TEST_PROVIDER_AUTHORITY);
    ContentProvider cp = new TestInformationProvider() {

        @Override
        public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
            try {
                ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe();
                AutoCloseOutputStream outputStream = new AutoCloseOutputStream(pipe[1]);
                ByteArrayOutputStream bos = new ByteArrayOutputStream();
                builder.build(new OutputStreamWriter(bos));
                outputStream.write(bos.toByteArray());
                outputStream.flush();
                outputStream.close();
                return pipe[0];
            } catch (Exception e) {
                throw new FileNotFoundException(e.getMessage());
            }
        }
    };
    setupProvider(TEST_PROVIDER_AUTHORITY, cp);
    return this;
}
Also used : TestInformationProvider(com.android.launcher3.testing.TestInformationProvider) ContentProvider(android.content.ContentProvider) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) AutoCloseOutputStream(android.os.ParcelFileDescriptor.AutoCloseOutputStream) ParcelFileDescriptor(android.os.ParcelFileDescriptor) FileNotFoundException(java.io.FileNotFoundException) OutputStreamWriter(java.io.OutputStreamWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Uri(android.net.Uri) FileNotFoundException(java.io.FileNotFoundException) ExecutionException(java.util.concurrent.ExecutionException)

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