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 4f84f66dfe6a49dddbb3aa677460d08ceb629da6..7f047e66ca4f58623202537c157d181a961f5958 100644 |
--- a/content/browser/download/download_item_impl_unittest.cc |
+++ b/content/browser/download/download_item_impl_unittest.cc |
@@ -1541,7 +1541,7 @@ TEST_F(DownloadItemTest, CompleteDelegate_BlockTwice) { |
EXPECT_EQ(DownloadItem::COMPLETE, item->GetState()); |
} |
-TEST_F(DownloadItemTest, StealDangerousDownload) { |
+TEST_F(DownloadItemTest, StealDangerousDownloadAndDiscard) { |
DownloadItemImpl* item = CreateDownloadItem(); |
MockDownloadFile* download_file = |
DoIntermediateRename(item, DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE); |
@@ -1553,7 +1553,9 @@ TEST_F(DownloadItemTest, StealDangerousDownload) { |
EXPECT_CALL(*download_file, Detach()); |
EXPECT_CALL(*mock_delegate(), DownloadRemoved(_)); |
base::WeakPtrFactory<DownloadItemTest> weak_ptr_factory(this); |
+ item->OnAllDataSaved(0, std::unique_ptr<crypto::SecureHash>()); |
item->StealDangerousDownload( |
+ true, // delete_file_after_feedback |
base::Bind(&DownloadItemTest::OnDownloadFileAcquired, |
weak_ptr_factory.GetWeakPtr(), |
base::Unretained(&returned_path))); |
@@ -1561,6 +1563,26 @@ TEST_F(DownloadItemTest, StealDangerousDownload) { |
EXPECT_EQ(full_path, returned_path); |
} |
+TEST_F(DownloadItemTest, StealDangerousDownloadAndKeep) { |
+ DownloadItemImpl* item = CreateDownloadItem(); |
+ MockDownloadFile* download_file = |
+ DoIntermediateRename(item, DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE); |
+ ASSERT_TRUE(item->IsDangerous()); |
+ base::FilePath full_path(FILE_PATH_LITERAL("foo.txt")); |
+ base::FilePath returned_path; |
+ EXPECT_CALL(*download_file, FullPath()).WillOnce(ReturnRefOfCopy(full_path)); |
+ base::WeakPtrFactory<DownloadItemTest> weak_ptr_factory(this); |
+ item->OnAllDataSaved(0, std::unique_ptr<crypto::SecureHash>()); |
+ item->StealDangerousDownload( |
+ false, // delete_file_after_feedback |
+ base::Bind(&DownloadItemTest::OnDownloadFileAcquired, |
+ weak_ptr_factory.GetWeakPtr(), |
+ base::Unretained(&returned_path))); |
+ RunAllPendingInMessageLoops(); |
+ EXPECT_NE(full_path, returned_path); |
+ CleanupItem(item, download_file, DownloadItem::IN_PROGRESS); |
+} |
+ |
TEST_F(DownloadItemTest, StealInterruptedDangerousDownload) { |
base::FilePath returned_path; |
DownloadItemImpl* item = CreateDownloadItem(); |
@@ -1577,10 +1599,11 @@ TEST_F(DownloadItemTest, StealInterruptedDangerousDownload) { |
EXPECT_CALL(*mock_delegate(), DownloadRemoved(_)); |
base::WeakPtrFactory<DownloadItemTest> weak_ptr_factory(this); |
+ item->OnAllDataSaved(0, std::unique_ptr<crypto::SecureHash>()); |
item->StealDangerousDownload( |
- base::Bind(&DownloadItemTest::OnDownloadFileAcquired, |
- weak_ptr_factory.GetWeakPtr(), |
- base::Unretained(&returned_path))); |
+ true, base::Bind(&DownloadItemTest::OnDownloadFileAcquired, |
+ weak_ptr_factory.GetWeakPtr(), |
+ base::Unretained(&returned_path))); |
RunAllPendingInMessageLoops(); |
EXPECT_EQ(full_path, returned_path); |
} |
@@ -1598,10 +1621,11 @@ TEST_F(DownloadItemTest, StealInterruptedNonResumableDangerousDownload) { |
EXPECT_CALL(*mock_delegate(), DownloadRemoved(_)); |
base::WeakPtrFactory<DownloadItemTest> weak_ptr_factory(this); |
+ item->OnAllDataSaved(0, std::unique_ptr<crypto::SecureHash>()); |
item->StealDangerousDownload( |
- base::Bind(&DownloadItemTest::OnDownloadFileAcquired, |
- weak_ptr_factory.GetWeakPtr(), |
- base::Unretained(&returned_path))); |
+ true, base::Bind(&DownloadItemTest::OnDownloadFileAcquired, |
+ weak_ptr_factory.GetWeakPtr(), |
+ base::Unretained(&returned_path))); |
RunAllPendingInMessageLoops(); |
EXPECT_TRUE(returned_path.empty()); |
} |