Java 类org.robolectric.res.ResourcePath 实例源码

项目:lex    文件:LexTestRunner.java   
@Override
protected AndroidManifest getAppManifest(Config config) {
    String appRoot = "src/main/";
    String manifestPath = appRoot + "AndroidManifest.xml";
    String resDir = appRoot + "res";
    String assetsDir = appRoot + "assets";

    //return new AndroidManifest(Fs.fileFromPath("src/main/AndroidManifest.xml"), Fs.fileFromPath(resDir), Fs.fileFromPath(assetsDir)) {
    return new AndroidManifest(Fs.fileFromPath(manifestPath), Fs.fileFromPath(resDir), Fs.fileFromPath(assetsDir)) {

        @Override
        public List<ResourcePath> getIncludedResourcePaths() {
            List<ResourcePath> paths = super.getIncludedResourcePaths();
            paths.add(new ResourcePath(getRClass(), Fs.fileFromPath("src/main/res"), getAssetsDirectory()));
            paths.add(new ResourcePath(getRClass(), Fs.fileFromPath("src/test/res"), getAssetsDirectory()));
            return paths;
        }
    };
}
项目:FullRobolectricTestSample    文件:RobolectricTestRunnerTest.java   
@Test public void rememberThatSomeTestRunnerMethodsShouldBeOverridable() throws Exception {
  // super weak test for now, just remember not to make these methods static!

  //noinspection UnusedDeclaration
  class CustomTestRunner extends RobolectricTestRunner {
    public CustomTestRunner(Class<?> testClass) throws InitializationError {
      super(testClass);
    }

    @Override public PackageResourceLoader createResourceLoader(ResourcePath resourcePath) {
      return super.createResourceLoader(resourcePath);
    }

    @Override
    protected ResourceLoader createAppResourceLoader(ResourceLoader systemResourceLoader,
        AndroidManifest appManifest) {
      return super.createAppResourceLoader(systemResourceLoader, appManifest);
    }
  }
}
项目:Oleaster    文件:OleasterRobolectricRunner.java   
/**
 * Returns the ResourceProvider for the compile time SDK.
 */
