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

Unified Diff: chrome/browser/history/history_unittest.cc

Issue 13044019: Clean up entries left by crashes in the DownloadDB. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Shift cleanup to DownloadDatabase. Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/history/history_service.cc ('k') | content/browser/download/download_item_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « chrome/browser/history/history_service.cc ('k') | content/browser/download/download_item_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698