OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "ui/views/corewm/tooltip_controller.h" | 5 #include "ui/views/corewm/tooltip_controller.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "ui/aura/client/cursor_client.h" | 8 #include "ui/aura/client/cursor_client.h" |
9 #include "ui/aura/client/tooltip_client.h" | 9 #include "ui/aura/client/tooltip_client.h" |
10 #include "ui/aura/env.h" | 10 #include "ui/aura/env.h" |
11 #include "ui/aura/root_window.h" | 11 #include "ui/aura/root_window.h" |
12 #include "ui/aura/test/aura_test_base.h" | 12 #include "ui/aura/test/aura_test_base.h" |
13 #include "ui/aura/test/event_generator.h" | 13 #include "ui/aura/test/event_generator.h" |
14 #include "ui/aura/window.h" | 14 #include "ui/aura/window.h" |
15 #include "ui/base/resource/resource_bundle.h" | 15 #include "ui/base/resource/resource_bundle.h" |
16 #include "ui/base/text/text_elider.h" | |
17 #include "ui/gfx/font.h" | 16 #include "ui/gfx/font.h" |
18 #include "ui/gfx/point.h" | 17 #include "ui/gfx/point.h" |
| 18 #include "ui/gfx/text_elider.h" |
19 #include "ui/views/corewm/tooltip_controller_test_helper.h" | 19 #include "ui/views/corewm/tooltip_controller_test_helper.h" |
20 #include "ui/views/view.h" | 20 #include "ui/views/view.h" |
21 #include "ui/views/widget/widget.h" | 21 #include "ui/views/widget/widget.h" |
22 | 22 |
23 #if defined(OS_WIN) | 23 #if defined(OS_WIN) |
24 #include "ui/base/win/scoped_ole_initializer.h" | 24 #include "ui/base/win/scoped_ole_initializer.h" |
25 #endif | 25 #endif |
26 #if !defined(OS_CHROMEOS) | 26 #if !defined(OS_CHROMEOS) |
27 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 27 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
28 #endif | 28 #endif |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 | 267 |
268 #if !defined(OS_WIN) | 268 #if !defined(OS_WIN) |
269 // Tooltip with really long word gets elided. | 269 // Tooltip with really long word gets elided. |
270 tooltip.clear(); | 270 tooltip.clear(); |
271 width = line_count = -1; | 271 width = line_count = -1; |
272 tooltip = UTF8ToUTF16(std::string('a', max_pixel_width)); | 272 tooltip = UTF8ToUTF16(std::string('a', max_pixel_width)); |
273 TooltipControllerTestHelper::TrimTooltipToFit( | 273 TooltipControllerTestHelper::TrimTooltipToFit( |
274 max_width, &tooltip, &width, &line_count); | 274 max_width, &tooltip, &width, &line_count); |
275 EXPECT_NEAR(max_pixel_width, width, 5); | 275 EXPECT_NEAR(max_pixel_width, width, 5); |
276 EXPECT_EQ(1, line_count); | 276 EXPECT_EQ(1, line_count); |
277 EXPECT_EQ(ui::ElideText(UTF8ToUTF16(std::string('a', max_pixel_width)), font, | 277 EXPECT_EQ(gfx::ElideText(UTF8ToUTF16(std::string('a', max_pixel_width)), font, |
278 max_pixel_width, ui::ELIDE_AT_END), tooltip); | 278 max_pixel_width, gfx::ELIDE_AT_END), tooltip); |
279 #endif | 279 #endif |
280 | 280 |
281 // Normal small tooltip should stay as is. | 281 // Normal small tooltip should stay as is. |
282 tooltip.clear(); | 282 tooltip.clear(); |
283 width = line_count = -1; | 283 width = line_count = -1; |
284 tooltip = ASCIIToUTF16("Small Tooltip"); | 284 tooltip = ASCIIToUTF16("Small Tooltip"); |
285 TooltipControllerTestHelper::TrimTooltipToFit( | 285 TooltipControllerTestHelper::TrimTooltipToFit( |
286 max_width, &tooltip, &width, &line_count); | 286 max_width, &tooltip, &width, &line_count); |
287 EXPECT_EQ(font.GetStringWidth(ASCIIToUTF16("Small Tooltip")), width); | 287 EXPECT_EQ(font.GetStringWidth(ASCIIToUTF16("Small Tooltip")), width); |
288 EXPECT_EQ(1, line_count); | 288 EXPECT_EQ(1, line_count); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 helper_->FireTooltipTimer(); | 422 helper_->FireTooltipTimer(); |
423 | 423 |
424 EXPECT_TRUE(helper_->IsTooltipVisible()); | 424 EXPECT_TRUE(helper_->IsTooltipVisible()); |
425 generator_->SendMouseExit(); | 425 generator_->SendMouseExit(); |
426 EXPECT_FALSE(helper_->IsTooltipVisible()); | 426 EXPECT_FALSE(helper_->IsTooltipVisible()); |
427 } | 427 } |
428 | 428 |
429 } // namespace test | 429 } // namespace test |
430 } // namespace corewm | 430 } // namespace corewm |
431 } // namespace views | 431 } // namespace views |
OLD | NEW |