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

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

Issue 10412009: Enable disabled omnibox tests on aura (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 8 years, 7 months 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 EXPECT_EQ(string16(), model.GetSelectedText()); 463 EXPECT_EQ(string16(), model.GetSelectedText());
464 EXPECT_STR_EQ("42", model.GetText()); 464 EXPECT_STR_EQ("42", model.GetText());
465 } 465 }
466 466
467 TEST_F(TextfieldViewsModelTest, SetText) { 467 TEST_F(TextfieldViewsModelTest, SetText) {
468 TextfieldViewsModel model(NULL); 468 TextfieldViewsModel model(NULL);
469 model.Append(ASCIIToUTF16("HELLO")); 469 model.Append(ASCIIToUTF16("HELLO"));
470 model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_RIGHT, false); 470 model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_RIGHT, false);
471 model.SetText(ASCIIToUTF16("GOODBYE")); 471 model.SetText(ASCIIToUTF16("GOODBYE"));
472 EXPECT_STR_EQ("GOODBYE", model.GetText()); 472 EXPECT_STR_EQ("GOODBYE", model.GetText());
473 // SetText won't reset the cursor posistion. 473 // SetText move the cursor to the end of the new text.
474 EXPECT_EQ(5U, model.GetCursorPosition()); 474 EXPECT_EQ(7U, model.GetCursorPosition());
475 model.SelectAll(); 475 model.SelectAll();
476 EXPECT_STR_EQ("GOODBYE", model.GetSelectedText()); 476 EXPECT_STR_EQ("GOODBYE", model.GetSelectedText());
477 model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_RIGHT, false); 477 model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_RIGHT, false);
478 EXPECT_EQ(7U, model.GetCursorPosition()); 478 EXPECT_EQ(7U, model.GetCursorPosition());
479 479
480 model.SetText(ASCIIToUTF16("BYE")); 480 model.SetText(ASCIIToUTF16("BYE"));
481 // Setting shorter string moves the cursor to the end of the new string. 481 // Setting shorter string moves the cursor to the end of the new string.
482 EXPECT_EQ(3U, model.GetCursorPosition()); 482 EXPECT_EQ(3U, model.GetCursorPosition());
483 EXPECT_EQ(string16(), model.GetSelectedText()); 483 EXPECT_EQ(string16(), model.GetSelectedText());
484 model.SetText(string16()); 484 model.SetText(string16());
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 EXPECT_EQ(2U, model.GetCursorPosition()); 1097 EXPECT_EQ(2U, model.GetCursorPosition());
1098 } 1098 }
1099 1099
1100 TEST_F(TextfieldViewsModelTest, UndoRedo_SetText) { 1100 TEST_F(TextfieldViewsModelTest, UndoRedo_SetText) {
1101 // This is to test the undo/redo behavior of omnibox. 1101 // This is to test the undo/redo behavior of omnibox.
1102 TextfieldViewsModel model(NULL); 1102 TextfieldViewsModel model(NULL);
1103 model.InsertChar('w'); 1103 model.InsertChar('w');
1104 EXPECT_STR_EQ("w", model.GetText()); 1104 EXPECT_STR_EQ("w", model.GetText());
1105 EXPECT_EQ(1U, model.GetCursorPosition()); 1105 EXPECT_EQ(1U, model.GetCursorPosition());
1106 model.SetText(ASCIIToUTF16("www.google.com")); 1106 model.SetText(ASCIIToUTF16("www.google.com"));
1107 EXPECT_EQ(1U, model.GetCursorPosition()); 1107 EXPECT_EQ(14U, model.GetCursorPosition());
1108 EXPECT_STR_EQ("www.google.com", model.GetText()); 1108 EXPECT_STR_EQ("www.google.com", model.GetText());
1109 model.SelectRange(ui::Range(14, 1)); 1109 model.SelectRange(ui::Range(14, 1));
1110 model.InsertChar('w'); 1110 model.InsertChar('w');
1111 EXPECT_STR_EQ("ww", model.GetText()); 1111 EXPECT_STR_EQ("ww", model.GetText());
1112 model.SetText(ASCIIToUTF16("www.google.com")); 1112 model.SetText(ASCIIToUTF16("www.google.com"));
1113 model.SelectRange(ui::Range(14, 2)); 1113 model.SelectRange(ui::Range(14, 2));
1114 model.InsertChar('w'); 1114 model.InsertChar('w');
1115 EXPECT_STR_EQ("www", model.GetText()); 1115 EXPECT_STR_EQ("www", model.GetText());
1116 model.SetText(ASCIIToUTF16("www.google.com")); 1116 model.SetText(ASCIIToUTF16("www.google.com"));
1117 model.SelectRange(ui::Range(14, 3)); 1117 model.SelectRange(ui::Range(14, 3));
1118 model.InsertChar('.'); 1118 model.InsertChar('.');
1119 EXPECT_STR_EQ("www.", model.GetText()); 1119 EXPECT_STR_EQ("www.", model.GetText());
1120 model.SetText(ASCIIToUTF16("www.google.com")); 1120 model.SetText(ASCIIToUTF16("www.google.com"));
1121 model.SelectRange(ui::Range(14, 4)); 1121 model.SelectRange(ui::Range(14, 4));
1122 model.InsertChar('y'); 1122 model.InsertChar('y');
1123 EXPECT_STR_EQ("www.y", model.GetText()); 1123 EXPECT_STR_EQ("www.y", model.GetText());
1124 model.SetText(ASCIIToUTF16("www.youtube.com")); 1124 model.SetText(ASCIIToUTF16("www.youtube.com"));
1125 EXPECT_STR_EQ("www.youtube.com", model.GetText()); 1125 EXPECT_STR_EQ("www.youtube.com", model.GetText());
1126 EXPECT_EQ(5U, model.GetCursorPosition()); 1126 EXPECT_EQ(15U, model.GetCursorPosition());
1127 1127
1128 EXPECT_TRUE(model.Undo()); 1128 EXPECT_TRUE(model.Undo());
1129 EXPECT_STR_EQ("www.google.com", model.GetText()); 1129 EXPECT_STR_EQ("www.google.com", model.GetText());
1130 EXPECT_EQ(4U, model.GetCursorPosition()); 1130 EXPECT_EQ(4U, model.GetCursorPosition());
1131 EXPECT_TRUE(model.Undo()); 1131 EXPECT_TRUE(model.Undo());
1132 EXPECT_STR_EQ("www.google.com", model.GetText()); 1132 EXPECT_STR_EQ("www.google.com", model.GetText());
1133 EXPECT_EQ(3U, model.GetCursorPosition()); 1133 EXPECT_EQ(3U, model.GetCursorPosition());
1134 EXPECT_TRUE(model.Undo()); 1134 EXPECT_TRUE(model.Undo());
1135 EXPECT_STR_EQ("www.google.com", model.GetText()); 1135 EXPECT_STR_EQ("www.google.com", model.GetText());
1136 EXPECT_EQ(2U, model.GetCursorPosition()); 1136 EXPECT_EQ(2U, model.GetCursorPosition());
(...skipping 22 matching lines...) Expand all
1159 EXPECT_FALSE(model.Redo()); 1159 EXPECT_FALSE(model.Redo());
1160 } 1160 }
1161 1161
1162 TEST_F(TextfieldViewsModelTest, UndoRedo_BackspaceThenSetText) { 1162 TEST_F(TextfieldViewsModelTest, UndoRedo_BackspaceThenSetText) {
1163 // This is to test the undo/redo behavior of omnibox. 1163 // This is to test the undo/redo behavior of omnibox.
1164 TextfieldViewsModel model(NULL); 1164 TextfieldViewsModel model(NULL);
1165 model.InsertChar('w'); 1165 model.InsertChar('w');
1166 EXPECT_STR_EQ("w", model.GetText()); 1166 EXPECT_STR_EQ("w", model.GetText());
1167 EXPECT_EQ(1U, model.GetCursorPosition()); 1167 EXPECT_EQ(1U, model.GetCursorPosition());
1168 model.SetText(ASCIIToUTF16("www.google.com")); 1168 model.SetText(ASCIIToUTF16("www.google.com"));
1169 EXPECT_EQ(1U, model.GetCursorPosition()); 1169 EXPECT_EQ(14U, model.GetCursorPosition());
1170 EXPECT_STR_EQ("www.google.com", model.GetText()); 1170 EXPECT_STR_EQ("www.google.com", model.GetText());
1171 model.SetText(ASCIIToUTF16("www.google.com")); // Confirm the text. 1171 model.SetText(ASCIIToUTF16("www.google.com")); // Confirm the text.
1172 model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_RIGHT, false); 1172 model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_RIGHT, false);
1173 EXPECT_EQ(14U, model.GetCursorPosition()); 1173 EXPECT_EQ(14U, model.GetCursorPosition());
1174 EXPECT_TRUE(model.Backspace()); 1174 EXPECT_TRUE(model.Backspace());
1175 EXPECT_TRUE(model.Backspace()); 1175 EXPECT_TRUE(model.Backspace());
1176 EXPECT_STR_EQ("www.google.c", model.GetText()); 1176 EXPECT_STR_EQ("www.google.c", model.GetText());
1177 // Autocomplete sets the text 1177 // Autocomplete sets the text
1178 model.SetText(ASCIIToUTF16("www.google.com/search=www.google.c")); 1178 model.SetText(ASCIIToUTF16("www.google.com/search=www.google.c"));
1179 EXPECT_STR_EQ("www.google.com/search=www.google.c", model.GetText()); 1179 EXPECT_STR_EQ("www.google.com/search=www.google.c", model.GetText());
(...skipping 15 matching lines...) Expand all
1195 EXPECT_TRUE(model.Undo()); 1195 EXPECT_TRUE(model.Undo());
1196 EXPECT_STR_EQ("ABCDE", model.GetText()); 1196 EXPECT_STR_EQ("ABCDE", model.GetText());
1197 EXPECT_EQ(3U, model.GetCursorPosition()); 1197 EXPECT_EQ(3U, model.GetCursorPosition());
1198 EXPECT_TRUE(model.Undo()); 1198 EXPECT_TRUE(model.Undo());
1199 EXPECT_STR_EQ("", model.GetText()); 1199 EXPECT_STR_EQ("", model.GetText());
1200 EXPECT_EQ(0U, model.GetCursorPosition()); 1200 EXPECT_EQ(0U, model.GetCursorPosition());
1201 EXPECT_FALSE(model.Undo()); // no more undo 1201 EXPECT_FALSE(model.Undo()); // no more undo
1202 EXPECT_STR_EQ("", model.GetText()); 1202 EXPECT_STR_EQ("", model.GetText());
1203 EXPECT_TRUE(model.Redo()); 1203 EXPECT_TRUE(model.Redo());
1204 EXPECT_STR_EQ("ABCDE", model.GetText()); 1204 EXPECT_STR_EQ("ABCDE", model.GetText());
1205 EXPECT_EQ(0U, model.GetCursorPosition()); 1205 EXPECT_EQ(5U, model.GetCursorPosition());
1206 EXPECT_TRUE(model.Redo()); 1206 EXPECT_TRUE(model.Redo());
1207 EXPECT_STR_EQ("ADE", model.GetText()); 1207 EXPECT_STR_EQ("ADE", model.GetText());
1208 EXPECT_EQ(1U, model.GetCursorPosition()); 1208 EXPECT_EQ(1U, model.GetCursorPosition());
1209 EXPECT_FALSE(model.Redo()); // no more redo 1209 EXPECT_FALSE(model.Redo()); // no more redo
1210 EXPECT_STR_EQ("ADE", model.GetText()); 1210 EXPECT_STR_EQ("ADE", model.GetText());
1211 1211
1212 model.Paste(); 1212 model.Paste();
1213 model.Paste(); 1213 model.Paste();
1214 model.Paste(); 1214 model.Paste();
1215 EXPECT_STR_EQ("ABCBCBCDE", model.GetText()); 1215 EXPECT_STR_EQ("ABCBCBCDE", model.GetText());
(...skipping 10 matching lines...) Expand all
1226 EXPECT_TRUE(model.Undo()); 1226 EXPECT_TRUE(model.Undo());
1227 EXPECT_STR_EQ("ABCDE", model.GetText()); 1227 EXPECT_STR_EQ("ABCDE", model.GetText());
1228 EXPECT_EQ(3U, model.GetCursorPosition()); 1228 EXPECT_EQ(3U, model.GetCursorPosition());
1229 EXPECT_TRUE(model.Undo()); 1229 EXPECT_TRUE(model.Undo());
1230 EXPECT_STR_EQ("", model.GetText()); 1230 EXPECT_STR_EQ("", model.GetText());
1231 EXPECT_EQ(0U, model.GetCursorPosition()); 1231 EXPECT_EQ(0U, model.GetCursorPosition());
1232 EXPECT_FALSE(model.Undo()); 1232 EXPECT_FALSE(model.Undo());
1233 EXPECT_STR_EQ("", model.GetText()); 1233 EXPECT_STR_EQ("", model.GetText());
1234 EXPECT_TRUE(model.Redo()); 1234 EXPECT_TRUE(model.Redo());
1235 EXPECT_STR_EQ("ABCDE", model.GetText()); // Redoing SetText 1235 EXPECT_STR_EQ("ABCDE", model.GetText()); // Redoing SetText
1236 EXPECT_EQ(0U, model.GetCursorPosition()); 1236 EXPECT_EQ(5U, model.GetCursorPosition());
1237 1237
1238 // Redo 1238 // Redo
1239 EXPECT_TRUE(model.Redo()); 1239 EXPECT_TRUE(model.Redo());
1240 EXPECT_STR_EQ("ADE", model.GetText()); 1240 EXPECT_STR_EQ("ADE", model.GetText());
1241 EXPECT_EQ(1U, model.GetCursorPosition()); 1241 EXPECT_EQ(1U, model.GetCursorPosition());
1242 EXPECT_TRUE(model.Redo()); 1242 EXPECT_TRUE(model.Redo());
1243 EXPECT_STR_EQ("ABCDE", model.GetText()); 1243 EXPECT_STR_EQ("ABCDE", model.GetText());
1244 EXPECT_EQ(3U, model.GetCursorPosition()); 1244 EXPECT_EQ(3U, model.GetCursorPosition());
1245 EXPECT_TRUE(model.Redo()); 1245 EXPECT_TRUE(model.Redo());
1246 EXPECT_STR_EQ("ABCBCDE", model.GetText()); 1246 EXPECT_STR_EQ("ABCBCDE", model.GetText());
(...skipping 19 matching lines...) Expand all
1266 EXPECT_EQ(7U, model.GetCursorPosition()); 1266 EXPECT_EQ(7U, model.GetCursorPosition());
1267 // empty cut shouldn't create an edit. 1267 // empty cut shouldn't create an edit.
1268 EXPECT_TRUE(model.Undo()); 1268 EXPECT_TRUE(model.Undo());
1269 EXPECT_STR_EQ("ABCBCBCDE", model.GetText()); 1269 EXPECT_STR_EQ("ABCBCBCDE", model.GetText());
1270 EXPECT_EQ(3U, model.GetCursorPosition()); 1270 EXPECT_EQ(3U, model.GetCursorPosition());
1271 1271
1272 // Copy 1272 // Copy
1273 ResetModel(&model); 1273 ResetModel(&model);
1274 model.SetText(ASCIIToUTF16("12345")); 1274 model.SetText(ASCIIToUTF16("12345"));
1275 EXPECT_STR_EQ("12345", model.GetText()); 1275 EXPECT_STR_EQ("12345", model.GetText());
1276 EXPECT_EQ(0U, model.GetCursorPosition()); 1276 EXPECT_EQ(5U, model.GetCursorPosition());
1277 model.SelectRange(ui::Range(1, 3)); 1277 model.SelectRange(ui::Range(1, 3));
1278 model.Copy(); // Copy "23" 1278 model.Copy(); // Copy "23"
1279 EXPECT_STR_EQ("12345", model.GetText()); 1279 EXPECT_STR_EQ("12345", model.GetText());
1280 EXPECT_EQ(3U, model.GetCursorPosition()); 1280 EXPECT_EQ(3U, model.GetCursorPosition());
1281 model.Paste(); // Paste "23" into "23". 1281 model.Paste(); // Paste "23" into "23".
1282 EXPECT_STR_EQ("12345", model.GetText()); 1282 EXPECT_STR_EQ("12345", model.GetText());
1283 EXPECT_EQ(3U, model.GetCursorPosition()); 1283 EXPECT_EQ(3U, model.GetCursorPosition());
1284 model.Paste(); 1284 model.Paste();
1285 EXPECT_STR_EQ("1232345", model.GetText()); 1285 EXPECT_STR_EQ("1232345", model.GetText());
1286 EXPECT_EQ(5U, model.GetCursorPosition()); 1286 EXPECT_EQ(5U, model.GetCursorPosition());
1287 EXPECT_TRUE(model.Undo()); 1287 EXPECT_TRUE(model.Undo());
1288 EXPECT_STR_EQ("12345", model.GetText()); 1288 EXPECT_STR_EQ("12345", model.GetText());
1289 EXPECT_EQ(3U, model.GetCursorPosition()); 1289 EXPECT_EQ(3U, model.GetCursorPosition());
1290 // TODO(oshima): We need to change the return type from bool to enum. 1290 // TODO(oshima): We need to change the return type from bool to enum.
1291 EXPECT_FALSE(model.Undo()); // No text change. 1291 EXPECT_FALSE(model.Undo()); // No text change.
1292 EXPECT_STR_EQ("12345", model.GetText()); 1292 EXPECT_STR_EQ("12345", model.GetText());
1293 EXPECT_EQ(3U, model.GetCursorPosition()); 1293 EXPECT_EQ(3U, model.GetCursorPosition());
1294 EXPECT_TRUE(model.Undo()); 1294 EXPECT_TRUE(model.Undo());
1295 EXPECT_STR_EQ("", model.GetText()); 1295 EXPECT_STR_EQ("", model.GetText());
1296 EXPECT_FALSE(model.Undo()); 1296 EXPECT_FALSE(model.Undo());
1297 // Redo 1297 // Redo
1298 EXPECT_TRUE(model.Redo()); 1298 EXPECT_TRUE(model.Redo());
1299 EXPECT_STR_EQ("12345", model.GetText()); 1299 EXPECT_STR_EQ("12345", model.GetText());
1300 EXPECT_EQ(0U, model.GetCursorPosition()); 1300 EXPECT_EQ(5U, model.GetCursorPosition());
1301 EXPECT_TRUE(model.Redo()); 1301 EXPECT_TRUE(model.Redo());
1302 EXPECT_STR_EQ("12345", model.GetText()); // For 1st paste 1302 EXPECT_STR_EQ("12345", model.GetText()); // For 1st paste
1303 EXPECT_EQ(3U, model.GetCursorPosition()); 1303 EXPECT_EQ(3U, model.GetCursorPosition());
1304 EXPECT_TRUE(model.Redo()); 1304 EXPECT_TRUE(model.Redo());
1305 EXPECT_STR_EQ("1232345", model.GetText()); 1305 EXPECT_STR_EQ("1232345", model.GetText());
1306 EXPECT_EQ(5U, model.GetCursorPosition()); 1306 EXPECT_EQ(5U, model.GetCursorPosition());
1307 EXPECT_FALSE(model.Redo()); 1307 EXPECT_FALSE(model.Redo());
1308 EXPECT_STR_EQ("1232345", model.GetText()); 1308 EXPECT_STR_EQ("1232345", model.GetText());
1309 1309
1310 // Test using SelectRange 1310 // Test using SelectRange
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1351 EXPECT_EQ(4U, model.GetCursorPosition()); 1351 EXPECT_EQ(4U, model.GetCursorPosition());
1352 EXPECT_TRUE(model.Undo()); 1352 EXPECT_TRUE(model.Undo());
1353 EXPECT_STR_EQ("abcd", model.GetText()); 1353 EXPECT_STR_EQ("abcd", model.GetText());
1354 EXPECT_EQ(reverse ? 1U : 3U, model.GetCursorPosition()); 1354 EXPECT_EQ(reverse ? 1U : 3U, model.GetCursorPosition());
1355 EXPECT_TRUE(model.Undo()); 1355 EXPECT_TRUE(model.Undo());
1356 EXPECT_STR_EQ("", model.GetText()); 1356 EXPECT_STR_EQ("", model.GetText());
1357 EXPECT_EQ(0U, model.GetCursorPosition()); 1357 EXPECT_EQ(0U, model.GetCursorPosition());
1358 EXPECT_FALSE(model.Undo()); 1358 EXPECT_FALSE(model.Undo());
1359 EXPECT_TRUE(model.Redo()); 1359 EXPECT_TRUE(model.Redo());
1360 EXPECT_STR_EQ("abcd", model.GetText()); 1360 EXPECT_STR_EQ("abcd", model.GetText());
1361 EXPECT_EQ(0U, model.GetCursorPosition()); // By SetText 1361 EXPECT_EQ(4U, model.GetCursorPosition()); // By SetText
1362 EXPECT_TRUE(model.Redo()); 1362 EXPECT_TRUE(model.Redo());
1363 EXPECT_STR_EQ("a123d", model.GetText()); 1363 EXPECT_STR_EQ("a123d", model.GetText());
1364 EXPECT_EQ(4U, model.GetCursorPosition()); 1364 EXPECT_EQ(4U, model.GetCursorPosition());
1365 EXPECT_FALSE(model.Redo()); 1365 EXPECT_FALSE(model.Redo());
1366 } 1366 }
1367 1367
1368 void RunOverwriteReplaceTest(TextfieldViewsModel& model) { 1368 void RunOverwriteReplaceTest(TextfieldViewsModel& model) {
1369 gfx::SelectionModel sel; 1369 gfx::SelectionModel sel;
1370 model.GetSelectionModel(&sel); 1370 model.GetSelectionModel(&sel);
1371 bool reverse = sel.selection().is_reversed(); 1371 bool reverse = sel.selection().is_reversed();
1372 1372
1373 model.ReplaceChar('1'); 1373 model.ReplaceChar('1');
1374 model.ReplaceChar('2'); 1374 model.ReplaceChar('2');
1375 model.ReplaceChar('3'); 1375 model.ReplaceChar('3');
1376 model.ReplaceChar('4'); 1376 model.ReplaceChar('4');
1377 EXPECT_STR_EQ("a1234", model.GetText()); 1377 EXPECT_STR_EQ("a1234", model.GetText());
1378 EXPECT_EQ(5U, model.GetCursorPosition()); 1378 EXPECT_EQ(5U, model.GetCursorPosition());
1379 EXPECT_TRUE(model.Undo()); 1379 EXPECT_TRUE(model.Undo());
1380 EXPECT_STR_EQ("abcd", model.GetText()); 1380 EXPECT_STR_EQ("abcd", model.GetText());
1381 EXPECT_EQ(reverse ? 1U : 3U, model.GetCursorPosition()); 1381 EXPECT_EQ(reverse ? 1U : 3U, model.GetCursorPosition());
1382 EXPECT_TRUE(model.Undo()); 1382 EXPECT_TRUE(model.Undo());
1383 EXPECT_STR_EQ("", model.GetText()); 1383 EXPECT_STR_EQ("", model.GetText());
1384 EXPECT_EQ(0U, model.GetCursorPosition()); 1384 EXPECT_EQ(0U, model.GetCursorPosition());
1385 EXPECT_FALSE(model.Undo()); 1385 EXPECT_FALSE(model.Undo());
1386 EXPECT_TRUE(model.Redo()); 1386 EXPECT_TRUE(model.Redo());
1387 EXPECT_STR_EQ("abcd", model.GetText()); 1387 EXPECT_STR_EQ("abcd", model.GetText());
1388 EXPECT_EQ(0U, model.GetCursorPosition()); 1388 EXPECT_EQ(4U, model.GetCursorPosition());
1389 EXPECT_TRUE(model.Redo()); 1389 EXPECT_TRUE(model.Redo());
1390 EXPECT_STR_EQ("a1234", model.GetText()); 1390 EXPECT_STR_EQ("a1234", model.GetText());
1391 EXPECT_EQ(5U, model.GetCursorPosition()); 1391 EXPECT_EQ(5U, model.GetCursorPosition());
1392 EXPECT_FALSE(model.Redo()); 1392 EXPECT_FALSE(model.Redo());
1393 } 1393 }
1394 1394
1395 TEST_F(TextfieldViewsModelTest, UndoRedo_ReplaceTest) { 1395 TEST_F(TextfieldViewsModelTest, UndoRedo_ReplaceTest) {
1396 // By Cursor 1396 // By Cursor
1397 { 1397 {
1398 SCOPED_TRACE("forward & insert by cursor"); 1398 SCOPED_TRACE("forward & insert by cursor");
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1524 EXPECT_TRUE(model.Undo()); 1524 EXPECT_TRUE(model.Undo());
1525 EXPECT_STR_EQ("ABCDE", model.GetText()); 1525 EXPECT_STR_EQ("ABCDE", model.GetText());
1526 EXPECT_TRUE(model.Redo()); 1526 EXPECT_TRUE(model.Redo());
1527 EXPECT_STR_EQ("1234", model.GetText()); 1527 EXPECT_STR_EQ("1234", model.GetText());
1528 EXPECT_FALSE(model.Redo()); 1528 EXPECT_FALSE(model.Redo());
1529 1529
1530 // TODO(oshima): We need MockInputMethod to test the behavior with IME. 1530 // TODO(oshima): We need MockInputMethod to test the behavior with IME.
1531 } 1531 }
1532 1532
1533 } // namespace views 1533 } // 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