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

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

Issue 10870029: Remove legacy migration code that coupled history and bookmarks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More android fixes. Created 8 years, 4 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
« no previous file with comments | « no previous file | chrome/browser/history/DEPS » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/bookmarks/bookmark_model_unittest.cc
diff --git a/chrome/browser/bookmarks/bookmark_model_unittest.cc b/chrome/browser/bookmarks/bookmark_model_unittest.cc
index 6c1ba4d0aae8fec12281fdc7116d3a1340e9f2e0..be237ac28e34da829d61a8545aa08e919fe60baa 100644
--- a/chrome/browser/bookmarks/bookmark_model_unittest.cc
+++ b/chrome/browser/bookmarks/bookmark_model_unittest.cc
@@ -930,161 +930,11 @@ TEST_F(BookmarkModelTestWithProfile, CreateAndRestore) {
}
}
-// Test class that creates a BookmarkModel with a real history backend.
-class BookmarkModelTestWithProfile2 : public BookmarkModelTestWithProfile {
- public:
- virtual void SetUp() {
- profile_.reset(new TestingProfile());
- }
-
- protected:
- // Verifies the state of the model matches that of the state in the saved
- // history file.
- void VerifyExpectedState() {
- // Here's the structure we expect:
- // bbn
- // www.google.com - Google
- // F1
- // http://www.google.com/intl/en/ads/ - Google Advertising
- // F11
- // http://www.google.com/services/ - Google Business Solutions
- // other
- // OF1
- // http://www.google.com/intl/en/about.html - About Google
- const BookmarkNode* bbn = bb_model_->bookmark_bar_node();
- ASSERT_EQ(2, bbn->child_count());
-
- const BookmarkNode* child = bbn->GetChild(0);
- ASSERT_EQ(BookmarkNode::URL, child->type());
- ASSERT_EQ(ASCIIToUTF16("Google"), child->GetTitle());
- ASSERT_TRUE(child->url() == GURL("http://www.google.com"));
-
- child = bbn->GetChild(1);
- ASSERT_TRUE(child->is_folder());
- ASSERT_EQ(ASCIIToUTF16("F1"), child->GetTitle());
- ASSERT_EQ(2, child->child_count());
-
- const BookmarkNode* parent = child;
- child = parent->GetChild(0);
- ASSERT_EQ(BookmarkNode::URL, child->type());
- ASSERT_EQ(ASCIIToUTF16("Google Advertising"), child->GetTitle());
- ASSERT_TRUE(child->url() == GURL("http://www.google.com/intl/en/ads/"));
-
- child = parent->GetChild(1);
- ASSERT_TRUE(child->is_folder());
- ASSERT_EQ(ASCIIToUTF16("F11"), child->GetTitle());
- ASSERT_EQ(1, child->child_count());
-
- parent = child;
- child = parent->GetChild(0);
- ASSERT_EQ(BookmarkNode::URL, child->type());
- ASSERT_EQ(ASCIIToUTF16("Google Business Solutions"), child->GetTitle());
- ASSERT_TRUE(child->url() == GURL("http://www.google.com/services/"));
-
- parent = bb_model_->other_node();
- ASSERT_EQ(2, parent->child_count());
-
- child = parent->GetChild(0);
- ASSERT_TRUE(child->is_folder());
- ASSERT_EQ(ASCIIToUTF16("OF1"), child->GetTitle());
- ASSERT_EQ(0, child->child_count());
-
- child = parent->GetChild(1);
- ASSERT_EQ(BookmarkNode::URL, child->type());
- ASSERT_EQ(ASCIIToUTF16("About Google"), child->GetTitle());
- ASSERT_TRUE(child->url() ==
- GURL("http://www.google.com/intl/en/about.html"));
-
- parent = bb_model_->mobile_node();
- ASSERT_EQ(0, parent->child_count());
-
- ASSERT_TRUE(bb_model_->IsBookmarked(GURL("http://www.google.com")));
- }
-
- void VerifyUniqueIDs() {
- std::set<int64> ids;
- bool has_unique = true;
- VerifyUniqueIDImpl(bb_model_->bookmark_bar_node(), &ids, &has_unique);
- VerifyUniqueIDImpl(bb_model_->other_node(), &ids, &has_unique);
- ASSERT_TRUE(has_unique);
- }
-
- private:
- void VerifyUniqueIDImpl(const BookmarkNode* node,
- std::set<int64>* ids,
- bool* has_unique) {
- if (!*has_unique)
- return;
- if (ids->count(node->id()) != 0) {
- *has_unique = false;
- return;
- }
- ids->insert(node->id());
- for (int i = 0; i < node->child_count(); ++i) {
- VerifyUniqueIDImpl(node->GetChild(i), ids, has_unique);
- if (!*has_unique)
- return;
- }
- }
-};
-
-// Tests migrating bookmarks from db into file. This copies an old history db
-// file containing bookmarks and make sure they are loaded correctly and
-// persisted correctly.
-TEST_F(BookmarkModelTestWithProfile2, MigrateFromDBToFileTest) {
- // Copy db file over that contains starred table.
- FilePath old_history_path;
- PathService::Get(chrome::DIR_TEST_DATA, &old_history_path);
- old_history_path = old_history_path.AppendASCII("bookmarks");
- old_history_path = old_history_path.AppendASCII("History_with_starred");
- FilePath new_history_path = profile_->GetPath();
- file_util::Delete(new_history_path, true);
- file_util::CreateDirectory(new_history_path);
- FilePath new_history_file = new_history_path.Append(
- chrome::kHistoryFilename);
- ASSERT_TRUE(file_util::CopyFile(old_history_path, new_history_file));
-
- // Create the history service making sure it doesn't blow away the file we
- // just copied.
- profile_->CreateHistoryService(false, false);
- profile_->CreateBookmarkModel(true);
- BlockTillBookmarkModelLoaded();
-
- // Make sure we loaded OK.
- VerifyExpectedState();
- if (HasFatalFailure())
- return;
-
- // Make sure the ids are unique.
- VerifyUniqueIDs();
- if (HasFatalFailure())
- return;
-
- // Create again. This time we shouldn't load from history at all.
- profile_->CreateBookmarkModel(false);
- BlockTillBookmarkModelLoaded();
-
- // Make sure we loaded OK.
- VerifyExpectedState();
- if (HasFatalFailure())
- return;
-
- VerifyUniqueIDs();
- if (HasFatalFailure())
- return;
-
- // Recreate the history service (with a clean db). Do this just to make sure
- // we're loading correctly from the bookmarks file.
- profile_->CreateHistoryService(true, false);
- profile_->CreateBookmarkModel(false);
- BlockTillBookmarkModelLoaded();
- VerifyExpectedState();
- VerifyUniqueIDs();
-}
-
// Simple test that removes a bookmark. This test exercises the code paths in
// History that block till bookmark bar model is loaded.
-TEST_F(BookmarkModelTestWithProfile2, RemoveNotification) {
+TEST_F(BookmarkModelTestWithProfile, RemoveNotification) {
+ profile_.reset(new TestingProfile());
+
profile_->CreateHistoryService(false, false);
profile_->CreateBookmarkModel(true);
BlockTillBookmarkModelLoaded();
« no previous file with comments | « no previous file | chrome/browser/history/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698