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

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

Issue 437423005: Show paste option on right click of bookmark bar if some URL is copied from outside browser or from… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed build break. Created 6 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 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 ace715a25d5ca7c24a07014165aa7af79eabd258..61711d2456c3049ac01960fcf7fc4c57c55abc16 100644
--- a/components/bookmarks/browser/bookmark_utils_unittest.cc
+++ b/components/bookmarks/browser/bookmark_utils_unittest.cc
@@ -257,6 +257,38 @@ TEST_F(BookmarkUtilsTest, GetBookmarksMatchingPropertiesConjunction) {
// Copy and paste is not yet supported on iOS. http://crbug.com/228147
#if !defined(OS_IOS)
+TEST_F(BookmarkUtilsTest, PasteBookmarkFromURL) {
+ TestBookmarkClient client;
+ scoped_ptr<BookmarkModel> model(client.CreateModel());
+ const base::string16 url_text = ASCIIToUTF16("http://www.google.com/");
+ const BookmarkNode* new_folder = model->AddFolder(
+ model->bookmark_bar_node(), 0, ASCIIToUTF16("New_Folder"));
+
+ // Write blank text to clipboard.
+ {
+ ui::ScopedClipboardWriter clipboard_writer(
+ ui::Clipboard::GetForCurrentThread(), ui::CLIPBOARD_TYPE_COPY_PASTE);
+ clipboard_writer.WriteText(base::string16());
+ }
+ // Now we shouldn't be able to paste from the clipboard.
+ EXPECT_FALSE(CanPasteFromClipboard(model.get(), new_folder));
+
+ // Write some valid url to the clipboard.
+ {
+ ui::ScopedClipboardWriter clipboard_writer(
+ ui::Clipboard::GetForCurrentThread(), ui::CLIPBOARD_TYPE_COPY_PASTE);
+ clipboard_writer.WriteText(url_text);
+ }
+ // Now we should be able to paste from the clipboard.
+ EXPECT_TRUE(CanPasteFromClipboard(model.get(), new_folder));
+
+ PasteFromClipboard(model.get(), new_folder, 0);
+ ASSERT_EQ(1, new_folder->child_count());
+
+ // Url for added node should be same as url_text.
+ EXPECT_EQ(url_text, ASCIIToUTF16(new_folder->GetChild(0)->url().spec()));
+}
+
TEST_F(BookmarkUtilsTest, CopyPaste) {
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