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

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

Issue 2618743006: Use previous target path when resuming a download after crash (Closed)
Patch Set: adding a helper function to get last used target path 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
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 e443b2d3e400766dc7ce82ec60887943d37c77c6..efca2125c050a527e15d5cea53e4e5fb33a13785 100644
--- a/chrome/browser/download/download_target_determiner_unittest.cc
+++ b/chrome/browser/download/download_target_determiner_unittest.cc
@@ -1618,6 +1618,37 @@ TEST_F(DownloadTargetDeterminerTest, ResumedForcedDownload) {
RunTestCase(test_case, GetPathInDownloadDir(kInitialPath), item.get());
}
+// Test that resuming a download will use the target file path if it is
+// provided.
+TEST_F(DownloadTargetDeterminerTest, ResumedWithTagetFilePath) {
+ const base::FilePath::CharType* kInitialPath =
+ FILE_PATH_LITERAL("some_path/bar.txt");
+ const DownloadTestCase kResumedDownload = {
+ AUTOMATIC,
+ content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
+ DownloadFileType::NOT_DANGEROUS,
+ "http://example.com/foo.txt",
+ "",
+ FILE_PATH_LITERAL(""),
+ FILE_PATH_LITERAL("target-foo.txt"),
+ DownloadItem::TARGET_DISPOSITION_OVERWRITE,
+ EXPECT_CRDOWNLOAD};
+
+ const DownloadTestCase& test_case = kResumedDownload;
+ base::FilePath expected_path =
+ GetPathInDownloadDir(test_case.expected_local_path);
+ std::unique_ptr<content::MockDownloadItem> item(
+ CreateActiveDownloadItem(0, test_case));
+ ON_CALL(*item.get(), GetTargetFilePath())
+ .WillByDefault(ReturnRefOfCopy(expected_path));
+ EXPECT_CALL(*delegate(), NotifyExtensions(_, _, _)).Times(0);
+ EXPECT_CALL(*delegate(), ReserveVirtualPath(_, expected_path, false, _, _));
+ EXPECT_CALL(*delegate(), PromptUserForDownloadPath(_, _, _)).Times(0);
+ EXPECT_CALL(*delegate(), DetermineLocalPath(_, expected_path, _));
+ EXPECT_CALL(*delegate(), CheckDownloadUrl(_, expected_path, _));
+ RunTestCase(test_case, GetPathInDownloadDir(kInitialPath), item.get());
+}
+
// Prompting behavior for resumed downloads is based on the last interrupt
// reason. If the reason indicates that the target path may not be suitable for
// the download (ACCESS_DENIED, NO_SPACE, etc..), then the user should be

Powered by Google App Engine
This is Rietveld 408576698