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

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

Issue 558913003: Remove clipboard argument from ScopedClipboardWriter constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't leak a clipboard on Windows Created 6 years, 3 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 EXPECT_EQ(3U, model.GetCursorPosition()); 472 EXPECT_EQ(3U, model.GetCursorPosition());
473 EXPECT_EQ(base::string16(), model.GetSelectedText()); 473 EXPECT_EQ(base::string16(), model.GetSelectedText());
474 model.SetText(base::string16()); 474 model.SetText(base::string16());
475 EXPECT_EQ(0U, model.GetCursorPosition()); 475 EXPECT_EQ(0U, model.GetCursorPosition());
476 } 476 }
477 477
478 TEST_F(TextfieldModelTest, Clipboard) { 478 TEST_F(TextfieldModelTest, Clipboard) {
479 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); 479 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
480 const base::string16 initial_clipboard_text = 480 const base::string16 initial_clipboard_text =
481 base::ASCIIToUTF16("initial text"); 481 base::ASCIIToUTF16("initial text");
482 ui::ScopedClipboardWriter(clipboard, ui::CLIPBOARD_TYPE_COPY_PASTE). 482 ui::ScopedClipboardWriter(ui::CLIPBOARD_TYPE_COPY_PASTE)
483 WriteText(initial_clipboard_text); 483 .WriteText(initial_clipboard_text);
484 484
485 base::string16 clipboard_text; 485 base::string16 clipboard_text;
486 TextfieldModel model(NULL); 486 TextfieldModel model(NULL);
487 model.Append(base::ASCIIToUTF16("HELLO WORLD")); 487 model.Append(base::ASCIIToUTF16("HELLO WORLD"));
488 488
489 // Cut with an empty selection should do nothing. 489 // Cut with an empty selection should do nothing.
490 model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_RIGHT, false); 490 model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_RIGHT, false);
491 EXPECT_FALSE(model.Cut()); 491 EXPECT_FALSE(model.Cut());
492 clipboard->ReadText(ui::CLIPBOARD_TYPE_COPY_PASTE, &clipboard_text); 492 clipboard->ReadText(ui::CLIPBOARD_TYPE_COPY_PASTE, &clipboard_text);
493 EXPECT_EQ(initial_clipboard_text, clipboard_text); 493 EXPECT_EQ(initial_clipboard_text, clipboard_text);
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after
1473 EXPECT_TRUE(model.Undo()); 1473 EXPECT_TRUE(model.Undo());
1474 EXPECT_STR_EQ("ABCDE", model.text()); 1474 EXPECT_STR_EQ("ABCDE", model.text());
1475 EXPECT_TRUE(model.Redo()); 1475 EXPECT_TRUE(model.Redo());
1476 EXPECT_STR_EQ("1234", model.text()); 1476 EXPECT_STR_EQ("1234", model.text());
1477 EXPECT_FALSE(model.Redo()); 1477 EXPECT_FALSE(model.Redo());
1478 1478
1479 // TODO(oshima): Test the behavior with an IME. 1479 // TODO(oshima): Test the behavior with an IME.
1480 } 1480 }
1481 1481
1482 } // namespace views 1482 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/textfield/textfield_model.cc ('k') | ui/views/controls/textfield/textfield_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698