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

Unified Diff: components/history/core/browser/history_backend_db_unittest.cc

Issue 2665243003: add a download slices table into history download db (Closed)
Patch Set: addressing comments Created 3 years, 11 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
Index: components/history/core/browser/history_backend_db_unittest.cc
diff --git a/components/history/core/browser/history_backend_db_unittest.cc b/components/history/core/browser/history_backend_db_unittest.cc
index fd033d7f8a2f867938a5b93dfc0bea2c8b864961..0a360bc5fdb555dbc5932d1e772338afa1388ada 100644
--- a/components/history/core/browser/history_backend_db_unittest.cc
+++ b/components/history/core/browser/history_backend_db_unittest.cc
@@ -749,7 +749,7 @@ TEST_F(HistoryBackendDBTest, DownloadCreateAndQuery) {
100, 1000, DownloadState::INTERRUPTED, DownloadDangerType::NOT_DANGEROUS,
kTestDownloadInterruptReasonCrash, "hash-value1", 1,
"FE672168-26EF-4275-A149-FEC25F6A75F9", false, "extension-id",
- "extension-name");
+ "extension-name", std::vector<DownloadJobInfo>());
ASSERT_TRUE(db_->CreateDownload(download_A));
url_chain.push_back(GURL("http://example.com/d"));
@@ -767,7 +767,7 @@ TEST_F(HistoryBackendDBTest, DownloadCreateAndQuery) {
1001, 1001, DownloadState::COMPLETE, DownloadDangerType::DANGEROUS_FILE,
kTestDownloadInterruptReasonNone, std::string(), 2,
"b70f3869-7d75-4878-acb4-4caf7026d12b", false, "extension-id",
- "extension-name");
+ "extension-name", std::vector<DownloadJobInfo>());
ASSERT_TRUE(db_->CreateDownload(download_B));
EXPECT_EQ(2u, db_->CountDownloads());
@@ -806,7 +806,7 @@ TEST_F(HistoryBackendDBTest, DownloadCreateAndUpdate_VolatileFields) {
"original/mime-type", start_time, end_time, "etag1", "last_modified_1",
100, 1000, DownloadState::INTERRUPTED, DownloadDangerType::NOT_DANGEROUS,
3, "some-hash-value", 1, "FE672168-26EF-4275-A149-FEC25F6A75F9", false,
- "extension-id", "extension-name");
+ "extension-id", "extension-name", std::vector<DownloadJobInfo>());
db_->CreateDownload(download);
download.current_path =
@@ -904,7 +904,8 @@ TEST_F(HistoryBackendDBTest, DownloadNukeRecordsMissingURLs) {
"application/octet-stream", now, now, std::string(), std::string(), 0,
512, DownloadState::COMPLETE, DownloadDangerType::NOT_DANGEROUS,
kTestDownloadInterruptReasonNone, std::string(), 1,
- "05AF6C8E-E4E0-45D7-B5CE-BC99F7019918", 0, "by_ext_id", "by_ext_name");
+ "05AF6C8E-E4E0-45D7-B5CE-BC99F7019918", 0, "by_ext_id", "by_ext_name",
+ std::vector<DownloadJobInfo>());
// Creating records without any urls should fail.
EXPECT_FALSE(db_->CreateDownload(download));
@@ -1004,6 +1005,47 @@ TEST_F(HistoryBackendDBTest, ConfirmDownloadInProgressCleanup) {
}
}
+TEST_F(HistoryBackendDBTest, CreateAndUpdateParallelDownloadingJob) {
+ // Create the DB.
+ CreateBackendAndDatabase();
+
+ std::vector<GURL> url_chain;
+ url_chain.push_back(GURL("http://example.com/a"));
+
+ DownloadId id = 1;
+ std::vector<DownloadJobInfo> job_info;
+ int64_t received = 0;
+ job_info.push_back(DownloadJobInfo(
+ id, 0, 0, 1000, received, DownloadState::INTERRUPTED,
sky 2017/02/03 16:02:34 Can you change the two zeros to non-zero values th
qinmin 2017/02/04 00:06:56 Done.
+ kTestDownloadInterruptReasonCrash));
+ base::Time start_time(base::Time::Now());
+ base::Time end_time(start_time + base::TimeDelta::FromHours(1));
+
+ DownloadRow download(
+ base::FilePath(FILE_PATH_LITERAL("/path/1")),
+ base::FilePath(FILE_PATH_LITERAL("/path/2")), url_chain,
+ GURL("http://example.com/referrer"), GURL("http://example.com"),
+ GURL("http://example.com/tab-url"),
+ GURL("http://example.com/tab-referrer"), "GET", "mime/type",
+ "original/mime-type", start_time, end_time, "etag1", "last_modified_1",
+ received, 1000, DownloadState::INTERRUPTED,
+ DownloadDangerType::NOT_DANGEROUS, kTestDownloadInterruptReasonCrash,
+ "hash-value1", id, "FE672168-26EF-4275-A149-FEC25F6A75F9",
+ false, "extension-id", "extension-name", job_info);
+ ASSERT_TRUE(db_->CreateDownload(download));
+ std::vector<DownloadRow> results;
+ db_->QueryDownloads(&results);
+ ASSERT_EQ(1u, results.size());
+ EXPECT_EQ(download, results[0]);
+
+ download.received_bytes += 10;
+ download.download_job_info[0].received_bytes = download.received_bytes;
+ ASSERT_TRUE(db_->UpdateDownload(download));
+ db_->QueryDownloads(&results);
+ ASSERT_EQ(1u, results.size());
+ EXPECT_EQ(download, results[0]);
+}
+
TEST_F(HistoryBackendDBTest, MigratePresentations) {
// Create the db we want. Use 22 since segments didn't change in that time
// frame.

Powered by Google App Engine
This is Rietveld 408576698