Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Unified Diff: testing/android/junit/java/src/org/chromium/testing/local/GNManifestFactory.java

Issue 2824863002: Revert of (Reland) Expose resources in Robolectric/JUnit tests. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: testing/android/junit/java/src/org/chromium/testing/local/GNManifestFactory.java
diff --git a/testing/android/junit/java/src/org/chromium/testing/local/GNManifestFactory.java b/testing/android/junit/java/src/org/chromium/testing/local/GNManifestFactory.java
index 49aaa622ee781fb2b1791402514cfbf162c35d13..09cec0738be785a7a2b99acff2375c88d4751f90 100644
--- a/testing/android/junit/java/src/org/chromium/testing/local/GNManifestFactory.java
+++ b/testing/android/junit/java/src/org/chromium/testing/local/GNManifestFactory.java
@@ -8,62 +8,33 @@
import org.robolectric.internal.ManifestFactory;
import org.robolectric.internal.ManifestIdentifier;
import org.robolectric.manifest.AndroidManifest;
-import org.robolectric.res.Fs;
-import org.robolectric.res.FsFile;
-import org.robolectric.res.ResourcePath;
-import java.util.ArrayList;
-import java.util.List;
+// TODO(mikecase): Add support for specifying the AndroidManifest for
+// Robolectric tests.
/**
* Class that manages passing Android manifest information to Robolectric.
*/
public class GNManifestFactory implements ManifestFactory {
- private static final String CHROMIUM_MANIFEST_PATH = "chromium.robolectric.manifest";
- private static final String CHROMIUM_RES_DIRECTORIES = "chromium.robolectric.resource.dirs";
+ private static final String DEFAULT_PACKAGE_NAME = "org.robolectric.default";
@Override
public ManifestIdentifier identify(Config config) {
- if (config.resourceDir() != null
- && !config.resourceDir().equals(Config.DEFAULT_RES_FOLDER)) {
- throw new RuntimeException("Resource dirs should be generated automatically by GN. "
- + "Make sure you specify the correct app package_name in the GN build file. "
- + "Make sure you run the tests using the generated run_<test name> scripts.");
+ if (!config.manifest().equals(Config.NONE)) {
+ throw new RuntimeException("Specifying custom manifest not currently supported. "
+ + "Please use annotation @Config(manifest = Config.NONE) on Robolectric tests "
+ + "for the time being.");
}
-
- if (config.manifest() != null && !config.manifest().equals(Config.NONE)) {
- throw new RuntimeException("Specify manifest path in GN build file.");
- }
-
return new ManifestIdentifier(null, null, null, config.packageName(), null);
}
@Override
public AndroidManifest create(ManifestIdentifier manifestIdentifier) {
- String manifestPath = System.getProperty(CHROMIUM_MANIFEST_PATH);
- String resourceDirs = System.getProperty(CHROMIUM_RES_DIRECTORIES);
-
- final List<FsFile> resourceDirsList = new ArrayList<FsFile>();
- if (resourceDirs != null) {
- for (String resourceDir : resourceDirs.split(":")) {
- resourceDirsList.add(Fs.fileFromPath(resourceDir));
- }
+ String packageName = manifestIdentifier.getPackageName();
+ if (packageName == null || packageName.equals("")) {
+ packageName = DEFAULT_PACKAGE_NAME;
}
- FsFile manifestFile = null;
- if (manifestPath != null) {
- manifestFile = Fs.fileFromPath(manifestPath);
- }
-
- return new AndroidManifest(manifestFile, null, null, manifestIdentifier.getPackageName()) {
- @Override
- public List<ResourcePath> getIncludedResourcePaths() {
- List<ResourcePath> paths = super.getIncludedResourcePaths();
- for (FsFile resourceDir : resourceDirsList) {
- paths.add(new ResourcePath(getRClass(), resourceDir, getAssetsDirectory()));
- }
- return paths;
- }
- };
+ return new AndroidManifest(null, null, null, packageName);
}
}
« no previous file with comments | « testing/android/OWNERS ('k') | testing/android/junit/java/src/org/chromium/testing/local/LocalRobolectricTestRunner.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698