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

Unified Diff: ui/views/controls/textfield/textfield_views_model_unittest.cc

Issue 8747001: Reintroduce password support to NativeTextfieldViews (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make password in RenderText an instance property and disable cut, copy, D&D, and word skipping Created 9 years 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/textfield/textfield_views_model_unittest.cc
diff --git a/ui/views/controls/textfield/textfield_views_model_unittest.cc b/ui/views/controls/textfield/textfield_views_model_unittest.cc
index 585d8494b7ab479bd0d24281ccd3be076f27761c..2cd7bd3574cc8a211ddb2b1e8201c7f051b3d4be 100644
--- a/ui/views/controls/textfield/textfield_views_model_unittest.cc
+++ b/ui/views/controls/textfield/textfield_views_model_unittest.cc
@@ -244,7 +244,6 @@ TEST_F(TextfieldViewsModelTest, EmptyString) {
TextfieldViewsModel model(NULL);
EXPECT_EQ(string16(), model.GetText());
EXPECT_EQ(string16(), model.GetSelectedText());
- EXPECT_EQ(string16(), model.GetVisibleText());
model.MoveCursorLeft(gfx::CHARACTER_BREAK, true);
EXPECT_EQ(0U, model.GetCursorPosition());
@@ -414,27 +413,6 @@ TEST_F(TextfieldViewsModelTest, SelectionAndEdit) {
EXPECT_STR_EQ("BEE", model.GetText());
}
-TEST_F(TextfieldViewsModelTest, Password) {
- TextfieldViewsModel model(NULL);
- model.set_is_password(true);
- model.Append(ASCIIToUTF16("HELLO"));
- EXPECT_STR_EQ("*****", model.GetVisibleText());
- EXPECT_STR_EQ("HELLO", model.GetText());
- EXPECT_TRUE(model.Delete());
-
- EXPECT_STR_EQ("****", model.GetVisibleText());
- EXPECT_STR_EQ("ELLO", model.GetText());
- EXPECT_EQ(0U, model.GetCursorPosition());
-
- model.SelectAll();
- EXPECT_STR_EQ("ELLO", model.GetSelectedText());
- EXPECT_EQ(4U, model.GetCursorPosition());
-
- model.InsertChar('X');
- EXPECT_STR_EQ("*", model.GetVisibleText());
- EXPECT_STR_EQ("X", model.GetText());
-}
-
TEST_F(TextfieldViewsModelTest, Word) {
TextfieldViewsModel model(NULL);
model.Append(
@@ -479,7 +457,7 @@ TEST_F(TextfieldViewsModelTest, Word) {
EXPECT_STR_EQ("The answer to Life", model.GetSelectedText());
model.ReplaceChar('4');
EXPECT_EQ(string16(), model.GetSelectedText());
- EXPECT_STR_EQ("42", model.GetVisibleText());
+ EXPECT_STR_EQ("42", model.GetText());
}
TEST_F(TextfieldViewsModelTest, SetText) {
@@ -534,6 +512,13 @@ TEST_F(TextfieldViewsModelTest, MAYBE_Clipboard) {
EXPECT_STR_EQ("HELLO ", model.GetText());
EXPECT_EQ(6U, model.GetCursorPosition());
+ // Test for cut: Password field.
+ model.render_text()->SetIsPassword(true);
+ model.SelectAll();
+ EXPECT_FALSE(model.Cut());
+ model.MoveCursorRight(gfx::WORD_BREAK, false);
msw 2011/12/03 00:22:40 Do we care to test the cursor movement in a passwo
benrg 2011/12/08 21:40:55 Presumably yes, but not until it works.
+ model.render_text()->SetIsPassword(false);
+
// Test for copy: Empty selection.
model.Copy();
clipboard->ReadText(ui::Clipboard::BUFFER_STANDARD, &clipboard_text);
@@ -550,7 +535,14 @@ TEST_F(TextfieldViewsModelTest, MAYBE_Clipboard) {
EXPECT_STR_EQ("HELLO HELLO WORLD", model.GetText());
EXPECT_EQ(17U, model.GetCursorPosition());
- // Test for paste.
+ // Test for copy: Password field.
+ model.render_text()->SetIsPassword(true);
+ model.MoveCursorLeft(gfx::WORD_BREAK, true);
+ model.Copy();
+ clipboard->ReadText(ui::Clipboard::BUFFER_STANDARD, &clipboard_text);
+ EXPECT_STR_EQ("HELLO HELLO WORLD", clipboard_text);
msw 2011/12/03 00:22:40 Shouldn't this fail? Why is the password text copi
benrg 2011/12/06 17:21:30 That was the text left in the clipboard from the p
+
+ // Test for paste (should ignore password bit).
model.ClearSelection();
model.MoveCursorRight(gfx::LINE_BREAK, false);
model.MoveCursorLeft(gfx::WORD_BREAK, true);

Powered by Google App Engine
This is Rietveld 408576698