| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/message_loop.h" | 5 #include "base/message_loop.h" |
| 6 #include "base/scoped_ptr.h" | 6 #include "base/scoped_ptr.h" |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "ui/base/clipboard/clipboard.h" | 9 #include "ui/base/clipboard/clipboard.h" |
| 10 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 10 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 EXPECT_EQ(7U, model.cursor_pos()); | 282 EXPECT_EQ(7U, model.cursor_pos()); |
| 283 | 283 |
| 284 model.SetText(ASCIIToUTF16("BYE")); | 284 model.SetText(ASCIIToUTF16("BYE")); |
| 285 EXPECT_EQ(3U, model.cursor_pos()); | 285 EXPECT_EQ(3U, model.cursor_pos()); |
| 286 EXPECT_EQ(string16(), model.GetSelectedText()); | 286 EXPECT_EQ(string16(), model.GetSelectedText()); |
| 287 model.SetText(ASCIIToUTF16("")); | 287 model.SetText(ASCIIToUTF16("")); |
| 288 EXPECT_EQ(0U, model.cursor_pos()); | 288 EXPECT_EQ(0U, model.cursor_pos()); |
| 289 } | 289 } |
| 290 | 290 |
| 291 TEST(TextfieldViewsModelTest, Clipboard) { | 291 TEST(TextfieldViewsModelTest, Clipboard) { |
| 292 views::ViewsDelegate::views_delegate = new TestViewsDelegate(); | 292 scoped_ptr<TestViewsDelegate> test_views_delegate = new TestViewsDelegate(); |
| 293 views::ViewsDelegate::views_delegate = test_views_delegate.get(); |
| 293 ui::Clipboard* clipboard | 294 ui::Clipboard* clipboard |
| 294 = views::ViewsDelegate::views_delegate->GetClipboard(); | 295 = views::ViewsDelegate::views_delegate->GetClipboard(); |
| 295 string16 initial_clipboard_text; | 296 string16 initial_clipboard_text; |
| 296 clipboard->ReadText(ui::Clipboard::BUFFER_STANDARD, &initial_clipboard_text); | 297 clipboard->ReadText(ui::Clipboard::BUFFER_STANDARD, &initial_clipboard_text); |
| 297 string16 clipboard_text; | 298 string16 clipboard_text; |
| 298 TextfieldViewsModel model; | 299 TextfieldViewsModel model; |
| 299 model.Append(ASCIIToUTF16("HELLO WORLD")); | 300 model.Append(ASCIIToUTF16("HELLO WORLD")); |
| 300 model.MoveCursorToEnd(false); | 301 model.MoveCursorToEnd(false); |
| 301 | 302 |
| 302 // Test for cut: Empty selection. | 303 // Test for cut: Empty selection. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 model.MoveCursorToEnd(false); | 336 model.MoveCursorToEnd(false); |
| 336 model.MoveCursorToPreviousWord(true); | 337 model.MoveCursorToPreviousWord(true); |
| 337 EXPECT_TRUE(model.Paste()); | 338 EXPECT_TRUE(model.Paste()); |
| 338 clipboard->ReadText(ui::Clipboard::BUFFER_STANDARD, &clipboard_text); | 339 clipboard->ReadText(ui::Clipboard::BUFFER_STANDARD, &clipboard_text); |
| 339 EXPECT_STR_EQ("HELLO HELLO WORLD", clipboard_text); | 340 EXPECT_STR_EQ("HELLO HELLO WORLD", clipboard_text); |
| 340 EXPECT_STR_EQ("HELLO HELLO HELLO HELLO WORLD", model.text()); | 341 EXPECT_STR_EQ("HELLO HELLO HELLO HELLO WORLD", model.text()); |
| 341 EXPECT_EQ(29U, model.cursor_pos()); | 342 EXPECT_EQ(29U, model.cursor_pos()); |
| 342 } | 343 } |
| 343 | 344 |
| 344 } // namespace views | 345 } // namespace views |
| OLD | NEW |