| Index: android_webview/tools/system_webview_shell/layout_tests/src/org/chromium/webview_shell/test/WebViewThreadTest.java
|
| diff --git a/android_webview/tools/system_webview_shell/layout_tests/src/org/chromium/webview_shell/test/WebViewThreadTest.java b/android_webview/tools/system_webview_shell/layout_tests/src/org/chromium/webview_shell/test/WebViewThreadTest.java
|
| index a5ea94d880f6a06b7252894af6c08ba61dde3a53..82965439376097ef8ec5662e15c94e58d3633714 100644
|
| --- a/android_webview/tools/system_webview_shell/layout_tests/src/org/chromium/webview_shell/test/WebViewThreadTest.java
|
| +++ b/android_webview/tools/system_webview_shell/layout_tests/src/org/chromium/webview_shell/test/WebViewThreadTest.java
|
| @@ -4,98 +4,112 @@
|
|
|
| package org.chromium.webview_shell.test;
|
|
|
| +import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout;
|
| +
|
| +import android.content.Intent;
|
| import android.support.test.filters.SmallTest;
|
| -import android.test.ActivityInstrumentationTestCase2;
|
| +import android.support.test.rule.ActivityTestRule;
|
| import android.webkit.CookieManager;
|
| import android.webkit.GeolocationPermissions;
|
| import android.webkit.WebStorage;
|
|
|
| -import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout;
|
| +import org.junit.After;
|
| +import org.junit.Assert;
|
| +import org.junit.Before;
|
| +import org.junit.Rule;
|
| +import org.junit.Test;
|
| +import org.junit.runner.RunWith;
|
|
|
| +import org.chromium.base.test.BaseJUnit4ClassRunner;
|
| import org.chromium.webview_shell.WebViewThreadTestActivity;
|
|
|
| /**
|
| * Tests running WebView on different threads.
|
| */
|
| -public class WebViewThreadTest extends ActivityInstrumentationTestCase2<WebViewThreadTestActivity> {
|
| +@RunWith(BaseJUnit4ClassRunner.class)
|
| +public class WebViewThreadTest {
|
| private static final long TIMEOUT = scaleTimeout(4000);
|
| private static final String DATA = "<html><body>Testing<script>"
|
| + "console.log(\"testing\")</script></body></html>";
|
| private static final String URL_DATA = "javascript:console.log(\"testing\")";
|
| private WebViewThreadTestActivity mActivity;
|
|
|
| - public WebViewThreadTest() {
|
| - super(WebViewThreadTestActivity.class);
|
| - }
|
| + @Rule
|
| + public ActivityTestRule<WebViewThreadTestActivity> mActivityTestRule =
|
| + new ActivityTestRule<>(WebViewThreadTestActivity.class, false, false);
|
|
|
| - @Override
|
| - protected void setUp() throws Exception {
|
| - super.setUp();
|
| - mActivity = getActivity();
|
| + @Before
|
| + public void setUp() throws Exception {
|
| + mActivity = mActivityTestRule.launchActivity(new Intent());
|
| }
|
|
|
| - @Override
|
| - protected void tearDown() throws Exception {
|
| + @After
|
| + public void tearDown() throws Exception {
|
| mActivity.finish();
|
| - super.tearDown();
|
| }
|
|
|
| /**
|
| * Create webview then loadData, on non-ui thread
|
| */
|
| + @Test
|
| @SmallTest
|
| public void testLoadDataNonUiThread() throws InterruptedException {
|
| - assertTrue(mActivity.createWebViewOnNonUiThread(TIMEOUT));
|
| - assertTrue(loadDataWebViewNonUiThread(DATA));
|
| + Assert.assertTrue(mActivity.createWebViewOnNonUiThread(TIMEOUT));
|
| + Assert.assertTrue(loadDataWebViewNonUiThread(DATA));
|
| }
|
|
|
| /**
|
| * Create webview then loadUrl, on non-ui thread
|
| */
|
| + @Test
|
| @SmallTest
|
| public void testLoadUrlNonUiThread() throws InterruptedException {
|
| - assertTrue(mActivity.createWebViewOnNonUiThread(TIMEOUT));
|
| - assertTrue(loadUrlWebViewNonUiThread(URL_DATA));
|
| + Assert.assertTrue(mActivity.createWebViewOnNonUiThread(TIMEOUT));
|
| + Assert.assertTrue(loadUrlWebViewNonUiThread(URL_DATA));
|
| }
|
|
|
| /**
|
| * Run getWebViewDatabase on a non-ui thread before creating webview on ui thread
|
| */
|
| + @Test
|
| @SmallTest
|
| public void testWebViewDatabaseBeforeCreateWebView() throws InterruptedException {
|
| mActivity.getWebViewDatabase();
|
| mActivity.createWebViewOnUiThread(TIMEOUT);
|
| - assertTrue(loadDataWebViewInUiThread(DATA));
|
| + Assert.assertTrue(loadDataWebViewInUiThread(DATA));
|
| }
|
|
|
| /**
|
| * Create webview on ui-thread, then getWebViewDatabase on non-ui thread
|
| */
|
| + @Test
|
| @SmallTest
|
| public void testWebViewDatabaseAfterCreateWebView() throws InterruptedException {
|
| - assertTrue(mActivity.createWebViewOnUiThread(TIMEOUT));
|
| + Assert.assertTrue(mActivity.createWebViewOnUiThread(TIMEOUT));
|
| mActivity.getWebViewDatabase();
|
| - assertTrue(loadDataWebViewInUiThread(DATA));
|
| + Assert.assertTrue(loadDataWebViewInUiThread(DATA));
|
| }
|
|
|
| /**
|
| * Run CookieManager.getInstance on a non-ui thread before creating webview on ui thread
|
| */
|
| + @Test
|
| @SmallTest
|
| public void testCookieManagerBeforeCreateWebView() throws InterruptedException {
|
| CookieManager.getInstance();
|
| mActivity.createWebViewOnUiThread(TIMEOUT);
|
| - assertTrue(loadDataWebViewInUiThread(DATA));
|
| + Assert.assertTrue(loadDataWebViewInUiThread(DATA));
|
| }
|
|
|
| /**
|
| * Create webview on ui-thread, then run CookieManager.getInstance on non-ui thread
|
| */
|
| + @Test
|
| @SmallTest
|
| public void testCookieManagerAfterCreateWebView() throws InterruptedException {
|
| - assertTrue(mActivity.createWebViewOnUiThread(TIMEOUT));
|
| + Assert.assertTrue(mActivity.createWebViewOnUiThread(TIMEOUT));
|
| CookieManager.getInstance();
|
| - assertTrue(loadDataWebViewInUiThread(DATA));
|
| + Assert.assertTrue(loadDataWebViewInUiThread(DATA));
|
| }
|
|
|
|
|
| @@ -103,43 +117,47 @@ public class WebViewThreadTest extends ActivityInstrumentationTestCase2<WebViewT
|
| * Run GeolocationPermissions.getInstance on a non-ui thread before creating
|
| * webview on ui thread
|
| */
|
| + @Test
|
| @SmallTest
|
| public void testGeolocationPermissionsBeforeCreateWebView() throws InterruptedException {
|
| GeolocationPermissions.getInstance();
|
| mActivity.createWebViewOnUiThread(TIMEOUT);
|
| - assertTrue(loadDataWebViewInUiThread(DATA));
|
| + Assert.assertTrue(loadDataWebViewInUiThread(DATA));
|
| }
|
|
|
| /**
|
| * Create webview on ui-thread, then run GeolocationPermissions.getInstance on non-ui thread
|
| */
|
| + @Test
|
| @SmallTest
|
| public void testGelolocationPermissionsAfterCreateWebView() throws InterruptedException {
|
| - assertTrue(mActivity.createWebViewOnUiThread(TIMEOUT));
|
| + Assert.assertTrue(mActivity.createWebViewOnUiThread(TIMEOUT));
|
| GeolocationPermissions.getInstance();
|
| - assertTrue(loadDataWebViewInUiThread(DATA));
|
| + Assert.assertTrue(loadDataWebViewInUiThread(DATA));
|
| }
|
|
|
|
|
| /**
|
| * Run WebStorage.getInstance on a non-ui thread before creating webview on ui thread
|
| */
|
| + @Test
|
| @SmallTest
|
| public void testWebStorageBeforeCreateWebView() throws InterruptedException {
|
| WebStorage.getInstance();
|
| mActivity.createWebViewOnUiThread(TIMEOUT);
|
| - assertTrue(loadDataWebViewInUiThread(DATA));
|
| + Assert.assertTrue(loadDataWebViewInUiThread(DATA));
|
| }
|
|
|
|
|
| /**
|
| * Create webview on ui-thread, then run WebStorage.getInstance on non-ui thread
|
| */
|
| + @Test
|
| @SmallTest
|
| public void testWebStorageAfterCreateWebView() throws InterruptedException {
|
| - assertTrue(mActivity.createWebViewOnUiThread(TIMEOUT));
|
| + Assert.assertTrue(mActivity.createWebViewOnUiThread(TIMEOUT));
|
| WebStorage.getInstance();
|
| - assertTrue(loadDataWebViewInUiThread(DATA));
|
| + Assert.assertTrue(loadDataWebViewInUiThread(DATA));
|
| }
|
|
|
| /**
|
|
|