Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1525)

Unified Diff: android_webview/tools/system_webview_shell/layout_tests/src/org/chromium/webview_shell/test/WebViewLayoutTest.java

Issue 2684313002: [WebViewLayoutTest] Implement a fallback mechanism and re-enable testWebViewIncludedStableInterface… (Closed)
Patch Set: fix bots Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « android_webview/tools/system_webview_shell/BUILD.gn ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 a7218502d06b5b5d427402276ae5a731eff3a559..8bd9124e0f48faca8040d5e36dc62b0277e69ea2 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
@@ -22,8 +22,10 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
@@ -39,12 +41,24 @@ public class WebViewLayoutTest
private static final String BASE_WEBVIEW_TEST_PATH =
"android_webview/tools/system_webview_shell/test/data/";
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 String GLOBAL_LISTING_FILE =
+ "webexposed/global-interface-listing-expected.txt";
+
+ // Due to the specifics of the rebaselining algorithm in blink the files containing
+ // stable interfaces can dissapear and reappear later. To select the file to compare
+ // against a fallback approach is used. The order in the List below is important due
+ // to how blink performs baseline optimizations. For more details see
+ // third_party/WebKit/Tools/Scripts/webkitpy/common/checkout/baseline_optimizer.py.
+ private static final List<String> BLINK_STABLE_FALLBACKS = Arrays.asList(
+ EXTERNAL_PREFIX + BASE_BLINK_TEST_PATH + "virtual/stable/" + GLOBAL_LISTING_FILE,
+ EXTERNAL_PREFIX + BASE_BLINK_TEST_PATH + "platform/linux/virtual/stable/"
+ + GLOBAL_LISTING_FILE,
+ EXTERNAL_PREFIX + BASE_BLINK_TEST_PATH + "platform/win/virtual/stable/"
+ + GLOBAL_LISTING_FILE,
+ EXTERNAL_PREFIX + BASE_BLINK_TEST_PATH + "platform/mac/virtual/stable/"
+ + GLOBAL_LISTING_FILE);
private static final long TIMEOUT_SECONDS = 20;
@@ -157,14 +171,12 @@ public class WebViewLayoutTest
assertEquals("Unexpected webview interfaces found", "", unexpected.toString());
}
- @DisabledTest(message = "crbug.com/683153")
@MediumTest
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 blinkStableExpected = readFileWithFallbacks(BLINK_STABLE_FALLBACKS);
String webviewExcluded = readFile(PATH_WEBVIEW_PREFIX
+ "webexposed/not-webview-exposed.txt");
mTestActivity.waitForFinish(TIMEOUT_SECONDS, TimeUnit.SECONDS);
@@ -343,6 +355,21 @@ public class WebViewLayoutTest
}
/**
+ * Reads the first available file in the 'fallback' list and returns the result.
+ * Throws FileNotFoundException if non of the files exist.
+ */
+ private static String readFileWithFallbacks(List<String> fallbackFileNames) throws IOException {
+ for (String fileName : fallbackFileNames) {
+ File file = new File(fileName);
+ if (file.exists()) {
+ return readFile(fileName);
+ }
+ }
+
+ throw new FileNotFoundException("None of the fallback files could be read");
+ }
+
+ /**
* Writes a file with the given fileName and contents. If overwrite is true overwrites any
* exisiting file with the same file name. If the file does not exist any intermediate
* required directories are created.
« no previous file with comments | « android_webview/tools/system_webview_shell/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698