本文整理汇总了Java中org.robolectric.res.FsFile类的典型用法代码示例。如果您正苦于以下问题:Java FsFile类的具体用法?Java FsFile怎么用?Java FsFile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FsFile类属于org.robolectric.res包,在下文中一共展示了FsFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldMatchPermissions
import org.robolectric.res.FsFile; //导入依赖的package包/类
@Test
public void shouldMatchPermissions() {
// Initialize: configure test for current app configuration
FsFile mergedManifestFile;
Object[] expectedPermissions;
if (BuildConfig.DEBUG) {
mergedManifestFile = Fs.fileFromPath(MERGED_DEBUG_MANIFEST_FILE);
expectedPermissions = EXPECTED_DEBUG_PERMISSIONS;
} else {
mergedManifestFile = Fs.fileFromPath(MERGED_RELEASE_MANIFEST_FILE);
expectedPermissions = EXPECTED_RELEASE_PERMISSIONS;
}
// Run: Creates a Robolectric configuration using specified manifest file
AndroidManifest manifest = new AndroidManifest(mergedManifestFile, null, null);
// Check: manifest file should contain only expected permissions
assertThat(manifest.getUsedPermissions())
.containsExactly(expectedPermissions);
}
示例2: getConfigProperties
import org.robolectric.res.FsFile; //导入依赖的package包/类
@Override
protected Properties getConfigProperties() {
Properties configProperties = super.getConfigProperties();
if (configProperties == null) {
configProperties = new Properties();
}
String manifestPath = "src/test/AndroidManifest.xml";
FsFile manifestFile = Fs.newFile(new File(manifestPath));
if (manifestFile.exists()) {
configProperties.put("manifest", manifestPath);
} else {
configProperties.put("manifest", "LikeOrmExample/" + manifestPath);
}
configProperties.put("emulateSdk", "16");
return configProperties;
}
示例3: createAppManifest
import org.robolectric.res.FsFile; //导入依赖的package包/类
@Override
protected AndroidManifest createAppManifest(FsFile manifestFile, FsFile resDir, FsFile assetsDir) {
return new AndroidManifest(
Fs.fileFromPath("src/main/AndroidManifest.xml"),
Fs.fileFromPath("src/main/res"),
Fs.fileFromPath("src/main/assets")) {
@Override
public int getTargetSdkVersion() {
return 18;
}
@Override
public String getThemeRef(Class<? extends Activity> activityClass) {
return "@android:style/Theme.Holo.Light.NoActionBar";
}
};
}
示例4: getAndResolve
import org.robolectric.res.FsFile; //导入依赖的package包/类
TypedResource getAndResolve(@NotNull ResName resName, String qualifiers, boolean resolveRefs) {
TypedResource value = resourceLoader.getValue(resName, qualifiers);
if (resolveRefs) {
value = resolve(value, qualifiers, resName);
}
// todo: make the drawable loader put stuff into the normal spot...
if (value == null && DrawableResourceLoader.isStillHandledHere(resName)) {
DrawableNode drawableNode = resourceLoader.getDrawableNode(resName, qualifiers);
return new TypedResource<FsFile>(drawableNode.getFsFile(), ResType.FILE);
}
// todo: gross. this is so resources.getString(R.layout.foo) works for ABS.
if (value == null && "layout".equals(resName.type)) {
throw new UnsupportedOperationException("ugh, this doesn't work still?");
}
return value;
}
示例5: whenNoAppManifest_shouldRunThingsInTheRightOrder
import org.robolectric.res.FsFile; //导入依赖的package包/类
@Test public void whenNoAppManifest_shouldRunThingsInTheRightOrder() throws Exception {
StateHolder.transcript = new Transcript();
assertNoFailures(run(new Runner(SimpleTest.class) {
@Override protected AndroidManifest createAppManifest(FsFile manifestFile, FsFile resDir, FsFile assetsDir) {
return null;
}
}));
StateHolder.transcript.assertEventsSoFar(
"configureShadows",
"createApplication",
"application.onCreate",
"beforeTest",
"application.beforeTest",
"prepareTest",
"application.prepareTest",
"TEST!",
"application.onTerminate",
"afterTest",
"application.afterTest"
);
}
示例6: findLibraries
import org.robolectric.res.FsFile; //导入依赖的package包/类
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;
}
示例7: getAppManifest
import org.robolectric.res.FsFile; //导入依赖的package包/类
@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());
}
}
示例8: getAppManifest
import org.robolectric.res.FsFile; //导入依赖的package包/类
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);
}
}
示例9: createAppManifest
import org.robolectric.res.FsFile; //导入依赖的package包/类
@Override
protected AndroidManifest createAppManifest(final FsFile manifestFile, final FsFile resDir,
final FsFile assetsDir) {
FsFile moduleManifestFile = fixModuleDirectoryPathIfNeeded(manifestFile);
FsFile moduleResDir = fixModuleDirectoryPathIfNeeded(resDir);
FsFile moduleAssetsDir = fixModuleDirectoryPathIfNeeded(assetsDir);
return super.createAppManifest(moduleManifestFile, moduleResDir, moduleAssetsDir);
}
示例10: getAppManifest
import org.robolectric.res.FsFile; //导入依赖的package包/类
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);
}
}
示例11: getAppManifest
import org.robolectric.res.FsFile; //导入依赖的package包/类
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);
}
}
示例12: getAppManifest
import org.robolectric.res.FsFile; //导入依赖的package包/类
@Override
protected AndroidManifest getAppManifest(Config config) {
String buckManifest = System.getProperty(ROBOLECTRIC_MANIFEST);
String buckResourcesProperty = System.getProperty(ROBOLECTRIC_RESOURCE_DIRECTORIES);
if (buckManifest != null && buckResourcesProperty != null) {
final List<String> buckResources = Arrays.asList(buckResourcesProperty.split(File.pathSeparator));
final FsFile res = Fs.fileFromPath(buckResources.get(buckResources.size() - 1));
final FsFile assets = Fs.fileFromPath(buckResources.get(buckResources.size() - 1));
final FsFile manifest = Fs.fileFromPath(buckManifest);
return new AndroidManifest(manifest, res, assets, config.packageName()) {
@Override
public List<ResourcePath> getIncludedResourcePaths() {
Collection<ResourcePath> resourcePaths = new LinkedHashSet<>();
resourcePaths.add(super.getResourcePath());
ListIterator<String> it = buckResources.listIterator(buckResources.size());
while (it.hasPrevious()) {
resourcePaths.add(new ResourcePath(
getRClass(),
getPackageName(),
Fs.fileFromPath(it.previous()),
getAssetsDirectory()));
}
return new ArrayList<>(resourcePaths);
}
};
} else {
return null;
}
}
示例13: createAppManifest
import org.robolectric.res.FsFile; //导入依赖的package包/类
protected AndroidManifest createAppManifest(FsFile manifestFile, FsFile resDir, FsFile assetsDir) {
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;
}
AndroidManifest manifest = new AndroidManifest(manifestFile, resDir, assetsDir);
String packageName = System.getProperty("android.package");
manifest.setPackageName(packageName);
return manifest;
}
示例14: getAppManifest
import org.robolectric.res.FsFile; //导入依赖的package包/类
protected AndroidManifest getAppManifest(Config config) {
if (config.manifest().equals(Config.NONE)) {
return null;
}
String manifestProperty = System.getProperty("android.manifest");
String resourcesProperty = System.getProperty("android.resources");
String assetsProperty = System.getProperty("android.assets");
FsFile fsFile = getBaseDir();
FsFile manifestFile;
FsFile resDir;
FsFile assetsDir;
boolean defaultManifest = config.manifest().equals(Config.DEFAULT);
if (defaultManifest && manifestProperty != null) {
manifestFile = Fs.fileFromPath(manifestProperty);
resDir = Fs.fileFromPath(resourcesProperty);
assetsDir = Fs.fileFromPath(assetsProperty);
} else {
manifestFile = fsFile.join(defaultManifest ? "AndroidManifest.xml" : config.manifest());
resDir = manifestFile.getParent().join(config.resourceDir());
assetsDir = manifestFile.getParent().join("assets");
}
synchronized (envHolder) {
AndroidManifest appManifest;
appManifest = envHolder.appManifestsByFile.get(manifestFile);
if (appManifest == null) {
long startTime = System.currentTimeMillis();
appManifest = createAppManifest(manifestFile, resDir, assetsDir);
if (DocumentLoader.DEBUG_PERF)
System.out.println(String.format("%4dms spent in %s", System.currentTimeMillis() - startTime, manifestFile));
envHolder.appManifestsByFile.put(manifestFile, appManifest);
}
return appManifest;
}
}
示例15: list
import org.robolectric.res.FsFile; //导入依赖的package包/类
@Implementation
public final String[] list(String path) throws IOException {
FsFile file = appManifest.getAssetsDirectory().join(path);
if (file.isDirectory()) {
return file.listFileNames();
}
return new String[0];
}