Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Side by Side Diff: ui/views/controls/label_unittest.cc

Issue 341713002: Remove Label::PaintText overrides. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync and rebase. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/label.cc ('k') | ui/views/controls/textfield/textfield.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 844 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 EXPECT_TRUE(gfx::Canvas::MULTI_LINE & flags); 855 EXPECT_TRUE(gfx::Canvas::MULTI_LINE & flags);
856 EXPECT_TRUE(gfx::Canvas::TEXT_ALIGN_LEFT & flags); 856 EXPECT_TRUE(gfx::Canvas::TEXT_ALIGN_LEFT & flags);
857 #if !defined(OS_WIN) 857 #if !defined(OS_WIN)
858 EXPECT_TRUE(gfx::Canvas::NO_ELLIPSIS & flags); 858 EXPECT_TRUE(gfx::Canvas::NO_ELLIPSIS & flags);
859 #endif 859 #endif
860 860
861 // Reset Locale 861 // Reset Locale
862 base::i18n::SetICUDefaultLocale(locale); 862 base::i18n::SetICUDefaultLocale(locale);
863 } 863 }
864 864
865 // Check that we disable subpixel rendering when a transparent background is 865 // Ensure the subpixel rendering flag and background color alpha are respected.
866 // being used.
867 TEST(LabelTest, DisableSubpixelRendering) { 866 TEST(LabelTest, DisableSubpixelRendering) {
868 Label label; 867 Label label;
869 label.SetBackgroundColor(SK_ColorWHITE); 868 label.SetBackgroundColor(SK_ColorWHITE);
870 EXPECT_EQ( 869 const int flag = gfx::Canvas::NO_SUBPIXEL_RENDERING;
871 0, label.ComputeDrawStringFlags() & gfx::Canvas::NO_SUBPIXEL_RENDERING); 870 EXPECT_EQ(0, label.ComputeDrawStringFlags() & flag);
872 871 label.set_subpixel_rendering_enabled(false);
872 EXPECT_EQ(flag, label.ComputeDrawStringFlags() & flag);
873 label.set_subpixel_rendering_enabled(true);
874 EXPECT_EQ(0, label.ComputeDrawStringFlags() & flag);
875 // Text cannot be drawn with subpixel rendering on transparent backgrounds.
873 label.SetBackgroundColor(SkColorSetARGB(64, 255, 255, 255)); 876 label.SetBackgroundColor(SkColorSetARGB(64, 255, 255, 255));
874 EXPECT_EQ( 877 EXPECT_EQ(flag, label.ComputeDrawStringFlags() & flag);
875 gfx::Canvas::NO_SUBPIXEL_RENDERING,
876 label.ComputeDrawStringFlags() & gfx::Canvas::NO_SUBPIXEL_RENDERING);
877 } 878 }
878 879
879 // Check that labels support GetTooltipHandlerForPoint. 880 // Check that labels support GetTooltipHandlerForPoint.
880 TEST(LabelTest, GetTooltipHandlerForPoint) { 881 TEST(LabelTest, GetTooltipHandlerForPoint) {
881 Label label; 882 Label label;
882 label.SetText( 883 label.SetText(
883 ASCIIToUTF16("A string that's long enough to exceed the bounds")); 884 ASCIIToUTF16("A string that's long enough to exceed the bounds"));
884 label.SetBounds(0, 0, 10, 10); 885 label.SetBounds(0, 0, 10, 10);
885 // There's a default tooltip if the text is too big to fit. 886 // There's a default tooltip if the text is too big to fit.
886 EXPECT_EQ(&label, label.GetTooltipHandlerForPoint(gfx::Point(2, 2))); 887 EXPECT_EQ(&label, label.GetTooltipHandlerForPoint(gfx::Point(2, 2)));
(...skipping 12 matching lines...) Expand all
899 EXPECT_FALSE(label.GetTooltipHandlerForPoint(gfx::Point(2, 51))); 900 EXPECT_FALSE(label.GetTooltipHandlerForPoint(gfx::Point(2, 51)));
900 EXPECT_FALSE(label.GetTooltipHandlerForPoint(gfx::Point(-1, 20))); 901 EXPECT_FALSE(label.GetTooltipHandlerForPoint(gfx::Point(-1, 20)));
901 902
902 // GetTooltipHandlerForPoint works should work in child bounds. 903 // GetTooltipHandlerForPoint works should work in child bounds.
903 label.SetBounds(2, 2, 10, 10); 904 label.SetBounds(2, 2, 10, 10);
904 EXPECT_EQ(&label, label.GetTooltipHandlerForPoint(gfx::Point(1, 5))); 905 EXPECT_EQ(&label, label.GetTooltipHandlerForPoint(gfx::Point(1, 5)));
905 EXPECT_FALSE(label.GetTooltipHandlerForPoint(gfx::Point(3, 11))); 906 EXPECT_FALSE(label.GetTooltipHandlerForPoint(gfx::Point(3, 11)));
906 } 907 }
907 908
908 } // namespace views 909 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/label.cc ('k') | ui/views/controls/textfield/textfield.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698