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..f270481b21b078df5d50e5dba82e117839cc6aca 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); |
@@ -1554,6 +1554,7 @@ TEST_F(DownloadItemTest, StealDangerousDownload) { |
EXPECT_CALL(*mock_delegate(), DownloadRemoved(_)); |
base::WeakPtrFactory<DownloadItemTest> weak_ptr_factory(this); |
item->StealDangerousDownload( |
+ true, // delete_file_after_feedback |
base::Bind(&DownloadItemTest::OnDownloadFileAcquired, |
weak_ptr_factory.GetWeakPtr(), |
base::Unretained(&returned_path))); |
@@ -1561,6 +1562,25 @@ 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->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(); |
@@ -1578,9 +1598,9 @@ TEST_F(DownloadItemTest, StealInterruptedDangerousDownload) { |
EXPECT_CALL(*mock_delegate(), DownloadRemoved(_)); |
base::WeakPtrFactory<DownloadItemTest> weak_ptr_factory(this); |
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); |
} |
@@ -1599,9 +1619,9 @@ TEST_F(DownloadItemTest, StealInterruptedNonResumableDangerousDownload) { |
EXPECT_CALL(*mock_delegate(), DownloadRemoved(_)); |
base::WeakPtrFactory<DownloadItemTest> weak_ptr_factory(this); |
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()); |
} |