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/client/window_types.h" | 10 #include "ui/aura/client/window_types.h" |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 EXPECT_EQ(1, line_count); | 289 EXPECT_EQ(1, line_count); |
290 EXPECT_EQ(ASCIIToUTF16("Small Tooltip"), tooltip); | 290 EXPECT_EQ(ASCIIToUTF16("Small Tooltip"), tooltip); |
291 | 291 |
292 // Normal small multi-line tooltip should stay as is. | 292 // Normal small multi-line tooltip should stay as is. |
293 tooltip.clear(); | 293 tooltip.clear(); |
294 width = line_count = -1; | 294 width = line_count = -1; |
295 tooltip = ASCIIToUTF16("Multi line\nTooltip"); | 295 tooltip = ASCIIToUTF16("Multi line\nTooltip"); |
296 TooltipControllerTestHelper::TrimTooltipToFit( | 296 TooltipControllerTestHelper::TrimTooltipToFit( |
297 max_width, &tooltip, &width, &line_count); | 297 max_width, &tooltip, &width, &line_count); |
298 int expected_width = font.GetStringWidth(ASCIIToUTF16("Multi line")); | 298 int expected_width = font.GetStringWidth(ASCIIToUTF16("Multi line")); |
299 expected_width = std::max(expected_width, | 299 expected_width = std::max<int>(expected_width, |
300 font.GetStringWidth(ASCIIToUTF16("Tooltip"))); | 300 font.GetStringWidth(ASCIIToUTF16("Tooltip"))); |
301 EXPECT_EQ(expected_width, width); | 301 EXPECT_EQ(expected_width, width); |
302 EXPECT_EQ(2, line_count); | 302 EXPECT_EQ(2, line_count); |
303 EXPECT_EQ(ASCIIToUTF16("Multi line\nTooltip"), tooltip); | 303 EXPECT_EQ(ASCIIToUTF16("Multi line\nTooltip"), tooltip); |
304 | 304 |
305 // Whitespaces in tooltips are preserved. | 305 // Whitespaces in tooltips are preserved. |
306 tooltip.clear(); | 306 tooltip.clear(); |
307 width = line_count = -1; | 307 width = line_count = -1; |
308 tooltip = ASCIIToUTF16("Small Tool t\tip"); | 308 tooltip = ASCIIToUTF16("Small Tool t\tip"); |
309 TooltipControllerTestHelper::TrimTooltipToFit( | 309 TooltipControllerTestHelper::TrimTooltipToFit( |
310 max_width, &tooltip, &width, &line_count); | 310 max_width, &tooltip, &width, &line_count); |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 EXPECT_EQ( | 538 EXPECT_EQ( |
539 widget_->GetNativeWindow()->GetRootWindow()->children().back()->type(), | 539 widget_->GetNativeWindow()->GetRootWindow()->children().back()->type(), |
540 aura::client::WINDOW_TYPE_TOOLTIP); | 540 aura::client::WINDOW_TYPE_TOOLTIP); |
541 } | 541 } |
542 | 542 |
543 #endif | 543 #endif |
544 | 544 |
545 } // namespace test | 545 } // namespace test |
546 } // namespace corewm | 546 } // namespace corewm |
547 } // namespace views | 547 } // namespace views |
OLD | NEW |