Chromium Code Reviews| 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 d55bfcb4040042a1e34a7fb3b83d15ac1da5ba98..56739e2efe75ef659c1afeb4515123b04ffca1ef 100644 |
| --- a/ui/views/controls/textfield/textfield_views_model_unittest.cc |
| +++ b/ui/views/controls/textfield/textfield_views_model_unittest.cc |
| @@ -500,31 +500,50 @@ TEST_F(TextfieldViewsModelTest, MAYBE_Clipboard) { |
| string16 clipboard_text; |
| TextfieldViewsModel model(NULL); |
| model.Append(ASCIIToUTF16("HELLO WORLD")); |
| - model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_RIGHT, false); |
| - // Test for cut: Empty selection. |
| + // Cut with an empty selection should do nothing. |
| + model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_RIGHT, false); |
| EXPECT_FALSE(model.Cut()); |
| clipboard->ReadText(ui::Clipboard::BUFFER_STANDARD, &clipboard_text); |
| - EXPECT_STR_EQ(UTF16ToUTF8(initial_clipboard_text), clipboard_text); |
| + EXPECT_EQ(initial_clipboard_text, clipboard_text); |
| EXPECT_STR_EQ("HELLO WORLD", model.GetText()); |
| EXPECT_EQ(11U, model.GetCursorPosition()); |
| - // Test for cut: Non-empty selection. |
| - model.MoveCursor(gfx::WORD_BREAK, gfx::CURSOR_LEFT, true); |
| - EXPECT_TRUE(model.Cut()); |
| + // Copy with an empty selection should do nothing. |
| + model.Copy(); |
| clipboard->ReadText(ui::Clipboard::BUFFER_STANDARD, &clipboard_text); |
| - EXPECT_STR_EQ("WORLD", clipboard_text); |
| - EXPECT_STR_EQ("HELLO ", model.GetText()); |
| - EXPECT_EQ(6U, model.GetCursorPosition()); |
| + EXPECT_EQ(initial_clipboard_text, clipboard_text); |
| + EXPECT_STR_EQ("HELLO WORLD", model.GetText()); |
| + EXPECT_EQ(11U, model.GetCursorPosition()); |
| - // Test for copy: Empty selection. |
|
msw
2012/02/22 00:33:26
Why remove this portion of the test?
benrg
2012/02/24 19:07:44
I didn't, I just moved it ("Copy with an empty sel
|
| - model.Copy(); |
| + // Cut on obscured (password) text should do nothing. |
| + model.render_text()->SetObscured(true); |
| + model.SelectAll(); |
| + EXPECT_FALSE(model.Cut()); |
| + clipboard->ReadText(ui::Clipboard::BUFFER_STANDARD, &clipboard_text); |
| + EXPECT_EQ(initial_clipboard_text, clipboard_text); |
| + EXPECT_STR_EQ("HELLO WORLD", model.GetText()); |
| + EXPECT_STR_EQ("HELLO WORLD", model.GetSelectedText()); |
| + |
| + // Copy on obscured text should do nothing. |
| + model.SelectAll(); |
| + EXPECT_FALSE(model.Cut()); |
|
xji
2012/02/18 01:28:47
s/Cut/Copy/
benrg
2012/02/24 19:07:44
Fixed.
|
| + clipboard->ReadText(ui::Clipboard::BUFFER_STANDARD, &clipboard_text); |
| + EXPECT_EQ(initial_clipboard_text, clipboard_text); |
| + EXPECT_STR_EQ("HELLO WORLD", model.GetText()); |
| + EXPECT_STR_EQ("HELLO WORLD", model.GetSelectedText()); |
| + |
| + // Cut with non-empty selection. |
| + model.render_text()->SetObscured(false); |
| + model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_RIGHT, false); |
| + model.MoveCursor(gfx::WORD_BREAK, gfx::CURSOR_LEFT, true); |
| + EXPECT_TRUE(model.Cut()); |
| clipboard->ReadText(ui::Clipboard::BUFFER_STANDARD, &clipboard_text); |
| EXPECT_STR_EQ("WORLD", clipboard_text); |
| EXPECT_STR_EQ("HELLO ", model.GetText()); |
| EXPECT_EQ(6U, model.GetCursorPosition()); |
| - // Test for copy: Non-empty selection. |
| + // Copy with non-empty selection. |
| model.Append(ASCIIToUTF16("HELLO WORLD")); |
| model.SelectAll(); |
| model.Copy(); |
| @@ -533,10 +552,11 @@ TEST_F(TextfieldViewsModelTest, MAYBE_Clipboard) { |
| EXPECT_STR_EQ("HELLO HELLO WORLD", model.GetText()); |
| EXPECT_EQ(17U, model.GetCursorPosition()); |
| - // Test for paste. |
| + // Paste (with obscured bit set; should be ignored). |
|
xji
2012/02/18 01:28:47
I feel the comment is a bit confusing. you mean "o
benrg
2012/02/24 19:07:44
Done.
|
| model.ClearSelection(); |
| model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_RIGHT, false); |
| model.MoveCursor(gfx::WORD_BREAK, gfx::CURSOR_LEFT, true); |
| + model.render_text()->SetObscured(true); |
|
xji
2012/02/18 01:28:47
keep the original test and add one with obscured =
benrg
2012/02/24 19:07:44
Done.
|
| EXPECT_TRUE(model.Paste()); |
| clipboard->ReadText(ui::Clipboard::BUFFER_STANDARD, &clipboard_text); |
| EXPECT_STR_EQ("HELLO HELLO WORLD", clipboard_text); |