| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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.graphics.Bitmap; | 9 import android.graphics.Bitmap; |
| 10 import android.os.Build; | 10 import android.os.Build; |
| 11 import android.util.Log; | 11 import android.util.Log; |
| 12 | 12 |
| 13 import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout; | 13 import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout; |
| 14 | 14 |
| 15 import org.chromium.android_webview.AwBrowserContext; | 15 import org.chromium.android_webview.AwBrowserContext; |
| 16 import org.chromium.android_webview.AwBrowserProcess; | 16 import org.chromium.android_webview.AwBrowserProcess; |
| 17 import org.chromium.android_webview.AwContents; | 17 import org.chromium.android_webview.AwContents; |
| 18 import org.chromium.android_webview.AwContentsClient; | 18 import org.chromium.android_webview.AwContentsClient; |
| 19 import org.chromium.android_webview.AwSettings; | 19 import org.chromium.android_webview.AwSettings; |
| 20 import org.chromium.android_webview.AwSwitches; |
| 20 import org.chromium.android_webview.test.util.GraphicsTestUtils; | 21 import org.chromium.android_webview.test.util.GraphicsTestUtils; |
| 21 import org.chromium.android_webview.test.util.JSUtils; | 22 import org.chromium.android_webview.test.util.JSUtils; |
| 22 import org.chromium.base.test.BaseActivityInstrumentationTestCase; | 23 import org.chromium.base.test.BaseActivityInstrumentationTestCase; |
| 24 import org.chromium.base.test.util.CommandLineFlags; |
| 23 import org.chromium.base.test.util.InMemorySharedPreferences; | 25 import org.chromium.base.test.util.InMemorySharedPreferences; |
| 24 import org.chromium.base.test.util.MinAndroidSdkLevel; | 26 import org.chromium.base.test.util.MinAndroidSdkLevel; |
| 27 import org.chromium.base.test.util.parameter.Parameter; |
| 28 import org.chromium.base.test.util.parameter.ParameterizedTest; |
| 25 import org.chromium.content.browser.test.util.CallbackHelper; | 29 import org.chromium.content.browser.test.util.CallbackHelper; |
| 26 import org.chromium.content.browser.test.util.Criteria; | 30 import org.chromium.content.browser.test.util.Criteria; |
| 27 import org.chromium.content.browser.test.util.CriteriaHelper; | 31 import org.chromium.content.browser.test.util.CriteriaHelper; |
| 28 import org.chromium.content.browser.test.util.TestCallbackHelperContainer.OnPage
FinishedHelper; | 32 import org.chromium.content.browser.test.util.TestCallbackHelperContainer.OnPage
FinishedHelper; |
| 29 import org.chromium.content_public.browser.LoadUrlParams; | 33 import org.chromium.content_public.browser.LoadUrlParams; |
| 30 import org.chromium.net.test.util.TestWebServer; | 34 import org.chromium.net.test.util.TestWebServer; |
| 31 | 35 |
| 32 import java.lang.annotation.Annotation; | 36 import java.lang.annotation.Annotation; |
| 33 import java.lang.reflect.Method; | 37 import java.lang.reflect.Method; |
| 34 import java.util.Map; | 38 import java.util.Map; |
| 35 import java.util.concurrent.Callable; | 39 import java.util.concurrent.Callable; |
| 36 import java.util.concurrent.FutureTask; | 40 import java.util.concurrent.FutureTask; |
| 37 import java.util.concurrent.TimeUnit; | 41 import java.util.concurrent.TimeUnit; |
| 38 import java.util.concurrent.atomic.AtomicReference; | 42 import java.util.concurrent.atomic.AtomicReference; |
| 39 | 43 |
| 40 /** | 44 /** |
| 41 * A base class for android_webview tests. WebView only runs on KitKat and later
, | 45 * A base class for android_webview tests. WebView only runs on KitKat and later
, |
| 42 * so make sure no one attempts to run the tests on earlier OS releases. | 46 * so make sure no one attempts to run the tests on earlier OS releases. |
| 47 * |
| 48 * By default, all tests run both in single-process mode, and with sandboxed ren
derer. |
| 49 * If a test doesn't yet work with sandboxed renderer, an entire class, or an in
dividual test |
| 50 * method can be marked for single-process testing only by adding the following
annotation: |
| 51 * |
| 52 * @ParameterizedTest.Set |
| 43 */ | 53 */ |
| 44 @MinAndroidSdkLevel(Build.VERSION_CODES.KITKAT) | 54 @MinAndroidSdkLevel(Build.VERSION_CODES.KITKAT) |
| 55 @ParameterizedTest.Set(tests = { |
| 56 @ParameterizedTest(parameters = { |
| 57 @Parameter( |
| 58 tag = CommandLineFlags.Parameter.PARAMETER_TAG)}
), |
| 59 @ParameterizedTest(parameters = { |
| 60 @Parameter( |
| 61 tag = CommandLineFlags.Parameter.PARAMETER_TAG, |
| 62 arguments = { |
| 63 @Parameter.Argument( |
| 64 name = CommandLineFlags.Parameter.ADD_AR
G, |
| 65 stringArray = {AwSwitches.WEBVIEW_SANDBO
XED_RENDERER}) |
| 66 })})}) |
| 45 public class AwTestBase | 67 public class AwTestBase |
| 46 extends BaseActivityInstrumentationTestCase<AwTestRunnerActivity> { | 68 extends BaseActivityInstrumentationTestCase<AwTestRunnerActivity> { |
| 47 public static final long WAIT_TIMEOUT_MS = scaleTimeout(15000); | 69 public static final long WAIT_TIMEOUT_MS = scaleTimeout(15000); |
| 48 public static final int CHECK_INTERVAL = 100; | 70 public static final int CHECK_INTERVAL = 100; |
| 49 private static final String TAG = "AwTestBase"; | 71 private static final String TAG = "AwTestBase"; |
| 50 | 72 |
| 51 // The browser context needs to be a process-wide singleton. | 73 // The browser context needs to be a process-wide singleton. |
| 52 private AwBrowserContext mBrowserContext; | 74 private AwBrowserContext mBrowserContext; |
| 53 | 75 |
| 54 public AwTestBase() { | 76 public AwTestBase() { |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 } | 652 } |
| 631 }); | 653 }); |
| 632 | 654 |
| 633 OnPageFinishedHelper onPageFinishedHelper = popupContentsClient.getOnPag
eFinishedHelper(); | 655 OnPageFinishedHelper onPageFinishedHelper = popupContentsClient.getOnPag
eFinishedHelper(); |
| 634 int callCount = onPageFinishedHelper.getCallCount(); | 656 int callCount = onPageFinishedHelper.getCallCount(); |
| 635 onPageFinishedHelper.waitForCallback(callCount, 1, WAIT_TIMEOUT_MS, Time
Unit.MILLISECONDS); | 657 onPageFinishedHelper.waitForCallback(callCount, 1, WAIT_TIMEOUT_MS, Time
Unit.MILLISECONDS); |
| 636 | 658 |
| 637 return new PopupInfo(popupContentsClient, popupContainerView, popupConte
nts); | 659 return new PopupInfo(popupContentsClient, popupContainerView, popupConte
nts); |
| 638 } | 660 } |
| 639 } | 661 } |
| OLD | NEW |