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

Unified Diff: Source/web/tests/WebViewTest.cpp

Issue 267313008: First-cut at fixing unhandled Tap event returns in Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added separate isInteractiveNode() static function to EventHandler.cpp. Created 6 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
Index: Source/web/tests/WebViewTest.cpp
diff --git a/Source/web/tests/WebViewTest.cpp b/Source/web/tests/WebViewTest.cpp
index 12161bf0b7de101af17e113e257e6dbacc4e1db9..2aff9c81c2ec6a6e20109aee4dc9f243ea990b26 100644
--- a/Source/web/tests/WebViewTest.cpp
+++ b/Source/web/tests/WebViewTest.cpp
@@ -1035,6 +1035,49 @@ TEST_F(WebViewTest, ClientTapHandling)
m_webViewHelper.reset(); // Explicitly reset to break dependency on locally scoped client.
}
+static bool tapElementAndReturnWasHandled(WebView* webView, WebInputEvent::Type type, const WebString& id)
+{
+ ASSERT(webView);
+ RefPtrWillBeRawPtr<WebCore::Element> element = static_cast<PassRefPtrWillBeRawPtr<WebCore::Element> >(webView->mainFrame()->document().getElementById(id));
+ ASSERT(element);
+
+ element->scrollIntoViewIfNeeded();
+ WebCore::IntPoint center = element->screenRect().center();
+
+ WebGestureEvent event;
+ event.type = type;
+ event.x = center.x();
+ event.y = center.y();
+
+ bool handled = webView->handleInputEvent(event);
+ runPendingTasks();
+ return handled;
+}
+
+TEST_F(WebViewTest, TapHandled)
+{
+ URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("tap_handled.html"));
+ TapHandlingWebViewClient client;
+ WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "tap_handled.html", true, 0, &client);
+
+ webView->resize(WebSize(500, 300));
+ webView->layout();
+ runPendingTasks();
+
+ WebString staticText = WebString::fromUTF8("static");
+ WebString editable = WebString::fromUTF8("editable");
+ WebString consumes = WebString::fromUTF8("consumes");
+ WebString ignores = WebString::fromUTF8("ignores");
+
+ EXPECT_FALSE(tapElementAndReturnWasHandled(webView, WebInputEvent::GestureTap, staticText));
+ EXPECT_TRUE(tapElementAndReturnWasHandled(webView, WebInputEvent::GestureTap, editable));
+ EXPECT_FALSE(tapElementAndReturnWasHandled(webView, WebInputEvent::GestureTap, consumes));
+ EXPECT_FALSE(tapElementAndReturnWasHandled(webView, WebInputEvent::GestureTap, ignores));
+
+ m_webViewHelper.reset(); // Explicitly reset to break dependency on locally scoped client.
+}
+
+
#if OS(ANDROID)
TEST_F(WebViewTest, LongPressSelection)
{

Powered by Google App Engine
This is Rietveld 408576698