private static Properties getProperties(FsFile propertiesFile) { Properties properties = new Properties(); // return an empty Properties object if the propertiesFile does not exist if (!propertiesFile.exists()) return properties; InputStream stream; try { stream = propertiesFile.getInputStream(); } catch (IOException e) { throw new RuntimeException(e); } try { try { properties.load(stream); } finally { stream.close(); } } catch (IOException e) { throw new RuntimeException(e); } return properties; }
@Override protected AndroidManifest createAppManifest(FsFile manifestFile) { if (!manifestFile.exists()) { manifestFile = Fs.fileFromPath("pathToMy/AndroidManifest.xml"); } return super.createAppManifest(manifestFile); }
/** @deprecated Do not use. */ @Deprecated synchronized public boolean supportsBinaryResourcesMode() { if (supportsBinaryResourcesMode == null) { supportsBinaryResourcesMode = apkFile != null && apkFile.exists(); } return supportsBinaryResourcesMode; } }
&& appManifest.getAndroidManifestFile().exists()) { parsedPackage = LegacyManifestParser.createPackage(appManifest); } else {
private FsFile findAssetFile(String fileName) throws IOException { for (FsFile assetDir : getAllAssetDirs()) { FsFile assetFile = assetDir.join(fileName); if (assetFile.exists()) { return assetFile; } } throw new FileNotFoundException("Asset file " + fileName + " not found"); }
public boolean hasResources() { return getResourceBase() != null && getResourceBase().exists(); }
public boolean hasResources() { return getResourceBase() != null && getResourceBase().exists(); }
private void loadFile(FsFile dir) { if (!dir.exists()) { throw new RuntimeException("no such directory " + dir); } for (FsFile file : dir.listFiles(ENDS_WITH_XML)) { loadResourceXmlFile(new XmlContext(packageName, file)); } }
if (unpack.exists()) { FsFile[] libs = unpack.listFiles(); if (libs != null) {
if (unpack.exists()) { FsFile[] libs = unpack.listFiles(); if (libs != null) {
if (unpack.exists()) { FsFile[] libs = unpack.listFiles(); if (libs != null) {
protected AndroidManifest createAppManifest(FsFile manifestFile, FsFile resDir, FsFile assetDir, String packageName) { if (!manifestFile.exists()) { System.out.print("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)."); return null; } 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); }
private void loadFile(FsFile dir) { if (!dir.exists()) { throw new RuntimeException("no such directory " + dir); } if (!dir.isDirectory()) { return; } Qualifiers qualifiers; try { qualifiers = Qualifiers.fromParentDir(dir); } catch (IllegalArgumentException e) { Logger.warn(dir + ": " + e.getMessage()); return; } for (FsFile file : dir.listFiles(ENDS_WITH_XML)) { loadResourceXmlFile(new XmlContext(packageName, file, qualifiers)); } }
if (androidManifestFile != null && androidManifestFile.exists()) { try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
if (androidManifestFile != null && androidManifestFile.exists()) { try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
@Implementation protected static Typeface createFromAsset(AssetManager mgr, String path) { ShadowAssetManager shadowAssetManager = Shadow.extract(mgr); Collection<FsFile> assetDirs = shadowAssetManager.getAllAssetDirs(); for (FsFile assetDir : assetDirs) { FsFile[] files = assetDir.listFiles(new StartsWith(path)); FsFile assetFile = assetDir.join(path); if (assetFile.exists() || files.length != 0) { return createUnderlyingTypeface(path, Typeface.NORMAL); } } throw new RuntimeException("Font asset not found " + path); }
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().replace("/res", "").replace("bundles", "res")); FsFile assetsDirectory = FileFsFile.from(moduleRoot, appManifest.getAssetsDirectory().getPath().replace("/assets", "").replace("bundles", "assets")); return new AndroidManifest(androidManifestFile, resDirectory, assetsDirectory); } }
protected AndroidManifest getAppManifest(Config config) { AndroidManifest appManifest = super.getAppManifest(config); FsFile androidManifestFile = appManifest.getAndroidManifestFile(); if (androidManifestFile.exists()) { return appManifest; } else { String moduleRoot = getModuleRootPath(config); final String build_test_out = "build" + File.separator + "out"; androidManifestFile = FileFsFile.from(moduleRoot, appManifest.getAndroidManifestFile().getPath() .replace("bundles", "manifests" + File.separator + "full") .replace("build", build_test_out)); FsFile resDirectory = FileFsFile.from(moduleRoot, appManifest.getResDirectory().getPath() .replace("" + File.separator + "res", "") .replace("bundles", "res") .replace("build", build_test_out)); FsFile assetsDirectory = FileFsFile.from(moduleRoot, appManifest.getAssetsDirectory().getPath() .replace("" + File.separator + "assets", "") .replace("bundles", "assets") .replace("build", build_test_out)); return new AndroidManifest(androidManifestFile, resDirectory, assetsDirectory); } }
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); } } }