当前位置: 首页>>代码示例>>Java>>正文


Java FsFile类代码示例

本文整理汇总了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);
}
 
开发者ID:AnironGlass,项目名称:MVP-Boilerplate,代码行数:21,代码来源:PermissionsTest.java

示例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;
}
 
开发者ID:nrudenko,项目名称:dora,代码行数:17,代码来源:DoraTestRunner.java

示例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";
        }
    };
}
 
开发者ID:WojciechKo,项目名称:stack-overflow-android,代码行数:19,代码来源:MyRobolectricTestRunner.java

示例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;
}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:20,代码来源:ShadowAssetManager.java

示例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"
  );
}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:22,代码来源:TestRunnerSequenceTest.java

示例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;
}
 
开发者ID:mapzen,项目名称:open,代码行数:27,代码来源:MapzenAndroidManifest.java

示例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());
  }
}
 
开发者ID:andrewlord1990,项目名称:materialandroid,代码行数:14,代码来源:LibraryRobolectricTestRunner.java

示例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);
	}
}
 
开发者ID:Stocard,项目名称:markdown-to-spanned,代码行数:15,代码来源:ManifestedRobolectricGradeTestRunner.java

示例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);
}
 
开发者ID:josephearl,项目名称:foundry,代码行数:10,代码来源:FoundryTestRunner.java

示例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);
    }
}
 
开发者ID:richardradics,项目名称:MVPAndroidBootstrap,代码行数:15,代码来源:AppRobolectricRunner.java

示例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);
    }
}
 
开发者ID:nightscout,项目名称:lasso,代码行数:15,代码来源:CustomRobolectricRunner.java

示例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;
    }
}
 
开发者ID:uber,项目名称:okbuck,代码行数:35,代码来源:BuckRobolectricTestRunner.java

示例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;
}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:13,代码来源:RobolectricTestRunner.java

示例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;
  }
}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:40,代码来源:RobolectricTestRunner.java

示例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];
}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:9,代码来源:ShadowAssetManager.java


注:本文中的org.robolectric.res.FsFile类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。