org.robolectric.res.FsFile Java Examples

The following examples show how to use org.robolectric.res.FsFile. 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: MapzenAndroidManifest.java    From open with GNU General Public License v3.0 6 votes vote down vote up
protected List<FsFile> findLibraries() {
  FsFile baseDir = getBaseDir();
  List<FsFile> libraryBaseDirs = new ArrayList<FsFile>();

  Properties properties = getProperties(baseDir.join("project.properties"));
  // get the project.properties overrides and apply them (if any)
  Properties overrideProperties = getProperties(baseDir.join("test-project.properties"));
  if (overrideProperties!=null) properties.putAll(overrideProperties);
  if (properties != null) {
    int libRef = 1;
    String lib;
    while ((lib = properties.getProperty("android.library.reference." + libRef)) != null) {
      FsFile libraryBaseDir = baseDir.join(lib);
      if (libraryBaseDir.isDirectory()) {
        // Ignore directories without any files
        FsFile[] libraryBaseDirFiles = libraryBaseDir.listFiles();
        if (libraryBaseDirFiles != null && libraryBaseDirFiles.length > 0) {
          libraryBaseDirs.add(libraryBaseDir);
        }
      }

      libRef++;
    }
  }
  return libraryBaseDirs;
}
 
Example #2
Source File: LibraryRobolectricTestRunner.java    From materialandroid with Apache License 2.0 5 votes vote down vote up
@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 #3
Source File: AppRobolectricRunner.java    From MVPAndroidBootstrap with Apache License 2.0 5 votes vote down vote up
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 #4
Source File: LibraryRobolectricTestRunner.java    From SnackbarBuilder with Apache License 2.0 5 votes vote down vote up
@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 #5
Source File: TickmateTestRunner.java    From tickmate with GNU General Public License v3.0 5 votes vote down vote up
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 #6
Source File: MapzenAndroidManifest.java    From open with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a Robolectric configuration using specified locations.
 *
 * @param androidManifestFile location of the AndroidManifest.xml file
 * @param resDirectory        location of the res directory
 * @param assetsDirectory     location of the assets directory
 */
public MapzenAndroidManifest(FsFile androidManifestFile, FsFile resDirectory,
        FsFile assetsDirectory) {
  super(androidManifestFile, resDirectory, assetsDirectory);
  this.androidManifestFile = androidManifestFile;
  this.resDirectory = resDirectory;
  this.assetsDirectory = assetsDirectory;
}
 
Example #7
Source File: MapzenAndroidManifest.java    From open with GNU General Public License v3.0 5 votes vote down vote up
protected void createLibraryManifests() {
  libraryManifests = new ArrayList<AndroidManifest>();
  if (libraryDirectories == null) {
    libraryDirectories = findLibraries();
  }

  for (FsFile libraryBaseDir : libraryDirectories) {
    MapzenAndroidManifest libraryManifest = createLibraryAndroidManifest(libraryBaseDir);
    libraryManifest.createLibraryManifests();
    libraryManifests.add(libraryManifest);
  }
}
 
Example #8
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 #9
Source File: MapzenAndroidManifest.java    From open with GNU General Public License v3.0 4 votes vote down vote up
public MapzenAndroidManifest(final FsFile androidManifestFile, final FsFile resDirectory) {
  this(androidManifestFile, resDirectory, resDirectory.getParent().join(DEFAULT_ASSETS_FOLDER));
}
 
Example #10
Source File: MapzenAndroidManifest.java    From open with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @deprecated Use {@link #MapzenAndroidManifest(org.robolectric.res.FsFile, org.robolectric.res.FsFile, org.robolectric.res.FsFile)} instead.}
 */
public MapzenAndroidManifest(final FsFile baseDir) {
  this(baseDir.join(DEFAULT_MANIFEST_NAME), baseDir.join(DEFAULT_RES_FOLDER),
      baseDir.join(DEFAULT_ASSETS_FOLDER));
}
 
Example #11
Source File: MapzenAndroidManifest.java    From open with GNU General Public License v3.0 4 votes vote down vote up
public void setLibraryDirectories(List<FsFile> libraryDirectories) {
  this.libraryDirectories = libraryDirectories;
}
 
Example #12
Source File: MapzenAndroidManifest.java    From open with GNU General Public License v3.0 4 votes vote down vote up
protected FsFile getBaseDir() {
  return getResDirectory().getParent();
}
 
Example #13
Source File: MapzenAndroidManifest.java    From open with GNU General Public License v3.0 4 votes vote down vote up
protected MapzenAndroidManifest createLibraryAndroidManifest(FsFile libraryBaseDir) {
  return new MapzenAndroidManifest(libraryBaseDir);
}
 
Example #14
Source File: MapzenAndroidManifest.java    From open with GNU General Public License v3.0 4 votes vote down vote up
public FsFile getResDirectory() {
  return resDirectory;
}
 
Example #15
Source File: MapzenAndroidManifest.java    From open with GNU General Public License v3.0 4 votes vote down vote up
public FsFile getAssetsDirectory() {
  return assetsDirectory;
}