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

Unified Diff: android_webview/javatests/src/org/chromium/android_webview/test/CookieManagerStartupTest.java

Issue 2076623002: 🍳 Fix and clean up application context in webview. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Wrap context. Created 4 years, 6 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: android_webview/javatests/src/org/chromium/android_webview/test/CookieManagerStartupTest.java
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/CookieManagerStartupTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/CookieManagerStartupTest.java
index 9cb017f9123ed18687e9af95caa947bf5c2c9fa5..0fe073ad6a15ff8383ae675e5fab48b7c02f4b0c 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/CookieManagerStartupTest.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/CookieManagerStartupTest.java
@@ -14,6 +14,7 @@ import org.chromium.android_webview.AwCookieManager;
import org.chromium.android_webview.AwWebResourceResponse;
import org.chromium.android_webview.test.util.CommonResources;
import org.chromium.android_webview.test.util.CookieUtils;
+import org.chromium.base.ContextUtils;
import org.chromium.base.test.util.Feature;
import org.chromium.net.test.util.TestWebServer;
@@ -29,10 +30,11 @@ public class CookieManagerStartupTest extends AwTestBase {
@Override
protected void setUp() throws Exception {
super.setUp();
- // CookeManager assumes that native is loaded, but webview browser should not be loaded for
+ // CookieManager assumes that native is loaded, but webview browser should not be loaded for
// these tests as webview is not necessarily loaded when CookieManager is called.
- AwBrowserProcess.loadLibrary(
- getInstrumentation().getTargetContext().getApplicationContext());
+ Context appContext = getInstrumentation().getTargetContext().getApplicationContext();
+ ContextUtils.initApplicationContext(appContext);
+ AwBrowserProcess.loadLibrary();
}
@Override
@@ -45,11 +47,12 @@ public class CookieManagerStartupTest extends AwTestBase {
}
private void startChromiumWithClient(TestAwContentsClient contentsClient) throws Exception {
- final Context context = getActivity();
+ // The activity must be launched in order for proper webview statics to be setup.
+ getActivity();
getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
- AwBrowserProcess.start(context);
+ AwBrowserProcess.start();
}
});

Powered by Google App Engine
This is Rietveld 408576698