org.robolectric.res.Fs Java Examples

The following examples show how to use org.robolectric.res.Fs. 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: PermissionsTest.java    From Forage with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * 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 #3
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 #4
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);
}
 
Example #5
Source File: MapzenAndroidManifest.java    From open with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Creates a Robolectric configuration using default Android files relative to the specified base directory.
 * <p/>
 * The manifest will be baseDir/AndroidManifest.xml, res will be baseDir/res, and assets in baseDir/assets.
 *
 * @param baseDir the base directory of your Android project
 * @deprecated Use {@link #MapzenAndroidManifest(org.robolectric.res.FsFile, org.robolectric.res.FsFile, org.robolectric.res.FsFile)} instead.}
 */
public MapzenAndroidManifest(final File baseDir) {
  this(Fs.newFile(baseDir));
}