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 e5f5853471570f257558f6449ee54a840f262d35..0fe29f5e6b485276f79e31ac482c6e1825830b5b 100644 |
--- a/content/browser/download/download_item_impl_unittest.cc |
+++ b/content/browser/download/download_item_impl_unittest.cc |
@@ -34,25 +34,18 @@ namespace { |
class MockDelegate : public DownloadItemImplDelegate { |
public: |
MOCK_METHOD2(DetermineDownloadTarget, void( |
- DownloadItemImpl* download, const DownloadTargetCallback& callback)); |
- MOCK_METHOD1(ShouldOpenDownload, bool(DownloadItemImpl* download)); |
- MOCK_METHOD1(ShouldOpenFileBasedOnExtension, bool(const FilePath& path)); |
- MOCK_METHOD1(CheckForFileRemoval, void(DownloadItemImpl* download)); |
+ DownloadItemImpl* download, const DownloadTargetCallback&)); |
+ MOCK_METHOD1(ShouldOpenDownload, bool(DownloadItemImpl*)); |
+ MOCK_METHOD1(ShouldOpenFileBasedOnExtension, bool(const FilePath&)); |
+ MOCK_METHOD1(CheckForFileRemoval, void(DownloadItemImpl*)); |
MOCK_CONST_METHOD0(GetBrowserContext, BrowserContext*()); |
- MOCK_METHOD1(UpdatePersistence, void(DownloadItemImpl* download)); |
- MOCK_METHOD1(DownloadStopped, void(DownloadItemImpl* download)); |
- MOCK_METHOD1(DownloadCompleted, void(DownloadItemImpl* download)); |
- MOCK_METHOD1(DownloadOpened, void(DownloadItemImpl* download)); |
- MOCK_METHOD1(DownloadRemoved, void(DownloadItemImpl* download)); |
- MOCK_METHOD1(DownloadRenamedToIntermediateName, |
- void(DownloadItemImpl* download)); |
- MOCK_METHOD1(DownloadRenamedToFinalName, void(DownloadItemImpl* download)); |
- MOCK_CONST_METHOD1(AssertStateConsistent, void(DownloadItemImpl* download)); |
- virtual DownloadFileManager* GetDownloadFileManager() OVERRIDE { |
- return file_manager_; |
- } |
- private: |
- DownloadFileManager* file_manager_; |
+ MOCK_METHOD1(UpdatePersistence, void(DownloadItemImpl*)); |
+ MOCK_METHOD1(DownloadStopped, void(DownloadItemImpl*)); |
+ MOCK_METHOD1(DownloadCompleted, void(DownloadItemImpl*)); |
+ MOCK_METHOD1(DownloadOpened, void(DownloadItemImpl*)); |
+ MOCK_METHOD1(DownloadRemoved, void(DownloadItemImpl*)); |
+ MOCK_METHOD1(ShowDownloadInBrowser, void(DownloadItemImpl*)); |
+ MOCK_CONST_METHOD1(AssertStateConsistent, void(DownloadItemImpl*)); |
}; |
class MockRequestHandle : public DownloadRequestHandleInterface { |
@@ -459,10 +452,6 @@ TEST_F(DownloadItemTest, Start) { |
} |
// Test that the delegate is invoked after the download file is renamed. |
-// Delegate::DownloadRenamedToIntermediateName() should be invoked when the |
-// download is renamed to the intermediate name. |
-// Delegate::DownloadRenamedToFinalName() should be invoked after the final |
-// rename. |
TEST_F(DownloadItemTest, CallbackAfterRename) { |
DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS); |
DownloadItemImplDelegate::DownloadTargetCallback callback; |
@@ -473,15 +462,9 @@ TEST_F(DownloadItemTest, CallbackAfterRename) { |
FilePath new_intermediate_path(final_path.InsertBeforeExtensionASCII("y")); |
EXPECT_CALL(*download_file, Rename(intermediate_path, false, _)) |
.WillOnce(ScheduleRenameCallback(new_intermediate_path)); |
+ EXPECT_CALL(*mock_delegate(), ShowDownloadInBrowser(item)) |
+ .Times(1); |
- // DownloadItemImpl should invoke this callback on the delegate once the |
- // download is renamed to the intermediate name. Also check that GetFullPath() |
- // returns the intermediate path at the time of the call. |
- EXPECT_CALL(*mock_delegate(), |
- DownloadRenamedToIntermediateName( |
- AllOf(item, |
- Property(&DownloadItem::GetFullPath, |
- new_intermediate_path)))); |
callback.Run(final_path, DownloadItem::TARGET_DISPOSITION_OVERWRITE, |
DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, intermediate_path); |
RunAllPendingInMessageLoops(); |
@@ -492,21 +475,11 @@ TEST_F(DownloadItemTest, CallbackAfterRename) { |
item->OnAllDataSaved(""); |
EXPECT_CALL(*download_file, Rename(final_path, true, _)) |
.WillOnce(ScheduleRenameCallback(final_path)); |
- // DownloadItemImpl should invoke this callback on the delegate after the |
- // final rename has completed. Also check that GetFullPath() and |
- // GetTargetFilePath() return the final path at the time of the call. |
- EXPECT_CALL(*mock_delegate(), |
- DownloadRenamedToFinalName( |
- AllOf(item, |
- Property(&DownloadItem::GetFullPath, final_path), |
- Property(&DownloadItem::GetTargetFilePath, |
- final_path)))); |
EXPECT_CALL(*mock_delegate(), DownloadCompleted(item)); |
EXPECT_CALL(*mock_delegate(), ShouldOpenDownload(item)) |
.WillOnce(Return(true)); |
EXPECT_CALL(*download_file, Detach(_)) |
.WillOnce(ScheduleDetachCallback()); |
- item->SetIsPersisted(); |
item->MaybeCompleteDownload(); |
RunAllPendingInMessageLoops(); |
::testing::Mock::VerifyAndClearExpectations(download_file); |