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

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

Issue 183743019: delete file if resume mode is invalid. DCHECK fails in DownloadItemImpl::OnDownloadRenamedToFinalNa… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: unit tests for RESUME_MODE_INVALID interrupt Created 6 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 | « content/browser/download/download_item_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/download/download_item_impl_unittest.cc
diff --git a/content/browser/download/download_item_impl_unittest.cc b/content/browser/download/download_item_impl_unittest.cc
index 9abe3417e7e3546978d2f05cb68ddd35b82cad65..1291ce11350ca19f80de32eacc34b4a6c0c27790 100644
--- a/content/browser/download/download_item_impl_unittest.cc
+++ b/content/browser/download/download_item_impl_unittest.cc
@@ -459,6 +459,37 @@ TEST_F(DownloadItemTest, RestartAfterInterrupted) {
CleanupItem(item, download_file, DownloadItem::INTERRUPTED);
}
+// Check we do correct cleanup for RESUME_MODE_INVALID interrupts.
+TEST_F(DownloadItemTest, UnresumableInterrupt) {
+ CommandLine::ForCurrentProcess()->AppendSwitch(
+ switches::kEnableDownloadResumption);
+
+ DownloadItemImpl* item = CreateDownloadItem();
+ MockObserver observer(item);
+ DownloadItemImplDelegate::DownloadTargetCallback callback;
+ MockDownloadFile* download_file =
+ DoIntermediateRename(item, DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS);
+
+ // Fail final rename with unresumable reason.
+ EXPECT_CALL(*mock_delegate(), ShouldCompleteDownload(item, _))
+ .WillOnce(Return(true));
+ EXPECT_CALL(*download_file, RenameAndAnnotate(base::FilePath(kDummyPath), _))
+ .WillOnce(ScheduleRenameCallback(DOWNLOAD_INTERRUPT_REASON_FILE_BLOCKED,
+ base::FilePath(kDummyPath)));
+ EXPECT_CALL(*download_file, Cancel());
+
+ // Complete download to trigger final rename.
+ item->DestinationObserverAsWeakPtr()->DestinationCompleted(std::string());
+ RunAllPendingInMessageLoops();
+
+ ASSERT_TRUE(observer.CheckUpdated());
+ // Should not try to auto-resume.
+ ASSERT_EQ(1, observer.GetInterruptCount());
+ ASSERT_EQ(0, observer.GetResumeCount());
+
+ CleanupItem(item, download_file, DownloadItem::INTERRUPTED);
+}
+
TEST_F(DownloadItemTest, LimitRestartsAfterInterrupted) {
CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableDownloadResumption);
« no previous file with comments | « content/browser/download/download_item_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698