| Index: third_party/WebKit/Source/core/input/EventHandlerTest.cpp
|
| diff --git a/third_party/WebKit/Source/core/input/EventHandlerTest.cpp b/third_party/WebKit/Source/core/input/EventHandlerTest.cpp
|
| index 29f825c94daa0f5591b4d6f5a2a38124eb46a991..08bd48fa748314d2039bebb84dd753831ed2259e 100644
|
| --- a/third_party/WebKit/Source/core/input/EventHandlerTest.cpp
|
| +++ b/third_party/WebKit/Source/core/input/EventHandlerTest.cpp
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "core/input/EventHandler.h"
|
|
|
| +#include <memory>
|
| #include "core/dom/Document.h"
|
| #include "core/dom/Range.h"
|
| #include "core/editing/Editor.h"
|
| @@ -11,11 +12,11 @@
|
| #include "core/frame/FrameView.h"
|
| #include "core/frame/LocalFrame.h"
|
| #include "core/frame/Settings.h"
|
| +#include "core/loader/EmptyClients.h"
|
| #include "core/page/AutoscrollController.h"
|
| #include "core/page/Page.h"
|
| #include "core/testing/DummyPageHolder.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| -#include <memory>
|
|
|
| namespace blink {
|
|
|
| @@ -29,7 +30,7 @@ class EventHandlerTest : public ::testing::Test {
|
|
|
| void setHtmlInnerHTML(const char* htmlContent);
|
|
|
| - private:
|
| + protected:
|
| std::unique_ptr<DummyPageHolder> m_dummyPageHolder;
|
| };
|
|
|
| @@ -461,4 +462,63 @@ TEST_F(EventHandlerTest, dragEndInNewDrag) {
|
| // This test passes if it doesn't crash.
|
| }
|
|
|
| +class TooltipCapturingChromeClient : public EmptyChromeClient {
|
| + public:
|
| + TooltipCapturingChromeClient() {}
|
| +
|
| + void setToolTip(LocalFrame&, const String& str, TextDirection) override {
|
| + m_lastToolTip = str;
|
| + }
|
| +
|
| + String& lastToolTip() { return m_lastToolTip; }
|
| +
|
| + private:
|
| + String m_lastToolTip;
|
| +};
|
| +
|
| +class EventHandlerTooltipTest : public EventHandlerTest {
|
| + public:
|
| + EventHandlerTooltipTest() {}
|
| +
|
| + void SetUp() override {
|
| + m_chromeClient = new TooltipCapturingChromeClient();
|
| + Page::PageClients clients;
|
| + fillWithEmptyClients(clients);
|
| + clients.chromeClient = m_chromeClient.get();
|
| + m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600), &clients);
|
| + }
|
| +
|
| + String& lastToolTip() { return m_chromeClient->lastToolTip(); }
|
| +
|
| + private:
|
| + Persistent<TooltipCapturingChromeClient> m_chromeClient;
|
| +};
|
| +
|
| +TEST_F(EventHandlerTooltipTest, mouseLeaveClearsTooltip) {
|
| + setHtmlInnerHTML(
|
| + "<style>.box { width: 100%; height: 100%; }</style>"
|
| + "<img src='image.png' class='box' title='tooltip'>link</img>");
|
| +
|
| + EXPECT_EQ(WTF::String(), lastToolTip());
|
| +
|
| + WebMouseEvent mouseMoveEvent(
|
| + WebInputEvent::MouseMove, WebFloatPoint(51, 50), WebFloatPoint(51, 50),
|
| + WebPointerProperties::Button::NoButton, 0, WebInputEvent::NoModifiers,
|
| + TimeTicks::Now().InSeconds());
|
| + mouseMoveEvent.setFrameScale(1);
|
| + document().frame()->eventHandler().handleMouseMoveEvent(
|
| + mouseMoveEvent, Vector<WebMouseEvent>());
|
| +
|
| + EXPECT_EQ("tooltip", lastToolTip());
|
| +
|
| + WebMouseEvent mouseLeaveEvent(
|
| + WebInputEvent::MouseLeave, WebFloatPoint(0, 0), WebFloatPoint(0, 0),
|
| + WebPointerProperties::Button::NoButton, 0, WebInputEvent::NoModifiers,
|
| + TimeTicks::Now().InSeconds());
|
| + mouseLeaveEvent.setFrameScale(1);
|
| + document().frame()->eventHandler().handleMouseLeaveEvent(mouseLeaveEvent);
|
| +
|
| + EXPECT_EQ(WTF::String(), lastToolTip());
|
| +}
|
| +
|
| } // namespace blink
|
|
|