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

Unified Diff: base/android/java/src/org/chromium/base/ContextUtils.java

Issue 1474723002: Support setting just the Java Context for JUnit tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/android/java/src/org/chromium/base/ContextUtils.java
diff --git a/base/android/java/src/org/chromium/base/ContextUtils.java b/base/android/java/src/org/chromium/base/ContextUtils.java
index 266e8eb8805d31acfad8fcfa74be2143aab7899c..51adcff8f67375a4bf0507fedfeecf72daa07396 100644
--- a/base/android/java/src/org/chromium/base/ContextUtils.java
+++ b/base/android/java/src/org/chromium/base/ContextUtils.java
@@ -41,14 +41,22 @@ public class ContextUtils {
* both sides.
*/
public static void initApplicationContext(Context appContext) {
+ assert appContext != null;
+ assert sApplicationContext == null || sApplicationContext == appContext;
initJavaSideApplicationContext(appContext);
nativeInitNativeSideApplicationContext(appContext);
}
+ /**
+ * JUnit Robolectric tests run without native code; allow them to set just the Java-side
+ * context. Do not use in configurations that actually run on Android!
+ */
+ public static void initApplicationContextForJUnitTests(Context appContext) {
+ initJavaSideApplicationContext(appContext);
+ }
+
@CalledByNative
private static void initJavaSideApplicationContext(Context appContext) {
- assert appContext != null;
- assert sApplicationContext == null || sApplicationContext == appContext;
sApplicationContext = appContext;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698