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 1ea59d3c968e9dc02f90db3193f76ed7e5dfb0a3..9a1a4c2e8b8c3fd7b78438bc5053a5830efeaa04 100644 |
| --- a/content/browser/download/download_item_impl_unittest.cc |
| +++ b/content/browser/download/download_item_impl_unittest.cc |
| @@ -26,10 +26,15 @@ |
| #include "content/public/browser/download_destination_observer.h" |
| #include "content/public/browser/download_interrupt_reasons.h" |
| #include "content/public/browser/download_url_parameters.h" |
| +#include "content/public/browser/site_instance.h" |
| +#include "content/public/browser/web_contents.h" |
| #include "content/public/common/content_features.h" |
| #include "content/public/test/mock_download_item.h" |
| +#include "content/public/test/mock_download_item.h" |
| +#include "content/public/test/test_browser_context.h" |
| #include "content/public/test/test_browser_context.h" |
| #include "content/public/test/test_browser_thread_bundle.h" |
| +#include "content/public/test/web_contents_tester.h" |
| #include "testing/gmock/include/gmock/gmock.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| @@ -76,7 +81,6 @@ class MockDelegate : public DownloadItemImplDelegate { |
| void(DownloadUrlParameters* params, uint32_t id)); |
| MOCK_CONST_METHOD0(GetBrowserContext, BrowserContext*()); |
| - MOCK_METHOD1(UpdatePersistence, void(DownloadItemImpl*)); |
| MOCK_METHOD1(DownloadOpened, void(DownloadItemImpl*)); |
| MOCK_METHOD1(DownloadRemoved, void(DownloadItemImpl*)); |
| MOCK_CONST_METHOD1(AssertStateConsistent, void(DownloadItemImpl*)); |
| @@ -138,8 +142,8 @@ class TestDownloadItemObserver : public DownloadItem::Observer { |
| private: |
| void OnDownloadRemoved(DownloadItem* download) override { |
| - DVLOG(20) << " " << __FUNCTION__ |
| - << " download = " << download->DebugString(false); |
| + SCOPED_TRACE(::testing::Message() << " " << __FUNCTION__ << " download = " |
| + << download->DebugString(false)); |
| removed_ = true; |
| } |
| @@ -213,12 +217,20 @@ ACTION_P(InvokeClosure, closure) { |
| class DownloadItemTest : public testing::Test { |
| public: |
| - DownloadItemTest() { |
| + DownloadItemTest() |
| + : delegate_(), next_download_id_(DownloadItem::kInvalidId + 1) { |
| base::FeatureList::ClearInstanceForTesting(); |
| scoped_ptr<base::FeatureList> feature_list(new base::FeatureList); |
| feature_list->InitializeFromCommandLine(features::kDownloadResumption.name, |
| std::string()); |
| base::FeatureList::SetInstance(std::move(feature_list)); |
| + |
| + create_info_.reset(new DownloadCreateInfo()); |
| + create_info_->save_info = |
| + scoped_ptr<DownloadSaveInfo>(new DownloadSaveInfo()); |
| + create_info_->save_info->prompt_for_save_location = false; |
| + create_info_->url_chain.push_back(GURL("http://example.com/download")); |
| + create_info_->etag = "SomethingToSatisfyResumption"; |
| } |
| ~DownloadItemTest() { |
| @@ -238,24 +250,20 @@ class DownloadItemTest : public testing::Test { |
| // be torn down at the end of the test unless DestroyDownloadItem is |
| // called. |
| DownloadItemImpl* CreateDownloadItem() { |
| - scoped_ptr<DownloadCreateInfo> info; |
| - |
| - info.reset(new DownloadCreateInfo()); |
| - info->save_info = scoped_ptr<DownloadSaveInfo>(new DownloadSaveInfo()); |
| - info->save_info->prompt_for_save_location = false; |
| - info->url_chain.push_back(GURL("http://example.com/download")); |
| - info->etag = "SomethingToSatisfyResumption"; |
| - |
| - return CreateDownloadItemWithCreateInfo(std::move(info)); |
| + create_info_->download_id = ++next_download_id_; |
| + DownloadItemImpl* download = |
| + new DownloadItemImpl(&delegate_, create_info_->download_id, |
| + *create_info_, net::BoundNetLog()); |
| + allocated_downloads_.insert(download); |
| + return download; |
| } |
| // Add DownloadFile to DownloadItem |
| MockDownloadFile* CallDownloadItemStart( |
| DownloadItemImpl* item, |
| DownloadItemImplDelegate::DownloadTargetCallback* callback) { |
| - MockDownloadFile* mock_download_file(new StrictMock<MockDownloadFile>); |
| - scoped_ptr<DownloadFile> download_file(mock_download_file); |
| - EXPECT_CALL(*mock_download_file, Initialize(_)); |
| + MockDownloadFile* mock_download_file = nullptr; |
| + scoped_ptr<DownloadFile> download_file; |
| if (callback) { |
| // Save the callback. |
| EXPECT_CALL(*mock_delegate(), DetermineDownloadTarget(item, _)) |
| @@ -265,9 +273,22 @@ class DownloadItemTest : public testing::Test { |
| EXPECT_CALL(*mock_delegate(), DetermineDownloadTarget(item, _)); |
| } |
| - scoped_ptr<DownloadRequestHandleInterface> request_handle( |
| + // Only create a DownloadFile if the request was successful. |
| + if (create_info_->result == DOWNLOAD_INTERRUPT_REASON_NONE) { |
| + mock_download_file = new StrictMock<MockDownloadFile>; |
| + download_file.reset(mock_download_file); |
| + EXPECT_CALL(*mock_download_file, Initialize(_)) |
| + .WillOnce(InvokeCallbackWithParam(DOWNLOAD_INTERRUPT_REASON_NONE)); |
| + EXPECT_CALL(*mock_download_file, FullPath()) |
| + .WillRepeatedly(Return(base::FilePath())); |
| + } |
| + |
| + scoped_ptr<MockRequestHandle> request_handle( |
| new NiceMock<MockRequestHandle>); |
| - item->Start(std::move(download_file), std::move(request_handle)); |
| + EXPECT_CALL(*request_handle, GetWebContents()) |
| + .WillRepeatedly(Return(GetWebContents())); |
| + item->Start(std::move(download_file), std::move(request_handle), |
| + *create_info_); |
| RunAllPendingInMessageLoops(); |
| // So that we don't have a function writing to a stack variable |
| @@ -352,13 +373,57 @@ class DownloadItemTest : public testing::Test { |
| *return_path = path; |
| } |
| + DownloadCreateInfo* create_info() { return create_info_.get(); } |
| + |
| + virtual WebContents* GetWebContents() { return nullptr; } |
| + |
| private: |
| - int next_download_id_ = DownloadItem::kInvalidId + 1; |
| StrictMock<MockDelegate> delegate_; |
| std::set<DownloadItem*> allocated_downloads_; |
| + scoped_ptr<DownloadCreateInfo> create_info_; |
| + uint32_t next_download_id_ = DownloadItem::kInvalidId + 1; |
| TestBrowserThreadBundle thread_bundle_; |
| }; |
| +// Test fixture for resumption tests. The fixture takes a GTest parameter of |
| +// type 'bool'. If the parameter is true, then the DownloadItem has a valid |
| +// WebContents. It would have a null WebContents otherwise. Whether or not a |
| +// WebContents exists has a bearing on the code path used for resumption. Hence |
| +// it's important to exercise both possibilities for these tests. |
| +class DownloadItemTestWithResumption |
|
asanka
2016/02/12 16:06:49
No longer need two sets of tests since there's onl
Randy Smith (Not in Mondays)
2016/02/12 19:10:28
Acknowledged.
|
| + : public DownloadItemTest, |
| + public ::testing::WithParamInterface<bool> { |
| + public: |
| + void SetUp() override { |
| + browser_context_.reset(new TestBrowserContext); |
| + if (GetParam()) { |
| + scoped_refptr<SiteInstance> site_instance( |
| + SiteInstance::Create(browser_context_.get())); |
| + web_contents_.reset(WebContentsTester::CreateTestWebContents( |
| + browser_context_.get(), site_instance.get())); |
| + } |
| + DownloadItemTest::SetUp(); |
| + } |
| + |
| + void TearDown() override { |
| + DownloadItemTest::TearDown(); |
| + web_contents_.reset(); |
| + browser_context_.reset(); |
| + } |
| + |
| + WebContents* GetWebContents() override { return web_contents_.get(); } |
| + |
| + BrowserContext* GetBrowserContext() { return browser_context_.get(); } |
| + |
| + private: |
| + scoped_ptr<TestBrowserContext> browser_context_; |
| + scoped_ptr<WebContents> web_contents_; |
| +}; |
| + |
| +INSTANTIATE_TEST_CASE_P(WithAndWithoutWebContents, |
| + DownloadItemTestWithResumption, |
| + ::testing::Bool()); |
| + |
| // Tests to ensure calls that change a DownloadItem generate an update to |
| // observers. |
| // State changing functions not tested: |
| @@ -435,8 +500,8 @@ TEST_F(DownloadItemTest, NotificationAfterDestroyed) { |
| ASSERT_TRUE(observer.download_destroyed()); |
| } |
| -TEST_F(DownloadItemTest, ContinueAfterInterrupted) { |
| - TestBrowserContext test_browser_context; |
| +// Test that a download is resumed automatcially after a continuable interrupt. |
| +TEST_P(DownloadItemTestWithResumption, ContinueAfterInterrupted) { |
| DownloadItemImpl* item = CreateDownloadItem(); |
| TestDownloadItemObserver observer(item); |
| MockDownloadFile* download_file = |
| @@ -447,7 +512,7 @@ TEST_F(DownloadItemTest, ContinueAfterInterrupted) { |
| .WillOnce(Return(base::FilePath())); |
| EXPECT_CALL(*download_file, Detach()); |
| EXPECT_CALL(*mock_delegate(), GetBrowserContext()) |
| - .WillRepeatedly(Return(&test_browser_context)); |
| + .WillRepeatedly(Return(GetBrowserContext())); |
| EXPECT_CALL(*mock_delegate(), MockResumeInterruptedDownload(_, _)).Times(1); |
| item->DestinationObserverAsWeakPtr()->DestinationError( |
| DOWNLOAD_INTERRUPT_REASON_FILE_TRANSIENT_ERROR); |
| @@ -468,8 +533,9 @@ TEST_F(DownloadItemTest, ContinueAfterInterrupted) { |
| CleanupItem(item, nullptr, DownloadItem::IN_PROGRESS); |
| } |
| -// Same as above, but with a non-continuable interrupt. |
| -TEST_F(DownloadItemTest, RestartAfterInterrupted) { |
| +// Test that automatic resumption doesn't happen after a non-continuable |
| +// interrupt. |
| +TEST_P(DownloadItemTestWithResumption, RestartAfterInterrupted) { |
| DownloadItemImpl* item = CreateDownloadItem(); |
| TestDownloadItemObserver observer(item); |
| MockDownloadFile* download_file = |
| @@ -516,8 +582,7 @@ TEST_F(DownloadItemTest, UnresumableInterrupt) { |
| CleanupItem(item, nullptr, DownloadItem::INTERRUPTED); |
| } |
| -TEST_F(DownloadItemTest, LimitRestartsAfterInterrupted) { |
| - TestBrowserContext test_browser_context; |
| +TEST_P(DownloadItemTestWithResumption, LimitRestartsAfterInterrupted) { |
| DownloadItemImpl* item = CreateDownloadItem(); |
| base::WeakPtr<DownloadDestinationObserver> as_observer( |
| item->DestinationObserverAsWeakPtr()); |
| @@ -531,11 +596,11 @@ TEST_F(DownloadItemTest, LimitRestartsAfterInterrupted) { |
| EXPECT_CALL(*mock_delegate(), DetermineDownloadTarget(item, _)) |
| .WillRepeatedly(SaveArg<1>(&callback)); |
| EXPECT_CALL(*mock_delegate(), GetBrowserContext()) |
| - .WillRepeatedly(Return(&test_browser_context)); |
| + .WillRepeatedly(Return(GetBrowserContext())); |
| EXPECT_CALL(*mock_delegate(), MockResumeInterruptedDownload(_, _)) |
| .Times(DownloadItemImpl::kMaxAutoResumeAttempts); |
| for (int i = 0; i < (DownloadItemImpl::kMaxAutoResumeAttempts + 1); ++i) { |
| - DVLOG(20) << "Loop iteration " << i; |
| + SCOPED_TRACE(::testing::Message() << "Iteration " << i); |
| mock_download_file = new NiceMock<MockDownloadFile>; |
| download_file.reset(mock_download_file); |
| @@ -547,7 +612,8 @@ TEST_F(DownloadItemTest, LimitRestartsAfterInterrupted) { |
| // Copied key parts of DoIntermediateRename & CallDownloadItemStart |
| // to allow for holding onto the request handle. |
| - item->Start(std::move(download_file), std::move(request_handle)); |
| + item->Start(std::move(download_file), std::move(request_handle), |
| + *create_info()); |
| RunAllPendingInMessageLoops(); |
| base::FilePath target_path(kDummyTargetPath); |
| @@ -568,6 +634,7 @@ TEST_F(DownloadItemTest, LimitRestartsAfterInterrupted) { |
| item->DestinationObserverAsWeakPtr()->DestinationError( |
| DOWNLOAD_INTERRUPT_REASON_FILE_TRANSIENT_ERROR); |
| + RunAllPendingInMessageLoops(); |
| ::testing::Mock::VerifyAndClearExpectations(mock_download_file); |
| } |
| @@ -576,19 +643,72 @@ TEST_F(DownloadItemTest, LimitRestartsAfterInterrupted) { |
| CleanupItem(item, nullptr, DownloadItem::INTERRUPTED); |
| } |
| +// If the download attempts to resume and the resumption request fails, the |
| +// subsequent Start() call shouldn't update the origin state (URL redirect |
| +// chains, Content-Disposition, download URL, etc..) |
| +TEST_P(DownloadItemTestWithResumption, |
| + FailedResumptionDoesntUpdateOriginState) { |
| + const char kContentDisposition[] = "attachment; filename=foo"; |
| + const char kFirstETag[] = "ABC"; |
| + const char kFirstLastModified[] = "Yesterday"; |
| + const char kFirstURL[] = "http://www.example.com/download"; |
| + create_info()->content_disposition = kContentDisposition; |
| + create_info()->etag = kFirstETag; |
| + create_info()->last_modified = kFirstLastModified; |
| + create_info()->url_chain.push_back(GURL(kFirstURL)); |
| + |
| + DownloadItemImpl* item = CreateDownloadItem(); |
| + MockDownloadFile* download_file = |
| + DoIntermediateRename(item, DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS); |
| + EXPECT_EQ(kContentDisposition, item->GetContentDisposition()); |
| + EXPECT_EQ(kFirstETag, item->GetETag()); |
| + EXPECT_EQ(kFirstLastModified, item->GetLastModifiedTime()); |
| + EXPECT_EQ(kFirstURL, item->GetURL().spec()); |
| + |
| + EXPECT_CALL(*mock_delegate(), MockResumeInterruptedDownload(_, _)); |
| + EXPECT_CALL(*mock_delegate(), GetBrowserContext()) |
| + .WillRepeatedly(Return(GetBrowserContext())); |
| + EXPECT_CALL(*download_file, Detach()); |
| + item->DestinationObserverAsWeakPtr()->DestinationError( |
| + DOWNLOAD_INTERRUPT_REASON_FILE_TRANSIENT_ERROR); |
| + RunAllPendingInMessageLoops(); |
| + EXPECT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
| + |
| + // Now change the create info. The changes should not cause the DownloadItem |
| + // to be updated. |
| + const char kSecondContentDisposition[] = "attachment; filename=bar"; |
| + const char kSecondETag[] = "123"; |
| + const char kSecondLastModified[] = "Today"; |
| + const char kSecondURL[] = "http://example.com/another-download"; |
| + create_info()->content_disposition = kSecondContentDisposition; |
| + create_info()->etag = kSecondETag; |
| + create_info()->last_modified = kSecondLastModified; |
| + create_info()->url_chain.clear(); |
| + create_info()->url_chain.push_back(GURL(kSecondURL)); |
| + create_info()->result = DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED; |
| + |
| + // The following ends up calling DownloadItem::Start(), but shouldn't result |
| + // in an origin update. |
| + DownloadItemImplDelegate::DownloadTargetCallback download_target_callback; |
| + download_file = CallDownloadItemStart(item, &download_target_callback); |
| + |
| + EXPECT_EQ(kContentDisposition, item->GetContentDisposition()); |
| + EXPECT_EQ(kFirstETag, item->GetETag()); |
| + EXPECT_EQ(kFirstLastModified, item->GetLastModifiedTime()); |
| + EXPECT_EQ(kFirstURL, item->GetURL().spec()); |
| + EXPECT_EQ(DownloadItem::INTERRUPTED, item->GetState()); |
| + EXPECT_EQ(DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, item->GetLastReason()); |
| +} |
| + |
| // Test that resumption uses the final URL in a URL chain when resuming. |
| -TEST_F(DownloadItemTest, ResumeUsingFinalURL) { |
| - TestBrowserContext test_browser_context; |
| - scoped_ptr<DownloadCreateInfo> create_info(new DownloadCreateInfo); |
| - create_info->save_info = scoped_ptr<DownloadSaveInfo>(new DownloadSaveInfo()); |
| - create_info->save_info->prompt_for_save_location = false; |
| - create_info->etag = "SomethingToSatisfyResumption"; |
| - create_info->url_chain.push_back(GURL("http://example.com/a")); |
| - create_info->url_chain.push_back(GURL("http://example.com/b")); |
| - create_info->url_chain.push_back(GURL("http://example.com/c")); |
| - |
| - DownloadItemImpl* item = |
| - CreateDownloadItemWithCreateInfo(std::move(create_info)); |
| +TEST_P(DownloadItemTestWithResumption, ResumeUsingFinalURL) { |
| + create_info()->save_info->prompt_for_save_location = false; |
| + create_info()->url_chain.clear(); |
| + create_info()->url_chain.push_back(GURL("http://example.com/a")); |
| + create_info()->url_chain.push_back(GURL("http://example.com/b")); |
| + create_info()->url_chain.push_back(GURL("http://example.com/c")); |
| + |
| + DownloadItemImpl* item = CreateDownloadItem(); |
| TestDownloadItemObserver observer(item); |
| MockDownloadFile* download_file = |
| DoIntermediateRename(item, DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS); |
| @@ -597,7 +717,7 @@ TEST_F(DownloadItemTest, ResumeUsingFinalURL) { |
| EXPECT_CALL(*download_file, FullPath()).WillOnce(Return(base::FilePath())); |
| EXPECT_CALL(*download_file, Detach()); |
| EXPECT_CALL(*mock_delegate(), GetBrowserContext()) |
| - .WillRepeatedly(Return(&test_browser_context)); |
| + .WillRepeatedly(Return(GetBrowserContext())); |
| EXPECT_CALL(*mock_delegate(), MockResumeInterruptedDownload( |
| Property(&DownloadUrlParameters::url, |
| GURL("http://example.com/c")), |
| @@ -720,7 +840,8 @@ TEST_F(DownloadItemTest, NotificationAfterTogglePause) { |
| EXPECT_CALL(*mock_download_file, Initialize(_)); |
| EXPECT_CALL(*mock_delegate(), DetermineDownloadTarget(_, _)); |
| - item->Start(std::move(download_file), std::move(request_handle)); |
| + item->Start(std::move(download_file), std::move(request_handle), |
| + *create_info()); |
| item->Pause(); |
| ASSERT_TRUE(observer.CheckAndResetDownloadUpdated()); |
| @@ -767,12 +888,45 @@ TEST_F(DownloadItemTest, Start) { |
| scoped_ptr<DownloadRequestHandleInterface> request_handle( |
| new NiceMock<MockRequestHandle>); |
| EXPECT_CALL(*mock_delegate(), DetermineDownloadTarget(item, _)); |
| - item->Start(std::move(download_file), std::move(request_handle)); |
| + item->Start(std::move(download_file), std::move(request_handle), |
| + *create_info()); |
| RunAllPendingInMessageLoops(); |
| CleanupItem(item, mock_download_file, DownloadItem::IN_PROGRESS); |
| } |
| +// Handling of downloads initiated via a failed request. In this case, Start() |
| +// will get called with a DownloadCreateInfo with a non-zero interrupt_reason. |
| +TEST_F(DownloadItemTest, StartFailedDownload) { |
| + create_info()->result = DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED; |
| + DownloadItemImpl* item = CreateDownloadItem(); |
| + |
| + // DownloadFile and DownloadRequestHandleInterface objects aren't created for |
| + // failed downloads. |
| + scoped_ptr<DownloadFile> null_download_file; |
| + scoped_ptr<DownloadRequestHandleInterface> null_request_handle; |
| + DownloadItemImplDelegate::DownloadTargetCallback download_target_callback; |
| + EXPECT_CALL(*mock_delegate(), DetermineDownloadTarget(item, _)) |
| + .WillOnce(SaveArg<1>(&download_target_callback)); |
| + item->Start(std::move(null_download_file), std::move(null_request_handle), |
| + *create_info()); |
| + EXPECT_EQ(DownloadItem::INTERRUPTED, item->GetState()); |
| + RunAllPendingInMessageLoops(); |
| + |
| + // The DownloadItemImpl should attempt to determine a target path even if the |
| + // download was interrupted. |
| + ASSERT_FALSE(download_target_callback.is_null()); |
| + ASSERT_EQ(DownloadItem::INTERRUPTED, item->GetState()); |
| + base::FilePath target_path(FILE_PATH_LITERAL("foo")); |
| + download_target_callback.Run(target_path, |
| + DownloadItem::TARGET_DISPOSITION_OVERWRITE, |
| + DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, target_path); |
| + RunAllPendingInMessageLoops(); |
| + |
| + EXPECT_EQ(target_path, item->GetTargetFilePath()); |
| + CleanupItem(item, NULL, DownloadItem::INTERRUPTED); |
| +} |
| + |
| // Test that the delegate is invoked after the download file is renamed. |
| TEST_F(DownloadItemTest, CallbackAfterRename) { |
| DownloadItemImpl* item = CreateDownloadItem(); |
| @@ -889,7 +1043,8 @@ TEST_F(DownloadItemTest, InterruptedBeforeIntermediateRename_Restart) { |
| // As above. But if the download can be resumed by continuing, then the |
| // intermediate path should be retained when the download is interrupted after |
| // the intermediate rename succeeds. |
| -TEST_F(DownloadItemTest, InterruptedBeforeIntermediateRename_Continue) { |
| +TEST_P(DownloadItemTestWithResumption, |
| + InterruptedBeforeIntermediateRename_Continue) { |
| DownloadItemImpl* item = CreateDownloadItem(); |
| DownloadItemImplDelegate::DownloadTargetCallback callback; |
| MockDownloadFile* download_file = CallDownloadItemStart(item, &callback); |
| @@ -922,7 +1077,8 @@ TEST_F(DownloadItemTest, InterruptedBeforeIntermediateRename_Continue) { |
| // As above. If the intermediate rename fails, then the interrupt reason should |
| // be set to the destination error and the intermediate path should be empty. |
| -TEST_F(DownloadItemTest, InterruptedBeforeIntermediateRename_Failed) { |
| +TEST_P(DownloadItemTestWithResumption, |
| + InterruptedBeforeIntermediateRename_Failed) { |
| DownloadItemImpl* item = CreateDownloadItem(); |
| DownloadItemImplDelegate::DownloadTargetCallback callback; |
| MockDownloadFile* download_file = CallDownloadItemStart(item, &callback); |
| @@ -1330,7 +1486,7 @@ TEST_F(DownloadItemTest, StealDangerousDownload) { |
| EXPECT_EQ(full_path, returned_path); |
| } |
| -TEST_F(DownloadItemTest, StealInterruptedDangerousDownload) { |
| +TEST_P(DownloadItemTestWithResumption, StealInterruptedDangerousDownload) { |
| base::FilePath returned_path; |
| DownloadItemImpl* item = CreateDownloadItem(); |
| MockDownloadFile* download_file = |
| @@ -1354,7 +1510,8 @@ TEST_F(DownloadItemTest, StealInterruptedDangerousDownload) { |
| EXPECT_EQ(full_path, returned_path); |
| } |
| -TEST_F(DownloadItemTest, StealInterruptedNonResumableDangerousDownload) { |
| +TEST_P(DownloadItemTestWithResumption, |
| + StealInterruptedNonResumableDangerousDownload) { |
| base::FilePath returned_path; |
| DownloadItemImpl* item = CreateDownloadItem(); |
| MockDownloadFile* download_file = |
| @@ -1587,11 +1744,12 @@ TEST_P(DownloadItemDestinationUpdateRaceTest, InitDownloadFileFails) { |
| // result. |
| EXPECT_CALL(*file_, Cancel()); |
| EXPECT_CALL(*request_handle_, CancelRequest()); |
| + EXPECT_CALL(*mock_delegate(), DetermineDownloadTarget(_, _)); |
| EXPECT_CALL(*file_, Initialize(_)) |
| .WillOnce(InvokeCallbackWithParam( |
| DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED)); |
| - item_->Start(std::move(file_), std::move(request_handle_)); |
| + item_->Start(std::move(file_), std::move(request_handle_), *create_info()); |
| RunAllPendingInMessageLoops(); |
| @@ -1614,7 +1772,7 @@ TEST_P(DownloadItemDestinationUpdateRaceTest, DownloadCancelledByUser) { |
| .WillOnce(DoAll(SaveArg<0>(&initialize_callback), |
| InvokeClosure(initialize_loop.QuitClosure()))); |
| - item_->Start(std::move(file_), std::move(request_handle_)); |
| + item_->Start(std::move(file_), std::move(request_handle_), *create_info()); |
| initialize_loop.Run(); |
| base::WeakPtr<DownloadDestinationObserver> destination_observer = |
| item_->DestinationObserverAsWeakPtr(); |
| @@ -1662,7 +1820,7 @@ TEST_P(DownloadItemDestinationUpdateRaceTest, IntermediateRenameFails) { |
| .WillOnce(DoAll(SaveArg<0>(&initialize_callback), |
| InvokeClosure(initialize_loop.QuitClosure()))); |
| - item_->Start(std::move(file_), std::move(request_handle_)); |
| + item_->Start(std::move(file_), std::move(request_handle_), *create_info()); |
| initialize_loop.Run(); |
| base::WeakPtr<DownloadDestinationObserver> destination_observer = |
| item_->DestinationObserverAsWeakPtr(); |
| @@ -1725,7 +1883,7 @@ TEST_P(DownloadItemDestinationUpdateRaceTest, IntermediateRenameSucceeds) { |
| .WillOnce(DoAll(SaveArg<0>(&initialize_callback), |
| InvokeClosure(initialize_loop.QuitClosure()))); |
| - item_->Start(std::move(file_), std::move(request_handle_)); |
| + item_->Start(std::move(file_), std::move(request_handle_), *create_info()); |
| initialize_loop.Run(); |
| base::WeakPtr<DownloadDestinationObserver> destination_observer = |
| item_->DestinationObserverAsWeakPtr(); |