OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/gfx/canvas.h" | 5 #include "app/gfx/canvas.h" |
6 #include "app/l10n_util.h" | 6 #include "app/l10n_util.h" |
| 7 #include "base/i18n/rtl.h" |
7 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "views/border.h" | 10 #include "views/border.h" |
10 #include "views/controls/label.h" | 11 #include "views/controls/label.h" |
11 | 12 |
12 namespace views { | 13 namespace views { |
13 | 14 |
14 // All text sizing measurements (width and height) should be greater than this. | 15 // All text sizing measurements (width and height) should be greater than this. |
15 const int kMinTextDimension = 4; | 16 const int kMinTextDimension = 4; |
16 | 17 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 SkColor color = SkColorSetARGB(20, 40, 10, 5); | 59 SkColor color = SkColorSetARGB(20, 40, 10, 5); |
59 label.SetColor(color); | 60 label.SetColor(color); |
60 EXPECT_EQ(color, label.GetColor()); | 61 EXPECT_EQ(color, label.GetColor()); |
61 SkColor h_color = SkColorSetARGB(40, 80, 20, 10); | 62 SkColor h_color = SkColorSetARGB(40, 80, 20, 10); |
62 label.SetHighlightColor(h_color); | 63 label.SetHighlightColor(h_color); |
63 EXPECT_EQ(h_color, label.GetHighlightColor()); | 64 EXPECT_EQ(h_color, label.GetHighlightColor()); |
64 } | 65 } |
65 | 66 |
66 TEST(LabelTest, AlignmentProperty) { | 67 TEST(LabelTest, AlignmentProperty) { |
67 Label label; | 68 Label label; |
68 bool reverse_alignment = | 69 bool reverse_alignment = base::i18n::IsRTL(); |
69 l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT; | |
70 | 70 |
71 label.SetHorizontalAlignment(Label::ALIGN_RIGHT); | 71 label.SetHorizontalAlignment(Label::ALIGN_RIGHT); |
72 EXPECT_EQ( | 72 EXPECT_EQ( |
73 reverse_alignment ? Label::ALIGN_LEFT : Label::ALIGN_RIGHT, | 73 reverse_alignment ? Label::ALIGN_LEFT : Label::ALIGN_RIGHT, |
74 label.GetHorizontalAlignment()); | 74 label.GetHorizontalAlignment()); |
75 label.SetHorizontalAlignment(Label::ALIGN_LEFT); | 75 label.SetHorizontalAlignment(Label::ALIGN_LEFT); |
76 EXPECT_EQ( | 76 EXPECT_EQ( |
77 reverse_alignment ? Label::ALIGN_RIGHT : Label::ALIGN_LEFT, | 77 reverse_alignment ? Label::ALIGN_RIGHT : Label::ALIGN_LEFT, |
78 label.GetHorizontalAlignment()); | 78 label.GetHorizontalAlignment()); |
79 label.SetHorizontalAlignment(Label::ALIGN_CENTER); | 79 label.SetHorizontalAlignment(Label::ALIGN_CENTER); |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 #else | 502 #else |
503 EXPECT_EQ( | 503 EXPECT_EQ( |
504 gfx::Canvas::MULTI_LINE | | 504 gfx::Canvas::MULTI_LINE | |
505 gfx::Canvas::TEXT_ALIGN_CENTER | | 505 gfx::Canvas::TEXT_ALIGN_CENTER | |
506 gfx::Canvas::NO_ELLIPSIS, | 506 gfx::Canvas::NO_ELLIPSIS, |
507 flags); | 507 flags); |
508 #endif | 508 #endif |
509 } | 509 } |
510 | 510 |
511 } // namespace views | 511 } // namespace views |
OLD | NEW |