OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/controls/label.h" | 5 #include "ui/views/controls/label.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 // Changing layout just resets |lines_|. It'll recover next time it's drawn. | 584 // Changing layout just resets |lines_|. It'll recover next time it's drawn. |
585 label.SetBounds(0, 0, 10, 10); | 585 label.SetBounds(0, 0, 10, 10); |
586 EXPECT_EQ(0u, label.lines_.size()); | 586 EXPECT_EQ(0u, label.lines_.size()); |
587 | 587 |
588 label.Paint(ui::CanvasPainter(&canvas, 1.f).context()); | 588 label.Paint(ui::CanvasPainter(&canvas, 1.f).context()); |
589 EXPECT_EQ(1u, label.lines_.size()); | 589 EXPECT_EQ(1u, label.lines_.size()); |
590 } | 590 } |
591 | 591 |
592 #if !defined(OS_MACOSX) | 592 #if !defined(OS_MACOSX) |
593 TEST_F(LabelTest, MultilineSupportedRenderText) { | 593 TEST_F(LabelTest, MultilineSupportedRenderText) { |
594 scoped_ptr<gfx::RenderText> render_text(gfx::RenderText::CreateInstance()); | 594 std::unique_ptr<gfx::RenderText> render_text( |
| 595 gfx::RenderText::CreateInstance()); |
595 ASSERT_TRUE(render_text->MultilineSupported()); | 596 ASSERT_TRUE(render_text->MultilineSupported()); |
596 | 597 |
597 Label label; | 598 Label label; |
598 label.SetText(ASCIIToUTF16("Example of\nmultilined label")); | 599 label.SetText(ASCIIToUTF16("Example of\nmultilined label")); |
599 label.SetMultiLine(true); | 600 label.SetMultiLine(true); |
600 label.SizeToPreferredSize(); | 601 label.SizeToPreferredSize(); |
601 | 602 |
602 gfx::Canvas canvas(label.GetPreferredSize(), 1.0f, true); | 603 gfx::Canvas canvas(label.GetPreferredSize(), 1.0f, true); |
603 label.Paint(ui::CanvasPainter(&canvas, 1.f).context()); | 604 label.Paint(ui::CanvasPainter(&canvas, 1.f).context()); |
604 | 605 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 label()->SetFocusable(true); | 652 label()->SetFocusable(true); |
652 label()->RequestFocus(); | 653 label()->RequestFocus(); |
653 label()->SizeToPreferredSize(); | 654 label()->SizeToPreferredSize(); |
654 | 655 |
655 gfx::Rect focus_bounds = label()->GetFocusBounds(); | 656 gfx::Rect focus_bounds = label()->GetFocusBounds(); |
656 EXPECT_FALSE(focus_bounds.IsEmpty()); | 657 EXPECT_FALSE(focus_bounds.IsEmpty()); |
657 EXPECT_LT(label()->font_list().GetHeight(), focus_bounds.height()); | 658 EXPECT_LT(label()->font_list().GetHeight(), focus_bounds.height()); |
658 } | 659 } |
659 | 660 |
660 } // namespace views | 661 } // namespace views |
OLD | NEW |