org.robolectric.manifest.AndroidManifest Java Examples
The following examples show how to use
org.robolectric.manifest.AndroidManifest.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CustomRobolectricTestRunner.java From RxAndroidOrm with Apache License 2.0 | 6 votes |
@Override protected AndroidManifest getAppManifest(Config config) { String path = PATH_MANIFEST; // android studio has a different execution root for tests than pure gradle // so we avoid here manual effort to get them running inside android studio if (!new File(path).exists()) { path = PATH_PREFIX + path; } config = overwriteConfig(config, CONFIG_MANIFEST, path); config = overwriteConfig(config, CONFIG_ASSET_DIR, PATH_ASSET); config = overwriteConfig(config, CONFIG_RESOURCE_DIR, PATH_RESOURCE); config = overwriteConfig(config, CONFIG_PACKAGE_NAME, PACKAGE_NAME); return super.getAppManifest(config); }
Example #2
Source File: AndroidUnitTestRunner.java From AndroidUnitTest with Apache License 2.0 | 6 votes |
@Override protected AndroidManifest getAppManifest(Config config) { String path = getPathManifest(); // android studio has a different execution root for tests than pure gradle // so we avoid here manual effort to get them running inside android studio if (!new File(path).exists()) { path = PATH_PREFIX + path; } config = overwriteConfig(config, CONFIG_MANIFEST, path); config = overwriteConfig(config, CONFIG_ASSET_DIR, getPathAssets()); config = overwriteConfig(config, CONFIG_RESOURCE_DIR, getPathResources()); if (packageName != null) { config = overwriteConfig(config, CONFIG_PACKAGE_NAME, packageName); } if (applicationClass != null) { config = overwriteConfig(config, CONFIG_APPLICATION, applicationClass.getCanonicalName()); } return super.getAppManifest(config); }
Example #3
Source File: CustomRobolectricTestRunner.java From Freezer with Apache License 2.0 | 6 votes |
@Override protected AndroidManifest getAppManifest(Config config) { String path = PATH_MANIFEST; // android studio has a different execution root for tests than pure gradle // so we avoid here manual effort to get them running inside android studio if (!new File(path).exists()) { path = PATH_PREFIX + path; } config = overwriteConfig(config, CONFIG_MANIFEST, path); config = overwriteConfig(config, CONFIG_ASSET_DIR, PATH_ASSET); config = overwriteConfig(config, CONFIG_RESOURCE_DIR, PATH_RESOURCE); config = overwriteConfig(config, CONFIG_PACKAGE_NAME, PACKAGE_NAME); return super.getAppManifest(config); }
Example #4
Source File: PermissionsTest.java From Forage with Mozilla Public License 2.0 | 5 votes |
/** * Test to check if libraries are adding extra permissions to the app manifest. */ @Test public void shouldMatchPermissions() { AndroidManifest manifest = new AndroidManifest( Fs.fileFromPath(MERGED_MANIFEST), null, null ); assertThat(new HashSet<>(manifest.getUsedPermissions())). containsExactly((Object[]) EXPECTED_PERMISSIONS); }
Example #5
Source File: LibraryRobolectricTestRunner.java From materialandroid with Apache License 2.0 | 5 votes |
@Override protected AndroidManifest getAppManifest(Config config) { AndroidManifest appManifest = super.getAppManifest(config); FsFile androidManifestFile = appManifest.getAndroidManifestFile(); if (androidManifestFile.exists()) { return appManifest; } else { androidManifestFile = FileFsFile.from(appManifest.getAndroidManifestFile().getPath() .replace("manifests/full", "manifests/aapt")); return new AndroidManifest(androidManifestFile, appManifest.getResDirectory(), appManifest.getAssetsDirectory()); } }
Example #6
Source File: AppRobolectricRunner.java From MVPAndroidBootstrap with Apache License 2.0 | 5 votes |
protected AndroidManifest getAppManifest(Config config) { AndroidManifest appManifest = super.getAppManifest(config); FsFile androidManifestFile = appManifest.getAndroidManifestFile(); if (androidManifestFile.exists()) { return appManifest; } else { String moduleRoot = getModuleRootPath(config); androidManifestFile = FileFsFile.from(moduleRoot, appManifest.getAndroidManifestFile().getPath().replace("bundles", "manifests/full")); FsFile resDirectory = FileFsFile.from(moduleRoot, appManifest.getResDirectory().getPath()); FsFile assetsDirectory = FileFsFile.from(moduleRoot, appManifest.getAssetsDirectory().getPath()); return new AndroidManifest(androidManifestFile, resDirectory, assetsDirectory); } }
Example #7
Source File: HokoGradleTestRunner.java From hoko-android with Apache License 2.0 | 5 votes |
@Override protected AndroidManifest getAppManifest(Config config) { if (config.constants() == Void.class) { Logger.error("Field 'constants' not specified in @Config annotation"); Logger.error("This is required when using RobolectricGradleTestRunner!"); throw new RuntimeException("No 'constants' field in @Config annotation!"); } final String type = getType(config); final String flavor = getFlavor(config); final String packageName = getPackageName(config); final FileFsFile res; final FileFsFile assets; final FileFsFile manifest; if (FileFsFile.from(BUILD_OUTPUT, "res").exists()) { res = FileFsFile.from(BUILD_OUTPUT, "res", flavor, type); } else { res = FileFsFile.from(BUILD_OUTPUT, "bundles", flavor, type, "res"); } if (FileFsFile.from(BUILD_OUTPUT, "assets").exists()) { assets = FileFsFile.from(BUILD_OUTPUT, "assets", flavor, type); } else { assets = FileFsFile.from(BUILD_OUTPUT, "bundles", flavor, type, "assets"); } if (FileFsFile.from(BUILD_OUTPUT, "manifests").exists()) { manifest = FileFsFile.from(BUILD_OUTPUT, "manifests", "androidTest", flavor, type, "AndroidManifest.xml"); } else { manifest = FileFsFile.from(BUILD_OUTPUT, "bundles", flavor, type, "AndroidManifest.xml"); } Logger.debug("Robolectric assets directory: " + assets.getPath()); Logger.debug(" Robolectric res directory: " + res.getPath()); Logger.debug(" Robolectric manifest path: " + manifest.getPath()); Logger.debug(" Robolectric package name: " + packageName); return new AndroidManifest(manifest, res, assets, packageName); }
Example #8
Source File: LibraryRobolectricTestRunner.java From SnackbarBuilder with Apache License 2.0 | 5 votes |
@Override protected AndroidManifest getAppManifest(Config config) { AndroidManifest appManifest = super.getAppManifest(config); FsFile androidManifestFile = appManifest.getAndroidManifestFile(); if (androidManifestFile.exists()) { return appManifest; } else { androidManifestFile = FileFsFile.from(appManifest.getAndroidManifestFile().getPath() .replace("manifests/full", "manifests/aapt")); return new AndroidManifest(androidManifestFile, appManifest.getResDirectory(), appManifest.getAssetsDirectory()); } }
Example #9
Source File: TickmateTestRunner.java From tickmate with GNU General Public License v3.0 | 5 votes |
protected AndroidManifest getAppManifest(Config config) { AndroidManifest appManifest = super.getAppManifest(config); FsFile androidManifestFile = appManifest.getAndroidManifestFile(); if (androidManifestFile.exists()) { return appManifest; } else { androidManifestFile = FileFsFile.from(MODULE_ROOT, "src/main/AndroidManifest.xml"); FsFile resDirectory = FileFsFile.from(MODULE_ROOT, "src/main/res"); FsFile assetsDirectory = FileFsFile.from(MODULE_ROOT, "src/main/assets"); return new AndroidManifest(androidManifestFile, resDirectory, assetsDirectory); } }
Example #10
Source File: CustomRobolectricTestRunner.java From RxAndroidOrm with Apache License 2.0 | 4 votes |
@Override protected int pickSdkVersion(Config config, AndroidManifest manifest) { config = overwriteConfig(config, CONFIG_SDK, String.valueOf(Build.VERSION_CODES.JELLY_BEAN)); return super.pickSdkVersion(config, manifest); }
Example #11
Source File: AndroidUnitTestRunner.java From AndroidUnitTest with Apache License 2.0 | 4 votes |
@Override protected int pickSdkVersion(Config config, AndroidManifest manifest) { config = overwriteConfig(config, CONFIG_SDK, String.valueOf(Build.VERSION_CODES.JELLY_BEAN)); return super.pickSdkVersion(config, manifest); }
Example #12
Source File: CustomRobolectricTestRunner.java From Freezer with Apache License 2.0 | 4 votes |
@Override protected int pickSdkVersion(Config config, AndroidManifest manifest) { config = overwriteConfig(config, CONFIG_SDK, String.valueOf(Build.VERSION_CODES.JELLY_BEAN)); return super.pickSdkVersion(config, manifest); }
Example #13
Source File: CustomRobolectricGradleTestRunner.java From Dagger-2-Example with Apache License 2.0 | 4 votes |
@Override protected AndroidManifest getAppManifest(Config config) { AndroidManifest appManifest = super.getAppManifest(config); appManifest.setPackageName("co.infinum.pokemon"); // needs to be the java package name, not applicationId return appManifest; }
Example #14
Source File: CustomRunner.java From algoliasearch-client-android with MIT License | 4 votes |
@Override protected AndroidManifest getAppManifest(Config config) { final String cwd = System.getProperty("user.dir"); Logger.debug("Current working directory: " + cwd); if (config.constants() == Void.class) { Logger.error("Field 'constants' not specified in @Config annotation"); Logger.error("This is required when using RobolectricGradleTestRunner!"); throw new RuntimeException("No 'constants' field in @Config annotation!"); } final String type = getType(config); final String flavor = getFlavor(config); final String packageName = getPackageName(config); final FileFsFile res; final FileFsFile assets; final FileFsFile manifest; if (FileFsFile.from(BUILD_OUTPUT, "res").exists()) { res = FileFsFile.from(BUILD_OUTPUT, "res", flavor, type); } else { res = FileFsFile.from(BUILD_OUTPUT, "bundles", flavor, type, "res"); } if (FileFsFile.from(BUILD_OUTPUT, "assets").exists()) { assets = FileFsFile.from(BUILD_OUTPUT, "assets", flavor, type); } else { assets = FileFsFile.from(BUILD_OUTPUT, "bundles", flavor, type, "assets"); } if (FileFsFile.from(BUILD_OUTPUT, "manifests").exists()) { // [CUSTOMIZED] The default implementation uses `full` instead of `aapt`. manifest = FileFsFile.from(BUILD_OUTPUT, "manifests", "aapt", flavor, type, "AndroidManifest.xml"); } else { manifest = FileFsFile.from(BUILD_OUTPUT, "bundles", flavor, type, "AndroidManifest.xml"); } Logger.debug("Robolectric assets directory: " + assets.getPath()); Logger.debug(" Robolectric res directory: " + res.getPath()); Logger.debug(" Robolectric manifest path: " + manifest.getPath()); Logger.debug(" Robolectric package name: " + packageName); return new AndroidManifest(manifest, res, assets, packageName); }