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

Side by Side Diff: ui/views/controls/textfield/textfield_views_model_unittest.cc

Issue 8823007: Don't merge replace edit if previous edit is delete edit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <vector> 5 #include <vector>
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/string16.h" 10 #include "base/string16.h"
(...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 EXPECT_EQ(3U, model.GetCursorPosition()); 1172 EXPECT_EQ(3U, model.GetCursorPosition());
1173 EXPECT_TRUE(model.Redo()); 1173 EXPECT_TRUE(model.Redo());
1174 EXPECT_STR_EQ("www.google.com", model.GetText()); 1174 EXPECT_STR_EQ("www.google.com", model.GetText());
1175 EXPECT_EQ(4U, model.GetCursorPosition()); 1175 EXPECT_EQ(4U, model.GetCursorPosition());
1176 EXPECT_TRUE(model.Redo()); 1176 EXPECT_TRUE(model.Redo());
1177 EXPECT_STR_EQ("www.youtube.com", model.GetText()); 1177 EXPECT_STR_EQ("www.youtube.com", model.GetText());
1178 EXPECT_EQ(5U, model.GetCursorPosition()); 1178 EXPECT_EQ(5U, model.GetCursorPosition());
1179 EXPECT_FALSE(model.Redo()); 1179 EXPECT_FALSE(model.Redo());
1180 } 1180 }
1181 1181
1182 #if defined(USE_AURA) && defined(OS_LINUX) 1182 TEST_F(TextfieldViewsModelTest, UndoRedo_BackspaceThenSetText) {
1183 // This can be re-enabled when aura on linux has clipboard support. 1183 // This is to test the undo/redo behavior of omnibox.
1184 // http://crbug.com/97845 1184 TextfieldViewsModel model(NULL);
1185 #define MAYBE_UndoRedo_CutCopyPasteTest DISABLED_UndoRedo_CutCopyPasteTest 1185 model.InsertChar('w');
1186 #else 1186 EXPECT_STR_EQ("w", model.GetText());
1187 #define MAYBE_UndoRedo_CutCopyPasteTest UndoRedo_CutCopyPasteTest 1187 EXPECT_EQ(1U, model.GetCursorPosition());
1188 #endif 1188 model.SetText(ASCIIToUTF16("www.google.com"));
1189 TEST_F(TextfieldViewsModelTest, MAYBE_UndoRedo_CutCopyPasteTest) { 1189 EXPECT_EQ(1U, model.GetCursorPosition());
1190 EXPECT_STR_EQ("www.google.com", model.GetText());
1191 model.SetText(ASCIIToUTF16("www.google.com")); // confirm the text.
msw 2011/12/07 00:55:22 nit: Captialize 'Confirm'.
oshima 2011/12/07 01:17:24 Done.
1192 model.MoveCursorRight(gfx::LINE_BREAK, false);
1193 EXPECT_EQ(14U, model.GetCursorPosition());
1194 EXPECT_TRUE(model.Backspace());
1195 EXPECT_TRUE(model.Backspace());
1196 EXPECT_STR_EQ("www.google.c", model.GetText());
1197 // autocomplete sets the text
msw 2011/12/07 00:55:22 nit: Captialize 'Autocomplete'.
oshima 2011/12/07 01:17:24 Done.
1198 model.SetText(ASCIIToUTF16("www.google.com"));
1199 EXPECT_STR_EQ("www.google.com", model.GetText());
1200 }
1201
1202 TEST_F(TextfieldViewsModelTest, UndoRedo_CutCopyPasteTest) {
1190 TextfieldViewsModel model(NULL); 1203 TextfieldViewsModel model(NULL);
1191 model.SetText(ASCIIToUTF16("ABCDE")); 1204 model.SetText(ASCIIToUTF16("ABCDE"));
1192 EXPECT_FALSE(model.Redo()); // nothing to redo 1205 EXPECT_FALSE(model.Redo()); // nothing to redo
1193 // Cut 1206 // Cut
1194 model.SelectRange(ui::Range(1, 3)); 1207 model.SelectRange(ui::Range(1, 3));
1195 model.Cut(); 1208 model.Cut();
1196 EXPECT_STR_EQ("ADE", model.GetText()); 1209 EXPECT_STR_EQ("ADE", model.GetText());
1197 EXPECT_EQ(1U, model.GetCursorPosition()); 1210 EXPECT_EQ(1U, model.GetCursorPosition());
1198 EXPECT_TRUE(model.Undo()); 1211 EXPECT_TRUE(model.Undo());
1199 EXPECT_STR_EQ("ABCDE", model.GetText()); 1212 EXPECT_STR_EQ("ABCDE", model.GetText());
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
1527 EXPECT_TRUE(model.Undo()); 1540 EXPECT_TRUE(model.Undo());
1528 EXPECT_STR_EQ("ABCDE", model.GetText()); 1541 EXPECT_STR_EQ("ABCDE", model.GetText());
1529 EXPECT_TRUE(model.Redo()); 1542 EXPECT_TRUE(model.Redo());
1530 EXPECT_STR_EQ("1234", model.GetText()); 1543 EXPECT_STR_EQ("1234", model.GetText());
1531 EXPECT_FALSE(model.Redo()); 1544 EXPECT_FALSE(model.Redo());
1532 1545
1533 // TODO(oshima): We need MockInputMethod to test the behavior with IME. 1546 // TODO(oshima): We need MockInputMethod to test the behavior with IME.
1534 } 1547 }
1535 1548
1536 } // namespace views 1549 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698