| 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 "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "ui/accessibility/ax_view_state.h" | 10 #include "ui/accessibility/ax_view_state.h" |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 EXPECT_EQ(test_text + test_text, label.GetDisplayTextForTesting()); | 170 EXPECT_EQ(test_text + test_text, label.GetDisplayTextForTesting()); |
| 171 EXPECT_EQ(test_text + test_text, label.text()); | 171 EXPECT_EQ(test_text + test_text, label.text()); |
| 172 } | 172 } |
| 173 | 173 |
| 174 TEST_F(LabelTest, ObscuredSurrogatePair) { | 174 TEST_F(LabelTest, ObscuredSurrogatePair) { |
| 175 // 'MUSICAL SYMBOL G CLEF': represented in UTF-16 as two characters | 175 // 'MUSICAL SYMBOL G CLEF': represented in UTF-16 as two characters |
| 176 // forming the surrogate pair 0x0001D11E. | 176 // forming the surrogate pair 0x0001D11E. |
| 177 Label label; | 177 Label label; |
| 178 base::string16 test_text = base::UTF8ToUTF16("\xF0\x9D\x84\x9E"); | 178 base::string16 test_text = base::UTF8ToUTF16("\xF0\x9D\x84\x9E"); |
| 179 label.SetText(test_text); | 179 label.SetText(test_text); |
| 180 label.SetObscured(true); |
| 180 label.SizeToPreferredSize(); | 181 label.SizeToPreferredSize(); |
| 181 | |
| 182 label.SetObscured(true); | |
| 183 EXPECT_EQ(ASCIIToUTF16("*"), label.GetDisplayTextForTesting()); | 182 EXPECT_EQ(ASCIIToUTF16("*"), label.GetDisplayTextForTesting()); |
| 184 EXPECT_EQ(test_text, label.text()); | 183 EXPECT_EQ(test_text, label.text()); |
| 185 } | 184 } |
| 186 | 185 |
| 187 // This test case verifies the label preferred size will change based on the | 186 // This test case verifies the label preferred size will change based on the |
| 188 // current layout, which may seem wrong. However many of our code base assumes | 187 // current layout, which may seem wrong. However many of our code base assumes |
| 189 // this behavior, therefore this behavior will have to be kept until the code | 188 // this behavior, therefore this behavior will have to be kept until the code |
| 190 // with this assumption is fixed. See http://crbug.com/468494 and | 189 // with this assumption is fixed. See http://crbug.com/468494 and |
| 191 // http://crbug.com/467526. | 190 // http://crbug.com/467526. |
| 192 // TODO(mukai): fix the code assuming this behavior and then fix Label | 191 // TODO(mukai): fix the code assuming this behavior and then fix Label |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 label()->SetFocusable(true); | 648 label()->SetFocusable(true); |
| 650 label()->RequestFocus(); | 649 label()->RequestFocus(); |
| 651 label()->SizeToPreferredSize(); | 650 label()->SizeToPreferredSize(); |
| 652 | 651 |
| 653 gfx::Rect focus_bounds = label()->GetFocusBounds(); | 652 gfx::Rect focus_bounds = label()->GetFocusBounds(); |
| 654 EXPECT_FALSE(focus_bounds.IsEmpty()); | 653 EXPECT_FALSE(focus_bounds.IsEmpty()); |
| 655 EXPECT_LT(label()->font_list().GetHeight(), focus_bounds.height()); | 654 EXPECT_LT(label()->font_list().GetHeight(), focus_bounds.height()); |
| 656 } | 655 } |
| 657 | 656 |
| 658 } // namespace views | 657 } // namespace views |
| OLD | NEW |