Index: android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java |
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java |
index d37e9b403167ac66b2eb8782a79de154787a64a8..a05ec32afaac7a79b974234bd75a71014273d251 100644 |
--- a/android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java |
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java |
@@ -98,12 +98,19 @@ public class AwTestBase |
if (mBrowserContext != null) { |
throw new AndroidRuntimeException("There should only be one browser context."); |
} |
- Context appContext = getInstrumentation().getTargetContext().getApplicationContext(); |
- mBrowserContext = new AwBrowserContext(new InMemorySharedPreferences(), appContext); |
+ getActivity(); // The Activity must be launched in order to load native code. |
+ final InMemorySharedPreferences prefs = new InMemorySharedPreferences(); |
+ final Context appContext = getInstrumentation().getTargetContext().getApplicationContext(); |
+ getInstrumentation().runOnMainSync(new Runnable() { |
+ @Override |
+ public void run() { |
+ mBrowserContext = new AwBrowserContext(prefs, appContext); |
+ } |
+ }); |
} |
protected void startBrowserProcess() throws Exception { |
- // The activity must be launched in order for proper webview statics to be setup. |
+ // The Activity must be launched in order for proper webview statics to be setup. |
getActivity(); |
getInstrumentation().runOnMainSync(new Runnable() { |
@Override |