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

Unified Diff: content/browser/download/download_browsertest.cc

Issue 1648683002: [Merge to 49] [Downloads] Avoid resetting SecureHash state across an interruption. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2623
Patch Set: Created 4 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
« no previous file with comments | « content/browser/download/base_file.cc ('k') | content/browser/download/download_file_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/download/download_browsertest.cc
diff --git a/content/browser/download/download_browsertest.cc b/content/browser/download/download_browsertest.cc
index 794e8327bf8dc9fe14eab0a932ba8036bffc26db..dc965d416464547701d5fd9e1f86e21c282a7658 100644
--- a/content/browser/download/download_browsertest.cc
+++ b/content/browser/download/download_browsertest.cc
@@ -383,6 +383,8 @@ class TestShellDownloadManagerDelegate : public ShellDownloadManagerDelegate {
return true;
}
+ bool GenerateFileHash() override { return true; }
+
void SetDelayedOpen(bool delay) {
delay_download_open_ = delay;
}
@@ -1399,6 +1401,59 @@ IN_PROC_BROWSER_TEST_P(DownloadResumptionContentTest,
EXPECT_EQ(download->GetState(), DownloadItem::COMPLETE);
}
+IN_PROC_BROWSER_TEST_P(DownloadResumptionContentTest, Resume_Hash) {
+ using InjectedError = TestDownloadRequestHandler::InjectedError;
+ const char kExpectedHash[] =
+ "\xa7\x44\x49\x86\x24\xc6\x84\x6c\x89\xdf\xd8\xec\xa0\xe0\x61\x12\xdc\x80"
+ "\x13\xf2\x83\x49\xa9\x14\x52\x32\xf0\x95\x20\xca\x5b\x30";
+ std::string expected_hash(kExpectedHash);
+ TestDownloadRequestHandler request_handler;
+ TestDownloadRequestHandler::Parameters parameters;
+
+ // As a control, let's try GetHash() on an uninterrupted download.
+ request_handler.StartServing(parameters);
+ DownloadItem* uninterrupted_download(StartDownloadAndReturnItem(
+ initiator_shell_for_resumption(), request_handler.url()));
+ WaitForCompletion(uninterrupted_download);
+ EXPECT_EQ(expected_hash, uninterrupted_download->GetHash());
+
+ // Now with interruptions.
+ parameters.injected_errors.push(
+ InjectedError(100, net::ERR_CONNECTION_RESET));
+ parameters.injected_errors.push(
+ InjectedError(211, net::ERR_CONNECTION_RESET));
+ parameters.injected_errors.push(
+ InjectedError(337, net::ERR_CONNECTION_RESET));
+ parameters.injected_errors.push(
+ InjectedError(400, net::ERR_CONNECTION_RESET));
+ parameters.injected_errors.push(
+ InjectedError(512, net::ERR_CONNECTION_RESET));
+ request_handler.StartServing(parameters);
+
+ // Start and watch for interrupt.
+ DownloadItem* download(StartDownloadAndReturnItem(
+ initiator_shell_for_resumption(), request_handler.url()));
+ WaitForInterrupt(download);
+
+ PrepareToResume();
+ download->Resume();
+ WaitForInterrupt(download);
+
+ download->Resume();
+ WaitForInterrupt(download);
+
+ download->Resume();
+ WaitForInterrupt(download);
+
+ download->Resume();
+ WaitForInterrupt(download);
+
+ download->Resume();
+ WaitForCompletion(download);
+
+ EXPECT_EQ(expected_hash, download->GetHash());
+}
+
// An interrupted download should remove the intermediate file when it is
// cancelled.
IN_PROC_BROWSER_TEST_P(DownloadResumptionContentTest,
« no previous file with comments | « content/browser/download/base_file.cc ('k') | content/browser/download/download_file_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698