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

Side by Side Diff: chrome/browser/history/history_unittest.cc

Issue 235863023: Eliminate the archived history database and clean up related code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename a few outstanding instances of "archived" to "expired". 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // History unit tests come in two flavors: 5 // History unit tests come in two flavors:
6 // 6 //
7 // 1. The more complicated style is that the unit test creates a full history 7 // 1. The more complicated style is that the unit test creates a full history
8 // service. This spawns a background thread for the history backend, and 8 // service. This spawns a background thread for the history backend, and
9 // all communication is asynchronous. This is useful for testing more 9 // all communication is asynchronous. This is useful for testing more
10 // complicated things or end-to-end behavior. 10 // complicated things or end-to-end behavior.
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 base::FilePath data_path; 133 base::FilePath data_path;
134 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); 134 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path));
135 data_path = data_path.AppendASCII("History"); 135 data_path = data_path.AppendASCII("History");
136 data_path = 136 data_path =
137 data_path.AppendASCII(base::StringPrintf("history.%d.sql", version)); 137 data_path.AppendASCII(base::StringPrintf("history.%d.sql", version));
138 ASSERT_NO_FATAL_FAILURE( 138 ASSERT_NO_FATAL_FAILURE(
139 ExecuteSQLScript(data_path, history_dir_.Append( 139 ExecuteSQLScript(data_path, history_dir_.Append(
140 chrome::kHistoryFilename))); 140 chrome::kHistoryFilename)));
141 } 141 }
142 142
143 void CreateArchivedDB() {
144 base::FilePath data_path;
145 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path));
146 data_path = data_path.AppendASCII("History");
147 data_path = data_path.AppendASCII("archived_history.4.sql");
148 ASSERT_NO_FATAL_FAILURE(
149 ExecuteSQLScript(data_path, history_dir_.Append(
150 chrome::kArchivedHistoryFilename)));
151 }
152
143 // testing::Test 153 // testing::Test
144 virtual void SetUp() { 154 virtual void SetUp() {
145 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 155 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
146 history_dir_ = temp_dir_.path().AppendASCII("HistoryBackendDBTest"); 156 history_dir_ = temp_dir_.path().AppendASCII("HistoryBackendDBTest");
147 ASSERT_TRUE(base::CreateDirectory(history_dir_)); 157 ASSERT_TRUE(base::CreateDirectory(history_dir_));
148 } 158 }
149 159
150 void DeleteBackend() { 160 void DeleteBackend() {
151 if (backend_.get()) { 161 if (backend_.get()) {
152 backend_->Closing(); 162 backend_->Closing();
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 { 622 {
613 sql::Statement s(db.GetUniqueStatement( 623 sql::Statement s(db.GetUniqueStatement(
614 "SELECT etag, last_modified from downloads")); 624 "SELECT etag, last_modified from downloads"));
615 EXPECT_TRUE(s.Step()); 625 EXPECT_TRUE(s.Step());
616 EXPECT_EQ(std::string(), s.ColumnString(0)); 626 EXPECT_EQ(std::string(), s.ColumnString(0));
617 EXPECT_EQ(std::string(), s.ColumnString(1)); 627 EXPECT_EQ(std::string(), s.ColumnString(1));
618 } 628 }
619 } 629 }
620 } 630 }
621 631
632 TEST_F(HistoryBackendDBTest, PurgeArchivedDatabase) {
633 ASSERT_NO_FATAL_FAILURE(CreateDBVersion(27));
634 ASSERT_NO_FATAL_FAILURE(CreateArchivedDB());
635
636 ASSERT_TRUE(base::PathExists(
637 history_dir_.Append(chrome::kArchivedHistoryFilename)));
638
639 CreateBackendAndDatabase();
640 DeleteBackend();
641
642 // We do not retain expired history entries in an archived database as of M37.
643 // Verify that any legacy archived database is deleted on start-up.
644 ASSERT_FALSE(base::PathExists(
645 history_dir_.Append(chrome::kArchivedHistoryFilename)));
646 }
647
622 TEST_F(HistoryBackendDBTest, ConfirmDownloadRowCreateAndDelete) { 648 TEST_F(HistoryBackendDBTest, ConfirmDownloadRowCreateAndDelete) {
623 // Create the DB. 649 // Create the DB.
624 CreateBackendAndDatabase(); 650 CreateBackendAndDatabase();
625 651
626 base::Time now(base::Time::Now()); 652 base::Time now(base::Time::Now());
627 653
628 // Add some downloads. 654 // Add some downloads.
629 uint32 id1 = 1, id2 = 2, id3 = 3; 655 uint32 id1 = 1, id2 = 2, id3 = 3;
630 AddDownload(id1, DownloadItem::COMPLETE, now); 656 AddDownload(id1, DownloadItem::COMPLETE, now);
631 AddDownload(id2, DownloadItem::COMPLETE, now + base::TimeDelta::FromDays(2)); 657 AddDownload(id2, DownloadItem::COMPLETE, now + base::TimeDelta::FromDays(2));
(...skipping 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after
1842 std::vector<PageUsageData*> results; 1868 std::vector<PageUsageData*> results;
1843 db_->QuerySegmentUsage(segment_time, 10, &results); 1869 db_->QuerySegmentUsage(segment_time, 10, &results);
1844 ASSERT_EQ(1u, results.size()); 1870 ASSERT_EQ(1u, results.size());
1845 EXPECT_EQ(url, results[0]->GetURL()); 1871 EXPECT_EQ(url, results[0]->GetURL());
1846 EXPECT_EQ(segment_id, results[0]->GetID()); 1872 EXPECT_EQ(segment_id, results[0]->GetID());
1847 EXPECT_EQ(title, results[0]->GetTitle()); 1873 EXPECT_EQ(title, results[0]->GetTitle());
1848 STLDeleteElements(&results); 1874 STLDeleteElements(&results);
1849 } 1875 }
1850 1876
1851 } // namespace history 1877 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698