OLD | NEW |
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/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 EXPECT_EQ(7U, model.GetCursorPosition()); | 495 EXPECT_EQ(7U, model.GetCursorPosition()); |
496 | 496 |
497 model.SetText(ASCIIToUTF16("BYE")); | 497 model.SetText(ASCIIToUTF16("BYE")); |
498 // Setting shorter string moves the cursor to the end of the new string. | 498 // Setting shorter string moves the cursor to the end of the new string. |
499 EXPECT_EQ(3U, model.GetCursorPosition()); | 499 EXPECT_EQ(3U, model.GetCursorPosition()); |
500 EXPECT_EQ(string16(), model.GetSelectedText()); | 500 EXPECT_EQ(string16(), model.GetSelectedText()); |
501 model.SetText(ASCIIToUTF16("")); | 501 model.SetText(ASCIIToUTF16("")); |
502 EXPECT_EQ(0U, model.GetCursorPosition()); | 502 EXPECT_EQ(0U, model.GetCursorPosition()); |
503 } | 503 } |
504 | 504 |
505 TEST_F(TextfieldViewsModelTest, Clipboard) { | 505 #if defined(USE_AURA) && defined(OS_LINUX) |
| 506 #define MAYBE_Clipboard DISABLED_Clipboard // http://crbug.com/97845 |
| 507 #else |
| 508 #define MAYBE_Clipboard Clipboard |
| 509 #endif |
| 510 TEST_F(TextfieldViewsModelTest, MAYBE_Clipboard) { |
506 ui::Clipboard* clipboard | 511 ui::Clipboard* clipboard |
507 = views::ViewsDelegate::views_delegate->GetClipboard(); | 512 = views::ViewsDelegate::views_delegate->GetClipboard(); |
508 string16 initial_clipboard_text; | 513 string16 initial_clipboard_text; |
509 clipboard->ReadText(ui::Clipboard::BUFFER_STANDARD, &initial_clipboard_text); | 514 clipboard->ReadText(ui::Clipboard::BUFFER_STANDARD, &initial_clipboard_text); |
510 string16 clipboard_text; | 515 string16 clipboard_text; |
511 TextfieldViewsModel model(NULL); | 516 TextfieldViewsModel model(NULL); |
512 model.Append(ASCIIToUTF16("HELLO WORLD")); | 517 model.Append(ASCIIToUTF16("HELLO WORLD")); |
513 model.MoveCursorRight(gfx::LINE_BREAK, false); | 518 model.MoveCursorRight(gfx::LINE_BREAK, false); |
514 | 519 |
515 // Test for cut: Empty selection. | 520 // Test for cut: Empty selection. |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1048 EXPECT_EQ(3U, model.GetCursorPosition()); | 1053 EXPECT_EQ(3U, model.GetCursorPosition()); |
1049 EXPECT_TRUE(model.Redo()); | 1054 EXPECT_TRUE(model.Redo()); |
1050 EXPECT_STR_EQ("www.google.com", model.GetText()); | 1055 EXPECT_STR_EQ("www.google.com", model.GetText()); |
1051 EXPECT_EQ(4U, model.GetCursorPosition()); | 1056 EXPECT_EQ(4U, model.GetCursorPosition()); |
1052 EXPECT_TRUE(model.Redo()); | 1057 EXPECT_TRUE(model.Redo()); |
1053 EXPECT_STR_EQ("www.youtube.com", model.GetText()); | 1058 EXPECT_STR_EQ("www.youtube.com", model.GetText()); |
1054 EXPECT_EQ(5U, model.GetCursorPosition()); | 1059 EXPECT_EQ(5U, model.GetCursorPosition()); |
1055 EXPECT_FALSE(model.Redo()); | 1060 EXPECT_FALSE(model.Redo()); |
1056 } | 1061 } |
1057 | 1062 |
1058 TEST_F(TextfieldViewsModelTest, UndoRedo_CutCopyPasteTest) { | 1063 #if defined(USE_AURA) && defined(OS_LINUX) |
| 1064 // This can be re-enabled when aura on linux has clipboard support. |
| 1065 // http://crbug.com/97845 |
| 1066 #define MAYBE_UndoRedo_CutCopyPasteTest DISABLED_UndoRedo_CutCopyPasteTest |
| 1067 #else |
| 1068 #define MAYBE_UndoRedo_CutCopyPasteTest UndoRedo_CutCopyPasteTest |
| 1069 #endif |
| 1070 TEST_F(TextfieldViewsModelTest, MAYBE_UndoRedo_CutCopyPasteTest) { |
1059 TextfieldViewsModel model(NULL); | 1071 TextfieldViewsModel model(NULL); |
1060 model.SetText(ASCIIToUTF16("ABCDE")); | 1072 model.SetText(ASCIIToUTF16("ABCDE")); |
1061 EXPECT_FALSE(model.Redo()); // nothing to redo | 1073 EXPECT_FALSE(model.Redo()); // nothing to redo |
1062 // Cut | 1074 // Cut |
1063 model.MoveCursorTo(gfx::SelectionModel(1, 3)); | 1075 model.MoveCursorTo(gfx::SelectionModel(1, 3)); |
1064 model.Cut(); | 1076 model.Cut(); |
1065 EXPECT_STR_EQ("ADE", model.GetText()); | 1077 EXPECT_STR_EQ("ADE", model.GetText()); |
1066 EXPECT_EQ(1U, model.GetCursorPosition()); | 1078 EXPECT_EQ(1U, model.GetCursorPosition()); |
1067 EXPECT_TRUE(model.Undo()); | 1079 EXPECT_TRUE(model.Undo()); |
1068 EXPECT_STR_EQ("ABCDE", model.GetText()); | 1080 EXPECT_STR_EQ("ABCDE", model.GetText()); |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1396 EXPECT_TRUE(model.Undo()); | 1408 EXPECT_TRUE(model.Undo()); |
1397 EXPECT_STR_EQ("ABCDE", model.GetText()); | 1409 EXPECT_STR_EQ("ABCDE", model.GetText()); |
1398 EXPECT_TRUE(model.Redo()); | 1410 EXPECT_TRUE(model.Redo()); |
1399 EXPECT_STR_EQ("1234", model.GetText()); | 1411 EXPECT_STR_EQ("1234", model.GetText()); |
1400 EXPECT_FALSE(model.Redo()); | 1412 EXPECT_FALSE(model.Redo()); |
1401 | 1413 |
1402 // TODO(oshima): We need MockInputMethod to test the behavior with IME. | 1414 // TODO(oshima): We need MockInputMethod to test the behavior with IME. |
1403 } | 1415 } |
1404 | 1416 |
1405 } // namespace views | 1417 } // namespace views |
OLD | NEW |