OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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_aura.h" | 5 #include "ui/views/corewm/tooltip_aura.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "ui/aura/test/aura_test_base.h" | 8 #include "ui/aura/test/aura_test_base.h" |
9 #include "ui/base/resource/resource_bundle.h" | 9 #include "ui/base/resource/resource_bundle.h" |
10 #include "ui/gfx/font_list.h" | 10 #include "ui/gfx/font_list.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 #if !defined(OS_WIN) | 79 #if !defined(OS_WIN) |
80 // Tooltip with really long word gets elided. | 80 // Tooltip with really long word gets elided. |
81 tooltip.clear(); | 81 tooltip.clear(); |
82 width = line_count = -1; | 82 width = line_count = -1; |
83 tooltip = UTF8ToUTF16(std::string('a', max_pixel_width)); | 83 tooltip = UTF8ToUTF16(std::string('a', max_pixel_width)); |
84 TooltipAura::TrimTooltipToFit(font_list, max_width, &tooltip, &width, | 84 TooltipAura::TrimTooltipToFit(font_list, max_width, &tooltip, &width, |
85 &line_count); | 85 &line_count); |
86 EXPECT_NEAR(max_pixel_width, width, 5); | 86 EXPECT_NEAR(max_pixel_width, width, 5); |
87 EXPECT_EQ(1, line_count); | 87 EXPECT_EQ(1, line_count); |
88 EXPECT_EQ(gfx::ElideText(UTF8ToUTF16(std::string('a', max_pixel_width)), | 88 EXPECT_EQ(gfx::ElideText(UTF8ToUTF16(std::string('a', max_pixel_width)), |
89 font_list, | 89 font_list, max_pixel_width, gfx::ELIDE_TAIL), |
90 max_pixel_width, gfx::ELIDE_AT_END), tooltip); | 90 tooltip); |
91 #endif | 91 #endif |
92 | 92 |
93 // Normal small tooltip should stay as is. | 93 // Normal small tooltip should stay as is. |
94 tooltip.clear(); | 94 tooltip.clear(); |
95 width = line_count = -1; | 95 width = line_count = -1; |
96 tooltip = ASCIIToUTF16("Small Tooltip"); | 96 tooltip = ASCIIToUTF16("Small Tooltip"); |
97 TooltipAura::TrimTooltipToFit(font_list, max_width, &tooltip, &width, | 97 TooltipAura::TrimTooltipToFit(font_list, max_width, &tooltip, &width, |
98 &line_count); | 98 &line_count); |
99 EXPECT_EQ(gfx::GetStringWidth(ASCIIToUTF16("Small Tooltip"), font_list), | 99 EXPECT_EQ(gfx::GetStringWidth(ASCIIToUTF16("Small Tooltip"), font_list), |
100 width); | 100 width); |
(...skipping 22 matching lines...) Expand all Loading... |
123 TooltipAura::TrimTooltipToFit(font_list, max_width, &tooltip, &width, | 123 TooltipAura::TrimTooltipToFit(font_list, max_width, &tooltip, &width, |
124 &line_count); | 124 &line_count); |
125 EXPECT_EQ(gfx::GetStringWidth(ASCIIToUTF16("Small Tool t\tip"), font_list), | 125 EXPECT_EQ(gfx::GetStringWidth(ASCIIToUTF16("Small Tool t\tip"), font_list), |
126 width); | 126 width); |
127 EXPECT_EQ(1, line_count); | 127 EXPECT_EQ(1, line_count); |
128 EXPECT_EQ(ASCIIToUTF16("Small Tool t\tip"), tooltip); | 128 EXPECT_EQ(ASCIIToUTF16("Small Tool t\tip"), tooltip); |
129 } | 129 } |
130 | 130 |
131 } // namespace corewm | 131 } // namespace corewm |
132 } // namespace views | 132 } // namespace views |
OLD | NEW |