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

Side by Side Diff: chrome/browser/bookmarks/bookmark_utils_unittest.cc

Issue 10829341: Desktop aura: Use the X11 clipboard (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix MessageLoop ordering in tests. 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
« no previous file with comments | « no previous file | ui/aura/aura.gyp » ('j') | 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 "chrome/browser/bookmarks/bookmark_utils.h" 5 #include "chrome/browser/bookmarks/bookmark_utils.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/bookmarks/bookmark_model.h" 9 #include "chrome/browser/bookmarks/bookmark_model.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "ui/base/clipboard/clipboard.h" 11 #include "ui/base/clipboard/clipboard.h"
12 #include "ui/base/clipboard/scoped_clipboard_writer.h" 12 #include "ui/base/clipboard/scoped_clipboard_writer.h"
13 13
14 using std::string; 14 using std::string;
15 15
16 namespace bookmark_utils { 16 namespace bookmark_utils {
17 namespace { 17 namespace {
18 18
19 class BookmarkUtilsTest : public ::testing::Test { 19 class BookmarkUtilsTest : public ::testing::Test {
20 public: 20 public:
21 virtual void TearDown() OVERRIDE { 21 virtual void TearDown() OVERRIDE {
22 ui::Clipboard::DestroyClipboardForCurrentThread(); 22 ui::Clipboard::DestroyClipboardForCurrentThread();
23 } 23 }
24
25 private:
26 // Clipboard requires a message loop.
27 MessageLoopForUI loop;
24 }; 28 };
25 29
26 TEST_F(BookmarkUtilsTest, GetBookmarksContainingText) { 30 TEST_F(BookmarkUtilsTest, GetBookmarksContainingText) {
27 BookmarkModel model(NULL); 31 BookmarkModel model(NULL);
28 const BookmarkNode* n1 = model.AddURL(model.other_node(), 32 const BookmarkNode* n1 = model.AddURL(model.other_node(),
29 0, 33 0,
30 ASCIIToUTF16("foo bar"), 34 ASCIIToUTF16("foo bar"),
31 GURL("http://www.google.com")); 35 GURL("http://www.google.com"));
32 const BookmarkNode* n2 = model.AddURL(model.other_node(), 36 const BookmarkNode* n2 = model.AddURL(model.other_node(),
33 0, 37 0,
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 EXPECT_TRUE(DoesBookmarkContainText( 124 EXPECT_TRUE(DoesBookmarkContainText(
121 node, WideToUTF16(L"Fr\u00C4n\u00C7\u00F3S\u00EA"), string())); 125 node, WideToUTF16(L"Fr\u00C4n\u00C7\u00F3S\u00EA"), string()));
122 EXPECT_TRUE(DoesBookmarkContainText( 126 EXPECT_TRUE(DoesBookmarkContainText(
123 node, WideToUTF16(L"fr\u00C4n\u00C7\u00D3s\u00CA"), string())); 127 node, WideToUTF16(L"fr\u00C4n\u00C7\u00D3s\u00CA"), string()));
124 EXPECT_TRUE(DoesBookmarkContainText(node, ASCIIToUTF16("fba"), string())); 128 EXPECT_TRUE(DoesBookmarkContainText(node, ASCIIToUTF16("fba"), string()));
125 EXPECT_TRUE(DoesBookmarkContainText(node, ASCIIToUTF16("FBA"), string())); 129 EXPECT_TRUE(DoesBookmarkContainText(node, ASCIIToUTF16("FBA"), string()));
126 } 130 }
127 131
128 #if !defined(OS_MACOSX) 132 #if !defined(OS_MACOSX)
129 TEST_F(BookmarkUtilsTest, CopyPaste) { 133 TEST_F(BookmarkUtilsTest, CopyPaste) {
130 // Clipboard requires a message loop.
131 MessageLoopForUI loop;
132
133 BookmarkModel model(NULL); 134 BookmarkModel model(NULL);
134 const BookmarkNode* node = model.AddURL(model.other_node(), 135 const BookmarkNode* node = model.AddURL(model.other_node(),
135 0, 136 0,
136 ASCIIToUTF16("foo bar"), 137 ASCIIToUTF16("foo bar"),
137 GURL("http://www.google.com")); 138 GURL("http://www.google.com"));
138 139
139 // Copy a node to the clipboard. 140 // Copy a node to the clipboard.
140 std::vector<const BookmarkNode*> nodes; 141 std::vector<const BookmarkNode*> nodes;
141 nodes.push_back(node); 142 nodes.push_back(node);
142 CopyToClipboard(&model, nodes, false); 143 CopyToClipboard(&model, nodes, false);
143 144
144 // And make sure we can paste a bookmark from the clipboard. 145 // And make sure we can paste a bookmark from the clipboard.
145 EXPECT_TRUE(CanPasteFromClipboard(model.bookmark_bar_node())); 146 EXPECT_TRUE(CanPasteFromClipboard(model.bookmark_bar_node()));
146 147
147 // Write some text to the clipboard. 148 // Write some text to the clipboard.
148 { 149 {
149 ui::ScopedClipboardWriter clipboard_writer( 150 ui::ScopedClipboardWriter clipboard_writer(
150 ui::Clipboard::GetForCurrentThread(), 151 ui::Clipboard::GetForCurrentThread(),
151 ui::Clipboard::BUFFER_STANDARD); 152 ui::Clipboard::BUFFER_STANDARD);
152 clipboard_writer.WriteText(ASCIIToUTF16("foo")); 153 clipboard_writer.WriteText(ASCIIToUTF16("foo"));
153 } 154 }
154 155
155 // Now we shouldn't be able to paste from the clipboard. 156 // Now we shouldn't be able to paste from the clipboard.
156 EXPECT_FALSE(CanPasteFromClipboard(model.bookmark_bar_node())); 157 EXPECT_FALSE(CanPasteFromClipboard(model.bookmark_bar_node()));
157 } 158 }
158 #endif 159 #endif
159 160
160 } // namespace 161 } // namespace
161 } // namespace bookmark_utils 162 } // namespace bookmark_utils
OLDNEW
« no previous file with comments | « no previous file | ui/aura/aura.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698