| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/page/ChromeClient.h" | 5 #include "core/page/ChromeClient.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/layout/HitTestResult.h" | 8 #include "core/layout/HitTestResult.h" |
| 9 #include "core/loader/EmptyClients.h" | 9 #include "core/loader/EmptyClients.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 void ClearToolTipForLastSetToolTip() { | 25 void ClearToolTipForLastSetToolTip() { |
| 26 tool_tip_for_last_set_tool_tip_ = String(); | 26 tool_tip_for_last_set_tool_tip_ = String(); |
| 27 } | 27 } |
| 28 | 28 |
| 29 private: | 29 private: |
| 30 String tool_tip_for_last_set_tool_tip_; | 30 String tool_tip_for_last_set_tool_tip_; |
| 31 }; | 31 }; |
| 32 | 32 |
| 33 } // anonymous namespace | 33 } // anonymous namespace |
| 34 | 34 |
| 35 class ChromeClientTest : public testing::Test {}; | 35 class ChromeClientTest : public ::testing::Test {}; |
| 36 | 36 |
| 37 TEST_F(ChromeClientTest, SetToolTipFlood) { | 37 TEST_F(ChromeClientTest, SetToolTipFlood) { |
| 38 ChromeClientToolTipLogger logger; | 38 ChromeClientToolTipLogger logger; |
| 39 ChromeClient* client = &logger; | 39 ChromeClient* client = &logger; |
| 40 HitTestResult result(HitTestRequest(HitTestRequest::kMove), | 40 HitTestResult result(HitTestRequest(HitTestRequest::kMove), |
| 41 LayoutPoint(10, 20)); | 41 LayoutPoint(10, 20)); |
| 42 Document* doc = Document::Create(); | 42 Document* doc = Document::Create(); |
| 43 Element* element = HTMLElement::Create(HTMLNames::divTag, *doc); | 43 Element* element = HTMLElement::Create(HTMLNames::divTag, *doc); |
| 44 element->setAttribute(HTMLNames::titleAttr, "tooltip"); | 44 element->setAttribute(HTMLNames::titleAttr, "tooltip"); |
| 45 result.SetInnerNode(element); | 45 result.SetInnerNode(element); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 62 | 62 |
| 63 logger.ClearToolTipForLastSetToolTip(); | 63 logger.ClearToolTipForLastSetToolTip(); |
| 64 element->setAttribute(HTMLNames::titleAttr, "updated"); | 64 element->setAttribute(HTMLNames::titleAttr, "updated"); |
| 65 client->SetToolTip(*doc->GetFrame(), result); | 65 client->SetToolTip(*doc->GetFrame(), result); |
| 66 // setToolTip(String,TextDirection) should be called because tooltip string | 66 // setToolTip(String,TextDirection) should be called because tooltip string |
| 67 // is different from the last one. | 67 // is different from the last one. |
| 68 EXPECT_EQ("updated", logger.ToolTipForLastSetToolTip()); | 68 EXPECT_EQ("updated", logger.ToolTipForLastSetToolTip()); |
| 69 } | 69 } |
| 70 | 70 |
| 71 } // namespace blink | 71 } // namespace blink |
| OLD | NEW |