Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6545)

Unified Diff: chrome/browser/download/download_target_determiner_unittest.cc

Issue 2641063002: Fix a problem that user validated dangerous download cannot resume (Closed)
Patch Set: remove dependencies Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/download/download_target_determiner.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/download_target_determiner_unittest.cc
diff --git a/chrome/browser/download/download_target_determiner_unittest.cc b/chrome/browser/download/download_target_determiner_unittest.cc
index 9cec6efb3b7ae9719a958ca68e529a69bcf54157..68585ab67bec87cacf2c0c63230dd29fa5f2da41 100644
--- a/chrome/browser/download/download_target_determiner_unittest.cc
+++ b/chrome/browser/download/download_target_determiner_unittest.cc
@@ -1912,6 +1912,44 @@ TEST_F(DownloadTargetDeterminerTest, MIMETypeDetermination) {
}
}
+// Test that a user validated download won't be treated as dangerous.
+TEST_F(DownloadTargetDeterminerTest, ResumedWithUserValidatedDownload) {
+ const base::FilePath::CharType kInitialPath[] =
+ FILE_PATH_LITERAL("some_path/bar.txt");
+ const base::FilePath::CharType* kIntermediatePath =
+ FILE_PATH_LITERAL("foo.crx.crdownload");
+
+ const DownloadTestCase kUserValidatedTestCase = {
+ AUTOMATIC,
+ content::DOWNLOAD_DANGER_TYPE_USER_VALIDATED,
+ DownloadFileType::NOT_DANGEROUS,
+ "http://example.com/foo.crx",
+ "",
+ FILE_PATH_LITERAL(""),
+ FILE_PATH_LITERAL("foo.crx"),
+ DownloadItem::TARGET_DISPOSITION_OVERWRITE,
+ EXPECT_CRDOWNLOAD};
+
+ const DownloadTestCase& test_case = kUserValidatedTestCase;
+ std::unique_ptr<content::MockDownloadItem> item(
+ CreateActiveDownloadItem(0, test_case));
+ base::FilePath expected_path =
+ GetPathInDownloadDir(test_case.expected_local_path);
+ ON_CALL(*item.get(), GetDangerType())
+ .WillByDefault(Return(content::DOWNLOAD_DANGER_TYPE_USER_VALIDATED));
+ ON_CALL(*item.get(), GetFullPath())
+ .WillByDefault(ReturnRefOfCopy(GetPathInDownloadDir(kIntermediatePath)));
+ ON_CALL(*item.get(), GetLastReason())
+ .WillByDefault(Return(content::DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED));
+ EXPECT_CALL(*delegate(), NotifyExtensions(_, _, _));
+ EXPECT_CALL(*delegate(), ReserveVirtualPath(_, expected_path, false, _, _));
+ EXPECT_CALL(*delegate(), PromptUserForDownloadPath(_, expected_path, _))
+ .Times(0);
+ EXPECT_CALL(*delegate(), DetermineLocalPath(_, expected_path, _));
+ EXPECT_CALL(*delegate(), CheckDownloadUrl(_, expected_path, _)).Times(0);
+ RunTestCase(test_case, GetPathInDownloadDir(kInitialPath), item.get());
+}
+
#if BUILDFLAG(ENABLE_PLUGINS)
void DummyGetPluginsCallback(
« no previous file with comments | « chrome/browser/download/download_target_determiner.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698