Skip to content

Commit

Permalink
Add CommandLineArgumentParameter and use it for WebView tests
Browse files Browse the repository at this point in the history
Introduce the new parameter: CommandLineArgumentParameter and
use it for running Android WebView instrumentation tests in
two modes: single-process and with sandboxed renderer.

The tests that currently fail in the sandboxed renderer mode
are marked with empty @ParameterizedTest.Set annotation to
override the superclass annotation.

BUG=526885

Review URL: https://codereview.chromium.org/1414403002

Cr-Commit-Position: refs/heads/master@{#358459}
  • Loading branch information
mnaganov authored and Commit bot committed Nov 7, 2015
1 parent 0ac5a42 commit 0d19045
Show file tree
Hide file tree
Showing 28 changed files with 382 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.chromium.base.ThreadUtils;
import org.chromium.base.annotations.SuppressFBWarnings;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.parameter.ParameterizedTest;
import org.chromium.content.browser.test.util.CallbackHelper;
import org.chromium.content_public.browser.GestureStateListener;
import org.chromium.net.test.util.TestWebServer;
Expand All @@ -32,6 +33,8 @@
* Integration tests for synchronous scrolling.
*/
@SuppressFBWarnings("DLS_DEAD_LOCAL_STORE")
// Run in single-process mode only. Blocked by rendering support crbug.com/526842.
@ParameterizedTest.Set
public class AndroidScrollIntegrationTest extends AwTestBase {
private TestWebServer mWebServer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.chromium.android_webview.test.util.CommonResources;
import org.chromium.android_webview.test.util.GraphicsTestUtils;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.parameter.ParameterizedTest;
import org.chromium.content.browser.test.util.CallbackHelper;
import org.chromium.ui.gfx.DeviceDisplayInfo;

Expand Down Expand Up @@ -303,6 +304,8 @@ public void testAbsolutePositionContributesToContentSize() throws Throwable {

@SmallTest
@Feature({"AndroidWebView"})
// Run in single-process mode only. Blocked by rendering support crbug.com/526842.
@ParameterizedTest.Set
public void testViewIsNotBlankInWrapContentsMode() throws Throwable {
final TestAwContentsClient contentsClient = new TestAwContentsClient();
final AwTestContainerView testContainerView =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.chromium.android_webview.test.util.JavascriptEventObserver;
import org.chromium.android_webview.test.util.VideoSurfaceViewUtils;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.parameter.ParameterizedTest;
import org.chromium.content.browser.ContentViewCore;
import org.chromium.content.browser.test.util.Criteria;
import org.chromium.content.browser.test.util.CriteriaHelper;
Expand All @@ -30,6 +31,8 @@
* we pick a div containing a video and custom html controls since this is a
* very common use case.
*/
// Run in single-process mode only. Blocked by rendering support crbug.com/526842.
@ParameterizedTest.Set
public class AwContentsClientFullScreenTest extends AwTestBase {
private static final String VIDEO_TEST_URL =
"file:///android_asset/full_screen_video_test.html";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import org.chromium.android_webview.AwContents;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.parameter.ParameterizedTest;
import org.chromium.content.browser.test.util.CallbackHelper;
import org.chromium.content.browser.test.util.DOMUtils;

Expand All @@ -25,6 +26,8 @@
* used to trigger switch occupies almost the whole WebView so the simulated click event
* can't miss it.
*/
// Run in single-process mode only. Blocked by rendering support crbug.com/526842.
@ParameterizedTest.Set
public class AwContentsClientGetVideoLoadingProgressViewTest extends AwTestBase
implements View.OnAttachStateChangeListener {
private static final String VIDEO_TEST_URL =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
import org.chromium.android_webview.AwContents;
import org.chromium.android_webview.test.util.CommonResources;
import org.chromium.base.ThreadUtils;
import org.chromium.base.test.util.parameter.ParameterizedTest;
import org.chromium.content.browser.test.util.Criteria;
import org.chromium.content.browser.test.util.CriteriaHelper;

/**
* Tests for the WebViewClient.onScaleChanged.
*/
// Run in single-process mode only. Blocked by rendering support crbug.com/526842.
@ParameterizedTest.Set
public class AwContentsClientOnScaleChangedTest extends AwTestBase {
private TestAwContentsClient mContentsClient;
private AwContents mAwContents;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.chromium.android_webview.test.util.JSUtils;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.TestFileUtil;
import org.chromium.base.test.util.parameter.ParameterizedTest;
import org.chromium.content.browser.test.util.CallbackHelper;
import org.chromium.content.browser.test.util.TestCallbackHelperContainer.OnReceivedErrorHelper;
import org.chromium.net.test.util.TestWebServer;
Expand Down Expand Up @@ -223,6 +224,8 @@ public void testCalledWithCorrectMethodParam() throws Throwable {

@SmallTest
@Feature({"AndroidWebView"})
// Run in single-process mode only. Blocked by software draws support crbug.com/545611.
@ParameterizedTest.Set
public void testCalledWithCorrectHasUserGestureParam() throws Throwable {
final String aboutPageUrl = addAboutPageToTestServer(mWebServer);
final String pageWithLinkUrl = addPageToTestServer(mWebServer, "/page_with_link.html",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.chromium.base.annotations.SuppressFBWarnings;
import org.chromium.base.test.util.DisabledTest;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.parameter.ParameterizedTest;
import org.chromium.content.browser.test.util.CallbackHelper;
import org.chromium.content.browser.test.util.DOMUtils;
import org.chromium.content.browser.test.util.TestCallbackHelperContainer.OnEvaluateJavaScriptResultHelper;
Expand Down Expand Up @@ -726,6 +727,8 @@ public Boolean call() {

@SmallTest
@Feature({"AndroidWebView", "Navigation"})
// Run in single-process mode only. Blocked by software draws support crbug.com/545611.
@ParameterizedTest.Set
public void testCalledOn302Redirect() throws Throwable {
final String redirectTargetUrl = createRedirectTargetPage();
final String redirectUrl = mWebServer.setRedirect("/302.html", redirectTargetUrl);
Expand All @@ -734,6 +737,8 @@ public void testCalledOn302Redirect() throws Throwable {

@SmallTest
@Feature({"AndroidWebView", "Navigation"})
// Run in single-process mode only. Blocked by software draws support crbug.com/545611.
@ParameterizedTest.Set
public void testCalledOnMetaRefreshRedirect() throws Throwable {
final String redirectTargetUrl = createRedirectTargetPage();
final String redirectUrl = addPageToTestServer("/meta_refresh.html",
Expand All @@ -744,6 +749,8 @@ public void testCalledOnMetaRefreshRedirect() throws Throwable {

@SmallTest
@Feature({"AndroidWebView", "Navigation"})
// Run in single-process mode only. Blocked by software draws support crbug.com/545611.
@ParameterizedTest.Set
public void testCalledOnJavaScriptLocationImmediateAssignRedirect()
throws Throwable {
final String redirectTargetUrl = createRedirectTargetPage();
Expand All @@ -754,6 +761,8 @@ public void testCalledOnJavaScriptLocationImmediateAssignRedirect()

@SmallTest
@Feature({"AndroidWebView", "Navigation"})
// Run in single-process mode only. Blocked by software draws support crbug.com/545611.
@ParameterizedTest.Set
public void testCalledOnJavaScriptLocationImmediateReplaceRedirect()
throws Throwable {
final String redirectTargetUrl = createRedirectTargetPage();
Expand All @@ -764,6 +773,8 @@ public void testCalledOnJavaScriptLocationImmediateReplaceRedirect()

@SmallTest
@Feature({"AndroidWebView", "Navigation"})
// Run in single-process mode only. Blocked by software draws support crbug.com/545611.
@ParameterizedTest.Set
public void testCalledOnJavaScriptLocationDelayedAssignRedirect()
throws Throwable {
final String redirectTargetUrl = createRedirectTargetPage();
Expand All @@ -774,6 +785,8 @@ public void testCalledOnJavaScriptLocationDelayedAssignRedirect()

@SmallTest
@Feature({"AndroidWebView", "Navigation"})
// Run in single-process mode only. Blocked by software draws support crbug.com/545611.
@ParameterizedTest.Set
public void testCalledOnJavaScriptLocationDelayedReplaceRedirect()
throws Throwable {
final String redirectTargetUrl = createRedirectTargetPage();
Expand Down Expand Up @@ -890,6 +903,8 @@ public Boolean call() {

@SmallTest
@Feature({"AndroidWebView"})
// Run in single-process mode only. Blocked by software draws support crbug.com/545611.
@ParameterizedTest.Set
public void testNullContentsClientOpenLink() throws Throwable {
try {
// The test will fire real intents through the test activity.
Expand Down Expand Up @@ -940,6 +955,8 @@ public Boolean call() {

@SmallTest
@Feature({"AndroidWebView"})
// Run in single-process mode only. Blocked by software draws support crbug.com/545611.
@ParameterizedTest.Set
public void testNullContentsClientClickableContent() throws Throwable {
try {
// The test will fire real intents through the test activity.
Expand Down Expand Up @@ -1023,12 +1040,16 @@ public Boolean call() {

@SmallTest
@Feature({"AndroidWebView"})
// Run in single-process mode only. Blocked by software draws support crbug.com/545611.
@ParameterizedTest.Set
public void testClickableContent() throws Throwable {
doTestClickableContent(true);
}

@SmallTest
@Feature({"AndroidWebView"})
// Run in single-process mode only. Blocked by software draws support crbug.com/545611.
@ParameterizedTest.Set
public void testClickableContentInIframe() throws Throwable {
doTestClickableContent(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@
import org.chromium.android_webview.test.util.GraphicsTestUtils;
import org.chromium.base.ThreadUtils;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.parameter.ParameterizedTest;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

/**
* AwContents rendering / pixel tests.
*/
// Run in single-process mode only. Blocked by software draws support crbug.com/545611.
@ParameterizedTest.Set
public class AwContentsRenderTest extends AwTestBase {

private TestAwContentsClient mContentsClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.chromium.base.annotations.SuppressFBWarnings;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.parameter.ParameterizedTest;
import org.chromium.content.browser.BindingManager;
import org.chromium.content.browser.ChildProcessConnection;
import org.chromium.content.browser.ChildProcessLauncher;
Expand Down Expand Up @@ -79,6 +80,8 @@ public void testCreateLoadPageDestroy() throws Throwable {

@LargeTest
@Feature({"AndroidWebView"})
// Run in single-process mode only. Blocked by rendering support crbug.com/526842.
@ParameterizedTest.Set
public void testCreateLoadDestroyManyTimes() throws Throwable {
for (int i = 0; i < 10; ++i) {
AwTestContainerView testView = createAwTestContainerViewOnMainSync(mContentsClient);
Expand Down Expand Up @@ -588,11 +591,15 @@ public void startModerateBindingManagement(
public void releaseAllModerateBindings() {}
}

/**
* Verifies that a child process is actually gets created with WEBVIEW_SANDBOXED_RENDERER flag.
*/
@Feature({"AndroidWebView"})
@SmallTest
@CommandLineFlags.Add({
AwSwitches.WEBVIEW_SANDBOXED_RENDERER,
ContentSwitches.IPC_SYNC_COMPOSITING})
@ParameterizedTest.Set
public void testSandboxedRendererWorks() throws Throwable {
MockBindingManager bindingManager = new MockBindingManager();
ChildProcessLauncher.setBindingManagerForTesting(bindingManager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.chromium.android_webview.AwSettings;
import org.chromium.base.annotations.SuppressFBWarnings;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.parameter.ParameterizedTest;
import org.chromium.content.browser.test.util.CallbackHelper;
import org.chromium.ui.gfx.DeviceDisplayInfo;

Expand Down Expand Up @@ -242,6 +243,8 @@ public void testMetaMergeContentQuirkOverrides() throws Throwable {

@MediumTest
@Feature({"AndroidWebView"})
// Run in single-process mode only. Blocked by rendering support crbug.com/526842.
@ParameterizedTest.Set
public void testInitialScaleClobberQuirk() throws Throwable {
final TestAwContentsClient contentClient = new TestAwContentsClient();
final AwTestContainerView testContainerView =
Expand Down Expand Up @@ -276,6 +279,8 @@ public void testInitialScaleClobberQuirk() throws Throwable {

@MediumTest
@Feature({"AndroidWebView"})
// Run in single-process mode only. Blocked by rendering support crbug.com/526842.
@ParameterizedTest.Set
public void testNoUserScalableQuirk() throws Throwable {
final TestAwContentsClient contentClient = new TestAwContentsClient();
final AwTestContainerView testContainerView =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.TestFileUtil;
import org.chromium.base.test.util.UrlUtils;
import org.chromium.base.test.util.parameter.ParameterizedTest;
import org.chromium.content.browser.test.util.CallbackHelper;
import org.chromium.content.browser.test.util.HistoryUtils;
import org.chromium.content.browser.test.util.TestCallbackHelperContainer;
Expand Down Expand Up @@ -2192,6 +2193,8 @@ public void testFileUrlAccessToggleDoesNotBlockResourceUrls() throws Throwable {

@SmallTest
@Feature({"AndroidWebView", "Preferences"})
// Run in single-process mode only. Blocked by rendering support crbug.com/526842.
@ParameterizedTest.Set
public void testLayoutAlgorithmWithTwoViews() throws Throwable {
ViewPair views = createViews();
runPerViewSettingsTest(
Expand All @@ -2210,6 +2213,8 @@ public void testTextZoomWithTwoViews() throws Throwable {

@SmallTest
@Feature({"AndroidWebView", "Preferences"})
// Run in single-process mode only. Blocked by rendering support crbug.com/526842.
@ParameterizedTest.Set
public void testTextZoomAutosizingWithTwoViews() throws Throwable {
ViewPair views = createViews();
runPerViewSettingsTest(
Expand Down Expand Up @@ -2578,6 +2583,8 @@ public void testUseWideViewportLayoutWidthNoQuirks() throws Throwable {

@MediumTest
@Feature({"AndroidWebView", "Preferences"})
// Run in single-process mode only. Blocked by rendering support crbug.com/526842.
@ParameterizedTest.Set
public void testUseWideViewportControlsDoubleTabToZoom() throws Throwable {
final TestAwContentsClient contentClient = new TestAwContentsClient();
final AwTestContainerView testContainerView =
Expand Down Expand Up @@ -2650,6 +2657,8 @@ public void testZeroLayoutHeightDisablesViewportQuirkWithTwoViews() throws Throw

@SmallTest
@Feature({"AndroidWebView", "Preferences"})
// Run in single-process mode only. Blocked by rendering support crbug.com/526842.
@ParameterizedTest.Set
public void testLoadWithOverviewModeWithTwoViews() throws Throwable {
ViewPair views = createViews();
runPerViewSettingsTest(
Expand All @@ -2661,6 +2670,8 @@ public void testLoadWithOverviewModeWithTwoViews() throws Throwable {

@SmallTest
@Feature({"AndroidWebView", "Preferences"})
// Run in single-process mode only. Blocked by rendering support crbug.com/526842.
@ParameterizedTest.Set
public void testLoadWithOverviewModeViewportTagWithTwoViews() throws Throwable {
ViewPair views = createViews();
runPerViewSettingsTest(
Expand All @@ -2672,6 +2683,8 @@ public void testLoadWithOverviewModeViewportTagWithTwoViews() throws Throwable {

@SmallTest
@Feature({"AndroidWebView", "Preferences"})
// Run in single-process mode only. Blocked by rendering support crbug.com/526842.
@ParameterizedTest.Set
public void testSetInitialScale() throws Throwable {
final TestAwContentsClient contentClient = new TestAwContentsClient();
final AwTestContainerView testContainerView =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@
import org.chromium.android_webview.AwContents;
import org.chromium.android_webview.AwContentsClient;
import org.chromium.android_webview.AwSettings;
import org.chromium.android_webview.AwSwitches;
import org.chromium.android_webview.test.util.GraphicsTestUtils;
import org.chromium.android_webview.test.util.JSUtils;
import org.chromium.base.ThreadUtils;
import org.chromium.base.test.BaseActivityInstrumentationTestCase;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.InMemorySharedPreferences;
import org.chromium.base.test.util.MinAndroidSdkLevel;
import org.chromium.base.test.util.parameter.Parameter;
import org.chromium.base.test.util.parameter.ParameterizedTest;
import org.chromium.content.browser.test.util.CallbackHelper;
import org.chromium.content.browser.test.util.Criteria;
import org.chromium.content.browser.test.util.CriteriaHelper;
Expand All @@ -40,8 +44,26 @@
/**
* A base class for android_webview tests. WebView only runs on KitKat and later,
* so make sure no one attempts to run the tests on earlier OS releases.
*
* By default, all tests run both in single-process mode, and with sandboxed renderer.
* If a test doesn't yet work with sandboxed renderer, an entire class, or an individual test
* method can be marked for single-process testing only by adding the following annotation:
*
* @ParameterizedTest.Set
*/
@MinAndroidSdkLevel(Build.VERSION_CODES.KITKAT)
@ParameterizedTest.Set(tests = {
@ParameterizedTest(parameters = {
@Parameter(
tag = CommandLineFlags.Parameter.PARAMETER_TAG)}),
@ParameterizedTest(parameters = {
@Parameter(
tag = CommandLineFlags.Parameter.PARAMETER_TAG,
arguments = {
@Parameter.Argument(
name = CommandLineFlags.Parameter.ADD_ARG,
stringArray = {AwSwitches.WEBVIEW_SANDBOXED_RENDERER})
})})})
public class AwTestBase
extends BaseActivityInstrumentationTestCase<AwTestRunnerActivity> {
public static final long WAIT_TIMEOUT_MS = scaleTimeout(15000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@
import org.chromium.android_webview.AwSettings;
import org.chromium.base.ThreadUtils;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.parameter.ParameterizedTest;

import java.util.Locale;
import java.util.concurrent.Callable;

/**
* A test suite for zooming-related methods and settings.
*/
// Run in single-process mode only. Blocked by rendering support crbug.com/526842.
@ParameterizedTest.Set
public class AwZoomTest extends AwTestBase {
private TestAwContentsClient mContentsClient;
private AwContents mAwContents;
Expand Down
Loading

0 comments on commit 0d19045

Please sign in to comment.