| OLD | NEW |
| 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 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 { | 431 { |
| 432 sql::Statement s(db.GetUniqueStatement( | 432 sql::Statement s(db.GetUniqueStatement( |
| 433 "SELECT etag, last_modified from downloads")); | 433 "SELECT etag, last_modified from downloads")); |
| 434 EXPECT_TRUE(s.Step()); | 434 EXPECT_TRUE(s.Step()); |
| 435 EXPECT_EQ(std::string(), s.ColumnString(0)); | 435 EXPECT_EQ(std::string(), s.ColumnString(0)); |
| 436 EXPECT_EQ(std::string(), s.ColumnString(1)); | 436 EXPECT_EQ(std::string(), s.ColumnString(1)); |
| 437 } | 437 } |
| 438 } | 438 } |
| 439 } | 439 } |
| 440 | 440 |
| 441 TEST_F(HistoryBackendDBTest, PurgeArchivedDatabase) { | |
| 442 ASSERT_NO_FATAL_FAILURE(CreateDBVersion(27)); | |
| 443 ASSERT_NO_FATAL_FAILURE(CreateArchivedDB()); | |
| 444 | |
| 445 ASSERT_TRUE(base::PathExists(history_dir_.Append(kArchivedHistoryFilename))); | |
| 446 | |
| 447 CreateBackendAndDatabase(); | |
| 448 DeleteBackend(); | |
| 449 | |
| 450 // We do not retain expired history entries in an archived database as of M37. | |
| 451 // Verify that any legacy archived database is deleted on start-up. | |
| 452 ASSERT_FALSE(base::PathExists(history_dir_.Append(kArchivedHistoryFilename))); | |
| 453 } | |
| 454 | |
| 455 TEST_F(HistoryBackendDBTest, MigrateDownloadMimeType) { | 441 TEST_F(HistoryBackendDBTest, MigrateDownloadMimeType) { |
| 456 base::Time now(base::Time::Now()); | 442 base::Time now(base::Time::Now()); |
| 457 ASSERT_NO_FATAL_FAILURE(CreateDBVersion(28)); | 443 ASSERT_NO_FATAL_FAILURE(CreateDBVersion(28)); |
| 458 { | 444 { |
| 459 sql::Connection db; | 445 sql::Connection db; |
| 460 ASSERT_TRUE(db.Open(history_dir_.Append(kHistoryFilename))); | 446 ASSERT_TRUE(db.Open(history_dir_.Append(kHistoryFilename))); |
| 461 { | 447 { |
| 462 sql::Statement s(db.GetUniqueStatement( | 448 sql::Statement s(db.GetUniqueStatement( |
| 463 "INSERT INTO downloads (id, current_path, target_path, start_time, " | 449 "INSERT INTO downloads (id, current_path, target_path, start_time, " |
| 464 "received_bytes, total_bytes, state, danger_type, interrupt_reason, " | 450 "received_bytes, total_bytes, state, danger_type, interrupt_reason, " |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 // Current browser version must be already higher than 28. | 774 // Current browser version must be already higher than 28. |
| 789 ASSERT_LT(28, HistoryDatabase::GetCurrentVersion()); | 775 ASSERT_LT(28, HistoryDatabase::GetCurrentVersion()); |
| 790 // Expect that version in DB remains the same. | 776 // Expect that version in DB remains the same. |
| 791 EXPECT_EQ(28, meta.GetVersionNumber()); | 777 EXPECT_EQ(28, meta.GetVersionNumber()); |
| 792 } | 778 } |
| 793 } | 779 } |
| 794 } | 780 } |
| 795 | 781 |
| 796 } // namespace | 782 } // namespace |
| 797 } // namespace history | 783 } // namespace history |
| OLD | NEW |