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

Unified Diff: components/bookmarks/browser/bookmark_utils_unittest.cc

Issue 446003002: Title: Same Bookmark url is getting pasted on the Bookmarkbar with same title. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/bookmarks/browser/bookmark_utils.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/bookmarks/browser/bookmark_utils_unittest.cc
diff --git a/components/bookmarks/browser/bookmark_utils_unittest.cc b/components/bookmarks/browser/bookmark_utils_unittest.cc
index 7a94080a4f94b666f8be64136cfdcb7598a2aa69..cc8c9f91a567ab36c29cbece71c96ae073910b9d 100644
--- a/components/bookmarks/browser/bookmark_utils_unittest.cc
+++ b/components/bookmarks/browser/bookmark_utils_unittest.cc
@@ -314,6 +314,42 @@ TEST_F(BookmarkUtilsTest, CopyPaste) {
EXPECT_FALSE(CanPasteFromClipboard(model.get(), model->bookmark_bar_node()));
}
+// Test for updating title such that url and title pair are unique among the
+// children of parent.
+TEST_F(BookmarkUtilsTest, MakeTitleUnique) {
+ TestBookmarkClient client;
+ scoped_ptr<BookmarkModel> model(client.CreateModel());
+ const base::string16 url_text = ASCIIToUTF16("http://www.google.com/");
+ const base::string16 title_text = ASCIIToUTF16("foobar");
+ const BookmarkNode* bookmark_bar_node = model->bookmark_bar_node();
+
+ const BookmarkNode* node =
+ model->AddURL(bookmark_bar_node, 0, title_text, GURL(url_text));
+
+ EXPECT_EQ(url_text,
+ ASCIIToUTF16(bookmark_bar_node->GetChild(0)->url().spec()));
+ EXPECT_EQ(title_text, bookmark_bar_node->GetChild(0)->GetTitle());
+
+ // Copy a node to the clipboard.
+ std::vector<const BookmarkNode*> nodes;
+ nodes.push_back(node);
+ CopyToClipboard(model.get(), nodes, false);
+
+ // Now we should be able to paste from the clipboard.
+ EXPECT_TRUE(CanPasteFromClipboard(model.get(), bookmark_bar_node));
+
+ PasteFromClipboard(model.get(), bookmark_bar_node, 1);
+ ASSERT_EQ(2, bookmark_bar_node->child_count());
+
+ // Url for added node should be same as url_text.
+ EXPECT_EQ(url_text,
+ ASCIIToUTF16(bookmark_bar_node->GetChild(1)->url().spec()));
+ // Title for added node should be numeric subscript suffix with copied node
+ // title.
+ EXPECT_EQ(ASCIIToUTF16("foobar (1)"),
+ bookmark_bar_node->GetChild(1)->GetTitle());
+}
+
TEST_F(BookmarkUtilsTest, CopyPasteMetaInfo) {
TestBookmarkClient client;
scoped_ptr<BookmarkModel> model(client.CreateModel());
« no previous file with comments | « components/bookmarks/browser/bookmark_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698