Index: Source/web/tests/LinkHighlightTest.cpp |
diff --git a/Source/web/tests/LinkHighlightTest.cpp b/Source/web/tests/LinkHighlightTest.cpp |
index 4fcf06d73b72db25fba34cbeca9beb9c0b4f6ccf..92598146ece44141344f32523ba09d29b54af30c 100644 |
--- a/Source/web/tests/LinkHighlightTest.cpp |
+++ b/Source/web/tests/LinkHighlightTest.cpp |
@@ -39,6 +39,7 @@ |
#include "bindings/v8/ExceptionStatePlaceholder.h" |
#include "core/dom/Node.h" |
#include "core/page/FrameView.h" |
+#include "core/page/TouchDisambiguation.h" |
#include "core/platform/graphics/IntRect.h" |
#include "public/platform/Platform.h" |
#include "public/platform/WebContentLayer.h" |
@@ -89,37 +90,37 @@ TEST(LinkHighlightTest, verifyWebViewImplIntegration) |
{ |
PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()->frameView(), touchEvent); |
- webViewImpl->enableTapHighlight(platformEvent); |
+ webViewImpl->enableTapHighlightAtPoint(platformEvent); |
} |
- EXPECT_TRUE(webViewImpl->linkHighlight()); |
- EXPECT_TRUE(webViewImpl->linkHighlight()->contentLayer()); |
- EXPECT_TRUE(webViewImpl->linkHighlight()->clipLayer()); |
+ EXPECT_TRUE(webViewImpl->linkHighlight(0)); |
+ EXPECT_TRUE(webViewImpl->linkHighlight(0)->contentLayer()); |
+ EXPECT_TRUE(webViewImpl->linkHighlight(0)->clipLayer()); |
// Find a target inside a scrollable div |
touchEvent.y = 100; |
{ |
PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()->frameView(), touchEvent); |
- webViewImpl->enableTapHighlight(platformEvent); |
+ webViewImpl->enableTapHighlightAtPoint(platformEvent); |
} |
- ASSERT_TRUE(webViewImpl->linkHighlight()); |
+ ASSERT_TRUE(webViewImpl->linkHighlight(0)); |
// Don't highlight if no "hand cursor" |
touchEvent.y = 220; // An A-link with cross-hair cursor. |
{ |
PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()->frameView(), touchEvent); |
- webViewImpl->enableTapHighlight(platformEvent); |
+ webViewImpl->enableTapHighlightAtPoint(platformEvent); |
} |
- ASSERT_FALSE(webViewImpl->linkHighlight()); |
+ ASSERT_EQ(0U, webViewImpl->numLinkHighlights()); |
touchEvent.y = 260; // A text input box. |
{ |
PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()->frameView(), touchEvent); |
- webViewImpl->enableTapHighlight(platformEvent); |
+ webViewImpl->enableTapHighlightAtPoint(platformEvent); |
} |
- ASSERT_FALSE(webViewImpl->linkHighlight()); |
+ ASSERT_EQ(0U, webViewImpl->numLinkHighlights()); |
webViewImpl->close(); |
Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); |
@@ -180,16 +181,47 @@ TEST(LinkHighlightTest, resetDuringNodeRemoval) |
Node* touchNode = webViewImpl->bestTapNode(platformEvent); |
ASSERT_TRUE(touchNode); |
- webViewImpl->enableTapHighlight(platformEvent); |
- ASSERT_TRUE(webViewImpl->linkHighlight()); |
+ webViewImpl->enableTapHighlightAtPoint(platformEvent); |
+ ASSERT_TRUE(webViewImpl->linkHighlight(0)); |
- GraphicsLayer* highlightLayer = webViewImpl->linkHighlight()->currentGraphicsLayerForTesting(); |
+ GraphicsLayer* highlightLayer = webViewImpl->linkHighlight(0)->currentGraphicsLayerForTesting(); |
ASSERT_TRUE(highlightLayer); |
- EXPECT_TRUE(highlightLayer->linkHighlight()); |
+ EXPECT_TRUE(highlightLayer->linkHighlight(0)); |
touchNode->remove(IGNORE_EXCEPTION); |
webViewImpl->layout(); |
- EXPECT_FALSE(highlightLayer->linkHighlight()); |
+ ASSERT_EQ(0U, highlightLayer->numLinkHighlights()); |
+ |
+ webViewImpl->close(); |
+ Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); |
+} |
+ |
+TEST(LinkHighlightTest, multipleHighlights) |
+{ |
+ const std::string baseURL("http://www.test.com/"); |
+ const std::string fileName("test_touch_link_highlight.html"); |
+ |
+ URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_str()), WebString::fromUTF8("test_touch_link_highlight.html")); |
+ WebViewImpl* webViewImpl = toWebViewImpl(FrameTestHelpers::createWebViewAndLoad(baseURL + fileName, true, 0, compositingWebViewClient())); |
+ |
+ int pageWidth = 640; |
+ int pageHeight = 480; |
+ webViewImpl->resize(WebSize(pageWidth, pageHeight)); |
+ webViewImpl->layout(); |
+ |
+ WebGestureEvent touchEvent; |
+ touchEvent.x = 50; |
+ touchEvent.y = 310; |
+ touchEvent.data.tap.width = 30; |
+ touchEvent.data.tap.height = 30; |
+ |
+ Vector<IntRect> goodTargets; |
+ Vector<Node*> highlightNodes; |
+ IntRect boundingBox(touchEvent.x - touchEvent.data.tap.width / 2, touchEvent.y - touchEvent.data.tap.height / 2, touchEvent.data.tap.width, touchEvent.data.tap.height); |
+ findGoodTouchTargets(boundingBox, webViewImpl->mainFrameImpl()->frame(), goodTargets, highlightNodes); |
+ |
+ webViewImpl->enableTapHighlights(highlightNodes); |
+ EXPECT_EQ(2U, webViewImpl->numLinkHighlights()); |
webViewImpl->close(); |
Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); |