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

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

Issue 1533583002: [Downloads] Factor out request handling logic between DRH and UD. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments and change .Pass() -> std::move(...) per PRESUBMIT check Created 5 years 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 | « no previous file | content/browser/download/download_create_info.h » ('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 c763b87fb7ff0423b5f767ed074330a28b08199e..77e438c565a2f5d0f71f118213bc8f37aa4c94b1 100644
--- a/content/browser/download/download_browsertest.cc
+++ b/content/browser/download/download_browsertest.cc
@@ -1521,7 +1521,7 @@ IN_PROC_BROWSER_TEST_P(DownloadResumptionContentTest, CancelResumingDownload) {
ASSERT_FALSE(intermediate_path.empty());
EXPECT_TRUE(base::PathExists(intermediate_path));
- // Resume and remove download. We expect only a single OnDownloadCreated()
+ // Resume and cancel download. We expect only a single OnDownloadCreated()
// call, and that's for the second download created below.
MockDownloadManagerObserver dm_observer(
DownloadManagerForShell(initiator_shell_for_resumption()));
@@ -1560,6 +1560,76 @@ IN_PROC_BROWSER_TEST_P(DownloadResumptionContentTest, CancelResumingDownload) {
EXPECT_TRUE(EnsureNoPendingDownloads());
}
+IN_PROC_BROWSER_TEST_P(DownloadResumptionContentTest, RemoveResumedDownload) {
+ TestDownloadRequestHandler::Parameters parameters =
+ TestDownloadRequestHandler::Parameters::WithSingleInterruption();
+ TestDownloadRequestHandler request_handler;
+ request_handler.StartServing(parameters);
+
+ DownloadItem* download = StartDownloadAndReturnItem(
+ initiator_shell_for_resumption(), request_handler.url());
+ WaitForInterrupt(download);
+
+ base::FilePath intermediate_path(download->GetFullPath());
+ base::FilePath target_path(download->GetTargetFilePath());
+ ASSERT_FALSE(intermediate_path.empty());
+ EXPECT_TRUE(base::PathExists(intermediate_path));
+ EXPECT_FALSE(base::PathExists(target_path));
+
+ // Resume and remove download. We don't expect OnDownloadCreated() calls.
+ MockDownloadManagerObserver dm_observer(
+ DownloadManagerForShell(initiator_shell_for_resumption()));
+ EXPECT_CALL(dm_observer, OnDownloadCreated(_, _)).Times(0);
+
+ PrepareToResume();
+ download->Resume();
+ WaitForInProgress(download);
+
+ download->Remove();
+
+ // The intermediate file should now be gone.
+ RunAllPendingInMessageLoop(BrowserThread::FILE);
+ RunAllPendingInMessageLoop();
+ EXPECT_FALSE(base::PathExists(intermediate_path));
+ EXPECT_FALSE(base::PathExists(target_path));
+ EXPECT_TRUE(EnsureNoPendingDownloads());
+}
+
+IN_PROC_BROWSER_TEST_P(DownloadResumptionContentTest, CancelResumedDownload) {
+ TestDownloadRequestHandler::Parameters parameters =
+ TestDownloadRequestHandler::Parameters::WithSingleInterruption();
+ TestDownloadRequestHandler request_handler;
+ request_handler.StartServing(parameters);
+
+ DownloadItem* download = StartDownloadAndReturnItem(
+ initiator_shell_for_resumption(), request_handler.url());
+ WaitForInterrupt(download);
+
+ base::FilePath intermediate_path(download->GetFullPath());
+ base::FilePath target_path(download->GetTargetFilePath());
+ ASSERT_FALSE(intermediate_path.empty());
+ EXPECT_TRUE(base::PathExists(intermediate_path));
+ EXPECT_FALSE(base::PathExists(target_path));
+
+ // Resume and remove download. We don't expect OnDownloadCreated() calls.
+ MockDownloadManagerObserver dm_observer(
+ DownloadManagerForShell(initiator_shell_for_resumption()));
+ EXPECT_CALL(dm_observer, OnDownloadCreated(_, _)).Times(0);
+
+ PrepareToResume();
+ download->Resume();
+ WaitForInProgress(download);
+
+ download->Cancel(true);
+
+ // The intermediate file should now be gone.
+ RunAllPendingInMessageLoop(BrowserThread::FILE);
+ RunAllPendingInMessageLoop();
+ EXPECT_FALSE(base::PathExists(intermediate_path));
+ EXPECT_FALSE(base::PathExists(target_path));
+ EXPECT_TRUE(EnsureNoPendingDownloads());
+}
+
// Check that the cookie policy is correctly updated when downloading a file
// that redirects cross origin.
IN_PROC_BROWSER_TEST_F(DownloadContentTest, CookiePolicy) {
@@ -1705,6 +1775,17 @@ IN_PROC_BROWSER_TEST_F(DownloadContentTest, DownloadGZipWithNoContent) {
// That's it. This should work without crashing.
}
+// Make sure that sniffed MIME types are correctly passed through to the
+// download item.
+IN_PROC_BROWSER_TEST_F(DownloadContentTest, SniffedMimeType) {
+ GURL url = net::URLRequestMockHTTPJob::GetMockUrl("gzip-content.gz");
+ DownloadItem* item = StartDownloadAndReturnItem(shell(), url);
+ WaitForCompletion(item);
+
+ EXPECT_STREQ("application/x-gzip", item->GetMimeType().c_str());
+ EXPECT_TRUE(item->GetOriginalMimeType().empty());
+}
+
IN_PROC_BROWSER_TEST_F(DownloadContentTest, Spam) {
ASSERT_TRUE(embedded_test_server()->Start());
« no previous file with comments | « no previous file | content/browser/download/download_create_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698