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

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

Issue 10917196: Fix memory leak in BookmarkUtilsTest.CopyPaste. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Now with three other cases. 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 | chrome/browser/ui/omnibox/omnibox_view_unittest.cc » ('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/scoped_clipboard_writer.h" 12 #include "ui/base/clipboard/scoped_clipboard_writer.h"
12 13
13 using std::string; 14 using std::string;
14 15
15 namespace bookmark_utils { 16 namespace bookmark_utils {
16 namespace { 17 namespace {
17 18
18 TEST(BookmarkUtilsTest, GetBookmarksContainingText) { 19 class BookmarkUtilsTest : public ::testing::Test {
20 public:
21 virtual void TearDown() OVERRIDE {
22 ui::Clipboard::DestroyClipboardForCurrentThread();
23 }
24 };
25
26 TEST_F(BookmarkUtilsTest, GetBookmarksContainingText) {
19 BookmarkModel model(NULL); 27 BookmarkModel model(NULL);
20 const BookmarkNode* n1 = model.AddURL(model.other_node(), 28 const BookmarkNode* n1 = model.AddURL(model.other_node(),
21 0, 29 0,
22 ASCIIToUTF16("foo bar"), 30 ASCIIToUTF16("foo bar"),
23 GURL("http://www.google.com")); 31 GURL("http://www.google.com"));
24 const BookmarkNode* n2 = model.AddURL(model.other_node(), 32 const BookmarkNode* n2 = model.AddURL(model.other_node(),
25 0, 33 0,
26 ASCIIToUTF16("baz buz"), 34 ASCIIToUTF16("baz buz"),
27 GURL("http://www.cnn.com")); 35 GURL("http://www.cnn.com"));
28 36
(...skipping 15 matching lines...) Expand all
44 nodes.clear(); 52 nodes.clear();
45 53
46 GetBookmarksContainingText( 54 GetBookmarksContainingText(
47 &model, ASCIIToUTF16("foo bar"), 100, string(), &nodes); 55 &model, ASCIIToUTF16("foo bar"), 100, string(), &nodes);
48 ASSERT_EQ(1U, nodes.size()); 56 ASSERT_EQ(1U, nodes.size());
49 EXPECT_TRUE(nodes[0] == n1); 57 EXPECT_TRUE(nodes[0] == n1);
50 EXPECT_TRUE(DoesBookmarkContainText(n1, ASCIIToUTF16("foo bar"), string())); 58 EXPECT_TRUE(DoesBookmarkContainText(n1, ASCIIToUTF16("foo bar"), string()));
51 nodes.clear(); 59 nodes.clear();
52 } 60 }
53 61
54 TEST(BookmarkUtilsTest, DoesBookmarkContainText) { 62 TEST_F(BookmarkUtilsTest, DoesBookmarkContainText) {
55 BookmarkModel model(NULL); 63 BookmarkModel model(NULL);
56 const BookmarkNode* node = model.AddURL(model.other_node(), 64 const BookmarkNode* node = model.AddURL(model.other_node(),
57 0, 65 0,
58 ASCIIToUTF16("foo bar"), 66 ASCIIToUTF16("foo bar"),
59 GURL("http://www.google.com")); 67 GURL("http://www.google.com"));
60 // Matches to the title. 68 // Matches to the title.
61 EXPECT_TRUE(DoesBookmarkContainText(node, ASCIIToUTF16("ar"), string())); 69 EXPECT_TRUE(DoesBookmarkContainText(node, ASCIIToUTF16("ar"), string()));
62 // Matches to the URL. 70 // Matches to the URL.
63 EXPECT_TRUE(DoesBookmarkContainText(node, ASCIIToUTF16("www"), string())); 71 EXPECT_TRUE(DoesBookmarkContainText(node, ASCIIToUTF16("www"), string()));
64 // No match. 72 // No match.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 string())); 119 string()));
112 EXPECT_TRUE(DoesBookmarkContainText( 120 EXPECT_TRUE(DoesBookmarkContainText(
113 node, WideToUTF16(L"Fr\u00C4n\u00C7\u00F3S\u00EA"), string())); 121 node, WideToUTF16(L"Fr\u00C4n\u00C7\u00F3S\u00EA"), string()));
114 EXPECT_TRUE(DoesBookmarkContainText( 122 EXPECT_TRUE(DoesBookmarkContainText(
115 node, WideToUTF16(L"fr\u00C4n\u00C7\u00D3s\u00CA"), string())); 123 node, WideToUTF16(L"fr\u00C4n\u00C7\u00D3s\u00CA"), string()));
116 EXPECT_TRUE(DoesBookmarkContainText(node, ASCIIToUTF16("fba"), string())); 124 EXPECT_TRUE(DoesBookmarkContainText(node, ASCIIToUTF16("fba"), string()));
117 EXPECT_TRUE(DoesBookmarkContainText(node, ASCIIToUTF16("FBA"), string())); 125 EXPECT_TRUE(DoesBookmarkContainText(node, ASCIIToUTF16("FBA"), string()));
118 } 126 }
119 127
120 #if !defined(OS_MACOSX) 128 #if !defined(OS_MACOSX)
121 TEST(BookmarkUtilsTest, CopyPaste) { 129 TEST_F(BookmarkUtilsTest, CopyPaste) {
122 // Clipboard requires a message loop. 130 // Clipboard requires a message loop.
123 MessageLoopForUI loop; 131 MessageLoopForUI loop;
124 132
125 BookmarkModel model(NULL); 133 BookmarkModel model(NULL);
126 const BookmarkNode* node = model.AddURL(model.other_node(), 134 const BookmarkNode* node = model.AddURL(model.other_node(),
127 0, 135 0,
128 ASCIIToUTF16("foo bar"), 136 ASCIIToUTF16("foo bar"),
129 GURL("http://www.google.com")); 137 GURL("http://www.google.com"));
130 138
131 // Copy a node to the clipboard. 139 // Copy a node to the clipboard.
(...skipping 12 matching lines...) Expand all
144 clipboard_writer.WriteText(ASCIIToUTF16("foo")); 152 clipboard_writer.WriteText(ASCIIToUTF16("foo"));
145 } 153 }
146 154
147 // Now we shouldn't be able to paste from the clipboard. 155 // Now we shouldn't be able to paste from the clipboard.
148 EXPECT_FALSE(CanPasteFromClipboard(model.bookmark_bar_node())); 156 EXPECT_FALSE(CanPasteFromClipboard(model.bookmark_bar_node()));
149 } 157 }
150 #endif 158 #endif
151 159
152 } // namespace 160 } // namespace
153 } // namespace bookmark_utils 161 } // namespace bookmark_utils
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/omnibox/omnibox_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698