summaryrefslogtreecommitdiff
path: root/content/browser/download/download_item_impl_unittest.cc
diff options
context:
space:
mode:
authorTorne (Richard Coles) <torne@google.com>2014-03-18 10:20:56 +0000
committerTorne (Richard Coles) <torne@google.com>2014-03-18 10:20:56 +0000
commita1401311d1ab56c4ed0a474bd38c108f75cb0cd9 (patch)
tree3437151d9ae1ce20a1e53a0d98c19ca01c786394 /content/browser/download/download_item_impl_unittest.cc
parentaf5066f1e36c6579e74752647e6c584438f80f94 (diff)
downloadchromium_org-a1401311d1ab56c4ed0a474bd38c108f75cb0cd9.tar.gz
Merge from Chromium at DEPS revision 257591
This commit was generated by merge_to_master.py. Change-Id: I0010df2ec3fbb5d4947cd026de2feb150ce7a6b5
Diffstat (limited to 'content/browser/download/download_item_impl_unittest.cc')
-rw-r--r--content/browser/download/download_item_impl_unittest.cc31
1 files changed, 31 insertions, 0 deletions
diff --git a/content/browser/download/download_item_impl_unittest.cc b/content/browser/download/download_item_impl_unittest.cc
index 9abe3417e7..1291ce1135 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);