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

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

Issue 2243353002: (Reland) Update all Robolectric tests to Robolectric 3.0 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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/LocalRobolectricTestRunner.java
diff --git a/testing/android/junit/java/src/org/chromium/testing/local/LocalRobolectricTestRunner.java b/testing/android/junit/java/src/org/chromium/testing/local/LocalRobolectricTestRunner.java
index cf6202b0507d863108ed40b2e814e144b7561c21..171b9c6aaf13047e5bf29b0501502ff0530293e3 100644
--- a/testing/android/junit/java/src/org/chromium/testing/local/LocalRobolectricTestRunner.java
+++ b/testing/android/junit/java/src/org/chromium/testing/local/LocalRobolectricTestRunner.java
@@ -6,44 +6,38 @@ package org.chromium.testing.local;
import org.junit.runners.model.InitializationError;
-import org.robolectric.AndroidManifest;
-import org.robolectric.DependencyResolver;
import org.robolectric.RobolectricTestRunner;
-import org.robolectric.SdkConfig;
import org.robolectric.annotation.Config;
+import org.robolectric.manifest.AndroidManifest;
/**
- * A custom Robolectric Junit4 Test Runner. This test runner will load the
- * "real" android jars from a local directory rather than use Maven to fetch
- * them from the Maven Central repository. Additionally, it will ignore the
+ * A custom Robolectric Junit4 Test Runner. This test runner will ignore the
* API level written in the AndroidManifest as that can cause issues if
- * robolectric does not support that API level.
+ * Robolectric does not support that API level. The API level will be grabbed
+ * from the robolectric Config annotation, or just be
+ * |DEFAULT_ANDROID_API_LEVEL|
*/
public class LocalRobolectricTestRunner extends RobolectricTestRunner {
- private static final int ANDROID_API_LEVEL = 18;
+ private static final int DEFAULT_ANDROID_API_LEVEL = 21;
public LocalRobolectricTestRunner(Class<?> testClass) throws InitializationError {
super(testClass);
}
@Override
- protected final DependencyResolver getJarResolver() {
- return new RobolectricClasspathDependencyResolver();
- }
-
- @Override
- protected SdkConfig pickSdkVersion(AndroidManifest appManifest, Config config) {
+ protected int pickSdkVersion(Config config, AndroidManifest appManifest) {
// Pulling from the manifest is dangerous as the apk might target a version of
// android that robolectric does not yet support. We still allow the API level to
// be overridden with the Config annotation.
- return config.emulateSdk() < 0
- ? new SdkConfig(ANDROID_API_LEVEL) : super.pickSdkVersion(null, config);
- }
-
- @Override
- protected int pickReportedSdkVersion(Config config, AndroidManifest appManifest) {
- return config.reportSdk() < 0
- ? ANDROID_API_LEVEL : super.pickReportedSdkVersion(config, appManifest);
+ if (config != null) {
+ if (config.sdk().length > 1) {
+ throw new IllegalArgumentException(
+ "RobolectricTestRunner does not support multiple values for @Config.sdk");
+ } else if (config.sdk().length == 1) {
+ return config.sdk()[0];
+ }
+ }
+ return DEFAULT_ANDROID_API_LEVEL;
}
-}
+}

Powered by Google App Engine
This is Rietveld 408576698