TEST(LinkHighlightImplTest, verifyWebViewImplIntegration)
{
    FrameTestHelpers::UseMockScrollbarSettings mockScrollbarSettings;

    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"));
    FrameTestHelpers::WebViewHelper webViewHelper;
    WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileName, true);
    int pageWidth = 640;
    int pageHeight = 480;
    webViewImpl->resize(WebSize(pageWidth, pageHeight));
    webViewImpl->updateAllLifecyclePhases();

    WebGestureEvent touchEvent;
    touchEvent.type = WebInputEvent::GestureShowPress;
    touchEvent.sourceDevice = WebGestureDeviceTouchscreen;

    // The coordinates below are linked to absolute positions in the referenced .html file.
    touchEvent.x = 20;
    touchEvent.y = 20;

    ASSERT_TRUE(webViewImpl->bestTapNode(getTargetedEvent(webViewImpl, touchEvent)));

    touchEvent.y = 40;
    EXPECT_FALSE(webViewImpl->bestTapNode(getTargetedEvent(webViewImpl, touchEvent)));

    touchEvent.y = 20;
    // Shouldn't crash.
    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;
    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.
    webViewImpl->enableTapHighlightAtPoint(getTargetedEvent(webViewImpl, touchEvent));
    ASSERT_EQ(0U, webViewImpl->numLinkHighlights());

    touchEvent.y = 260; // A text input box.
    webViewImpl->enableTapHighlightAtPoint(getTargetedEvent(webViewImpl, touchEvent));
    ASSERT_EQ(0U, webViewImpl->numLinkHighlights());

    Platform::current()->unitTestSupport()->unregisterAllMockedURLs();
}