| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.android_webview.test; | 5 package org.chromium.android_webview.test; |
| 6 | 6 |
| 7 import android.app.Instrumentation; | 7 import android.app.Instrumentation; |
| 8 import android.content.Context; | 8 import android.content.Context; |
| 9 import android.test.ActivityInstrumentationTestCase2; | 9 import android.test.ActivityInstrumentationTestCase2; |
| 10 | 10 |
| 11 import junit.framework.Assert; | 11 import junit.framework.Assert; |
| 12 | 12 |
| 13 import org.chromium.android_webview.AwBrowserProcess; |
| 13 import org.chromium.android_webview.AwContents; | 14 import org.chromium.android_webview.AwContents; |
| 14 import org.chromium.android_webview.AwContentsClient; | 15 import org.chromium.android_webview.AwContentsClient; |
| 15 import org.chromium.android_webview.AwSettings; | 16 import org.chromium.android_webview.AwSettings; |
| 16 import org.chromium.android_webview.test.util.JSUtils; | 17 import org.chromium.android_webview.test.util.JSUtils; |
| 17 import org.chromium.content.browser.ContentSettings; | 18 import org.chromium.content.browser.ContentSettings; |
| 18 import org.chromium.content.browser.ContentView; | |
| 19 import org.chromium.content.browser.ContentViewCore; | 19 import org.chromium.content.browser.ContentViewCore; |
| 20 import org.chromium.content.browser.LoadUrlParams; | 20 import org.chromium.content.browser.LoadUrlParams; |
| 21 import org.chromium.content.browser.test.util.CallbackHelper; | 21 import org.chromium.content.browser.test.util.CallbackHelper; |
| 22 import org.chromium.content.browser.test.util.Criteria; | 22 import org.chromium.content.browser.test.util.Criteria; |
| 23 import org.chromium.content.browser.test.util.CriteriaHelper; | 23 import org.chromium.content.browser.test.util.CriteriaHelper; |
| 24 import org.chromium.content.browser.test.util.TestCallbackHelperContainer; | 24 import org.chromium.content.browser.test.util.TestCallbackHelperContainer; |
| 25 import org.chromium.content.common.ProcessInitException; | 25 import org.chromium.content.common.ProcessInitException; |
| 26 import org.chromium.ui.gfx.ActivityNativeWindow; | 26 import org.chromium.ui.gfx.ActivityNativeWindow; |
| 27 | 27 |
| 28 import java.util.concurrent.atomic.AtomicInteger; | 28 import java.util.concurrent.atomic.AtomicInteger; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 45 } | 45 } |
| 46 | 46 |
| 47 @Override | 47 @Override |
| 48 protected void setUp() throws Exception { | 48 protected void setUp() throws Exception { |
| 49 super.setUp(); | 49 super.setUp(); |
| 50 final Context context = getActivity(); | 50 final Context context = getActivity(); |
| 51 getInstrumentation().runOnMainSync(new Runnable() { | 51 getInstrumentation().runOnMainSync(new Runnable() { |
| 52 @Override | 52 @Override |
| 53 public void run() { | 53 public void run() { |
| 54 AwTestResourceProvider.registerResources(context); | 54 AwTestResourceProvider.registerResources(context); |
| 55 try { | 55 AwBrowserProcess.start(context); |
| 56 ContentViewCore.initChromiumBrowserProcess( | 56 } |
| 57 context, ContentView.MAX_RENDERERS_SINGLE_PROCESS); | |
| 58 } catch (ProcessInitException e) { | |
| 59 throw new Error("Failed to initialize browser process", e); | |
| 60 } | |
| 61 } | |
| 62 }); | 57 }); |
| 63 } | 58 } |
| 64 | 59 |
| 65 /** | 60 /** |
| 66 * Runs a {@link Callable} on the main thread, blocking until it is | 61 * Runs a {@link Callable} on the main thread, blocking until it is |
| 67 * complete, and returns the result. Calls | 62 * complete, and returns the result. Calls |
| 68 * {@link Instrumentation#waitForIdleSync()} first to help avoid certain | 63 * {@link Instrumentation#waitForIdleSync()} first to help avoid certain |
| 69 * race conditions. | 64 * race conditions. |
| 70 * | 65 * |
| 71 * @param <R> Type of result to return | 66 * @param <R> Type of result to return |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 final AwContents awContents, | 306 final AwContents awContents, |
| 312 final boolean includeDiskFiles) throws Throwable { | 307 final boolean includeDiskFiles) throws Throwable { |
| 313 runTestOnUiThread(new Runnable() { | 308 runTestOnUiThread(new Runnable() { |
| 314 @Override | 309 @Override |
| 315 public void run() { | 310 public void run() { |
| 316 awContents.clearCache(includeDiskFiles); | 311 awContents.clearCache(includeDiskFiles); |
| 317 } | 312 } |
| 318 }); | 313 }); |
| 319 } | 314 } |
| 320 } | 315 } |
| OLD | NEW |