using base::Time;
using base::TimeDelta;
+namespace bookmarks {
namespace {
// Test cases used to test the removal of extra whitespace when adding
int index2_;
};
- BookmarkModelTest() : model_(client_.CreateModel(false)) {
+ BookmarkModelTest() : model_(client_.CreateModel()) {
model_->AddObserver(this);
ClearCounts();
}
observer_details_.Set(old_parent, new_parent, old_index, new_index);
}
- virtual void OnWillAddBookmarkNode(BookmarkModel* model,
- BookmarkNode* node) OVERRIDE {
- ++will_add_count_;
- EXPECT_TRUE(node->parent() == NULL);
- }
-
virtual void BookmarkNodeAdded(BookmarkModel* model,
const BookmarkNode* parent,
int index) OVERRIDE {
}
void ClearCounts() {
- will_add_count_ = added_count_ = moved_count_ = removed_count_ =
- changed_count_ = reordered_count_ = extensive_changes_beginning_count_ =
+ added_count_ = moved_count_ = removed_count_ = changed_count_ =
+ reordered_count_ = extensive_changes_beginning_count_ =
extensive_changes_ended_count_ = all_bookmarks_removed_ =
before_remove_count_ = before_change_count_ = before_reorder_count_ =
before_remove_all_count_ = 0;
}
- void AssertObserverCount(int will_add_count,
- int added_count,
+ void AssertObserverCount(int added_count,
int moved_count,
int removed_count,
int changed_count,
int before_change_count,
int before_reorder_count,
int before_remove_all_count) {
- EXPECT_EQ(will_add_count_, will_add_count);
EXPECT_EQ(added_count_, added_count);
EXPECT_EQ(moved_count_, moved_count);
EXPECT_EQ(removed_count_, removed_count);
client_.SetExtraNodesToLoad(extra_nodes.Pass());
model_->RemoveObserver(this);
- model_ = client_.CreateModel(false);
+ model_ = client_.CreateModel();
model_->AddObserver(this);
ClearCounts();
}
protected:
- test::TestBookmarkClient client_;
+ TestBookmarkClient client_;
scoped_ptr<BookmarkModel> model_;
ObserverDetails observer_details_;
private:
- int will_add_count_;
int added_count_;
int moved_count_;
int removed_count_;
const GURL url("http://foo.com");
const BookmarkNode* new_node = model_->AddURL(root, 0, title, url);
- AssertObserverCount(1, 1, 0, 0, 0, 0, 0, 0, 0, 0);
+ AssertObserverCount(1, 0, 0, 0, 0, 0, 0, 0, 0);
observer_details_.ExpectEquals(root, NULL, 0, -1);
ASSERT_EQ(1, root->child_count());
const GURL url("https://www.baidu.com/");
const BookmarkNode* new_node = model_->AddURL(root, 0, title, url);
- AssertObserverCount(1, 1, 0, 0, 0, 0, 0, 0, 0, 0);
+ AssertObserverCount(1, 0, 0, 0, 0, 0, 0, 0, 0);
observer_details_.ExpectEquals(root, NULL, 0, -1);
ASSERT_EQ(1, root->child_count());
const BookmarkNode* new_node = model_->AddURLWithCreationTimeAndMetaInfo(
root, 0, title, url, time, &meta_info);
- AssertObserverCount(1, 1, 0, 0, 0, 0, 0, 0, 0, 0);
+ AssertObserverCount(1, 0, 0, 0, 0, 0, 0, 0, 0);
observer_details_.ExpectEquals(root, NULL, 0, -1);
ASSERT_EQ(1, root->child_count());
const GURL url("http://foo.com");
const BookmarkNode* new_node = model_->AddURL(root, 0, title, url);
- AssertObserverCount(1, 1, 0, 0, 0, 0, 0, 0, 0, 0);
+ AssertObserverCount(1, 0, 0, 0, 0, 0, 0, 0, 0);
observer_details_.ExpectEquals(root, NULL, 0, -1);
ASSERT_EQ(1, root->child_count());
const base::string16 title(ASCIIToUTF16("foo"));
const BookmarkNode* new_node = model_->AddFolder(root, 0, title);
- AssertObserverCount(1, 1, 0, 0, 0, 0, 0, 0, 0, 0);
+ AssertObserverCount(1, 0, 0, 0, 0, 0, 0, 0, 0);
observer_details_.ExpectEquals(root, NULL, 0, -1);
ASSERT_EQ(1, root->child_count());
// Add another folder, just to make sure folder_ids are incremented correctly.
ClearCounts();
model_->AddFolder(root, 0, title);
- AssertObserverCount(1, 1, 0, 0, 0, 0, 0, 0, 0, 0);
+ AssertObserverCount(1, 0, 0, 0, 0, 0, 0, 0, 0);
observer_details_.ExpectEquals(root, NULL, 0, -1);
}
model_->Remove(root, 0);
ASSERT_EQ(0, root->child_count());
- AssertObserverCount(0, 0, 0, 1, 0, 0, 1, 0, 0, 0);
+ AssertObserverCount(0, 0, 1, 0, 0, 1, 0, 0, 0);
observer_details_.ExpectEquals(root, NULL, 0, -1);
// Make sure there is no mapping for the URL.
// Now remove the folder.
model_->Remove(root, 0);
ASSERT_EQ(0, root->child_count());
- AssertObserverCount(0, 0, 0, 1, 0, 0, 1, 0, 0, 0);
+ AssertObserverCount(0, 0, 1, 0, 0, 1, 0, 0, 0);
observer_details_.ExpectEquals(root, NULL, 0, -1);
// Make sure there is no mapping for the URL.
const BookmarkNode* folder = model_->AddFolder(bookmark_bar_node, 0, title);
model_->AddURL(folder, 0, title, url);
- AssertObserverCount(3, 3, 0, 0, 0, 0, 0, 0, 0, 0);
+ AssertObserverCount(3, 0, 0, 0, 0, 0, 0, 0, 0);
ClearCounts();
model_->RemoveAllUserBookmarks();
EXPECT_EQ(0, bookmark_bar_node->child_count());
// No individual BookmarkNodeRemoved events are fired, so removed count
// should be 0.
- AssertObserverCount(0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
+ AssertObserverCount(0, 0, 0, 0, 0, 0, 0, 0, 1);
AssertExtensiveChangesObserverCount(1, 1);
EXPECT_EQ(1, AllNodesRemovedObserverCount());
}
title = ASCIIToUTF16("foo2");
model_->SetTitle(node, title);
- AssertObserverCount(0, 0, 0, 0, 1, 0, 0, 1, 0, 0);
+ AssertObserverCount(0, 0, 0, 1, 0, 0, 1, 0, 0);
observer_details_.ExpectEquals(node, NULL, -1, -1);
EXPECT_EQ(title, node->GetTitle());
}
url = GURL("http://foo2.com");
model_->SetURL(node, url);
- AssertObserverCount(0, 0, 0, 0, 1, 0, 0, 1, 0, 0);
+ AssertObserverCount(0, 0, 0, 1, 0, 0, 1, 0, 0);
observer_details_.ExpectEquals(node, NULL, -1, -1);
EXPECT_EQ(url, node->url());
}
base::Time new_time = base::Time::Now() + base::TimeDelta::FromMinutes(20);
model_->SetDateAdded(node, new_time);
- AssertObserverCount(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
+ AssertObserverCount(0, 0, 0, 0, 0, 0, 0, 0, 0);
EXPECT_EQ(new_time, node->date_added());
EXPECT_EQ(new_time, model_->bookmark_bar_node()->date_folder_modified());
}
model_->Move(node, folder1, 0);
- AssertObserverCount(0, 0, 1, 0, 0, 0, 0, 0, 0, 0);
+ AssertObserverCount(0, 1, 0, 0, 0, 0, 0, 0, 0);
observer_details_.ExpectEquals(root, folder1, 1, 0);
EXPECT_TRUE(folder1 == node->parent());
EXPECT_EQ(1, root->child_count());
// And remove the folder.
ClearCounts();
model_->Remove(root, 0);
- AssertObserverCount(0, 0, 0, 1, 0, 0, 1, 0, 0, 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_EQ(0, root->child_count());
ASSERT_TRUE(ids.insert(it.Next()->id()).second);
}
- test::TestBookmarkClient client_;
+ TestBookmarkClient client_;
scoped_ptr<BookmarkModel> model_;
};
{ "a b c [ d e [ f ] ]", "g h i [ j k [ l ] ]"},
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) {
- model_ = client_.CreateModel(false);
+ model_ = client_.CreateModel();
TestNode bbn;
PopulateNodeFromString(data[i].bbn_contents, &bbn);
model_->SortChildren(parent);
// Make sure we were notified.
- AssertObserverCount(0, 0, 0, 0, 0, 1, 0, 0, 1, 0);
+ AssertObserverCount(0, 0, 0, 0, 1, 0, 0, 1, 0);
// Make sure the order matches (remember, 'a' and 'C' are folders and
// come first).
model_->ReorderChildren(parent, new_order);
// Make sure we were notified.
- AssertObserverCount(0, 0, 0, 0, 0, 1, 0, 0, 1, 0);
+ AssertObserverCount(0, 0, 0, 0, 1, 0, 0, 1, 0);
// Make sure the order matches is correct (it should be reversed).
ASSERT_EQ(4, parent->child_count());
}
} // namespace
+} // namespace bookmarks