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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
307 { | 307 { |
308 ui::ScopedClipboardWriter clipboard_writer( | 308 ui::ScopedClipboardWriter clipboard_writer( |
309 ui::CLIPBOARD_TYPE_COPY_PASTE); | 309 ui::CLIPBOARD_TYPE_COPY_PASTE); |
310 clipboard_writer.WriteText(ASCIIToUTF16("foo")); | 310 clipboard_writer.WriteText(ASCIIToUTF16("foo")); |
311 } | 311 } |
312 | 312 |
313 // Now we shouldn't be able to paste from the clipboard. | 313 // Now we shouldn't be able to paste from the clipboard. |
314 EXPECT_FALSE(CanPasteFromClipboard(model.get(), model->bookmark_bar_node())); | 314 EXPECT_FALSE(CanPasteFromClipboard(model.get(), model->bookmark_bar_node())); |
315 } | 315 } |
316 | 316 |
317 // Test for updating title such that url and title pair are unique among the | |
318 // children of parent. | |
319 TEST_F(BookmarkUtilsTest, MakeTitleUniqueTest) { | |
sky
2014/10/14 19:22:33
You don't need to duplicate Test. MakeTitleUnique
Deepak
2014/10/15 04:02:54
Done.
| |
320 TestBookmarkClient client; | |
321 scoped_ptr<BookmarkModel> model(client.CreateModel()); | |
322 const base::string16 url_text = ASCIIToUTF16("http://www.google.com/"); | |
323 const base::string16 title_text = ASCIIToUTF16("foobar"); | |
324 const BookmarkNode* bookmark_bar_node = model->bookmark_bar_node(); | |
325 | |
326 const BookmarkNode* node = | |
327 model->AddURL(bookmark_bar_node, 0, title_text, GURL(url_text)); | |
328 | |
329 EXPECT_EQ(url_text, | |
330 ASCIIToUTF16(bookmark_bar_node->GetChild(0)->url().spec())); | |
331 EXPECT_EQ(title_text, bookmark_bar_node->GetChild(0)->GetTitle()); | |
332 | |
333 // Copy a node to the clipboard. | |
334 std::vector<const BookmarkNode*> nodes; | |
335 nodes.push_back(node); | |
336 CopyToClipboard(model.get(), nodes, false); | |
337 | |
338 // Now we should be able to paste from the clipboard. | |
339 EXPECT_TRUE(CanPasteFromClipboard(model.get(), bookmark_bar_node)); | |
340 | |
341 PasteFromClipboard(model.get(), bookmark_bar_node, 1); | |
342 ASSERT_EQ(2, bookmark_bar_node->child_count()); | |
343 | |
344 // Url for added node should be same as url_text. | |
345 EXPECT_EQ(url_text, | |
346 ASCIIToUTF16(bookmark_bar_node->GetChild(1)->url().spec())); | |
347 // Title for added node should be numeric subscript suffix with copied node | |
348 // title. | |
349 EXPECT_EQ(ASCIIToUTF16("foobar (1)"), | |
350 bookmark_bar_node->GetChild(1)->GetTitle()); | |
351 } | |
352 | |
317 TEST_F(BookmarkUtilsTest, CopyPasteMetaInfo) { | 353 TEST_F(BookmarkUtilsTest, CopyPasteMetaInfo) { |
318 TestBookmarkClient client; | 354 TestBookmarkClient client; |
319 scoped_ptr<BookmarkModel> model(client.CreateModel()); | 355 scoped_ptr<BookmarkModel> model(client.CreateModel()); |
320 const BookmarkNode* node = model->AddURL(model->other_node(), | 356 const BookmarkNode* node = model->AddURL(model->other_node(), |
321 0, | 357 0, |
322 ASCIIToUTF16("foo bar"), | 358 ASCIIToUTF16("foo bar"), |
323 GURL("http://www.google.com")); | 359 GURL("http://www.google.com")); |
324 model->SetNodeMetaInfo(node, "somekey", "somevalue"); | 360 model->SetNodeMetaInfo(node, "somekey", "somevalue"); |
325 model->SetNodeMetaInfo(node, "someotherkey", "someothervalue"); | 361 model->SetNodeMetaInfo(node, "someotherkey", "someothervalue"); |
326 | 362 |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
517 model->GetNodesByURL(url, &nodes); | 553 model->GetNodesByURL(url, &nodes); |
518 ASSERT_EQ(1u, nodes.size()); | 554 ASSERT_EQ(1u, nodes.size()); |
519 EXPECT_TRUE(model->bookmark_bar_node()->empty()); | 555 EXPECT_TRUE(model->bookmark_bar_node()->empty()); |
520 EXPECT_TRUE(model->other_node()->empty()); | 556 EXPECT_TRUE(model->other_node()->empty()); |
521 EXPECT_TRUE(model->mobile_node()->empty()); | 557 EXPECT_TRUE(model->mobile_node()->empty()); |
522 EXPECT_EQ(1, extra_node->child_count()); | 558 EXPECT_EQ(1, extra_node->child_count()); |
523 } | 559 } |
524 | 560 |
525 } // namespace | 561 } // namespace |
526 } // namespace bookmarks | 562 } // namespace bookmarks |
OLD | NEW |