Chromium Code Reviews| Index: android_webview/tools/system_webview_shell/layout_tests/src/org/chromium/webview_shell/test/WebViewLayoutTest.java |
| diff --git a/android_webview/tools/system_webview_shell/layout_tests/src/org/chromium/webview_shell/test/WebViewLayoutTest.java b/android_webview/tools/system_webview_shell/layout_tests/src/org/chromium/webview_shell/test/WebViewLayoutTest.java |
| index 77f83f1f6e906e2f50fe6fa1392bcf37605df477..68997d4bd4cd13dcbae3a4104373231169cc75b4 100644 |
| --- a/android_webview/tools/system_webview_shell/layout_tests/src/org/chromium/webview_shell/test/WebViewLayoutTest.java |
| +++ b/android_webview/tools/system_webview_shell/layout_tests/src/org/chromium/webview_shell/test/WebViewLayoutTest.java |
| @@ -4,12 +4,23 @@ |
| package org.chromium.webview_shell.test; |
| +import android.content.Intent; |
| +import android.os.Bundle; |
| +import android.support.test.InstrumentationRegistry; |
| import android.support.test.filters.MediumTest; |
| -import android.test.ActivityInstrumentationTestCase2; |
| +import android.support.test.rule.ActivityTestRule; |
| import junit.framework.ComparisonFailure; |
| +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.Log; |
| +import org.chromium.base.test.BaseJUnit4ClassRunner; |
| import org.chromium.base.test.util.DisableIf; |
| import org.chromium.base.test.util.DisabledTest; |
| import org.chromium.base.test.util.UrlUtils; |
| @@ -30,8 +41,8 @@ import java.util.concurrent.TimeoutException; |
| /** |
| * Tests running end-to-end layout tests. |
| */ |
| -public class WebViewLayoutTest |
| - extends ActivityInstrumentationTestCase2<WebViewLayoutTestActivity> { |
| +@RunWith(BaseJUnit4ClassRunner.class) |
| +public class WebViewLayoutTest { |
| private static final String TAG = "WebViewLayoutTest"; |
| @@ -48,29 +59,35 @@ public class WebViewLayoutTest |
| private static final long TIMEOUT_SECONDS = 20; |
| - private WebViewLayoutTestActivity mTestActivity; |
| - |
| - public WebViewLayoutTest() { |
| - super(WebViewLayoutTestActivity.class); |
| - } |
| + private static final String MODE_REBASELINE = "rebaseline"; |
| - @Override |
| - protected void setUp() throws Exception { |
| - super.setUp(); |
| - mTestActivity = (WebViewLayoutTestActivity) getActivity(); |
| + private WebViewLayoutTestActivity mTestActivity; |
| + private boolean mRebaseLine; |
| + |
| + @Rule |
| + public ActivityTestRule<WebViewLayoutTestActivity> mActivityTestRule = |
| + new ActivityTestRule<>(WebViewLayoutTestActivity.class, false, false); |
| + |
| + @Before |
| + public void setUp() throws Exception { |
| + mTestActivity = mActivityTestRule.launchActivity(new Intent()); |
| + Bundle arguments = InstrumentationRegistry.getArguments(); |
| + if (arguments != null) { |
| + String modeArgument = arguments.getString("mode"); |
| + mRebaseLine = modeArgument != null ? modeArgument.equals(MODE_REBASELINE) : false; |
| + } |
| } |
| - @Override |
| - protected void tearDown() throws Exception { |
| + @After |
| + public void tearDown() throws Exception { |
| mTestActivity.finish(); |
| - super.tearDown(); |
| } |
| - @Override |
| - public WebViewLayoutTestRunner getInstrumentation() { |
| - return (WebViewLayoutTestRunner) super.getInstrumentation(); |
| + private boolean isRebaseline() { |
|
mikecase (-- gone --)
2017/02/01 17:56:48
delete this function:
https://cs.chromium.org/chr
the real yoland
2017/02/01 18:52:51
Done
|
| + return mRebaseLine; |
| } |
| + @Test |
| @MediumTest |
| public void testSimple() throws Exception { |
| runWebViewLayoutTest("experimental/basic-logging.html", |
| @@ -78,6 +95,7 @@ public class WebViewLayoutTest |
| } |
| // This is a non-failing test because it tends to require frequent rebaselines. |
| + @Test |
| @MediumTest |
| public void testGlobalInterfaceNoFail() throws Exception { |
| runBlinkLayoutTest("webexposed/global-interface-listing.html", |
| @@ -86,6 +104,7 @@ public class WebViewLayoutTest |
| // This is a non-failing test to avoid 'blind' rebaselines by the sheriff |
| // (see crbug.com/564765). |
| + @Test |
| @MediumTest |
| public void testNoUnexpectedInterfaces() throws Exception { |
| ensureJsTestCopied(); |
| @@ -114,6 +133,7 @@ public class WebViewLayoutTest |
| } |
| @DisabledTest(message = "crbug.com/683153") |
| + @Test |
| @MediumTest |
| public void testWebViewExcludedInterfaces() throws Exception { |
| ensureJsTestCopied(); |
| @@ -138,7 +158,7 @@ public class WebViewLayoutTest |
| webviewExcludedInterfacesMap.entrySet()) { |
| String interfaceS = entry.getKey(); |
| HashSet<String> subsetBlink = blinkInterfacesMap.get(interfaceS); |
| - assertNotNull("Interface " + interfaceS + " not exposed in blink", subsetBlink); |
| + Assert.assertNotNull("Interface " + interfaceS + " not exposed in blink", subsetBlink); |
| HashSet<String> subsetWebView = webviewInterfacesMap.get(interfaceS); |
| HashSet<String> subsetExcluded = entry.getValue(); |
| @@ -148,17 +168,18 @@ public class WebViewLayoutTest |
| } |
| for (String property : subsetExcluded) { |
| - assertTrue("Interface " + interfaceS + "." + property + " not exposed in blink", |
| - subsetBlink.contains(property)); |
| + Assert.assertTrue("Interface " + interfaceS + "." + property |
| + + " not exposed in blink", subsetBlink.contains(property)); |
| if (subsetWebView != null && subsetWebView.contains(property)) { |
| unexpected.append(interfaceS + "." + property + "\n"); |
| } |
| } |
| } |
| - assertEquals("Unexpected webview interfaces found", "", unexpected.toString()); |
| + Assert.assertEquals("Unexpected webview interfaces found", "", unexpected.toString()); |
| } |
| @DisabledTest(message = "crbug.com/683153") |
| + @Test |
| @MediumTest |
| public void testWebViewIncludedStableInterfaces() throws Exception { |
| ensureJsTestCopied(); |
| @@ -201,15 +222,17 @@ public class WebViewLayoutTest |
| } |
| } |
| } |
| - assertEquals("Missing webview interfaces found", "", missing.toString()); |
| + Assert.assertEquals("Missing webview interfaces found", "", missing.toString()); |
| } |
| + @Test |
| @MediumTest |
| public void testRequestMIDIAccess() throws Exception { |
| runWebViewLayoutTest("blink-apis/webmidi/requestmidiaccess.html", |
| "blink-apis/webmidi/requestmidiaccess-expected.txt"); |
| } |
| + @Test |
| @MediumTest |
| public void testRequestMIDIAccessWithSysex() throws Exception { |
| mTestActivity.setGrantPermission(true); |
| @@ -218,6 +241,7 @@ public class WebViewLayoutTest |
| mTestActivity.setGrantPermission(false); |
| } |
| + @Test |
| @MediumTest |
| public void testRequestMIDIAccessDenyPermission() throws Exception { |
| runWebViewLayoutTest("blink-apis/webmidi/requestmidiaccess-permission-denied.html", |
| @@ -226,18 +250,21 @@ public class WebViewLayoutTest |
| // Blink platform API tests |
| + @Test |
| @MediumTest |
| public void testGeolocationCallbacks() throws Exception { |
| runWebViewLayoutTest("blink-apis/geolocation/geolocation-permission-callbacks.html", |
| "blink-apis/geolocation/geolocation-permission-callbacks-expected.txt"); |
| } |
| + @Test |
| @MediumTest |
| public void testMediaStreamApiDenyPermission() throws Exception { |
| runWebViewLayoutTest("blink-apis/webrtc/mediastream-permission-denied-callbacks.html", |
| "blink-apis/webrtc/mediastream-permission-denied-callbacks-expected.txt"); |
| } |
| + @Test |
| @MediumTest |
| public void testMediaStreamApi() throws Exception { |
| mTestActivity.setGrantPermission(true); |
| @@ -246,6 +273,7 @@ public class WebViewLayoutTest |
| mTestActivity.setGrantPermission(false); |
| } |
| + @Test |
| @MediumTest |
| public void testBatteryApi() throws Exception { |
| runWebViewLayoutTest("blink-apis/battery-status/battery-callback.html", |
| @@ -255,6 +283,7 @@ public class WebViewLayoutTest |
| /* |
| currently failing on aosp bots, see crbug.com/607350 |
| */ |
| + @Test |
| @MediumTest |
| @DisableIf.Build(product_name_includes = "aosp") |
| public void testEMEPermission() throws Exception { |
| @@ -281,7 +310,7 @@ public class WebViewLayoutTest |
| throws FileNotFoundException, IOException, InterruptedException, TimeoutException { |
| loadUrlWebViewAsync("file://" + fileName, mTestActivity); |
| - if (getInstrumentation().isRebaseline()) { |
| + if (isRebaseline()) { |
| // this is the rebaseline process |
| mTestActivity.waitForFinish(TIMEOUT_SECONDS, TimeUnit.SECONDS); |
| String result = mTestActivity.getTestResult(); |
| @@ -295,14 +324,14 @@ public class WebViewLayoutTest |
| ComparisonFailure cf = new ComparisonFailure("Unexpected result", expected, result); |
| Log.e(TAG, cf.toString()); |
| } else { |
| - assertEquals(expected, result); |
| + Assert.assertEquals(expected, result); |
| } |
| } |
| } |
| private void loadUrlWebViewAsync(final String fileUrl, |
| final WebViewLayoutTestActivity activity) { |
| - getInstrumentation().runOnMainSync(new Runnable() { |
| + InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() { |
| @Override |
| public void run() { |
| activity.loadUrl(fileUrl); |