From 12261bfeed735d1da74b45209b02b2b9fd444d4b Mon Sep 17 00:00:00 2001 From: timvolodine Date: Fri, 31 Jul 2015 11:21:21 -0700 Subject: [PATCH] [Android WebViewShell] Add inclusion test for webview exposed stable interfaces. This patch adds a test to make sure the exposed stable interfaces in blink match with the exposed interfaces in webview. All interfaces listed in virtual/stable/webexposed/global-interface-listing-expected.txt are checked except the excluded interfaces which are listed in not-webview-exposed.txt. BUG=514217 Review URL: https://codereview.chromium.org/1261953004 Cr-Commit-Position: refs/heads/master@{#341370} --- .../android_webview_shell_test_apk.isolate | 1 + .../chromium/webview_shell/WebViewLayoutTest.java | 36 ++++++++++++++++++++++ .../test/webexposed/not-webview-exposed.txt | 4 +++ 3 files changed, 41 insertions(+) diff --git a/android_webview/android_webview_shell_test_apk.isolate b/android_webview/android_webview_shell_test_apk.isolate index 09b7b70b8f24..85e85d360004 100644 --- a/android_webview/android_webview_shell_test_apk.isolate +++ b/android_webview/android_webview_shell_test_apk.isolate @@ -8,6 +8,7 @@ 'variables': { 'files': [ '<(DEPTH)/android_webview/tools/WebViewShell/test/', + '<(DEPTH)/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-expected.txt', '<(DEPTH)/third_party/WebKit/LayoutTests/webexposed/global-interface-listing.html', '<(DEPTH)/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt', '<(DEPTH)/third_party/WebKit/LayoutTests/webexposed/resources/global-interface-listing.js', diff --git a/android_webview/tools/WebViewShell/src/org/chromium/webview_shell/WebViewLayoutTest.java b/android_webview/tools/WebViewShell/src/org/chromium/webview_shell/WebViewLayoutTest.java index d78dd606154c..4d6414adf21d 100644 --- a/android_webview/tools/WebViewShell/src/org/chromium/webview_shell/WebViewLayoutTest.java +++ b/android_webview/tools/WebViewShell/src/org/chromium/webview_shell/WebViewLayoutTest.java @@ -33,8 +33,12 @@ public class WebViewLayoutTest Environment.getExternalStorageDirectory().getAbsolutePath() + "/"; private static final String BASE_WEBVIEW_TEST_PATH = "android_webview/tools/WebViewShell/test/"; private static final String BASE_BLINK_TEST_PATH = "third_party/WebKit/LayoutTests/"; + private static final String BASE_BLINK_STABLE_TEST_PATH = + BASE_BLINK_TEST_PATH + "virtual/stable/"; private static final String PATH_WEBVIEW_PREFIX = EXTERNAL_PREFIX + BASE_WEBVIEW_TEST_PATH; private static final String PATH_BLINK_PREFIX = EXTERNAL_PREFIX + BASE_BLINK_TEST_PATH; + private static final String PATH_BLINK_STABLE_PREFIX = + EXTERNAL_PREFIX + BASE_BLINK_STABLE_TEST_PATH; private static final long TIMEOUT_SECONDS = 20; @@ -100,6 +104,38 @@ public class WebViewLayoutTest assertEquals("Unexpected webview interfaces found", "", unexpected.toString()); } + public void testWebViewIncludedStableInterfaces() throws Exception { + ensureJsTestCopied(); + loadUrlWebViewAsync("file://" + PATH_BLINK_PREFIX + + "webexposed/global-interface-listing.html", mTestActivity); + String blinkStableExpected = readFile(PATH_BLINK_STABLE_PREFIX + + "webexposed/global-interface-listing-expected.txt"); + String webviewExcluded = readFile(PATH_WEBVIEW_PREFIX + + "webexposed/not-webview-exposed.txt"); + mTestActivity.waitForFinish(TIMEOUT_SECONDS, TimeUnit.SECONDS); + String result = mTestActivity.getTestResult(); + + HashMap> webviewExcludedInterfacesMap = + buildHashMap(webviewExcluded); + HashMap> webviewInterfacesMap = buildHashMap(result); + HashMap> blinkStableInterfacesMap = + buildHashMap(blinkStableExpected); + StringBuilder missing = new StringBuilder(); + + // Check that each stable blink interface is present in webview except the excluded + // interfaces. + for (String interfaceS : blinkStableInterfacesMap.keySet()) { + // TODO(timvolodine): consider implementing matching of subsets as well. + HashSet subsetExcluded = webviewExcludedInterfacesMap.get(interfaceS); + if (subsetExcluded != null && subsetExcluded.isEmpty()) continue; + + if (webviewInterfacesMap.get(interfaceS) == null) { + missing.append(interfaceS + "\n"); + } + } + assertEquals("Missing webview interfaces found", "", missing.toString()); + } + // test helper methods private void runWebViewLayoutTest(final String fileName, final String fileNameExpected) diff --git a/android_webview/tools/WebViewShell/test/webexposed/not-webview-exposed.txt b/android_webview/tools/WebViewShell/test/webexposed/not-webview-exposed.txt index d0c323e4afa7..1d1c1693f6c7 100644 --- a/android_webview/tools/WebViewShell/test/webexposed/not-webview-exposed.txt +++ b/android_webview/tools/WebViewShell/test/webexposed/not-webview-exposed.txt @@ -17,6 +17,10 @@ interface Notification # not yet supported in webview. interface SharedWorker +# push API not supported in webview +interface PushManager +interface PushSubscription + # TODO(timvolodine): check screen orientation lock api # TODO(timvolodine): check notifications in service workers # TODO(timvolodine): add Presentation API -- 2.11.4.GIT