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

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

Issue 470833002: Add WebKit API for doing a hit-test that mimics GestureTap (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: tapCount Created 6 years, 1 month 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 | « Source/web/WebViewImpl.cpp ('k') | Source/web/tests/data/hit_test.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/tests/WebViewTest.cpp
diff --git a/Source/web/tests/WebViewTest.cpp b/Source/web/tests/WebViewTest.cpp
index 2fc38570ce3e9aaf461da08dca4bdf7f907cbbe9..797482ec3e94a70f9e82db9a66d68daee0fe572a 100644
--- a/Source/web/tests/WebViewTest.cpp
+++ b/Source/web/tests/WebViewTest.cpp
@@ -427,6 +427,35 @@ TEST_F(WebViewTest, HitTestResultAtWithPageScale)
positiveResult.reset();
}
+TEST_F(WebViewTest, HitTestResultForTapWithTapArea)
+{
+ std::string url = m_baseURL + "hit_test.html";
+ URLTestHelpers::registerMockedURLLoad(toKURL(url), "hit_test.html");
+ WebView* webView = m_webViewHelper.initializeAndLoad(url, true, 0);
+ webView->resize(WebSize(100, 100));
+ WebPoint hitPoint(55, 55);
+
+ // Image is at top left quandrant, so should not hit it.
+ WebHitTestResult negativeResult = webView->hitTestResultAt(hitPoint);
+ ASSERT_EQ(WebNode::ElementNode, negativeResult.node().nodeType());
+ EXPECT_FALSE(negativeResult.node().to<WebElement>().hasHTMLTagName("img"));
+ negativeResult.reset();
+
+ // The tap area is 20 by 20 square, centered at 55, 55.
+ WebSize tapArea(20, 20);
+ WebHitTestResult positiveResult = webView->hitTestResultForTap(hitPoint, tapArea);
+ ASSERT_EQ(WebNode::ElementNode, positiveResult.node().nodeType());
+ EXPECT_TRUE(positiveResult.node().to<WebElement>().hasHTMLTagName("img"));
+ positiveResult.reset();
+
+ // Scale down page by half so the image is outside the tapped area now.
+ webView->setPageScaleFactor(0.5f);
+ WebHitTestResult negativeResult2 = webView->hitTestResultForTap(hitPoint, tapArea);
+ ASSERT_EQ(WebNode::ElementNode, negativeResult2.node().nodeType());
+ EXPECT_FALSE(negativeResult2.node().to<WebElement>().hasHTMLTagName("img"));
+ negativeResult2.reset();
+}
+
void WebViewTest::testAutoResize(const WebSize& minAutoResize, const WebSize& maxAutoResize,
const std::string& pageWidth, const std::string& pageHeight,
int expectedWidth, int expectedHeight,
« no previous file with comments | « Source/web/WebViewImpl.cpp ('k') | Source/web/tests/data/hit_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698