| 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 cb4e8b096da8030cb36537f2486c02501c585455..bd76a45cad3dffed113ecfabb992c275c37aee93 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
|
| @@ -10,8 +10,10 @@ import android.app.Instrumentation;
|
| import android.content.Context;
|
| import android.graphics.Bitmap;
|
| import android.os.Build;
|
| +import android.util.AndroidRuntimeException;
|
| import android.util.Log;
|
|
|
| +
|
| import org.chromium.android_webview.AwBrowserContext;
|
| import org.chromium.android_webview.AwBrowserProcess;
|
| import org.chromium.android_webview.AwContents;
|
| @@ -80,8 +82,9 @@ public class AwTestBase
|
|
|
| @Override
|
| protected void setUp() throws Exception {
|
| - Context appContext = getInstrumentation().getTargetContext().getApplicationContext();
|
| - mBrowserContext = new AwBrowserContext(new InMemorySharedPreferences(), appContext);
|
| + if (needsAwBrowserContextCreated()) {
|
| + createAwBrowserContext();
|
| + }
|
|
|
| super.setUp();
|
| if (needsBrowserProcessStarted()) {
|
| @@ -89,6 +92,14 @@ public class AwTestBase
|
| }
|
| }
|
|
|
| + protected void createAwBrowserContext() {
|
| + if (mBrowserContext != null) {
|
| + throw new AndroidRuntimeException("There should only be one browser context.");
|
| + }
|
| + Context appContext = getInstrumentation().getTargetContext().getApplicationContext();
|
| + mBrowserContext = new AwBrowserContext(new InMemorySharedPreferences(), appContext);
|
| + }
|
| +
|
| protected void startBrowserProcess() throws Exception {
|
| // The activity must be launched in order for proper webview statics to be setup.
|
| getActivity();
|
| @@ -101,6 +112,14 @@ public class AwTestBase
|
| }
|
|
|
| /**
|
| + * Override this to return false if the test doesn't want to create an AwBrowserContext
|
| + * automatically.
|
| + */
|
| + protected boolean needsAwBrowserContextCreated() {
|
| + return true;
|
| + }
|
| +
|
| + /**
|
| * Override this to return false if the test doesn't want the browser startup sequence to
|
| * be run automatically.
|
| * @return Whether the instrumentation test requires the browser process to already be started.
|
|
|