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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 event.x = 25; 1028 event.x = 25;
1029 event.y = 7; 1029 event.y = 7;
1030 webView->handleInputEvent(event); 1030 webView->handleInputEvent(event);
1031 runPendingTasks(); 1031 runPendingTasks();
1032 EXPECT_EQ(25, client.longpressX()); 1032 EXPECT_EQ(25, client.longpressX());
1033 EXPECT_EQ(7, client.longpressY()); 1033 EXPECT_EQ(7, client.longpressY());
1034 1034
1035 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally scoped client. 1035 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally scoped client.
1036 } 1036 }
1037 1037
1038 static bool tapElementAndReturnWasHandled(WebView* webView, WebInputEvent::Type type, const WebString& id)
1039 {
1040 ASSERT(webView);
1041 RefPtrWillBeRawPtr<WebCore::Element> element = static_cast<PassRefPtrWillBeR awPtr<WebCore::Element> >(webView->mainFrame()->document().getElementById(id));
1042 ASSERT(element);
1043
1044 element->scrollIntoViewIfNeeded();
1045 WebCore::IntPoint center = element->screenRect().center();
1046
1047 WebGestureEvent event;
1048 event.type = type;
1049 event.x = center.x();
1050 event.y = center.y();
1051
1052 bool handled = webView->handleInputEvent(event);
1053 runPendingTasks();
1054 return handled;
1055 }
1056
1057 TEST_F(WebViewTest, TapHandled)
1058 {
1059 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("tap_handled.html"));
1060 TapHandlingWebViewClient client;
1061 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "tap_handle d.html", true, 0, &client);
1062
1063 webView->resize(WebSize(500, 300));
1064 webView->layout();
1065 runPendingTasks();
1066
1067 WebString staticText = WebString::fromUTF8("static");
1068 WebString editable = WebString::fromUTF8("editable");
1069 WebString consumes = WebString::fromUTF8("consumes");
1070 WebString ignores = WebString::fromUTF8("ignores");
1071
1072 EXPECT_FALSE(tapElementAndReturnWasHandled(webView, WebInputEvent::GestureTa p, staticText));
1073 EXPECT_TRUE(tapElementAndReturnWasHandled(webView, WebInputEvent::GestureTap , editable));
1074 EXPECT_FALSE(tapElementAndReturnWasHandled(webView, WebInputEvent::GestureTa p, consumes));
1075 EXPECT_FALSE(tapElementAndReturnWasHandled(webView, WebInputEvent::GestureTa p, ignores));
1076
1077 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally scoped client.
1078 }
1079
1080
1038 #if OS(ANDROID) 1081 #if OS(ANDROID)
1039 TEST_F(WebViewTest, LongPressSelection) 1082 TEST_F(WebViewTest, LongPressSelection)
1040 { 1083 {
1041 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("longpress_selection.html")); 1084 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("longpress_selection.html"));
1042 1085
1043 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "longpress_ selection.html", true); 1086 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "longpress_ selection.html", true);
1044 webView->resize(WebSize(500, 300)); 1087 webView->resize(WebSize(500, 300));
1045 webView->layout(); 1088 webView->layout();
1046 runPendingTasks(); 1089 runPendingTasks();
1047 1090
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after
1944 1987
1945 EXPECT_EQ(0, client.getUserGestureNotificationsCount()); 1988 EXPECT_EQ(0, client.getUserGestureNotificationsCount());
1946 1989
1947 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, WebString::fr omUTF8("target"))); 1990 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, WebString::fr omUTF8("target")));
1948 1991
1949 EXPECT_EQ(1, client.getUserGestureNotificationsCount()); 1992 EXPECT_EQ(1, client.getUserGestureNotificationsCount());
1950 webView->setAutofillClient(0); 1993 webView->setAutofillClient(0);
1951 } 1994 }
1952 1995
1953 } // namespace 1996 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698