Chromium Code Reviews| Index: views/controls/textfield/textfield_views_model_unittest.cc |
| =================================================================== |
| --- views/controls/textfield/textfield_views_model_unittest.cc (revision 96008) |
| +++ views/controls/textfield/textfield_views_model_unittest.cc (working copy) |
| @@ -128,15 +128,14 @@ |
| // Select and move cursor |
| gfx::SelectionModel selection(1U); |
|
msw
2011/08/13 19:37:38
These two lines are no longer necessary.
|
| model.MoveCursorTo(selection); |
| - selection.set_selection_end(3U); |
| + selection = gfx::SelectionModel(1U, 3U); |
|
msw
2011/08/13 19:37:38
You can optionally get rid of |selection| and just
|
| model.MoveCursorTo(selection); |
| EXPECT_STR_EQ("EL", model.GetSelectedText()); |
| model.MoveCursorLeft(gfx::CHARACTER_BREAK, false); |
| EXPECT_EQ(1U, model.GetCursorPosition()); |
| - selection.set_selection_end(1U); |
| - selection.set_selection_start(selection.selection_end()); |
| + selection = gfx::SelectionModel(1U); |
| model.MoveCursorTo(selection); |
| - selection.set_selection_end(3U); |
| + selection = gfx::SelectionModel(1U, 3U); |
| model.MoveCursorTo(selection); |
| model.MoveCursorRight(gfx::CHARACTER_BREAK, false); |
| EXPECT_EQ(3U, model.GetCursorPosition()); |
| @@ -342,24 +341,21 @@ |
| SelectWordTestVerifier(model, "HELLO", 7U); |
| // Test when cursor is at the end of a word. |
| - selection.set_selection_end(15U); |
| - selection.set_selection_start(selection.selection_end()); |
| + selection = gfx::SelectionModel(15U); |
| model.MoveCursorTo(selection); |
| model.SelectWord(); |
| SelectWordTestVerifier(model, "WO", 15U); |
| // Test when cursor is somewhere in a non-alph-numeric fragment. |
| for (size_t cursor_pos = 8; cursor_pos < 13U; cursor_pos++) { |
| - selection.set_selection_end(cursor_pos); |
| - selection.set_selection_start(selection.selection_end()); |
| + selection = gfx::SelectionModel(cursor_pos); |
| model.MoveCursorTo(selection); |
| model.SelectWord(); |
| SelectWordTestVerifier(model, " !! ", 13U); |
| } |
| // Test when cursor is somewhere in a whitespace fragment. |
| - selection.set_selection_end(17U); |
| - selection.set_selection_start(selection.selection_end()); |
| + selection = gfx::SelectionModel(17U); |
| model.MoveCursorTo(selection); |
| model.SelectWord(); |
| SelectWordTestVerifier(model, " ", 20U); |
| @@ -811,7 +807,7 @@ |
| // Cut |
| gfx::SelectionModel sel(1); |
|
msw
2011/08/13 19:37:38
You can remove these two lines.
|
| model.MoveCursorTo(sel); |
| - sel.set_selection_end(3); |
| + sel = gfx::SelectionModel(1, 3); |
| model.MoveCursorTo(sel); |
| model.Cut(); |
| EXPECT_STR_EQ("ADE", model.GetText()); |
| @@ -901,7 +897,7 @@ |
| sel.set_selection_end(1); |
|
msw
2011/08/13 19:37:38
You can remove these three lines.
|
| sel.set_selection_start(sel.selection_end()); |
| model.MoveCursorTo(sel); |
| - sel.set_selection_end(3); |
| + sel = gfx::SelectionModel(1, 3); |
| model.MoveCursorTo(sel); |
| model.Copy(); // Copy "23" |
| EXPECT_STR_EQ("12345", model.GetText()); |
| @@ -1028,7 +1024,7 @@ |
| model.SetText(ASCIIToUTF16("abcd")); |
| gfx::SelectionModel sel(1); |
|
msw
2011/08/13 19:37:38
You can remove these two lines.
|
| model.MoveCursorTo(sel); |
| - sel.set_selection_end(3); |
| + sel = gfx::SelectionModel(1, 3); |
| model.MoveCursorTo(sel); |
| RunInsertReplaceTest(model); |
| } |
| @@ -1038,7 +1034,7 @@ |
| model.SetText(ASCIIToUTF16("abcd")); |
| gfx::SelectionModel sel(3); |
|
msw
2011/08/13 19:37:38
You can remove these two lines.
|
| model.MoveCursorTo(sel); |
| - sel.set_selection_end(1); |
| + sel = gfx::SelectionModel(3, 1); |
| model.MoveCursorTo(sel); |
| RunInsertReplaceTest(model); |
| } |
| @@ -1048,7 +1044,7 @@ |
| model.SetText(ASCIIToUTF16("abcd")); |
| gfx::SelectionModel sel(1); |
|
msw
2011/08/13 19:37:38
You can remove these two lines.
|
| model.MoveCursorTo(sel); |
| - sel.set_selection_end(3); |
| + sel = gfx::SelectionModel(1, 3); |
| model.MoveCursorTo(sel); |
| RunOverwriteReplaceTest(model); |
| } |
| @@ -1058,7 +1054,7 @@ |
| model.SetText(ASCIIToUTF16("abcd")); |
| gfx::SelectionModel sel(3); |
|
msw
2011/08/13 19:37:38
You can remove these two lines.
|
| model.MoveCursorTo(sel); |
| - sel.set_selection_end(1); |
| + sel = gfx::SelectionModel(3, 1); |
| model.MoveCursorTo(sel); |
| RunOverwriteReplaceTest(model); |
| } |