@Override public URL getLocalArtifactUrl(DependencyJar dependency) { String depShortName = dependency.getShortName(); String path = properties.getProperty(depShortName); if (path != null) { File pathFile = new File(path); if (!pathFile.isAbsolute()) { pathFile = new File(baseDir.getPath(), path); } try { return pathFile.toURI().toURL(); } catch (MalformedURLException e) { throw new RuntimeException(e); } } else { if (delegate != null) { return delegate.getLocalArtifactUrl(dependency); } } throw new RuntimeException("no artifacts found for " + dependency); } }
private void populateAssetPaths(AssetManager assetManager, AndroidManifest appManifest) { for (AndroidManifest manifest : appManifest.getAllManifests()) { if (manifest.getAssetsDirectory() != null) { assetManager.addAssetPath(manifest.getAssetsDirectory().getPath()); } } }
public FileTypedResource(FsFile fsFile, ResType resType, XmlContext xmlContext) { super(fsFile.getPath(), resType, xmlContext); this.fsFile = fsFile; }
public FileTypedResource(FsFile fsFile, ResType resType, XmlContext xmlContext) { super(fsFile.getPath(), resType, xmlContext); this.fsFile = fsFile; }
@Override public boolean fillTypedValue(FsFile data, TypedValue typedValue) { typedValue.type = TypedValue.TYPE_STRING; typedValue.data = 0; typedValue.string = data.getPath(); typedValue.assetCookie = getNextStringCookie(); return true; } }
@Override public boolean fillTypedValue(FsFile data, TypedValue typedValue) { typedValue.type = TypedValue.TYPE_STRING; typedValue.data = 0; typedValue.string = data.getPath(); typedValue.assetCookie = getNextStringCookie(); return true; } }
@Override public boolean fillTypedValue(Object data, TypedValue typedValue) { typedValue.type = TypedValue.TYPE_STRING; typedValue.data = 0; typedValue.string = data instanceof FsFile ? ((FsFile) data).getPath() : (CharSequence) data; typedValue.assetCookie = getNextStringCookie(); return true; } }
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); }
@Nullable public static XmlBlock create(FsFile fsFile, String packageName) { Document document = parse(fsFile); return document == null ? null : new XmlBlock(document, fsFile.getPath(), packageName); }
@Nullable public static XmlBlock create(FsFile fsFile, String packageName) { Document document = parse(fsFile); return document == null ? null : new XmlBlock(document, fsFile.getPath(), packageName); }
public File getNativeLibraryPath() { String tempPath = System.getProperty("java.io.tmpdir"); if (tempPath == null) { throw new IllegalStateException("Java temporary directory is not defined (java.io.tmpdir)"); } return new File(Fs.fileFromPath(tempPath).join("robolectric-libs", getLibName()).getPath()); }
public File getNativeLibraryPath() { String tempPath = System.getProperty("java.io.tmpdir"); if (tempPath == null) { throw new IllegalStateException("Java temporary directory is not defined (java.io.tmpdir)"); } return new File(Fs.fileFromPath(tempPath).join("robolectric-libs", getLibName()).getPath()); }
public File getNativeLibraryPath() { String tempPath = System.getProperty("java.io.tmpdir"); if (tempPath == null) { throw new IllegalStateException("Java temporary directory is not defined (java.io.tmpdir)"); } return new File(Fs.fileFromPath(tempPath).join("robolectric-libs", getLibName()).getPath()); }
@Override Collection<FsFile> getAllAssetDirs() { ArrayList<FsFile> fsFiles = new ArrayList<>(); for (AssetPath assetPath : cppAssetManager.getAssetPaths()) { if (assetPath.file.isFile()) { fsFiles.add(Fs.newJarFile(new File(assetPath.file.getPath())).join("assets")); } else { fsFiles.add(assetPath.file); } } return fsFiles; }
@Implementation protected final AssetFileDescriptor openFd(String fileName) throws IOException { File file = new File(findAssetFile(fileName).getPath()); if (file.getPath().startsWith("jar")) { file = getFileFromZip(file); } ParcelFileDescriptor parcelFileDescriptor = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY); return new AssetFileDescriptor(parcelFileDescriptor, 0, file.length()); }
/** * @deprecated Avoid use. */ @Deprecated synchronized public ResTable getCompileTimeResTable() { if (compileTimeResTable == null) { CppAssetManager compileTimeCppAssetManager = new CppAssetManager(); for (AssetPath assetPath : getAssetPaths()) { if (assetPath.isSystem) { compileTimeCppAssetManager.addDefaultAssets( RuntimeEnvironment.compileTimeSystemResourcesFile.getPath()); } else { compileTimeCppAssetManager.addAssetPath(new String8(assetPath.file.getPath()), null, false); } } compileTimeResTable = compileTimeCppAssetManager.getResources(); } return compileTimeResTable; }
@Implementation public final AssetFileDescriptor openFd(String fileName) throws IOException { File file = new File(ShadowApplication.getInstance().getAppManifest().getAssetsDirectory().join(fileName).getPath()); ParcelFileDescriptor parcelFileDescriptor = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY); return new AssetFileDescriptor(parcelFileDescriptor, 0, file.length()); }
@Implementation public final AssetFileDescriptor openFd(String fileName) throws IOException { File file = new File(ShadowApplication.getInstance().getAppManifest().getAssetsDirectory().join(fileName).getPath()); ParcelFileDescriptor parcelFileDescriptor = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY); return new AssetFileDescriptor(parcelFileDescriptor, 0, file.length()); }
@Implementation public final AssetFileDescriptor openFd(String fileName) throws IOException { File file = new File(ShadowApplication.getInstance().getAppManifest().getAssetsDirectory().join(fileName).getPath()); ParcelFileDescriptor parcelFileDescriptor = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY); return new AssetFileDescriptor(parcelFileDescriptor, 0, file.length()); }
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); } }