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

Side by Side Diff: components/bookmarks/browser/bookmark_node_data_unittest.cc

Issue 677423004: Add unittest coverage for WriteToClipboard with a single URL (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/files/scoped_temp_dir.h" 6 #include "base/files/scoped_temp_dir.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 read_data.GetNodes(model(), GetProfilePath()); 269 read_data.GetNodes(model(), GetProfilePath());
270 ASSERT_EQ(2u, read_nodes.size()); 270 ASSERT_EQ(2u, read_nodes.size());
271 EXPECT_TRUE(read_nodes[0] == folder); 271 EXPECT_TRUE(read_nodes[0] == folder);
272 EXPECT_TRUE(read_nodes[1] == url_node); 272 EXPECT_TRUE(read_nodes[1] == url_node);
273 273
274 // Asking for the first node should return NULL with more than one element 274 // Asking for the first node should return NULL with more than one element
275 // present. 275 // present.
276 EXPECT_TRUE(read_data.GetFirstNode(model(), GetProfilePath()) == NULL); 276 EXPECT_TRUE(read_data.GetFirstNode(model(), GetProfilePath()) == NULL);
277 } 277 }
278 278
279 TEST_F(BookmarkNodeDataTest, WriteToClipboardURL) {
280 BookmarkNodeData data;
281 GURL url(GURL("http://foo.com"));
282 const base::string16 title(ASCIIToUTF16("blah"));
283
284 data.ReadFromTuple(url, title);
285 data.WriteToClipboard(ui::CLIPBOARD_TYPE_COPY_PASTE);
286
287 // Now read the data back in.
288 base::string16 clipboard_result;
289 clipboard().ReadText(ui::CLIPBOARD_TYPE_COPY_PASTE, &clipboard_result);
290 EXPECT_EQ(base::UTF8ToUTF16(url.spec()), clipboard_result);
291 }
292
279 TEST_F(BookmarkNodeDataTest, WriteToClipboardMultipleURLs) { 293 TEST_F(BookmarkNodeDataTest, WriteToClipboardMultipleURLs) {
280 BookmarkNodeData data; 294 BookmarkNodeData data;
281 const BookmarkNode* root = model()->bookmark_bar_node(); 295 const BookmarkNode* root = model()->bookmark_bar_node();
282 GURL url(GURL("http://foo.com")); 296 GURL url(GURL("http://foo.com"));
283 const base::string16 title(ASCIIToUTF16("blah")); 297 const base::string16 title(ASCIIToUTF16("blah"));
284 GURL url2(GURL("http://bar.com")); 298 GURL url2(GURL("http://bar.com"));
285 const base::string16 title2(ASCIIToUTF16("blah2")); 299 const base::string16 title2(ASCIIToUTF16("blah2"));
286 const BookmarkNode* url_node = model()->AddURL(root, 0, title, url); 300 const BookmarkNode* url_node = model()->AddURL(root, 0, title, url);
287 const BookmarkNode* url_node2 = model()->AddURL(root, 1, title2, url2); 301 const BookmarkNode* url_node2 = model()->AddURL(root, 1, title2, url2);
288 std::vector<const BookmarkNode*> nodes; 302 std::vector<const BookmarkNode*> nodes;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 ASSERT_EQ(1u, read_data.elements.size()); 397 ASSERT_EQ(1u, read_data.elements.size());
384 398
385 // Verify that the read data contains the same meta info. 399 // Verify that the read data contains the same meta info.
386 BookmarkNode::MetaInfoMap meta_info_map = read_data.elements[0].meta_info_map; 400 BookmarkNode::MetaInfoMap meta_info_map = read_data.elements[0].meta_info_map;
387 EXPECT_EQ(2u, meta_info_map.size()); 401 EXPECT_EQ(2u, meta_info_map.size());
388 EXPECT_EQ("somevalue", meta_info_map["somekey"]); 402 EXPECT_EQ("somevalue", meta_info_map["somekey"]);
389 EXPECT_EQ("someothervalue", meta_info_map["someotherkey"]); 403 EXPECT_EQ("someothervalue", meta_info_map["someotherkey"]);
390 } 404 }
391 405
392 } // namespace bookmarks 406 } // namespace bookmarks
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698