| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "base/string_util.h" | 5 #include "base/string_util.h" |
| 6 #include "chrome/common/gfx/chrome_canvas.h" | 6 #include "chrome/common/gfx/chrome_canvas.h" |
| 7 #include "chrome/common/l10n_util.h" | 7 #include "chrome/common/l10n_util.h" |
| 8 #include "chrome/views/border.h" | 8 #include "chrome/views/border.h" |
| 9 #include "chrome/views/controls/label.h" | 9 #include "chrome/views/controls/label.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 EXPECT_STREQ(tooltip_text.c_str(), tooltip.c_str()); | 139 EXPECT_STREQ(tooltip_text.c_str(), tooltip.c_str()); |
| 140 // Clear out the tooltip. | 140 // Clear out the tooltip. |
| 141 label.SetTooltipText(empty_text); | 141 label.SetTooltipText(empty_text); |
| 142 } | 142 } |
| 143 | 143 |
| 144 TEST(LabelTest, Accessibility) { | 144 TEST(LabelTest, Accessibility) { |
| 145 Label label; | 145 Label label; |
| 146 std::wstring test_text(L"My special text."); | 146 std::wstring test_text(L"My special text."); |
| 147 label.SetText(test_text); | 147 label.SetText(test_text); |
| 148 | 148 |
| 149 VARIANT role; | 149 AccessibilityTypes::Role role; |
| 150 ::VariantInit(&role); | |
| 151 EXPECT_TRUE(label.GetAccessibleRole(&role)); | 150 EXPECT_TRUE(label.GetAccessibleRole(&role)); |
| 152 EXPECT_EQ(VT_I4, role.vt); | 151 EXPECT_EQ(AccessibilityTypes::ROLE_TEXT, role); |
| 153 EXPECT_EQ(ROLE_SYSTEM_TEXT, role.lVal); | |
| 154 | 152 |
| 155 std::wstring name; | 153 std::wstring name; |
| 156 EXPECT_TRUE(label.GetAccessibleName(&name)); | 154 EXPECT_TRUE(label.GetAccessibleName(&name)); |
| 157 EXPECT_STREQ(test_text.c_str(), name.c_str()); | 155 EXPECT_STREQ(test_text.c_str(), name.c_str()); |
| 158 | 156 |
| 159 VARIANT state; | 157 AccessibilityTypes::State state; |
| 160 ::VariantInit(&state); | |
| 161 state.vt = VT_I4; | |
| 162 state.lVal = 0; | |
| 163 EXPECT_TRUE(label.GetAccessibleState(&state)); | 158 EXPECT_TRUE(label.GetAccessibleState(&state)); |
| 164 EXPECT_EQ(VT_I4, state.vt); | 159 EXPECT_EQ(AccessibilityTypes::STATE_READONLY, state); |
| 165 EXPECT_EQ(STATE_SYSTEM_READONLY, state.lVal); | |
| 166 } | 160 } |
| 167 | 161 |
| 168 TEST(LabelTest, SingleLineSizing) { | 162 TEST(LabelTest, SingleLineSizing) { |
| 169 Label label; | 163 Label label; |
| 170 std::wstring test_text(L"A not so random string in one line."); | 164 std::wstring test_text(L"A not so random string in one line."); |
| 171 label.SetText(test_text); | 165 label.SetText(test_text); |
| 172 | 166 |
| 173 // GetPreferredSize | 167 // GetPreferredSize |
| 174 gfx::Size required_size = label.GetPreferredSize(); | 168 gfx::Size required_size = label.GetPreferredSize(); |
| 175 EXPECT_GT(required_size.height(), kMinTextDimension); | 169 EXPECT_GT(required_size.height(), kMinTextDimension); |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 label.CalculateDrawStringParams(&paint_text, &text_bounds, &flags); | 432 label.CalculateDrawStringParams(&paint_text, &text_bounds, &flags); |
| 439 EXPECT_STREQ(test_text.c_str(), paint_text.c_str()); | 433 EXPECT_STREQ(test_text.c_str(), paint_text.c_str()); |
| 440 EXPECT_EQ(center_bounds.x() + border.left(), text_bounds.x()); | 434 EXPECT_EQ(center_bounds.x() + border.left(), text_bounds.x()); |
| 441 EXPECT_EQ(center_bounds.y() + border.top(), text_bounds.y()); | 435 EXPECT_EQ(center_bounds.y() + border.top(), text_bounds.y()); |
| 442 EXPECT_EQ(center_bounds.width(), text_bounds.width()); | 436 EXPECT_EQ(center_bounds.width(), text_bounds.width()); |
| 443 EXPECT_EQ(center_bounds.height(), text_bounds.height()); | 437 EXPECT_EQ(center_bounds.height(), text_bounds.height()); |
| 444 EXPECT_EQ(ChromeCanvas::MULTI_LINE | ChromeCanvas::TEXT_ALIGN_CENTER, flags); | 438 EXPECT_EQ(ChromeCanvas::MULTI_LINE | ChromeCanvas::TEXT_ALIGN_CENTER, flags); |
| 445 } | 439 } |
| 446 | 440 |
| 447 } // namespace views | 441 } // namespace views |
| OLD | NEW |