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

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

Issue 312093007: Revert of Added BookmarkClient::CanBeEditedByUser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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
Index: components/bookmarks/browser/bookmark_model_unittest.cc
diff --git a/components/bookmarks/browser/bookmark_model_unittest.cc b/components/bookmarks/browser/bookmark_model_unittest.cc
index c1b77b131776ca25460188e1b82e6ed1db6309e5..cd6b09272bdec302ddc8dab83acf360fd6e576e7 100644
--- a/components/bookmarks/browser/bookmark_model_unittest.cc
+++ b/components/bookmarks/browser/bookmark_model_unittest.cc
@@ -267,23 +267,6 @@
int AllNodesRemovedObserverCount() const { return all_bookmarks_removed_; }
- BookmarkPermanentNode* ReloadModelWithExtraNode() {
- BookmarkPermanentNode* extra_node = new BookmarkPermanentNode(100);
- bookmarks::BookmarkPermanentNodeList extra_nodes;
- extra_nodes.push_back(extra_node);
- client_.SetExtraNodesToLoad(extra_nodes.Pass());
-
- model_->RemoveObserver(this);
- model_ = client_.CreateModel(false);
- model_->AddObserver(this);
- ClearCounts();
-
- if (model_->root_node()->GetIndexOf(extra_node) == -1)
- ADD_FAILURE();
-
- return extra_node;
- }
-
protected:
test::TestBookmarkClient client_;
scoped_ptr<BookmarkModel> model_;
@@ -340,7 +323,7 @@
ASSERT_EQ(title, new_node->GetTitle());
ASSERT_TRUE(url == new_node->url());
ASSERT_EQ(BookmarkNode::URL, new_node->type());
- ASSERT_TRUE(new_node == model_->GetMostRecentlyAddedUserNodeForURL(url));
+ ASSERT_TRUE(new_node == model_->GetMostRecentlyAddedNodeForURL(url));
EXPECT_TRUE(new_node->id() != root->id() &&
new_node->id() != model_->other_node()->id() &&
@@ -361,7 +344,7 @@
ASSERT_EQ(title, new_node->GetTitle());
ASSERT_TRUE(url == new_node->url());
ASSERT_EQ(BookmarkNode::URL, new_node->type());
- ASSERT_TRUE(new_node == model_->GetMostRecentlyAddedUserNodeForURL(url));
+ ASSERT_TRUE(new_node == model_->GetMostRecentlyAddedNodeForURL(url));
EXPECT_TRUE(new_node->id() != root->id() &&
new_node->id() != model_->other_node()->id() &&
@@ -405,7 +388,7 @@
ASSERT_EQ(time, new_node->date_added());
ASSERT_TRUE(new_node->GetMetaInfoMap());
ASSERT_EQ(meta_info, *new_node->GetMetaInfoMap());
- ASSERT_TRUE(new_node == model_->GetMostRecentlyAddedUserNodeForURL(url));
+ ASSERT_TRUE(new_node == model_->GetMostRecentlyAddedNodeForURL(url));
EXPECT_TRUE(new_node->id() != root->id() &&
new_node->id() != model_->other_node()->id() &&
@@ -425,7 +408,7 @@
ASSERT_EQ(title, new_node->GetTitle());
ASSERT_TRUE(url == new_node->url());
ASSERT_EQ(BookmarkNode::URL, new_node->type());
- ASSERT_TRUE(new_node == model_->GetMostRecentlyAddedUserNodeForURL(url));
+ ASSERT_TRUE(new_node == model_->GetMostRecentlyAddedNodeForURL(url));
EXPECT_TRUE(new_node->id() != root->id() &&
new_node->id() != model_->other_node()->id() &&
@@ -484,7 +467,7 @@
observer_details_.ExpectEquals(root, NULL, 0, -1);
// Make sure there is no mapping for the URL.
- ASSERT_TRUE(model_->GetMostRecentlyAddedUserNodeForURL(url) == NULL);
+ ASSERT_TRUE(model_->GetMostRecentlyAddedNodeForURL(url) == NULL);
}
TEST_F(BookmarkModelTest, RemoveFolder) {
@@ -507,7 +490,7 @@
observer_details_.ExpectEquals(root, NULL, 0, -1);
// Make sure there is no mapping for the URL.
- ASSERT_TRUE(model_->GetMostRecentlyAddedUserNodeForURL(url) == NULL);
+ ASSERT_TRUE(model_->GetMostRecentlyAddedNodeForURL(url) == NULL);
}
TEST_F(BookmarkModelTest, RemoveAll) {
@@ -619,7 +602,7 @@
model_->Remove(root, 0);
AssertObserverCount(0, 0, 1, 0, 0, 1, 0, 0, 0);
observer_details_.ExpectEquals(root, NULL, 0, -1);
- EXPECT_TRUE(model_->GetMostRecentlyAddedUserNodeForURL(url) == NULL);
+ EXPECT_TRUE(model_->GetMostRecentlyAddedNodeForURL(url) == NULL);
EXPECT_EQ(0, root->child_count());
}
@@ -726,7 +709,7 @@
// Make sure folder is in the most recently modified.
std::vector<const BookmarkNode*> most_recent_folders =
- bookmark_utils::GetMostRecentlyModifiedUserFolders(model_.get(), 1);
+ bookmark_utils::GetMostRecentlyModifiedFolders(model_.get(), 1);
ASSERT_EQ(1U, most_recent_folders.size());
ASSERT_EQ(folder, most_recent_folders[0]);
@@ -734,7 +717,7 @@
// returned list.
model_->Remove(folder->parent(), 0);
most_recent_folders =
- bookmark_utils::GetMostRecentlyModifiedUserFolders(model_.get(), 1);
+ bookmark_utils::GetMostRecentlyModifiedFolders(model_.get(), 1);
ASSERT_EQ(1U, most_recent_folders.size());
ASSERT_TRUE(most_recent_folders[0] != folder);
}
@@ -783,8 +766,8 @@
ASSERT_TRUE(n4 == recently_added[3]);
}
-// Makes sure GetMostRecentlyAddedUserNodeForURL stays in sync.
-TEST_F(BookmarkModelTest, GetMostRecentlyAddedUserNodeForURL) {
+// Makes sure GetMostRecentlyAddedNodeForURL stays in sync.
+TEST_F(BookmarkModelTest, GetMostRecentlyAddedNodeForURL) {
// Add a couple of nodes such that the following holds for the time of the
// nodes: n1 > n2
Time base_time = Time::Now();
@@ -797,11 +780,11 @@
n2->set_date_added(base_time + TimeDelta::FromDays(3));
// Make sure order is honored.
- ASSERT_EQ(n1, model_->GetMostRecentlyAddedUserNodeForURL(url));
+ ASSERT_EQ(n1, model_->GetMostRecentlyAddedNodeForURL(url));
// swap 1 and 2, then check again.
SwapDateAdded(n1, n2);
- ASSERT_EQ(n2, model_->GetMostRecentlyAddedUserNodeForURL(url));
+ ASSERT_EQ(n2, model_->GetMostRecentlyAddedNodeForURL(url));
}
// Makes sure GetBookmarks removes duplicates.
@@ -1114,60 +1097,6 @@
AssertExtensiveChangesObserverCount(1, 1);
}
-// Verifies that IsBookmarked is true if any bookmark matches the given URL,
-// and that IsBookmarkedByUser is true only if at least one of the matching
-// bookmarks can be edited by the user.
-TEST_F(BookmarkModelTest, IsBookmarked) {
- // Reload the model with an extra node that is not editable by the user.
- BookmarkPermanentNode* extra_node = ReloadModelWithExtraNode();
-
- // "google.com" is a "user" bookmark.
- model_->AddURL(model_->other_node(), 0, base::ASCIIToUTF16("User"),
- GURL("http://google.com"));
- // "youtube.com" is not.
- model_->AddURL(extra_node, 0, base::ASCIIToUTF16("Extra"),
- GURL("http://youtube.com"));
-
- EXPECT_TRUE(model_->IsBookmarked(GURL("http://google.com")));
- EXPECT_TRUE(model_->IsBookmarked(GURL("http://youtube.com")));
- EXPECT_FALSE(model_->IsBookmarked(GURL("http://reddit.com")));
-
- EXPECT_TRUE(bookmark_utils::IsBookmarkedByUser(model_.get(),
- GURL("http://google.com")));
- EXPECT_FALSE(bookmark_utils::IsBookmarkedByUser(model_.get(),
- GURL("http://youtube.com")));
- EXPECT_FALSE(bookmark_utils::IsBookmarkedByUser(model_.get(),
- GURL("http://reddit.com")));
-}
-
-// Verifies that GetMostRecentlyAddedUserNodeForURL skips bookmarks that
-// are not owned by the user.
-TEST_F(BookmarkModelTest, GetMostRecentlyAddedUserNodeForURLSkipsManagedNodes) {
- // Reload the model with an extra node that is not editable by the user.
- BookmarkPermanentNode* extra_node = ReloadModelWithExtraNode();
-
- const base::string16 title = base::ASCIIToUTF16("Title");
- const BookmarkNode* user_parent = model_->other_node();
- const BookmarkNode* managed_parent = extra_node;
- const GURL url("http://google.com");
-
- // |url| is not bookmarked yet.
- EXPECT_TRUE(model_->GetMostRecentlyAddedUserNodeForURL(url) == NULL);
-
- // Having a managed node doesn't count.
- model_->AddURL(managed_parent, 0, title, url);
- EXPECT_TRUE(model_->GetMostRecentlyAddedUserNodeForURL(url) == NULL);
-
- // Now add a user node.
- const BookmarkNode* user = model_->AddURL(user_parent, 0, title, url);
- EXPECT_EQ(user, model_->GetMostRecentlyAddedUserNodeForURL(url));
-
- // Having a more recent managed node doesn't count either.
- const BookmarkNode* managed = model_->AddURL(managed_parent, 0, title, url);
- EXPECT_GT(managed->date_added(), user->date_added());
- EXPECT_EQ(user, model_->GetMostRecentlyAddedUserNodeForURL(url));
-}
-
TEST(BookmarkNodeTest, NodeMetaInfo) {
GURL url;
BookmarkNode node(url);
« no previous file with comments | « components/bookmarks/browser/bookmark_model_observer.h ('k') | components/bookmarks/browser/bookmark_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698