use of com.android.launcher3.util.LauncherLayoutBuilder in project android_packages_apps_Launcher3 by crdroidandroid.
the class DefaultLayoutProviderTest method testCustomProfileLoaded_with_widget.
@Test
public void testCustomProfileLoaded_with_widget() throws Exception {
String pendingAppPkg = "com.test.pending";
// Add a placeholder session info so that the widget exists
SessionParams params = new SessionParams(SessionParams.MODE_FULL_INSTALL);
params.setAppPackageName(pendingAppPkg);
PackageInstaller installer = mTargetContext.getPackageManager().getPackageInstaller();
int sessionId = installer.createSession(params);
SessionInfo sessionInfo = installer.getSessionInfo(sessionId);
setField(sessionInfo, "installerPackageName", "com.test");
setField(sessionInfo, "appIcon", BitmapInfo.LOW_RES_ICON);
writeLayoutAndLoad(new LauncherLayoutBuilder().atWorkspace(0, 1, 0).putWidget(pendingAppPkg, "PlaceholderWidget", 2, 2));
// Verify widget
assertEquals(1, mModelHelper.getBgDataModel().appWidgets.size());
ItemInfo info = mModelHelper.getBgDataModel().appWidgets.get(0);
assertEquals(LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET, info.itemType);
assertEquals(2, info.spanX);
assertEquals(2, info.spanY);
}
use of com.android.launcher3.util.LauncherLayoutBuilder in project android_packages_apps_Launcher3 by crdroidandroid.
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_PACKAGE).addApp(TEST_PACKAGE, TEST_PACKAGE).addApp(TEST_PACKAGE, TEST_PACKAGE).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());
}
use of com.android.launcher3.util.LauncherLayoutBuilder in project android_packages_apps_Launcher3 by crdroidandroid.
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);
}
use of com.android.launcher3.util.LauncherLayoutBuilder 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;
}
use of com.android.launcher3.util.LauncherLayoutBuilder 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;
}
Aggregations