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

Side by Side Diff: third_party/WebKit/Source/core/page/ChromeClientTest.cpp

Issue 1504743002: Do not show a tooltip same as the previous one. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2564
Patch Set: Created 5 years 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/page/ChromeClient.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "core/page/ChromeClient.h"
7
8 #include "core/dom/Document.h"
9 #include "core/layout/HitTestResult.h"
10 #include "core/loader/EmptyClients.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 namespace blink {
14
15 namespace {
16
17 class ChromeClientToolTipLogger : public EmptyChromeClient {
18 public:
19 void setToolTip(const String& text, TextDirection) override
20 {
21 m_toolTipForLastSetToolTip = text;
22 }
23
24 String toolTipForLastSetToolTip() const { return m_toolTipForLastSetToolTip; }
25 void clearToolTipForLastSetToolTip() { m_toolTipForLastSetToolTip = String() ; }
26
27 private:
28 String m_toolTipForLastSetToolTip;
29 };
30
31 } // anonymous namespace
32
33 class ChromeClientTest : public testing::Test {
34 };
35
36 TEST_F(ChromeClientTest, SetToolTipFlood)
37 {
38 ChromeClientToolTipLogger logger;
39 ChromeClient* client = &logger;
40 HitTestResult result(HitTestRequest(HitTestRequest::Move), LayoutPoint(10, 2 0));
41 RefPtrWillBeRawPtr<Document> doc = Document::create();
42 RefPtrWillBeRawPtr<Element> element = HTMLElement::create(HTMLNames::divTag, *doc);
43 element->setAttribute(HTMLNames::titleAttr, "tooltip");
44 result.setInnerNode(element.get());
45
46 client->setToolTip(result);
47 EXPECT_EQ("tooltip", logger.toolTipForLastSetToolTip());
48
49 // seToolTip(HitTestResult) again in the same condition.
50 logger.clearToolTipForLastSetToolTip();
51 client->setToolTip(result);
52 // setToolTip(String,TextDirection) should not be called.
53 EXPECT_EQ(String(), logger.toolTipForLastSetToolTip());
54
55 // Cancel the tooltip, and setToolTip(HitTestResult) again.
56 client->clearToolTip();
57 logger.clearToolTipForLastSetToolTip();
58 client->setToolTip(result);
59 // setToolTip(String,TextDirection) should not be called.
60 EXPECT_EQ(String(), logger.toolTipForLastSetToolTip());
61
62 logger.clearToolTipForLastSetToolTip();
63 element->setAttribute(HTMLNames::titleAttr, "updated");
64 client->setToolTip(result);
65 // setToolTip(String,TextDirection) should be called because tooltip string
66 // is different from the last one.
67 EXPECT_EQ("updated", logger.toolTipForLastSetToolTip());
68 }
69
70 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/page/ChromeClient.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698