Index: chrome/browser/history/history_unittest.cc |
diff --git a/chrome/browser/history/history_unittest.cc b/chrome/browser/history/history_unittest.cc |
index d28fada2ae8fc5b36e628bafbe63cbfea213fcf8..9d67e7f33a496ef4d04ed5929c54f730e98f4b71 100644 |
--- a/chrome/browser/history/history_unittest.cc |
+++ b/chrome/browser/history/history_unittest.cc |
@@ -170,6 +170,8 @@ class HistoryBackendDBTest : public HistoryUnitTestBase { |
base::FilePath(FILE_PATH_LITERAL("target-path")), |
url_chain, |
GURL("http://referrer.com/"), |
+ "application/octet-stream", |
+ "application/octet-stream", |
time, |
time, |
std::string(), |
@@ -617,6 +619,74 @@ TEST_F(HistoryBackendDBTest, MigrateDownloadValidators) { |
} |
} |
+TEST_F(HistoryBackendDBTest, MigrateDownloadMimeType) { |
+ Time now(base::Time::Now()); |
+ ASSERT_NO_FATAL_FAILURE(CreateDBVersion(28)); |
+ { |
+ sql::Connection db; |
+ ASSERT_TRUE(db.Open(history_dir_.Append(chrome::kHistoryFilename))); |
+ { |
+ sql::Statement s(db.GetUniqueStatement( |
+ "INSERT INTO downloads (id, current_path, target_path, start_time, " |
+ "received_bytes, total_bytes, state, danger_type, interrupt_reason, " |
+ "end_time, opened, referrer, by_ext_id, by_ext_name, etag, " |
+ "last_modified) VALUES " |
+ "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")); |
+ s.BindInt64(0, 1); |
+ s.BindString(1, "current_path"); |
+ s.BindString(2, "target_path"); |
+ s.BindInt64(3, now.ToTimeT()); |
+ s.BindInt64(4, 100); |
+ s.BindInt64(5, 100); |
+ s.BindInt(6, 1); |
+ s.BindInt(7, 0); |
+ s.BindInt(8, 0); |
+ s.BindInt64(9, now.ToTimeT()); |
+ s.BindInt(10, 1); |
+ s.BindString(11, "referrer"); |
+ s.BindString(12, "by extension ID"); |
+ s.BindString(13, "by extension name"); |
+ s.BindString(14, "etag"); |
+ s.BindInt64(15, now.ToTimeT()); |
+ ASSERT_TRUE(s.Run()); |
+ } |
+ { |
+ sql::Statement s(db.GetUniqueStatement( |
+ "INSERT INTO downloads_url_chains (id, chain_index, url) VALUES " |
+ "(?, ?, ?)")); |
+ s.BindInt64(0, 4); |
+ s.BindInt64(1, 0); |
+ s.BindString(2, "url"); |
+ ASSERT_TRUE(s.Run()); |
+ } |
+ } |
+ // Re-open the db using the HistoryDatabase, which should migrate to the |
+ // current version, creating the etag and last_modified columns. |
+ CreateBackendAndDatabase(); |
+ DeleteBackend(); |
+ { |
+ // Re-open the db for manual manipulation. |
+ sql::Connection db; |
+ ASSERT_TRUE(db.Open(history_dir_.Append(chrome::kHistoryFilename))); |
+ // The version should have been updated. |
+ int cur_version = HistoryDatabase::GetCurrentVersion(); |
+ ASSERT_LE(29, cur_version); |
+ { |
+ sql::Statement s(db.GetUniqueStatement( |
+ "SELECT value FROM meta WHERE key = 'version'")); |
+ EXPECT_TRUE(s.Step()); |
+ EXPECT_EQ(cur_version, s.ColumnInt(0)); |
+ } |
+ { |
+ sql::Statement s(db.GetUniqueStatement( |
+ "SELECT mime_type, original_mime_type from downloads")); |
+ EXPECT_TRUE(s.Step()); |
+ EXPECT_EQ(std::string(), s.ColumnString(0)); |
+ EXPECT_EQ(std::string(), s.ColumnString(1)); |
+ } |
+ } |
+} |
+ |
TEST_F(HistoryBackendDBTest, ConfirmDownloadRowCreateAndDelete) { |
// Create the DB. |
CreateBackendAndDatabase(); |
@@ -673,6 +743,8 @@ TEST_F(HistoryBackendDBTest, DownloadNukeRecordsMissingURLs) { |
base::FilePath(FILE_PATH_LITERAL("foo-path")), |
url_chain, |
GURL(std::string()), |
+ "application/octet-stream", |
+ "application/octet-stream", |
now, |
now, |
std::string(), |