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

Unified Diff: ui/views/controls/label_unittest.cc

Issue 222033002: Add an 'obscured' flag to views::Label. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: *facepalm* Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: ui/views/controls/label_unittest.cc
diff --git a/ui/views/controls/label_unittest.cc b/ui/views/controls/label_unittest.cc
index 42cc0cda47da2728e158f4baedfe1207b54ddc4b..db60b4321b4eb61891850db90438ee36fc7eaea2 100644
--- a/ui/views/controls/label_unittest.cc
+++ b/ui/views/controls/label_unittest.cc
@@ -98,6 +98,26 @@ TEST(LabelTest, MultiLineProperty) {
EXPECT_FALSE(label.is_multi_line());
}
+TEST(LabelTest, ObscuredProperty) {
+ Label label;
+ base::string16 test_text(ASCIIToUTF16("Password!"));
+ label.SetText(test_text);
+
+ // Should be false by default...
+ EXPECT_FALSE(label.is_obscured());
+ EXPECT_EQ(ASCIIToUTF16("Password!"), label.display_text());
msw 2014/04/03 01:38:48 nit: re-use test_text here and below.
+
+ label.SetObscured(true);
+ EXPECT_TRUE(label.is_obscured());
+ EXPECT_EQ(base::WideToUTF16(
+ L"\x2022\x2022\x2022\x2022\x2022\x2022\x2022\x2022\x2022"),
+ label.display_text());
+
msw 2014/04/03 01:38:48 nit: test that a SetText call while the Label is o
+ label.SetObscured(false);
+ EXPECT_FALSE(label.is_obscured());
+ EXPECT_EQ(ASCIIToUTF16("Password!"), label.display_text());
+}
+
TEST(LabelTest, TooltipProperty) {
Label label;
base::string16 test_text(ASCIIToUTF16("My cool string."));
@@ -133,7 +153,12 @@ TEST(LabelTest, TooltipProperty) {
label.SetBounds(0, 0, 1, 1);
EXPECT_TRUE(label.GetTooltipText(gfx::Point(), &tooltip));
- // Make the label multiline and there is no tooltip again.
+ // Make the label obscured and there is no tooltip.
+ label.SetObscured(true);
+ EXPECT_FALSE(label.GetTooltipText(gfx::Point(), &tooltip));
+ label.SetObscured(false);
msw 2014/04/03 01:38:48 nit: after this call, EXPECT_TRUE(label.GetTooltip
msw 2014/04/03 18:27:48 ping.
Mike West 2014/04/04 07:05:15 Done.
+
+ // Make the label multiline and there is no tooltip.
label.SetMultiLine(true);
EXPECT_FALSE(label.GetTooltipText(gfx::Point(), &tooltip));

Powered by Google App Engine
This is Rietveld 408576698