Index: chrome/browser/history/history_unittest.cc |
diff --git a/chrome/browser/history/history_unittest.cc b/chrome/browser/history/history_unittest.cc |
index 374a6cb142efb5aaee2548db7191abe65809fd61..258d8a8e212a7157bbf54797600c890afec4f26d 100644 |
--- a/chrome/browser/history/history_unittest.cc |
+++ b/chrome/browser/history/history_unittest.cc |
@@ -462,6 +462,65 @@ TEST_F(HistoryBackendDBTest, ConfirmDownloadRowCreateAndDelete) { |
} |
} |
+TEST_F(HistoryBackendDBTest, ConfirmDownloadInProgressCleanup) { |
+ // Create the DB. |
+ CreateBackendAndDatabase(); |
+ |
+ base::Time now(base::Time::Now()); |
+ |
+ // Put an IN_PROGRESS download in the DB. |
+ AddDownload(DownloadItem::IN_PROGRESS, now); |
+ |
+ // Confirm that they made it into the DB unchanged. |
+ DeleteBackend(); |
+ { |
+ sql::Connection db; |
+ ASSERT_TRUE(db.Open(history_dir_.Append(chrome::kHistoryFilename))); |
+ sql::Statement statement(db.GetUniqueStatement( |
+ "Select Count(*) from downloads")); |
+ EXPECT_TRUE(statement.Step()); |
+ EXPECT_EQ(1, statement.ColumnInt(0)); |
+ |
+ sql::Statement statement1(db.GetUniqueStatement( |
+ "Select state, interrupt_reason from downloads")); |
+ EXPECT_TRUE(statement1.Step()); |
+ EXPECT_EQ(DownloadDatabase::kStateInProgress, statement1.ColumnInt(0)); |
+ EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_NONE, statement1.ColumnInt(1)); |
+ EXPECT_FALSE(statement1.Step()); |
+ } |
+ |
+ // Read in the DB through query downloads, then test that the |
+ // right transformation was returned. |
+ CreateBackendAndDatabase(); |
+ std::vector<DownloadRow> results; |
+ db_->QueryDownloads(&results); |
+ ASSERT_EQ(1u, results.size()); |
+ EXPECT_EQ(content::DownloadItem::INTERRUPTED, results[0].state); |
+ EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_CRASH, |
+ results[0].interrupt_reason); |
benjhayden
2013/03/28 19:21:03
Do you want to also test that adding an in_progres
Randy Smith (Not in Mondays)
2013/03/28 19:40:12
I think chrome/browser/download/download_browserte
|
+ |
+ // Allow the update to propagate, shut down the DB, and confirm that |
+ // the query updated the on disk database as well. |
+ MessageLoop::current()->RunUntilIdle(); |
+ DeleteBackend(); |
+ { |
+ sql::Connection db; |
+ ASSERT_TRUE(db.Open(history_dir_.Append(chrome::kHistoryFilename))); |
+ sql::Statement statement(db.GetUniqueStatement( |
+ "Select Count(*) from downloads")); |
+ EXPECT_TRUE(statement.Step()); |
+ EXPECT_EQ(1, statement.ColumnInt(0)); |
+ |
+ sql::Statement statement1(db.GetUniqueStatement( |
+ "Select state, interrupt_reason from downloads")); |
+ EXPECT_TRUE(statement1.Step()); |
+ EXPECT_EQ(DownloadDatabase::kStateInterrupted, statement1.ColumnInt(0)); |
+ EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_CRASH, |
+ statement1.ColumnInt(1)); |
+ EXPECT_FALSE(statement1.Step()); |
+ } |
+} |
+ |
struct InterruptReasonAssociation { |
std::string name; |
int value; |