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

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: fix comments 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
« no previous file with comments | « ui/views/controls/textfield/textfield_views_model.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
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
1198 model.SetText(ASCIIToUTF16("www.google.com/search=www.google.c"));
1199 EXPECT_STR_EQ("www.google.com/search=www.google.c", model.GetText());
1200 EXPECT_TRUE(model.Undo());
1201 EXPECT_STR_EQ("www.google.c", model.GetText());
1202 EXPECT_TRUE(model.Undo());
1203 EXPECT_STR_EQ("www.google.com", model.GetText());
1204 }
1205
1206 TEST_F(TextfieldViewsModelTest, UndoRedo_CutCopyPasteTest) {
1190 TextfieldViewsModel model(NULL); 1207 TextfieldViewsModel model(NULL);
1191 model.SetText(ASCIIToUTF16("ABCDE")); 1208 model.SetText(ASCIIToUTF16("ABCDE"));
1192 EXPECT_FALSE(model.Redo()); // nothing to redo 1209 EXPECT_FALSE(model.Redo()); // nothing to redo
1193 // Cut 1210 // Cut
1194 model.SelectRange(ui::Range(1, 3)); 1211 model.SelectRange(ui::Range(1, 3));
1195 model.Cut(); 1212 model.Cut();
1196 EXPECT_STR_EQ("ADE", model.GetText()); 1213 EXPECT_STR_EQ("ADE", model.GetText());
1197 EXPECT_EQ(1U, model.GetCursorPosition()); 1214 EXPECT_EQ(1U, model.GetCursorPosition());
1198 EXPECT_TRUE(model.Undo()); 1215 EXPECT_TRUE(model.Undo());
1199 EXPECT_STR_EQ("ABCDE", model.GetText()); 1216 EXPECT_STR_EQ("ABCDE", model.GetText());
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
1527 EXPECT_TRUE(model.Undo()); 1544 EXPECT_TRUE(model.Undo());
1528 EXPECT_STR_EQ("ABCDE", model.GetText()); 1545 EXPECT_STR_EQ("ABCDE", model.GetText());
1529 EXPECT_TRUE(model.Redo()); 1546 EXPECT_TRUE(model.Redo());
1530 EXPECT_STR_EQ("1234", model.GetText()); 1547 EXPECT_STR_EQ("1234", model.GetText());
1531 EXPECT_FALSE(model.Redo()); 1548 EXPECT_FALSE(model.Redo());
1532 1549
1533 // TODO(oshima): We need MockInputMethod to test the behavior with IME. 1550 // TODO(oshima): We need MockInputMethod to test the behavior with IME.
1534 } 1551 }
1535 1552
1536 } // namespace views 1553 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/textfield/textfield_views_model.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698