Chromium Code Reviews| 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 6553d0d5bde5168c44cf4354a07e7af0e5a1cb66..1989d4d372df1e3d147342a9a3c0eec2464f9712 100644 |
| --- a/content/browser/download/download_item_impl_unittest.cc |
| +++ b/content/browser/download/download_item_impl_unittest.cc |
| @@ -719,6 +719,44 @@ TEST_F(DownloadItemTest, AutomaticResumption_NeedsUserAction) { |
| CleanupItem(item, nullptr, DownloadItem::INTERRUPTED); |
| } |
| +// Test that a download is resumed automatcially after a content length mismatch |
|
David Trainor- moved to gerrit
2017/04/25 03:50:41
automatically
qinmin
2017/04/25 19:27:47
Done.
|
| +// error. |
| +TEST_F(DownloadItemTest, AutomaticResumption_ContentLengthMismatch) { |
| + DownloadItemImpl* item = CreateDownloadItem(); |
| + TestDownloadItemObserver observer(item); |
| + MockDownloadFile* download_file = |
| + DoIntermediateRename(item, DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS); |
| + |
| + // Interrupt the download with content length mismatch error. The intermediate |
| + // file with data shouldn't be discarded. |
| + |
| + // The DownloadFile should be detached without discarding. |
| + EXPECT_CALL(*download_file, FullPath()) |
| + .WillOnce(ReturnRefOfCopy(base::FilePath())); |
| + EXPECT_CALL(*download_file, Detach()); |
| + |
| + // Resumption attempt should pass the intermediate file along. |
| + EXPECT_CALL(*mock_delegate(), |
| + MockResumeInterruptedDownload( |
| + AllOf(Property(&DownloadUrlParameters::file_path, |
| + Property(&base::FilePath::value, |
| + kDummyIntermediatePath)), |
| + Property(&DownloadUrlParameters::offset, 1)), |
| + _)); |
| + |
| + item->DestinationObserverAsWeakPtr()->DestinationError( |
| + DOWNLOAD_INTERRUPT_REASON_SERVER_CONTENT_LENGTH_MISMATCH, 1, |
| + std::unique_ptr<crypto::SecureHash>()); |
| + ASSERT_TRUE(observer.CheckAndResetDownloadUpdated()); |
| + // Since the download is resumed automatically, the observer shouldn't notice |
| + // the interruption. |
| + ASSERT_EQ(0, observer.interrupt_count()); |
| + ASSERT_EQ(0, observer.resume_count()); |
| + |
| + RunAllPendingInMessageLoops(); |
| + CleanupItem(item, nullptr, DownloadItem::IN_PROGRESS); |
| +} |
| + |
| // Check we do correct cleanup for RESUME_MODE_INVALID interrupts. |
| TEST_F(DownloadItemTest, UnresumableInterrupt) { |
| DownloadItemImpl* item = CreateDownloadItem(); |