OLD | NEW |
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 "components/bookmarks/browser/bookmark_utils.h" | 5 #include "components/bookmarks/browser/bookmark_utils.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 fields[i]->reset(new base::string16(ASCIIToUTF16("fjdkslafjkldsa"))); | 250 fields[i]->reset(new base::string16(ASCIIToUTF16("fjdkslafjkldsa"))); |
251 GetBookmarksMatchingProperties(model.get(), query, 100, string(), &nodes); | 251 GetBookmarksMatchingProperties(model.get(), query, 100, string(), &nodes); |
252 ASSERT_EQ(0U, nodes.size()); | 252 ASSERT_EQ(0U, nodes.size()); |
253 nodes.clear(); | 253 nodes.clear(); |
254 fields[i]->reset(original_value.release()); | 254 fields[i]->reset(original_value.release()); |
255 } | 255 } |
256 } | 256 } |
257 | 257 |
258 // Copy and paste is not yet supported on iOS. http://crbug.com/228147 | 258 // Copy and paste is not yet supported on iOS. http://crbug.com/228147 |
259 #if !defined(OS_IOS) | 259 #if !defined(OS_IOS) |
| 260 TEST_F(BookmarkUtilsTest, PasteBookmarkFromURL) { |
| 261 TestBookmarkClient client; |
| 262 scoped_ptr<BookmarkModel> model(client.CreateModel()); |
| 263 const base::string16 url_text = ASCIIToUTF16("http://www.google.com/"); |
| 264 const BookmarkNode* new_folder = model->AddFolder( |
| 265 model->bookmark_bar_node(), 0, ASCIIToUTF16("New_Folder")); |
| 266 |
| 267 // Write blank text to clipboard. |
| 268 { |
| 269 ui::ScopedClipboardWriter clipboard_writer( |
| 270 ui::Clipboard::GetForCurrentThread(), ui::CLIPBOARD_TYPE_COPY_PASTE); |
| 271 clipboard_writer.WriteText(base::string16()); |
| 272 } |
| 273 // Now we shouldn't be able to paste from the clipboard. |
| 274 EXPECT_FALSE(CanPasteFromClipboard(model.get(), new_folder)); |
| 275 |
| 276 // Write some valid url to the clipboard. |
| 277 { |
| 278 ui::ScopedClipboardWriter clipboard_writer( |
| 279 ui::Clipboard::GetForCurrentThread(), ui::CLIPBOARD_TYPE_COPY_PASTE); |
| 280 clipboard_writer.WriteText(url_text); |
| 281 } |
| 282 // Now we should be able to paste from the clipboard. |
| 283 EXPECT_TRUE(CanPasteFromClipboard(model.get(), new_folder)); |
| 284 |
| 285 PasteFromClipboard(model.get(), new_folder, 0); |
| 286 ASSERT_EQ(1, new_folder->child_count()); |
| 287 |
| 288 // Url for added node should be same as url_text. |
| 289 EXPECT_EQ(url_text, ASCIIToUTF16(new_folder->GetChild(0)->url().spec())); |
| 290 } |
| 291 |
260 TEST_F(BookmarkUtilsTest, CopyPaste) { | 292 TEST_F(BookmarkUtilsTest, CopyPaste) { |
261 TestBookmarkClient client; | 293 TestBookmarkClient client; |
262 scoped_ptr<BookmarkModel> model(client.CreateModel()); | 294 scoped_ptr<BookmarkModel> model(client.CreateModel()); |
263 const BookmarkNode* node = model->AddURL(model->other_node(), | 295 const BookmarkNode* node = model->AddURL(model->other_node(), |
264 0, | 296 0, |
265 ASCIIToUTF16("foo bar"), | 297 ASCIIToUTF16("foo bar"), |
266 GURL("http://www.google.com")); | 298 GURL("http://www.google.com")); |
267 | 299 |
268 // Copy a node to the clipboard. | 300 // Copy a node to the clipboard. |
269 std::vector<const BookmarkNode*> nodes; | 301 std::vector<const BookmarkNode*> nodes; |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 model->GetNodesByURL(url, &nodes); | 520 model->GetNodesByURL(url, &nodes); |
489 ASSERT_EQ(1u, nodes.size()); | 521 ASSERT_EQ(1u, nodes.size()); |
490 EXPECT_TRUE(model->bookmark_bar_node()->empty()); | 522 EXPECT_TRUE(model->bookmark_bar_node()->empty()); |
491 EXPECT_TRUE(model->other_node()->empty()); | 523 EXPECT_TRUE(model->other_node()->empty()); |
492 EXPECT_TRUE(model->mobile_node()->empty()); | 524 EXPECT_TRUE(model->mobile_node()->empty()); |
493 EXPECT_EQ(1, extra_node->child_count()); | 525 EXPECT_EQ(1, extra_node->child_count()); |
494 } | 526 } |
495 | 527 |
496 } // namespace | 528 } // namespace |
497 } // namespace bookmarks | 529 } // namespace bookmarks |
OLD | NEW |