Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / web / tests / LinkHighlightTest.cpp
index 3adcd9d..065db88 100644 (file)
 #include "bindings/core/v8/ExceptionStatePlaceholder.h"
 #include "core/dom/Node.h"
 #include "core/frame/FrameView.h"
+#include "core/page/EventHandler.h"
+#include "core/page/Page.h"
 #include "core/page/TouchDisambiguation.h"
+#include "core/testing/URLTestHelpers.h"
 #include "platform/geometry/IntRect.h"
 #include "public/platform/Platform.h"
 #include "public/platform/WebContentLayer.h"
 #include "web/WebLocalFrameImpl.h"
 #include "web/WebViewImpl.h"
 #include "web/tests/FrameTestHelpers.h"
-#include "web/tests/URLTestHelpers.h"
 #include "wtf/PassOwnPtr.h"
 #include <gtest/gtest.h>
 
-
-using namespace blink;
 using namespace blink;
 
 namespace {
 
+GestureEventWithHitTestResults getTargetedEvent(WebViewImpl* webViewImpl, WebGestureEvent& touchEvent)
+{
+    PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()->frameView(), touchEvent);
+    return webViewImpl->page()->deprecatedLocalMainFrame()->eventHandler().targetGestureEvent(platformEvent, true);
+}
+
 TEST(LinkHighlightTest, verifyWebViewImplIntegration)
 {
     const std::string baseURL("http://www.test.com/");
@@ -74,53 +80,31 @@ TEST(LinkHighlightTest, verifyWebViewImplIntegration)
     touchEvent.x = 20;
     touchEvent.y = 20;
 
-    {
-        PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()->frameView(), touchEvent);
-        Node* touchNode = webViewImpl->bestTapNode(platformEvent);
-        ASSERT_TRUE(touchNode);
-    }
+    ASSERT_TRUE(webViewImpl->bestTapNode(getTargetedEvent(webViewImpl, touchEvent)));
 
     touchEvent.y = 40;
-    {
-        PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()->frameView(), touchEvent);
-        EXPECT_FALSE(webViewImpl->bestTapNode(platformEvent));
-    }
+    EXPECT_FALSE(webViewImpl->bestTapNode(getTargetedEvent(webViewImpl, touchEvent)));
 
     touchEvent.y = 20;
     // Shouldn't crash.
-
-    {
-        PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()->frameView(), touchEvent);
-        webViewImpl->enableTapHighlightAtPoint(platformEvent);
-    }
+    webViewImpl->enableTapHighlightAtPoint(getTargetedEvent(webViewImpl, touchEvent));
 
     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->enableTapHighlightAtPoint(platformEvent);
-    }
-
+    webViewImpl->enableTapHighlightAtPoint(getTargetedEvent(webViewImpl, touchEvent));
     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->enableTapHighlightAtPoint(platformEvent);
-    }
+    webViewImpl->enableTapHighlightAtPoint(getTargetedEvent(webViewImpl, touchEvent));
     ASSERT_EQ(0U, webViewImpl->numLinkHighlights());
 
     touchEvent.y = 260; // A text input box.
-    {
-        PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()->frameView(), touchEvent);
-        webViewImpl->enableTapHighlightAtPoint(platformEvent);
-    }
+    webViewImpl->enableTapHighlightAtPoint(getTargetedEvent(webViewImpl, touchEvent));
     ASSERT_EQ(0U, webViewImpl->numLinkHighlights());
 
     Platform::current()->unitTestSupport()->unregisterAllMockedURLs();
@@ -160,11 +144,11 @@ TEST(LinkHighlightTest, resetDuringNodeRemoval)
     touchEvent.x = 20;
     touchEvent.y = 20;
 
-    PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()->frameView(), touchEvent);
-    Node* touchNode = webViewImpl->bestTapNode(platformEvent);
+    GestureEventWithHitTestResults targetedEvent = getTargetedEvent(webViewImpl, touchEvent);
+    Node* touchNode = webViewImpl->bestTapNode(targetedEvent);
     ASSERT_TRUE(touchNode);
 
-    webViewImpl->enableTapHighlightAtPoint(platformEvent);
+    webViewImpl->enableTapHighlightAtPoint(targetedEvent);
     ASSERT_TRUE(webViewImpl->linkHighlight(0));
 
     GraphicsLayer* highlightLayer = webViewImpl->linkHighlight(0)->currentGraphicsLayerForTesting();