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

Unified Diff: android_webview/javatests/src/org/chromium/android_webview/test/WebViewModalDialogOverrideTest.java

Issue 2869563004: Deflake WebViewModalDialogOverrideTest#testOverrideBeforeUnloadHandling. (Closed)
Patch Set: throw Created 3 years, 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/javatests/src/org/chromium/android_webview/test/WebViewModalDialogOverrideTest.java
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/WebViewModalDialogOverrideTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/WebViewModalDialogOverrideTest.java
index 788074acd9f970e8b4b58503cf64a9f179836644..12f4a0ecb460d7145f9f635c24e7f1c62c6295ee 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/WebViewModalDialogOverrideTest.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/WebViewModalDialogOverrideTest.java
@@ -17,7 +17,7 @@ import org.chromium.android_webview.JsResultReceiver;
import org.chromium.android_webview.test.util.AwTestTouchUtils;
import org.chromium.base.test.util.CallbackHelper;
import org.chromium.base.test.util.Feature;
-import org.chromium.base.test.util.RetryOnFailure;
+import org.chromium.content_public.browser.GestureStateListener;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -157,13 +157,40 @@ public class WebViewModalDialogOverrideTest extends AwTestBase {
assertEquals("false", result);
}
+ private static class TapGestureStateListener extends GestureStateListener {
+ private CallbackHelper mCallbackHelper = new CallbackHelper();
+
+ public int getCallCount() {
+ return mCallbackHelper.getCallCount();
+ }
+
+ public void waitForTap(int currentCallCount) throws Throwable {
+ mCallbackHelper.waitForCallback(currentCallCount);
+ }
+
+ @Override
+ public void onSingleTap(boolean consumed) {
+ mCallbackHelper.notifyCalled();
+ }
+ }
+
+ /**
+ * Taps on a view and waits for a callback.
+ */
+ private void tapViewAndWait(AwTestContainerView view) throws Throwable {
+ final TapGestureStateListener tapGestureStateListener = new TapGestureStateListener();
+ int callCount = tapGestureStateListener.getCallCount();
+ view.getContentViewCore().addGestureStateListener(tapGestureStateListener);
+
+ AwTestTouchUtils.simulateTouchCenterOfView(view);
+ tapGestureStateListener.waitForTap(callCount);
+ }
+
/*
* Verify that when the AwContentsClient calls handleJsBeforeUnload
- * Flaky (crbug/719308)
*/
@MediumTest
@Feature({"AndroidWebView"})
- @RetryOnFailure
public void testOverrideBeforeUnloadHandling() throws Throwable {
final CallbackHelper jsBeforeUnloadHelper = new CallbackHelper();
TestAwContentsClient client = new TestAwContentsClient() {
@@ -181,7 +208,7 @@ public class WebViewModalDialogOverrideTest extends AwTestBase {
"text/html", false);
enableJavaScriptOnUiThread(awContents);
// JavaScript onbeforeunload dialogs require a user gesture.
- AwTestTouchUtils.simulateTouchCenterOfView(view);
+ tapViewAndWait(view);
// Don't wait synchronously because we don't leave the page.
int currentCallCount = jsBeforeUnloadHelper.getCallCount();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698