private static PackageResourceTable getCompiletimeSdkResourceTable() {
    if (compiletimeSdkResourceTable == null) {
        ResourceTableFactory resourceTableFactory = new ResourceTableFactory();
        compiletimeSdkResourceTable = resourceTableFactory.newFrameworkResourceTable(
                new ResourcePath(android.R.class, null, null));
    }
    return compiletimeSdkResourceTable;
}
项目:okbuck    文件:BuckRobolectricTestRunner.java   
@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;
    }
}
项目:FullRobolectricTestSample    文件:RobolectricTestRunner.java   
protected ResourceLoader createAppResourceLoader(ResourceLoader systemResourceLoader, AndroidManifest appManifest) {
  List<PackageResourceLoader> appAndLibraryResourceLoaders = new ArrayList<PackageResourceLoader>();
  for (ResourcePath resourcePath : appManifest.getIncludedResourcePaths()) {
    appAndLibraryResourceLoaders.add(createResourceLoader(resourcePath));
  }
  OverlayResourceLoader overlayResourceLoader = new OverlayResourceLoader(appManifest.getPackageName(), appAndLibraryResourceLoaders);

  Map<String, ResourceLoader> resourceLoaders = new HashMap<String, ResourceLoader>();
  resourceLoaders.put("android", systemResourceLoader);
  resourceLoaders.put(appManifest.getPackageName(), overlayResourceLoader);
  return new RoutingResourceLoader(resourceLoaders);
}
项目:FullRobolectricTestSample    文件:SdkEnvironment.java   
public PackageResourceLoader createSystemResourceLoader(MavenCentral mavenCentral, RobolectricTestRunner robolectricTestRunner) {
  URL url = mavenCentral.getLocalArtifactUrl(robolectricTestRunner, sdkConfig.getSystemResourceDependency());
  Fs systemResFs = Fs.fromJar(url);
  ResourceExtractor resourceExtractor = new ResourceExtractor(getRobolectricClassLoader());
  ResourcePath resourcePath = new ResourcePath(resourceExtractor.getProcessedRFile(), resourceExtractor.getPackageName(), systemResFs.join("res"), systemResFs.join("assets"));
  return new PackageResourceLoader(resourcePath, resourceExtractor);
}
项目:FullRobolectricTestSample    文件:AndroidManifestTest.java   
private List<String> stringify(Collection<ResourcePath> resourcePaths) {
  List<String> resourcePathBases = new ArrayList<String>();
  for (ResourcePath resourcePath : resourcePaths) {
    resourcePathBases.add(resourcePath.resourceBase.toString());
  }
  return resourcePathBases;
}
项目:webpay-token-android    文件:RobolectricTestRunnerWithDummyResources.java   
@Override
protected ResourceLoader createAppResourceLoader(ResourceLoader systemResourceLoader, AndroidManifest appManifest) {
    List<PackageResourceLoader> appAndLibraryResourceLoaders = new ArrayList<PackageResourceLoader>();
    for (ResourcePath resourcePath : appManifest.getIncludedResourcePaths()) {
        appAndLibraryResourceLoaders.add(createResourceLoader(resourcePath));
    }
    OverlayResourceLoader overlayResourceLoader =
            new OverlayResourceLoaderWithDummyResources(
                    appManifest.getPackageName(), appAndLibraryResourceLoaders, systemResourceLoader);

    Map<String, ResourceLoader> resourceLoaders = new HashMap<String, ResourceLoader>();
    resourceLoaders.put("android", systemResourceLoader);
    resourceLoaders.put(appManifest.getPackageName(), overlayResourceLoader);
    return new RoutingResourceLoader(resourceLoaders);
}
项目:open    文件:MapzenAndroidManifest.java   
public List<ResourcePath> getIncludedResourcePaths() {
  Collection<ResourcePath> resourcePaths = new LinkedHashSet<ResourcePath>(); // Needs stable ordering and no duplicates
  resourcePaths.add(getResourcePath());
  for (AndroidManifest libraryManifest : getLibraryManifests()) {
    resourcePaths.addAll(libraryManifest.getIncludedResourcePaths());
  }
  return new ArrayList<ResourcePath>(resourcePaths);
}
项目:FullRobolectricTestSample    文件:RobolectricTestRunner.java   
public PackageResourceLoader createResourceLoader(ResourcePath resourcePath) {
  return new PackageResourceLoader(resourcePath);
}
项目:FullRobolectricTestSample    文件:SystemResourceExtractor.java   
public SystemResourceExtractor(ResourcePath systemResourcePath) {
  super(systemResourcePath);
}
项目:FullRobolectricTestSample    文件:TestUtil.java   
public static ResourcePath testResources() {
  return TEST_RESOURCE_PATH;
}
项目:FullRobolectricTestSample    文件:TestUtil.java   
public static ResourcePath lib1Resources() {
  return new ResourcePath(org.robolectric.lib1.R.class, "org.robolectric.lib1", resourceFile("lib1/res"), resourceFile("lib1/assets"));
}
项目:FullRobolectricTestSample    文件:TestUtil.java   
public static ResourcePath lib2Resources() {
  return new ResourcePath(org.robolectric.lib2.R.class, "org.robolectric.lib2", resourceFile("lib2/res"), resourceFile("lib2/assets"));
}
项目:FullRobolectricTestSample    文件:TestUtil.java   
public static ResourcePath lib3Resources() {
  return new ResourcePath(org.robolectric.lib3.R.class, "org.robolectric.lib3", resourceFile("lib3/res"), resourceFile("lib3/assets"));
}
项目:FullRobolectricTestSample    文件:TestUtil.java   
public static ResourcePath gradleAppResources() {
  return new ResourcePath(org.robolectric.gradleapp.R.class, "org.robolectric.gradleapp", resourceFile("gradle/res/layoutFlavor/menuBuildType"), resourceFile("gradle/assets/layoutFlavor/menuBuildType"));
}
项目:open    文件:MapzenAndroidManifest.java   
public ResourcePath getResourcePath() {
  validate();
  return new ResourcePath(getRClass(), getPackageName(), resDirectory, assetsDirectory);
}