use of org.robolectric.res.FsFile in project RoboBinding by RoboBinding.
the class TestUtil method resourceFile.
public static FsFile resourceFile(String... pathParts) {
File testDir = Util.file("src", "test", "resources");
FsFile resourcesBaseDir = Fs.newFile(testDir);
return resourcesBaseDir.join(pathParts);
}
use of org.robolectric.res.FsFile in project robolectric by robolectric.
the class BuckManifestFactory method create.
@Override
public AndroidManifest create(ManifestIdentifier manifestIdentifier) {
String buckResDirs = System.getProperty(BUCK_ROBOLECTRIC_RES_DIRECTORIES);
String buckAssetsDirs = System.getProperty(BUCK_ROBOLECTRIC_ASSETS_DIRECTORIES);
String packageName = manifestIdentifier.getPackageName();
FsFile manifestFile = manifestIdentifier.getManifestFile();
final List<String> buckResources = buckResDirs == null ? null : Arrays.asList(buckResDirs.split(File.pathSeparator));
final List<String> buckAssets = buckAssetsDirs == null ? null : Arrays.asList(buckAssetsDirs.split(File.pathSeparator));
final FsFile resDir = (buckResources == null || "".equals(buckResources)) ? null : Fs.fileFromPath(buckResources.get(buckResources.size() - 1));
final FsFile assetsDir = (buckAssets == null || "".equals(buckAssets)) ? null : Fs.fileFromPath(buckAssets.get(buckAssets.size() - 1));
Logger.debug("Robolectric assets directory: " + (assetsDir == null ? null : assetsDir.getPath()));
Logger.debug(" Robolectric res directory: " + (resDir == null ? null : resDir.getPath()));
Logger.debug(" Robolectric manifest path: " + manifestFile.getPath());
Logger.debug(" Robolectric package name: " + packageName);
return new AndroidManifest(manifestFile, resDir, assetsDir, packageName) {
@Override
public List<ResourcePath> getIncludedResourcePaths() {
// Needs stable ordering and no duplicates
Collection<ResourcePath> resourcePaths = new LinkedHashSet<>();
resourcePaths.add(super.getResourcePath());
// Add all the buck resource folders, no duplicates as they are being added to a set.
if (buckResources != null) {
ListIterator<String> it = buckResources.listIterator(buckResources.size());
while (it.hasPrevious()) {
resourcePaths.add(new ResourcePath(getRClass(), Fs.fileFromPath(it.previous()), getAssetsDirectory()));
}
}
return new ArrayList<>(resourcePaths);
}
};
}
use of org.robolectric.res.FsFile in project robolectric by robolectric.
the class DefaultManifestFactory method resolveFile.
private FsFile resolveFile(String manifestConfig) {
FsFile manifestFile;
URL manifestUrl = getClass().getResource(manifestConfig);
if (manifestUrl == null || !manifestUrl.getProtocol().equals("file")) {
throw new IllegalArgumentException("couldn't find '" + manifestConfig + "'");
}
manifestFile = Fs.fileFromPath(manifestUrl.getPath());
return manifestFile;
}
use of org.robolectric.res.FsFile in project robolectric by robolectric.
the class GradleManifestFactory method create.
@Override
public AndroidManifest create(ManifestIdentifier manifestIdentifier) {
FsFile manifestFile = manifestIdentifier.getManifestFile();
FsFile resDir = manifestIdentifier.getResDir();
FsFile assetDir = manifestIdentifier.getAssetDir();
final String packageName = manifestIdentifier.getPackageName();
Logger.debug("Robolectric assets directory: " + assetDir.getPath());
Logger.debug(" Robolectric res directory: " + resDir.getPath());
Logger.debug(" Robolectric manifest path: " + manifestFile.getPath());
Logger.debug(" Robolectric package name: " + packageName);
return new AndroidManifest(manifestFile, resDir, assetDir, packageName);
}
use of org.robolectric.res.FsFile in project robolectric by robolectric.
the class MavenManifestFactory method create.
@Override
public AndroidManifest create(ManifestIdentifier manifestIdentifier) {
AndroidManifest appManifest;
FsFile manifestFile = manifestIdentifier.getManifestFile();
if (manifestFile == null) {
appManifest = createDummyManifest(manifestIdentifier.getPackageName());
} else if (!manifestFile.exists()) {
System.out.println("WARNING: No manifest file found at " + manifestFile.getPath() + ".");
System.out.println("Falling back to the Android OS resources only.");
System.out.println("To remove this warning, annotate your test class with @Config(manifest=Config.NONE).");
appManifest = createDummyManifest(manifestIdentifier.getPackageName());
} else {
FsFile resDir = manifestIdentifier.getResDir();
FsFile assetDir = manifestIdentifier.getAssetDir();
String packageName = manifestIdentifier.getPackageName();
Logger.debug("Robolectric assets directory: " + assetDir.getPath());
Logger.debug(" Robolectric res directory: " + resDir.getPath());
Logger.debug(" Robolectric manifest path: " + manifestFile.getPath());
Logger.debug(" Robolectric package name: " + packageName);
appManifest = new AndroidManifest(manifestFile, resDir, assetDir, packageName);
}
List<FsFile> libraryDirs = manifestIdentifier.getLibraryDirs();
appManifest.setLibraryManifests(createLibraryManifests(appManifest, libraryDirs));
return appManifest;
}
Aggregations