| Index: content/public/android/javatests/src/org/chromium/content/browser/TestsJavaScriptEvalTest.java
|
| diff --git a/content/public/android/javatests/src/org/chromium/content/browser/TestsJavaScriptEvalTest.java b/content/public/android/javatests/src/org/chromium/content/browser/TestsJavaScriptEvalTest.java
|
| index 1f50f0532a8d75b14b41aa1cdf6783c063061f75..4813c1a91c57633b99b87c7fbafdd1e0b3216ad3 100644
|
| --- a/content/public/android/javatests/src/org/chromium/content/browser/TestsJavaScriptEvalTest.java
|
| +++ b/content/public/android/javatests/src/org/chromium/content/browser/TestsJavaScriptEvalTest.java
|
| @@ -1,4 +1,4 @@
|
| -// Copyright 2012 The Chromium Authors. All rights reserved.
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| @@ -6,16 +6,26 @@ package org.chromium.content.browser;
|
|
|
| import android.support.test.filters.LargeTest;
|
|
|
| +import org.junit.Assert;
|
| +import org.junit.Rule;
|
| +import org.junit.Test;
|
| +import org.junit.runner.RunWith;
|
| +
|
| +import org.chromium.base.test.BaseJUnit4ClassRunner;
|
| import org.chromium.base.test.util.Feature;
|
| import org.chromium.base.test.util.UrlUtils;
|
| import org.chromium.content.browser.test.util.DOMUtils;
|
| import org.chromium.content_public.browser.WebContents;
|
| -import org.chromium.content_shell_apk.ContentShellTestBase;
|
| +import org.chromium.content_shell_apk.ContentShellActivityTestRule;
|
|
|
| /**
|
| * Integration tests for JavaScript execution.
|
| */
|
| -public class TestsJavaScriptEvalTest extends ContentShellTestBase {
|
| +@RunWith(BaseJUnit4ClassRunner.class)
|
| +public class TestsJavaScriptEvalTest {
|
| + @Rule
|
| + public ContentShellActivityTestRule mActivityTestRule = new ContentShellActivityTestRule();
|
| +
|
| private static final String JSTEST_URL = UrlUtils.encodeHtmlDataUri("<html><head><script>"
|
| + " function foobar() { return 'foobar'; }"
|
| + "</script></head>"
|
| @@ -28,22 +38,23 @@ public class TestsJavaScriptEvalTest extends ContentShellTestBase {
|
| * Tests that evaluation of JavaScript for test purposes (using JavaScriptUtils, DOMUtils etc)
|
| * works even in presence of "background" (non-test-initiated) JavaScript evaluation activity.
|
| */
|
| + @Test
|
| @LargeTest
|
| @Feature({"Browser"})
|
| public void testJavaScriptEvalIsCorrectlyOrdered()
|
| throws InterruptedException, Exception, Throwable {
|
| - launchContentShellWithUrl(JSTEST_URL);
|
| - waitForActiveShellToBeDoneLoading();
|
| + mActivityTestRule.launchContentShellWithUrl(JSTEST_URL);
|
| + mActivityTestRule.waitForActiveShellToBeDoneLoading();
|
|
|
| - final WebContents webContents = getWebContents();
|
| + final WebContents webContents = mActivityTestRule.getWebContents();
|
| for (int i = 0; i < 30; ++i) {
|
| for (int j = 0; j < 10; ++j) {
|
| // Start evaluation of a JavaScript script -- we don't need a result.
|
| webContents.evaluateJavaScriptForTests("foobar();", null);
|
| }
|
| // DOMUtils does need to evaluate a JavaScript and get its result to get DOM bounds.
|
| - assertNotNull("Failed to get bounds",
|
| - DOMUtils.getNodeBounds(webContents, "test"));
|
| + Assert.assertNotNull(
|
| + "Failed to get bounds", DOMUtils.getNodeBounds(webContents, "test"));
|
| }
|
| }
|
| }
|
|
|