diff options
author | Torne (Richard Coles) <torne@google.com> | 2013-05-15 11:34:50 +0100 |
---|---|---|
committer | Torne (Richard Coles) <torne@google.com> | 2013-05-15 11:34:50 +0100 |
commit | a93a17c8d99d686bd4a1511e5504e5e6cc9fcadf (patch) | |
tree | 2fc96923f36ddec68fee218d79dd407c28fa46f8 /content/browser/download/download_item_impl_unittest.cc | |
parent | 770489ea635fbf896c1ace4db0d08d6981a2db8b (diff) | |
download | chromium_org-a93a17c8d99d686bd4a1511e5504e5e6cc9fcadf.tar.gz |
Merge from Chromium at DEPS revision r200144
This commit was generated by merge_to_master.py.
Change-Id: I85f3a249ae157fd8253431215fb2dfcd12ee9bf3
Diffstat (limited to 'content/browser/download/download_item_impl_unittest.cc')
-rw-r--r-- | content/browser/download/download_item_impl_unittest.cc | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/content/browser/download/download_item_impl_unittest.cc b/content/browser/download/download_item_impl_unittest.cc index 275b4d2c29..7a29f28e71 100644 --- a/content/browser/download/download_item_impl_unittest.cc +++ b/content/browser/download/download_item_impl_unittest.cc @@ -748,6 +748,38 @@ TEST_F(DownloadItemTest, Interrupted) { EXPECT_EQ(DOWNLOAD_INTERRUPT_REASON_USER_CANCELED, item->GetLastReason()); } +// Destination errors that occur before the intermediate rename shouldn't cause +// the download to be marked as interrupted until after the intermediate rename. +TEST_F(DownloadItemTest, InterruptedBeforeIntermediateRename) { + DownloadItemImpl* item = CreateDownloadItem(); + DownloadItemImplDelegate::DownloadTargetCallback callback; + MockDownloadFile* download_file = + AddDownloadFileToDownloadItem(item, &callback); + item->DestinationObserverAsWeakPtr()->DestinationError( + DOWNLOAD_INTERRUPT_REASON_FILE_FAILED); + ASSERT_TRUE(item->IsInProgress()); + + base::FilePath final_path(base::FilePath(kDummyPath).AppendASCII("foo.bar")); + base::FilePath intermediate_path(final_path.InsertBeforeExtensionASCII("x")); + base::FilePath new_intermediate_path( + final_path.InsertBeforeExtensionASCII("y")); + EXPECT_CALL(*download_file, RenameAndUniquify(intermediate_path, _)) + .WillOnce(ScheduleRenameCallback(DOWNLOAD_INTERRUPT_REASON_NONE, + new_intermediate_path)); + EXPECT_CALL(*download_file, Cancel()) + .Times(1); + + callback.Run(final_path, DownloadItem::TARGET_DISPOSITION_OVERWRITE, + DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, intermediate_path); + RunAllPendingInMessageLoops(); + // All the callbacks should have happened by now. + ::testing::Mock::VerifyAndClearExpectations(download_file); + mock_delegate()->VerifyAndClearExpectations(); + EXPECT_TRUE(item->IsInterrupted()); + EXPECT_TRUE(item->GetFullPath().empty()); + EXPECT_EQ(final_path, item->GetTargetFilePath()); +} + TEST_F(DownloadItemTest, Canceled) { DownloadItemImpl* item = CreateDownloadItem(); MockDownloadFile* download_file = AddDownloadFileToDownloadItem(item, NULL); |