org.robolectric.AndroidManifest Java Examples

The following examples show how to use org.robolectric.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: RobolectricGradleTestRunner.java    From android-alltest-gradle-sample with GNU General Public License v2.0 6 votes vote down vote up
@Override
 protected AndroidManifest getAppManifest(Config config) {
   //String appRoot = "D:\\TmpCodingProjects\\TripComputer\\app\\src\\main\\";
   String appRoot = "../app/src/main/";
   String manifestPath = appRoot + "AndroidManifest.xml";
   String resDir = appRoot + "res";
   String assetsDir = appRoot + "assets";
   AndroidManifest manifest = createAppManifest(Fs.fileFromPath(manifestPath),
     Fs.fileFromPath(resDir),
     Fs.fileFromPath(assetsDir));

// If you change the package - don't forget to change the build.gradle and the AndroidManifest.xml
   manifest.setPackageName("com.soagrowers.android");
   // Robolectric is already going to look in the  'app' dir ...
   // so no need to add to package name
   return manifest;
 }
 
Example #2
Source File: NoxRobolectricTestRunner.java    From Nox with Apache License 2.0 5 votes vote down vote up
@Override protected AndroidManifest getAppManifest(Config config) {
  String manifestProperty = "../nox/src/test/AndroidManifest.xml";
  String resProperty = "../nox/src/main/res";
  return new AndroidManifest(Fs.fileFromPath(manifestProperty), Fs.fileFromPath(resProperty)) {
    @Override public int getTargetSdkVersion() {
      return MAX_SDK_SUPPORTED_BY_ROBOLECTRIC;
    }
  };
}
 
Example #3
Source File: FullEnvTestLifeCycle.java    From matomo-sdk-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public Application createApplication(Method method, AndroidManifest appManifest, Config config) {
    // FIXME If a future version of Robolectric implements "setInstallerPackageName", remove this.
    RobolectricPackageManager oldManager = Robolectric.packageManager;
    RobolectricPackageManager newManager = new FullEnvPackageManager();
    for (PackageInfo pkg : oldManager.getInstalledPackages(0))
        newManager.addPackage(pkg);
    Robolectric.packageManager = newManager;
    return new MatomoTestApplication();
}
 
Example #4
Source File: MapzenTestRunner.java    From open with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Uses custom manifest as workaround to maintain backward compatibility with library projects
 * that do not yet include the <code>&lt;application/&gt;</code> tag in AndroidManifest.xml.
 * <p />
 * See https://github.com/robolectric/robolectric/pull/1309 for more info.
 */
@Override
protected AndroidManifest createAppManifest(FsFile manifestFile,
        FsFile resDir, FsFile assetsDir) {
    AndroidManifest manifest = new MapzenAndroidManifest(manifestFile, resDir, assetsDir);
    String packageName = System.getProperty("android.package");
    manifest.setPackageName(packageName);
    return manifest;
}
 
Example #5
Source File: MapzenTestRunner.java    From open with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected AndroidManifest getAppManifest(Config config) {
    String manifestProperty = System.getProperty("android.manifest");
    if (config.manifest().equals(Config.DEFAULT) && manifestProperty != null) {
        String resProperty = System.getProperty("android.resources");
        String assetsProperty = System.getProperty("android.assets");
        AndroidManifest androidManifest = new AndroidManifest(
                Fs.fileFromPath(manifestProperty),
                Fs.fileFromPath(resProperty),
                Fs.fileFromPath(assetsProperty));
        androidManifest.setPackageName("com.mapzen.open");
        return androidManifest;
    }
    return super.getAppManifest(config);
}