Chromium Code Reviews| Index: chrome/browser/bookmarks/bookmark_utils_unittest.cc |
| diff --git a/chrome/browser/bookmarks/bookmark_utils_unittest.cc b/chrome/browser/bookmarks/bookmark_utils_unittest.cc |
| index 0bb86b76b78fbe68e5a0ff91bfa20be51affa630..def67cc3580c74ee4cad06ab071b0e36482614df 100644 |
| --- a/chrome/browser/bookmarks/bookmark_utils_unittest.cc |
| +++ b/chrome/browser/bookmarks/bookmark_utils_unittest.cc |
| @@ -8,6 +8,7 @@ |
| #include "base/message_loop/message_loop.h" |
| #include "base/strings/utf_string_conversions.h" |
| +#include "chrome/browser/bookmarks/base_bookmark_model_observer.h" |
| #include "chrome/browser/bookmarks/bookmark_model.h" |
| #include "chrome/browser/bookmarks/bookmark_node_data.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| @@ -20,16 +21,37 @@ using std::string; |
| namespace bookmark_utils { |
| namespace { |
| -class BookmarkUtilsTest : public ::testing::Test { |
| +class BookmarkUtilsTest : public testing::Test, |
| + public BaseBookmarkModelObserver { |
| public: |
| - BookmarkUtilsTest() {} |
| - virtual ~BookmarkUtilsTest() {} |
| + BookmarkUtilsTest() |
| + : grouped_changes_beginning_count_(0), grouped_changes_ended_count_(0) {} |
|
tfarina
2014/02/22 15:09:30
where is my virtual destructor? Looks like you rem
Tom Cassiotis
2014/02/22 20:54:02
I made a mistake resolving the conflict.
Fixed.
|
| virtual void TearDown() OVERRIDE { |
| ui::Clipboard::DestroyClipboardForCurrentThread(); |
| } |
| + void ExpectGroupedChangeCount(int expected_beginning_count, |
| + int expected_ended_count) { |
| + EXPECT_EQ(grouped_changes_beginning_count_, expected_beginning_count); |
| + EXPECT_EQ(grouped_changes_ended_count_, expected_ended_count); |
| + } |
| + |
| + // BookmarkModelObserver: |
|
tfarina
2014/02/22 15:09:30
BaseBookmarkModelObserver
Tom Cassiotis
2014/02/22 20:54:02
Done.
|
| + virtual void BookmarkModelChanged() OVERRIDE {} |
| + |
| + virtual void GroupedBookmarkChangesBeginning(BookmarkModel* model) OVERRIDE { |
| + ++grouped_changes_beginning_count_; |
| + } |
| + |
| + virtual void GroupedBookmarkChangesEnded(BookmarkModel* model) OVERRIDE { |
| + ++grouped_changes_ended_count_; |
| + } |
| + |
| private: |
| + int grouped_changes_beginning_count_; |
| + int grouped_changes_ended_count_; |
| + |
| // Clipboard requires a message loop. |
| base::MessageLoopForUI loop_; |
| @@ -242,6 +264,31 @@ TEST_F(BookmarkUtilsTest, CopyPaste) { |
| EXPECT_FALSE(CanPasteFromClipboard(model.bookmark_bar_node())); |
| } |
| +TEST_F(BookmarkUtilsTest, CutToClipboard) { |
| + BookmarkModel model(NULL); |
| + model.AddObserver(this); |
| + |
| + base::string16 title(ASCIIToUTF16("foo")); |
| + GURL url("http://foo.com"); |
| + const BookmarkNode* n1 = model.AddURL(model.other_node(), 0, title, url); |
| + const BookmarkNode* n2 = model.AddURL(model.other_node(), 1, title, url); |
| + |
| + // Cut the nodes to the clipboard. |
| + std::vector<const BookmarkNode*> nodes; |
| + nodes.push_back(n1); |
| + nodes.push_back(n2); |
| + CopyToClipboard(&model, nodes, true); |
| + |
| + // Make sure the nodes were removed. |
| + EXPECT_EQ(0, model.other_node()->child_count()); |
| + |
| + // Make sure observers were notified the set of changes should be grouped. |
| + ExpectGroupedChangeCount(1, 1); |
| + |
| + // And make sure we can paste from the clipboard. |
| + EXPECT_TRUE(CanPasteFromClipboard(model.other_node())); |
| +} |
| + |
| TEST_F(BookmarkUtilsTest, GetParentForNewNodes) { |
| BookmarkModel model(NULL); |
| // This tests the case where selection contains one item and that item is a |