| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 const bool rtl = j == 0; | 89 const bool rtl = j == 0; |
| 90 label.SetText(rtl ? base::WideToUTF16(L"\x5d0") : ASCIIToUTF16("A")); | 90 label.SetText(rtl ? base::WideToUTF16(L"\x5d0") : ASCIIToUTF16("A")); |
| 91 EXPECT_EQ(rtl ? gfx::ALIGN_RIGHT : gfx::ALIGN_LEFT, | 91 EXPECT_EQ(rtl ? gfx::ALIGN_RIGHT : gfx::ALIGN_LEFT, |
| 92 label.GetHorizontalAlignment()); | 92 label.GetHorizontalAlignment()); |
| 93 } | 93 } |
| 94 } | 94 } |
| 95 | 95 |
| 96 EXPECT_EQ(was_rtl, base::i18n::IsRTL()); | 96 EXPECT_EQ(was_rtl, base::i18n::IsRTL()); |
| 97 } | 97 } |
| 98 | 98 |
| 99 TEST_F(LabelTest, DirectionalityModeProperty) { | |
| 100 Label label; | |
| 101 EXPECT_EQ(gfx::DIRECTIONALITY_FROM_UI, label.directionality_mode()); | |
| 102 | |
| 103 label.set_directionality_mode(gfx::DIRECTIONALITY_FROM_TEXT); | |
| 104 EXPECT_EQ(gfx::DIRECTIONALITY_FROM_TEXT, label.directionality_mode()); | |
| 105 | |
| 106 label.set_directionality_mode(gfx::DIRECTIONALITY_FROM_UI); | |
| 107 EXPECT_EQ(gfx::DIRECTIONALITY_FROM_UI, label.directionality_mode()); | |
| 108 } | |
| 109 | |
| 110 TEST_F(LabelTest, MultiLineProperty) { | 99 TEST_F(LabelTest, MultiLineProperty) { |
| 111 Label label; | 100 Label label; |
| 112 EXPECT_FALSE(label.is_multi_line()); | 101 EXPECT_FALSE(label.multi_line()); |
| 113 label.SetMultiLine(true); | 102 label.SetMultiLine(true); |
| 114 EXPECT_TRUE(label.is_multi_line()); | 103 EXPECT_TRUE(label.multi_line()); |
| 115 label.SetMultiLine(false); | 104 label.SetMultiLine(false); |
| 116 EXPECT_FALSE(label.is_multi_line()); | 105 EXPECT_FALSE(label.multi_line()); |
| 117 } | 106 } |
| 118 | 107 |
| 119 TEST_F(LabelTest, ObscuredProperty) { | 108 TEST_F(LabelTest, ObscuredProperty) { |
| 120 Label label; | 109 Label label; |
| 121 base::string16 test_text(ASCIIToUTF16("Password!")); | 110 base::string16 test_text(ASCIIToUTF16("Password!")); |
| 122 label.SetText(test_text); | 111 label.SetText(test_text); |
| 123 | 112 |
| 124 // Should be false by default... | 113 // The text should be unobscured by default. |
| 125 EXPECT_FALSE(label.is_obscured()); | 114 EXPECT_FALSE(label.obscured()); |
| 126 EXPECT_EQ(test_text, label.layout_text()); | 115 EXPECT_EQ(test_text, label.GetLayoutTextForTesting()); |
| 127 EXPECT_EQ(test_text, label.text()); | 116 EXPECT_EQ(test_text, label.text()); |
| 128 | 117 |
| 129 label.SetObscured(true); | 118 label.SetObscured(true); |
| 130 EXPECT_TRUE(label.is_obscured()); | 119 EXPECT_TRUE(label.obscured()); |
| 131 EXPECT_EQ(ASCIIToUTF16("*********"), label.layout_text()); | 120 EXPECT_EQ(ASCIIToUTF16("*********"), label.GetLayoutTextForTesting()); |
| 132 EXPECT_EQ(test_text, label.text()); | 121 EXPECT_EQ(test_text, label.text()); |
| 133 | 122 |
| 134 label.SetText(test_text + test_text); | 123 label.SetText(test_text + test_text); |
| 135 EXPECT_EQ(ASCIIToUTF16("******************"), label.layout_text()); | 124 EXPECT_EQ(ASCIIToUTF16("******************"), |
| 125 label.GetLayoutTextForTesting()); |
| 136 EXPECT_EQ(test_text + test_text, label.text()); | 126 EXPECT_EQ(test_text + test_text, label.text()); |
| 137 | 127 |
| 138 label.SetObscured(false); | 128 label.SetObscured(false); |
| 139 EXPECT_FALSE(label.is_obscured()); | 129 EXPECT_FALSE(label.obscured()); |
| 140 EXPECT_EQ(test_text + test_text, label.layout_text()); | 130 EXPECT_EQ(test_text + test_text, label.GetLayoutTextForTesting()); |
| 141 EXPECT_EQ(test_text + test_text, label.text()); | 131 EXPECT_EQ(test_text + test_text, label.text()); |
| 142 } | 132 } |
| 143 | 133 |
| 144 TEST_F(LabelTest, ObscuredSurrogatePair) { | 134 TEST_F(LabelTest, ObscuredSurrogatePair) { |
| 145 // 'MUSICAL SYMBOL G CLEF': represented in UTF-16 as two characters | 135 // 'MUSICAL SYMBOL G CLEF': represented in UTF-16 as two characters |
| 146 // forming the surrogate pair 0x0001D11E. | 136 // forming the surrogate pair 0x0001D11E. |
| 147 Label label; | 137 Label label; |
| 148 base::string16 test_text = base::UTF8ToUTF16("\xF0\x9D\x84\x9E"); | 138 base::string16 test_text = base::UTF8ToUTF16("\xF0\x9D\x84\x9E"); |
| 149 label.SetText(test_text); | 139 label.SetText(test_text); |
| 150 | 140 |
| 151 label.SetObscured(true); | 141 label.SetObscured(true); |
| 152 EXPECT_EQ(ASCIIToUTF16("*"), label.layout_text()); | 142 EXPECT_EQ(ASCIIToUTF16("*"), label.GetLayoutTextForTesting()); |
| 153 EXPECT_EQ(test_text, label.text()); | 143 EXPECT_EQ(test_text, label.text()); |
| 154 } | 144 } |
| 155 | 145 |
| 156 TEST_F(LabelTest, TooltipProperty) { | 146 TEST_F(LabelTest, TooltipProperty) { |
| 157 Label label; | 147 Label label; |
| 158 label.SetText(ASCIIToUTF16("My cool string.")); | 148 label.SetText(ASCIIToUTF16("My cool string.")); |
| 159 | 149 |
| 160 base::string16 tooltip; | 150 base::string16 tooltip; |
| 161 EXPECT_TRUE(label.GetTooltipText(gfx::Point(), &tooltip)); | 151 EXPECT_TRUE(label.GetTooltipText(gfx::Point(), &tooltip)); |
| 162 EXPECT_EQ(label.text(), tooltip); | 152 EXPECT_EQ(label.text(), tooltip); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 176 EXPECT_FALSE(label.GetTooltipText(gfx::Point(), &tooltip)); | 166 EXPECT_FALSE(label.GetTooltipText(gfx::Point(), &tooltip)); |
| 177 | 167 |
| 178 // Verify that setting the tooltip still shows it. | 168 // Verify that setting the tooltip still shows it. |
| 179 label.SetTooltipText(tooltip_text); | 169 label.SetTooltipText(tooltip_text); |
| 180 EXPECT_TRUE(label.GetTooltipText(gfx::Point(), &tooltip)); | 170 EXPECT_TRUE(label.GetTooltipText(gfx::Point(), &tooltip)); |
| 181 EXPECT_EQ(tooltip_text, tooltip); | 171 EXPECT_EQ(tooltip_text, tooltip); |
| 182 // Clear out the tooltip. | 172 // Clear out the tooltip. |
| 183 label.SetTooltipText(base::string16()); | 173 label.SetTooltipText(base::string16()); |
| 184 | 174 |
| 185 // Shrink the bounds and the tooltip should come back. | 175 // Shrink the bounds and the tooltip should come back. |
| 186 label.SetBounds(0, 0, 1, 1); | 176 label.SetBounds(0, 0, 10, 10); |
| 187 EXPECT_TRUE(label.GetTooltipText(gfx::Point(), &tooltip)); | 177 EXPECT_TRUE(label.GetTooltipText(gfx::Point(), &tooltip)); |
| 188 | 178 |
| 189 // Make the label obscured and there is no tooltip. | 179 // Make the label obscured and there is no tooltip. |
| 190 label.SetObscured(true); | 180 label.SetObscured(true); |
| 191 EXPECT_FALSE(label.GetTooltipText(gfx::Point(), &tooltip)); | 181 EXPECT_FALSE(label.GetTooltipText(gfx::Point(), &tooltip)); |
| 192 | 182 |
| 193 // Obscuring the text shouldn't permanently clobber the tooltip. | 183 // Obscuring the text shouldn't permanently clobber the tooltip. |
| 194 label.SetObscured(false); | 184 label.SetObscured(false); |
| 195 EXPECT_TRUE(label.GetTooltipText(gfx::Point(), &tooltip)); | 185 EXPECT_TRUE(label.GetTooltipText(gfx::Point(), &tooltip)); |
| 196 | 186 |
| 197 // Make the label multiline and there is no tooltip. | 187 // Making the label multiline shouldn't eliminate the tooltip. |
| 198 label.SetMultiLine(true); | 188 label.SetMultiLine(true); |
| 189 EXPECT_TRUE(label.GetTooltipText(gfx::Point(), &tooltip)); |
| 190 // Expanding the multiline label bounds should eliminate the tooltip. |
| 191 label.SetBounds(0, 0, 1000, 1000); |
| 199 EXPECT_FALSE(label.GetTooltipText(gfx::Point(), &tooltip)); | 192 EXPECT_FALSE(label.GetTooltipText(gfx::Point(), &tooltip)); |
| 200 | 193 |
| 201 // Verify that setting the tooltip still shows it. | 194 // Verify that setting the tooltip still shows it. |
| 202 label.SetTooltipText(tooltip_text); | 195 label.SetTooltipText(tooltip_text); |
| 203 EXPECT_TRUE(label.GetTooltipText(gfx::Point(), &tooltip)); | 196 EXPECT_TRUE(label.GetTooltipText(gfx::Point(), &tooltip)); |
| 204 EXPECT_EQ(tooltip_text, tooltip); | 197 EXPECT_EQ(tooltip_text, tooltip); |
| 205 // Clear out the tooltip. | 198 // Clear out the tooltip. |
| 206 label.SetTooltipText(base::string16()); | 199 label.SetTooltipText(base::string16()); |
| 207 } | 200 } |
| 208 | 201 |
| 209 TEST_F(LabelTest, Accessibility) { | 202 TEST_F(LabelTest, Accessibility) { |
| 210 Label label; | 203 Label label; |
| 211 label.SetText(ASCIIToUTF16("My special text.")); | 204 label.SetText(ASCIIToUTF16("My special text.")); |
| 212 | 205 |
| 213 ui::AXViewState state; | 206 ui::AXViewState state; |
| 214 label.GetAccessibleState(&state); | 207 label.GetAccessibleState(&state); |
| 215 EXPECT_EQ(ui::AX_ROLE_STATIC_TEXT, state.role); | 208 EXPECT_EQ(ui::AX_ROLE_STATIC_TEXT, state.role); |
| 216 EXPECT_EQ(label.text(), state.name); | 209 EXPECT_EQ(label.text(), state.name); |
| 217 EXPECT_TRUE(state.HasStateFlag(ui::AX_STATE_READ_ONLY)); | 210 EXPECT_TRUE(state.HasStateFlag(ui::AX_STATE_READ_ONLY)); |
| 218 } | 211 } |
| 219 | 212 |
| 213 TEST_F(LabelTest, EmptyLabelSizing) { |
| 214 Label label; |
| 215 const gfx::Size expected_size(0, gfx::FontList().GetHeight()); |
| 216 EXPECT_EQ(expected_size, label.GetPreferredSize()); |
| 217 label.SetMultiLine(!label.multi_line()); |
| 218 EXPECT_EQ(expected_size, label.GetPreferredSize()); |
| 219 } |
| 220 |
| 220 TEST_F(LabelTest, SingleLineSizing) { | 221 TEST_F(LabelTest, SingleLineSizing) { |
| 221 Label label; | 222 Label label; |
| 222 label.SetText(ASCIIToUTF16("A not so random string in one line.")); | 223 label.SetText(ASCIIToUTF16("A not so random string in one line.")); |
| 224 const gfx::Size size = label.GetPreferredSize(); |
| 225 EXPECT_GT(size.height(), kMinTextDimension); |
| 226 EXPECT_GT(size.width(), kMinTextDimension); |
| 223 | 227 |
| 224 // GetPreferredSize | 228 // Setting a size smaller than preferred should not change the preferred size. |
| 225 gfx::Size required_size = label.GetPreferredSize(); | 229 label.SetSize(gfx::Size(size.width() / 2, size.height() / 2)); |
| 226 EXPECT_GT(required_size.height(), kMinTextDimension); | 230 EXPECT_EQ(size, label.GetPreferredSize()); |
| 227 EXPECT_GT(required_size.width(), kMinTextDimension); | |
| 228 | 231 |
| 229 // Test everything with borders. | 232 const gfx::Insets border(10, 20, 30, 40); |
| 230 gfx::Insets border(10, 20, 30, 40); | |
| 231 label.SetBorder(Border::CreateEmptyBorder( | 233 label.SetBorder(Border::CreateEmptyBorder( |
| 232 border.top(), border.left(), border.bottom(), border.right())); | 234 border.top(), border.left(), border.bottom(), border.right())); |
| 233 | 235 const gfx::Size size_with_border = label.GetPreferredSize(); |
| 234 // GetPreferredSize and borders. | 236 EXPECT_EQ(size_with_border.height(), size.height() + border.height()); |
| 235 label.SetBounds(0, 0, 0, 0); | 237 EXPECT_EQ(size_with_border.width(), size.width() + border.width()); |
| 236 gfx::Size required_size_with_border = label.GetPreferredSize(); | |
| 237 EXPECT_EQ(required_size_with_border.height(), | |
| 238 required_size.height() + border.height()); | |
| 239 EXPECT_EQ(required_size_with_border.width(), | |
| 240 required_size.width() + border.width()); | |
| 241 } | 238 } |
| 242 | 239 |
| 243 TEST_F(LabelTest, MultilineSmallAvailableWidthSizing) { | 240 TEST_F(LabelTest, MultilineSmallAvailableWidthSizing) { |
| 244 Label label; | 241 Label label; |
| 245 label.SetMultiLine(true); | 242 label.SetMultiLine(true); |
| 246 label.SetAllowCharacterBreak(true); | 243 label.SetAllowCharacterBreak(true); |
| 247 label.SetText(ASCIIToUTF16("Too Wide.")); | 244 label.SetText(ASCIIToUTF16("Too Wide.")); |
| 248 | 245 |
| 249 // Check that Label can be laid out at a variety of small sizes, | 246 // Check that Label can be laid out at a variety of small sizes, |
| 250 // splitting the words into up to one character per line if necessary. | 247 // splitting the words into up to one character per line if necessary. |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 label.SetBounds(0, 0, 0, 0); | 327 label.SetBounds(0, 0, 0, 0); |
| 331 gfx::Size required_size_with_border = label.GetPreferredSize(); | 328 gfx::Size required_size_with_border = label.GetPreferredSize(); |
| 332 EXPECT_EQ(required_size_with_border.height(), | 329 EXPECT_EQ(required_size_with_border.height(), |
| 333 required_size.height() + border.height()); | 330 required_size.height() + border.height()); |
| 334 EXPECT_EQ(required_size_with_border.width(), | 331 EXPECT_EQ(required_size_with_border.width(), |
| 335 required_size.width() + border.width()); | 332 required_size.width() + border.width()); |
| 336 } | 333 } |
| 337 | 334 |
| 338 TEST_F(LabelTest, DirectionalityFromText) { | 335 TEST_F(LabelTest, DirectionalityFromText) { |
| 339 Label label; | 336 Label label; |
| 340 label.set_directionality_mode(gfx::DIRECTIONALITY_FROM_TEXT); | |
| 341 label.SetBounds(0, 0, 1000, 1000); | 337 label.SetBounds(0, 0, 1000, 1000); |
| 342 base::string16 paint_text; | 338 base::string16 paint_text; |
| 343 gfx::Rect text_bounds; | 339 gfx::Rect text_bounds; |
| 344 int flags = -1; | 340 int flags = -1; |
| 345 | 341 |
| 346 // Test text starts with RTL character. | 342 // Test text starts with RTL character. |
| 347 label.SetText(base::WideToUTF16(L" \x5d0\x5d1\x5d2 abc")); | 343 label.SetText(base::WideToUTF16(L" \x5d0\x5d1\x5d2 abc")); |
| 348 label.CalculateDrawStringParams(&paint_text, &text_bounds, &flags); | 344 label.CalculateDrawStringParams(&paint_text, &text_bounds, &flags); |
| 349 EXPECT_EQ(gfx::Canvas::FORCE_RTL_DIRECTIONALITY, | 345 EXPECT_EQ(gfx::Canvas::FORCE_RTL_DIRECTIONALITY, |
| 350 flags & (gfx::Canvas::FORCE_RTL_DIRECTIONALITY | | 346 flags & (gfx::Canvas::FORCE_RTL_DIRECTIONALITY | |
| 351 gfx::Canvas::FORCE_LTR_DIRECTIONALITY)); | 347 gfx::Canvas::FORCE_LTR_DIRECTIONALITY)); |
| 352 | 348 |
| 353 // Test text starts with LTR character. | 349 // Test text starts with LTR character. |
| 354 label.SetText(base::WideToUTF16(L"ltr \x5d0\x5d1\x5d2 abc")); | 350 label.SetText(base::WideToUTF16(L"ltr \x5d0\x5d1\x5d2 abc")); |
| 355 label.CalculateDrawStringParams(&paint_text, &text_bounds, &flags); | 351 label.CalculateDrawStringParams(&paint_text, &text_bounds, &flags); |
| 356 EXPECT_EQ(gfx::Canvas::FORCE_LTR_DIRECTIONALITY, | 352 EXPECT_EQ(gfx::Canvas::FORCE_LTR_DIRECTIONALITY, |
| 357 flags & (gfx::Canvas::FORCE_RTL_DIRECTIONALITY | | 353 flags & (gfx::Canvas::FORCE_RTL_DIRECTIONALITY | |
| 358 gfx::Canvas::FORCE_LTR_DIRECTIONALITY)); | 354 gfx::Canvas::FORCE_LTR_DIRECTIONALITY)); |
| 359 } | 355 } |
| 360 | 356 |
| 361 TEST_F(LabelTest, DrawSingleLineString) { | 357 TEST_F(LabelTest, DrawSingleLineString) { |
| 362 Label label; | 358 Label label; |
| 363 label.SetFocusable(false); | 359 label.SetFocusable(false); |
| 364 // Force a directionality to simplify alignment value testing. | |
| 365 label.set_directionality_mode(gfx::DIRECTIONALITY_FORCE_LTR); | |
| 366 | 360 |
| 367 label.SetText(ASCIIToUTF16("Here's a string with no returns.")); | 361 label.SetText(ASCIIToUTF16("Here's a string with no returns.")); |
| 368 gfx::Size required_size(label.GetPreferredSize()); | 362 gfx::Size required_size(label.GetPreferredSize()); |
| 369 gfx::Size extra(22, 8); | 363 gfx::Size extra(22, 8); |
| 370 label.SetBounds(0, 0, required_size.width() + extra.width(), | 364 label.SetBounds(0, 0, required_size.width() + extra.width(), |
| 371 required_size.height() + extra.height()); | 365 required_size.height() + extra.height()); |
| 372 | 366 |
| 373 // Do some basic verifications for all three alignments. | 367 // Do some basic verifications for all three alignments. |
| 374 base::string16 paint_text; | 368 base::string16 paint_text; |
| 375 gfx::Rect text_bounds; | 369 gfx::Rect text_bounds; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 EXPECT_EQ(gfx::Canvas::TEXT_ALIGN_RIGHT, | 473 EXPECT_EQ(gfx::Canvas::TEXT_ALIGN_RIGHT, |
| 480 flags & (gfx::Canvas::TEXT_ALIGN_LEFT | | 474 flags & (gfx::Canvas::TEXT_ALIGN_LEFT | |
| 481 gfx::Canvas::TEXT_ALIGN_CENTER | | 475 gfx::Canvas::TEXT_ALIGN_CENTER | |
| 482 gfx::Canvas::TEXT_ALIGN_RIGHT)); | 476 gfx::Canvas::TEXT_ALIGN_RIGHT)); |
| 483 } | 477 } |
| 484 | 478 |
| 485 // Pango needs a max height to elide multiline text; that is not supported here. | 479 // Pango needs a max height to elide multiline text; that is not supported here. |
| 486 TEST_F(LabelTest, DrawMultiLineString) { | 480 TEST_F(LabelTest, DrawMultiLineString) { |
| 487 Label label; | 481 Label label; |
| 488 label.SetFocusable(false); | 482 label.SetFocusable(false); |
| 489 // Force a directionality to simplify alignment value testing. | |
| 490 label.set_directionality_mode(gfx::DIRECTIONALITY_FORCE_LTR); | |
| 491 // Set a background color to prevent gfx::Canvas::NO_SUBPIXEL_RENDERING flags. | 483 // Set a background color to prevent gfx::Canvas::NO_SUBPIXEL_RENDERING flags. |
| 492 label.SetBackgroundColor(SK_ColorWHITE); | 484 label.SetBackgroundColor(SK_ColorWHITE); |
| 493 | 485 |
| 494 label.SetText(ASCIIToUTF16("Another string\nwith returns\n\n!")); | 486 label.SetText(ASCIIToUTF16("Another string\nwith returns\n\n!")); |
| 495 label.SetMultiLine(true); | 487 label.SetMultiLine(true); |
| 496 label.SizeToFit(0); | 488 label.SizeToFit(0); |
| 497 gfx::Size extra(50, 10); | 489 gfx::Size extra(50, 10); |
| 498 label.SetBounds(label.x(), label.y(), | 490 label.SetBounds(label.x(), label.y(), |
| 499 label.width() + extra.width(), | 491 label.width() + extra.width(), |
| 500 label.height() + extra.height()); | 492 label.height() + extra.height()); |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 865 // Reset Locale | 857 // Reset Locale |
| 866 base::i18n::SetICUDefaultLocale(locale); | 858 base::i18n::SetICUDefaultLocale(locale); |
| 867 } | 859 } |
| 868 | 860 |
| 869 // Ensure the subpixel rendering flag and background color alpha are respected. | 861 // Ensure the subpixel rendering flag and background color alpha are respected. |
| 870 TEST_F(LabelTest, DisableSubpixelRendering) { | 862 TEST_F(LabelTest, DisableSubpixelRendering) { |
| 871 Label label; | 863 Label label; |
| 872 label.SetBackgroundColor(SK_ColorWHITE); | 864 label.SetBackgroundColor(SK_ColorWHITE); |
| 873 const int flag = gfx::Canvas::NO_SUBPIXEL_RENDERING; | 865 const int flag = gfx::Canvas::NO_SUBPIXEL_RENDERING; |
| 874 EXPECT_EQ(0, label.ComputeDrawStringFlags() & flag); | 866 EXPECT_EQ(0, label.ComputeDrawStringFlags() & flag); |
| 875 label.set_subpixel_rendering_enabled(false); | 867 label.SetSubpixelRenderingEnabled(false); |
| 876 EXPECT_EQ(flag, label.ComputeDrawStringFlags() & flag); | 868 EXPECT_EQ(flag, label.ComputeDrawStringFlags() & flag); |
| 877 label.set_subpixel_rendering_enabled(true); | 869 label.SetSubpixelRenderingEnabled(true); |
| 878 EXPECT_EQ(0, label.ComputeDrawStringFlags() & flag); | 870 EXPECT_EQ(0, label.ComputeDrawStringFlags() & flag); |
| 879 // Text cannot be drawn with subpixel rendering on transparent backgrounds. | 871 // Text cannot be drawn with subpixel rendering on transparent backgrounds. |
| 880 label.SetBackgroundColor(SkColorSetARGB(64, 255, 255, 255)); | 872 label.SetBackgroundColor(SkColorSetARGB(64, 255, 255, 255)); |
| 881 EXPECT_EQ(flag, label.ComputeDrawStringFlags() & flag); | 873 EXPECT_EQ(flag, label.ComputeDrawStringFlags() & flag); |
| 882 } | 874 } |
| 883 | 875 |
| 884 // Check that labels support GetTooltipHandlerForPoint. | 876 // Check that labels support GetTooltipHandlerForPoint. |
| 885 TEST_F(LabelTest, GetTooltipHandlerForPoint) { | 877 TEST_F(LabelTest, GetTooltipHandlerForPoint) { |
| 886 // A root view must be defined for this test because the hit-testing | 878 // A root view must be defined for this test because the hit-testing |
| 887 // behaviour used by GetTooltipHandlerForPoint() is defined by | 879 // behaviour used by GetTooltipHandlerForPoint() is defined by |
| (...skipping 28 matching lines...) Expand all Loading... |
| 916 EXPECT_FALSE(label.GetTooltipHandlerForPoint(gfx::Point(2, 51))); | 908 EXPECT_FALSE(label.GetTooltipHandlerForPoint(gfx::Point(2, 51))); |
| 917 EXPECT_FALSE(label.GetTooltipHandlerForPoint(gfx::Point(-1, 20))); | 909 EXPECT_FALSE(label.GetTooltipHandlerForPoint(gfx::Point(-1, 20))); |
| 918 | 910 |
| 919 // GetTooltipHandlerForPoint works should work in child bounds. | 911 // GetTooltipHandlerForPoint works should work in child bounds. |
| 920 label.SetBounds(2, 2, 10, 10); | 912 label.SetBounds(2, 2, 10, 10); |
| 921 EXPECT_EQ(&label, label.GetTooltipHandlerForPoint(gfx::Point(1, 5))); | 913 EXPECT_EQ(&label, label.GetTooltipHandlerForPoint(gfx::Point(1, 5))); |
| 922 EXPECT_FALSE(label.GetTooltipHandlerForPoint(gfx::Point(3, 11))); | 914 EXPECT_FALSE(label.GetTooltipHandlerForPoint(gfx::Point(3, 11))); |
| 923 } | 915 } |
| 924 | 916 |
| 925 } // namespace views | 917 } // namespace views |
| OLD | NEW |