Index: chrome/browser/history/history_backend_unittest.cc |
diff --git a/chrome/browser/history/history_backend_unittest.cc b/chrome/browser/history/history_backend_unittest.cc |
index fc5ea50d0ef567e6772e7dc6291af621c6f3e743..38b28a812161c8b7a46b643b4613fb4996c2b05d 100644 |
--- a/chrome/browser/history/history_backend_unittest.cc |
+++ b/chrome/browser/history/history_backend_unittest.cc |
@@ -822,19 +822,14 @@ TEST_F(HistoryBackendTest, AddPagesWithDetails) { |
rows.push_back(row4); |
backend_->AddPagesWithDetails(rows, history::SOURCE_BROWSED); |
- // Verify that recent URLs have ended up in the main |db_|, while expired URLs |
- // have ended up in the |archived_db_|. |
+ // Verify that recent URLs have ended up in the main |db_|, while the expired |
+ // URL has not. |
URLRow stored_row1, stored_row2, stored_row3, stored_row4; |
EXPECT_NE(0, backend_->db_->GetRowForURL(row1.url(), &stored_row1)); |
EXPECT_NE(0, backend_->db_->GetRowForURL(row2.url(), &stored_row2)); |
EXPECT_NE(0, backend_->db_->GetRowForURL(row3.url(), &stored_row3)); |
EXPECT_EQ(0, backend_->db_->GetRowForURL(row4.url(), &stored_row4)); |
- EXPECT_EQ(0, backend_->archived_db_->GetRowForURL(row1.url(), &stored_row1)); |
- EXPECT_EQ(0, backend_->archived_db_->GetRowForURL(row2.url(), &stored_row2)); |
- EXPECT_EQ(0, backend_->archived_db_->GetRowForURL(row3.url(), &stored_row3)); |
- EXPECT_NE(0, backend_->archived_db_->GetRowForURL(row4.url(), &stored_row4)); |
- |
ASSERT_EQ(1u, broadcasted_notifications().size()); |
ASSERT_EQ(chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, |
broadcasted_notifications()[0].first); |
@@ -2608,11 +2603,10 @@ TEST_F(HistoryBackendTest, MigrationVisitDuration) { |
backend_->Closing(); |
backend_ = NULL; |
- base::FilePath old_history_path, old_history, old_archived; |
+ base::FilePath old_history_path, old_history; |
ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &old_history_path)); |
old_history_path = old_history_path.AppendASCII("History"); |
old_history = old_history_path.AppendASCII("HistoryNoDuration"); |
- old_archived = old_history_path.AppendASCII("ArchivedNoDuration"); |
// Copy history database file to current directory so that it will be deleted |
// in Teardown. |
@@ -2621,10 +2615,7 @@ TEST_F(HistoryBackendTest, MigrationVisitDuration) { |
base::CreateDirectory(new_history_path); |
base::FilePath new_history_file = |
new_history_path.Append(chrome::kHistoryFilename); |
- base::FilePath new_archived_file = |
- new_history_path.Append(chrome::kArchivedHistoryFilename); |
ASSERT_TRUE(base::CopyFile(old_history, new_history_file)); |
- ASSERT_TRUE(base::CopyFile(old_archived, new_archived_file)); |
backend_ = new HistoryBackend(new_history_path, |
new HistoryBackendTestDelegate(this), |
@@ -2633,7 +2624,7 @@ TEST_F(HistoryBackendTest, MigrationVisitDuration) { |
backend_->Closing(); |
backend_ = NULL; |
- // Now both history and archived_history databases should already be migrated. |
+ // Now the history database should already be migrated. |
// Check version in history database first. |
int cur_version = HistoryDatabase::GetCurrentVersion(); |
@@ -2650,23 +2641,6 @@ TEST_F(HistoryBackendTest, MigrationVisitDuration) { |
"SELECT visit_duration FROM visits LIMIT 1")); |
ASSERT_TRUE(s.Step()); |
EXPECT_EQ(0, s.ColumnInt(0)); |
- |
- // Repeat version and visit_duration checks in archived history database |
- // also. |
- cur_version = ArchivedDatabase::GetCurrentVersion(); |
- sql::Connection archived_db; |
- ASSERT_TRUE(archived_db.Open(new_archived_file)); |
- sql::Statement s1(archived_db.GetUniqueStatement( |
- "SELECT value FROM meta WHERE key = 'version'")); |
- ASSERT_TRUE(s1.Step()); |
- file_version = s1.ColumnInt(0); |
- EXPECT_EQ(cur_version, file_version); |
- |
- // Check visit_duration column in visits table is created and set to 0. |
- s1.Assign(archived_db.GetUniqueStatement( |
- "SELECT visit_duration FROM visits LIMIT 1")); |
- ASSERT_TRUE(s1.Step()); |
- EXPECT_EQ(0, s1.ColumnInt(0)); |
} |
TEST_F(HistoryBackendTest, AddPageNoVisitForBookmark) { |
@@ -2916,4 +2890,51 @@ TEST_F(HistoryBackendTest, DeleteFTSIndexDatabases) { |
EXPECT_TRUE(base::PathExists(db2_actual)); // Symlinks shouldn't be followed. |
} |
+TEST_F(HistoryBackendTest, ArchiveDatabaseGetsPurged) { |
+ ASSERT_TRUE(backend_.get()); |
+ backend_->Closing(); |
+ backend_ = NULL; |
+ |
+ // kArchivedHistoryFilename |
+ |
+ base::FilePath old_history_path; |
+ ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &old_history_path)); |
+ old_history_path = old_history_path.AppendASCII("History"); |
+ old_history_path = old_history_path.AppendASCII("HistoryNoSource"); |
+ |
+ // Copy history database file to current directory so that it will be deleted |
+ // in Teardown. |
+ base::FilePath new_history_path(getTestDir()); |
+ base::DeleteFile(new_history_path, true); |
+ base::CreateDirectory(new_history_path); |
+ base::FilePath new_history_file = |
+ new_history_path.Append(chrome::kHistoryFilename); |
+ ASSERT_TRUE(base::CopyFile(old_history_path, new_history_file)); |
+ |
+ backend_ = new HistoryBackend(new_history_path, |
+ new HistoryBackendTestDelegate(this), |
+ &bookmark_model_); |
+ backend_->Init(std::string(), false); |
+ backend_->Closing(); |
+ backend_ = NULL; |
+ |
+ // Now the database should already be migrated. |
+ // Check version first. |
+ int cur_version = HistoryDatabase::GetCurrentVersion(); |
+ sql::Connection db; |
+ ASSERT_TRUE(db.Open(new_history_file)); |
+ sql::Statement s(db.GetUniqueStatement( |
+ "SELECT value FROM meta WHERE key = 'version'")); |
+ ASSERT_TRUE(s.Step()); |
+ int file_version = s.ColumnInt(0); |
+ EXPECT_EQ(cur_version, file_version); |
+ |
+ // Check visit_source table is created and empty. |
+ s.Assign(db.GetUniqueStatement( |
+ "SELECT name FROM sqlite_master WHERE name=\"visit_source\"")); |
+ ASSERT_TRUE(s.Step()); |
+ s.Assign(db.GetUniqueStatement("SELECT * FROM visit_source LIMIT 10")); |
+ EXPECT_FALSE(s.Step()); |
+} |
+ |
} // namespace history |