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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 | 147 |
148 TEST(LabelTest, Accessibility) { | 148 TEST(LabelTest, Accessibility) { |
149 Label label; | 149 Label label; |
150 base::string16 test_text(ASCIIToUTF16("My special text.")); | 150 base::string16 test_text(ASCIIToUTF16("My special text.")); |
151 label.SetText(test_text); | 151 label.SetText(test_text); |
152 | 152 |
153 ui::AXViewState state; | 153 ui::AXViewState state; |
154 label.GetAccessibleState(&state); | 154 label.GetAccessibleState(&state); |
155 EXPECT_EQ(ui::AX_ROLE_STATIC_TEXT, state.role); | 155 EXPECT_EQ(ui::AX_ROLE_STATIC_TEXT, state.role); |
156 EXPECT_EQ(test_text, state.name); | 156 EXPECT_EQ(test_text, state.name); |
157 EXPECT_TRUE(ui::AX_STATE_READ_ONLY & state.state); | 157 EXPECT_TRUE(state.HasStateFlag(ui::AX_STATE_READ_ONLY)); |
158 } | 158 } |
159 | 159 |
160 TEST(LabelTest, SingleLineSizing) { | 160 TEST(LabelTest, SingleLineSizing) { |
161 Label label; | 161 Label label; |
162 base::string16 test_text(ASCIIToUTF16("A not so random string in one line.")); | 162 base::string16 test_text(ASCIIToUTF16("A not so random string in one line.")); |
163 label.SetText(test_text); | 163 label.SetText(test_text); |
164 | 164 |
165 // GetPreferredSize | 165 // GetPreferredSize |
166 gfx::Size required_size = label.GetPreferredSize(); | 166 gfx::Size required_size = label.GetPreferredSize(); |
167 EXPECT_GT(required_size.height(), kMinTextDimension); | 167 EXPECT_GT(required_size.height(), kMinTextDimension); |
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
913 EXPECT_FALSE(label.GetTooltipHandlerForPoint(gfx::Point(2, 51))); | 913 EXPECT_FALSE(label.GetTooltipHandlerForPoint(gfx::Point(2, 51))); |
914 EXPECT_FALSE(label.GetTooltipHandlerForPoint(gfx::Point(-1, 20))); | 914 EXPECT_FALSE(label.GetTooltipHandlerForPoint(gfx::Point(-1, 20))); |
915 | 915 |
916 // GetTooltipHandlerForPoint works should work in child bounds. | 916 // GetTooltipHandlerForPoint works should work in child bounds. |
917 label.SetBounds(2, 2, 10, 10); | 917 label.SetBounds(2, 2, 10, 10); |
918 EXPECT_EQ(&label, label.GetTooltipHandlerForPoint(gfx::Point(1, 5))); | 918 EXPECT_EQ(&label, label.GetTooltipHandlerForPoint(gfx::Point(1, 5))); |
919 EXPECT_FALSE(label.GetTooltipHandlerForPoint(gfx::Point(3, 11))); | 919 EXPECT_FALSE(label.GetTooltipHandlerForPoint(gfx::Point(3, 11))); |
920 } | 920 } |
921 | 921 |
922 } // namespace views | 922 } // namespace views |
OLD | NEW |