| 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 3dce43e94f6cc961613675783a4627f712c51323..3303320887dadc9fc990eb6aa46700036d4bf860 100644
|
| --- a/content/browser/download/download_item_impl_unittest.cc
|
| +++ b/content/browser/download/download_item_impl_unittest.cc
|
| @@ -620,7 +620,7 @@ TEST_F(DownloadItemTest, NotificationAfterTogglePause) {
|
| CleanupItem(item, mock_download_file, DownloadItem::IN_PROGRESS);
|
| }
|
|
|
| -// Test that a download is resumed automatcially after a continuable interrupt.
|
| +// Test that a download is resumed automatically after a continuable interrupt.
|
| TEST_F(DownloadItemTest, AutomaticResumption_Continue) {
|
| DownloadItemImpl* item = CreateDownloadItem();
|
| TestDownloadItemObserver observer(item);
|
| @@ -719,6 +719,44 @@ TEST_F(DownloadItemTest, AutomaticResumption_NeedsUserAction) {
|
| CleanupItem(item, nullptr, DownloadItem::INTERRUPTED);
|
| }
|
|
|
| +// Test that a download is resumed automatically after a content length mismatch
|
| +// 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();
|
|
|