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

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

Issue 10916214: Try 2 - Change how ui::Clipboard is accessed so there's only one per thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved to BrowserThreadsStarted Created 8 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 | Annotate | Revision Log
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"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "ui/base/clipboard/clipboard.h" 13 #include "ui/base/clipboard/clipboard.h"
14 #include "ui/base/clipboard/scoped_clipboard_writer.h" 14 #include "ui/base/clipboard/scoped_clipboard_writer.h"
15 #include "ui/base/range/range.h" 15 #include "ui/base/range/range.h"
16 #include "ui/gfx/render_text.h" 16 #include "ui/gfx/render_text.h"
17 #include "ui/views/controls/textfield/textfield.h" 17 #include "ui/views/controls/textfield/textfield.h"
18 #include "ui/views/controls/textfield/textfield_views_model.h" 18 #include "ui/views/controls/textfield/textfield_views_model.h"
19 #include "ui/views/test/test_views_delegate.h" 19 #include "ui/views/test/test_views_delegate.h"
20 #include "ui/views/test/views_test_base.h" 20 #include "ui/views/test/views_test_base.h"
21 #include "ui/views/views_delegate.h"
22 21
23 #if defined(OS_WIN) 22 #if defined(OS_WIN)
24 #include "base/win/windows_version.h" 23 #include "base/win/windows_version.h"
25 #endif 24 #endif
26 25
27 namespace { 26 namespace {
28 27
29 struct WordAndCursor { 28 struct WordAndCursor {
30 WordAndCursor(const wchar_t* w, size_t c) 29 WordAndCursor(const wchar_t* w, size_t c)
31 : word(w), 30 : word(w),
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 EXPECT_EQ(0U, model.GetCursorPosition()); 487 EXPECT_EQ(0U, model.GetCursorPosition());
489 } 488 }
490 489
491 #if defined(USE_AURA) && defined(OS_LINUX) 490 #if defined(USE_AURA) && defined(OS_LINUX)
492 #define MAYBE_Clipboard DISABLED_Clipboard // http://crbug.com/97845 491 #define MAYBE_Clipboard DISABLED_Clipboard // http://crbug.com/97845
493 #else 492 #else
494 #define MAYBE_Clipboard Clipboard 493 #define MAYBE_Clipboard Clipboard
495 #endif 494 #endif
496 TEST_F(TextfieldViewsModelTest, MAYBE_Clipboard) { 495 TEST_F(TextfieldViewsModelTest, MAYBE_Clipboard) {
497 ui::Clipboard* clipboard 496 ui::Clipboard* clipboard
498 = views::ViewsDelegate::views_delegate->GetClipboard(); 497 = ui::Clipboard::GetForCurrentThread();
499 string16 initial_clipboard_text = ASCIIToUTF16("initial text"); 498 string16 initial_clipboard_text = ASCIIToUTF16("initial text");
500 ui::ScopedClipboardWriter( 499 ui::ScopedClipboardWriter(
501 clipboard, 500 clipboard,
502 ui::Clipboard::BUFFER_STANDARD).WriteText(initial_clipboard_text); 501 ui::Clipboard::BUFFER_STANDARD).WriteText(initial_clipboard_text);
503 502
504 string16 clipboard_text; 503 string16 clipboard_text;
505 TextfieldViewsModel model(NULL); 504 TextfieldViewsModel model(NULL);
506 model.Append(ASCIIToUTF16("HELLO WORLD")); 505 model.Append(ASCIIToUTF16("HELLO WORLD"));
507 506
508 // Cut with an empty selection should do nothing. 507 // Cut with an empty selection should do nothing.
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after
1527 EXPECT_TRUE(model.Undo()); 1526 EXPECT_TRUE(model.Undo());
1528 EXPECT_STR_EQ("ABCDE", model.GetText()); 1527 EXPECT_STR_EQ("ABCDE", model.GetText());
1529 EXPECT_TRUE(model.Redo()); 1528 EXPECT_TRUE(model.Redo());
1530 EXPECT_STR_EQ("1234", model.GetText()); 1529 EXPECT_STR_EQ("1234", model.GetText());
1531 EXPECT_FALSE(model.Redo()); 1530 EXPECT_FALSE(model.Redo());
1532 1531
1533 // TODO(oshima): We need MockInputMethod to test the behavior with IME. 1532 // TODO(oshima): We need MockInputMethod to test the behavior with IME.
1534 } 1533 }
1535 1534
1536 } // namespace views 1535 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/textfield/textfield_views_model.cc ('k') | ui/views/test/test_views_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698