| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include "base/at_exit.h" | 8 #include "base/at_exit.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| (...skipping 1600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1611 EXPECT_CALL(*delegate(), NotifyExtensions(_, _, _)) | 1611 EXPECT_CALL(*delegate(), NotifyExtensions(_, _, _)) |
| 1612 .Times(test_case.test_type == AUTOMATIC ? 1 : 0); | 1612 .Times(test_case.test_type == AUTOMATIC ? 1 : 0); |
| 1613 EXPECT_CALL(*delegate(), ReserveVirtualPath(_, expected_path, false, _, _)); | 1613 EXPECT_CALL(*delegate(), ReserveVirtualPath(_, expected_path, false, _, _)); |
| 1614 EXPECT_CALL(*delegate(), PromptUserForDownloadPath(_, _, _)) | 1614 EXPECT_CALL(*delegate(), PromptUserForDownloadPath(_, _, _)) |
| 1615 .Times(0); | 1615 .Times(0); |
| 1616 EXPECT_CALL(*delegate(), DetermineLocalPath(_, expected_path, _)); | 1616 EXPECT_CALL(*delegate(), DetermineLocalPath(_, expected_path, _)); |
| 1617 EXPECT_CALL(*delegate(), CheckDownloadUrl(_, expected_path, _)); | 1617 EXPECT_CALL(*delegate(), CheckDownloadUrl(_, expected_path, _)); |
| 1618 RunTestCase(test_case, GetPathInDownloadDir(kInitialPath), item.get()); | 1618 RunTestCase(test_case, GetPathInDownloadDir(kInitialPath), item.get()); |
| 1619 } | 1619 } |
| 1620 | 1620 |
| 1621 // Test that resuming a download will use the target file path if it is |
| 1622 // provided. |
| 1623 TEST_F(DownloadTargetDeterminerTest, ResumedWithTagetFilePath) { |
| 1624 const base::FilePath::CharType* kInitialPath = |
| 1625 FILE_PATH_LITERAL("some_path/bar.txt"); |
| 1626 const DownloadTestCase kResumedDownload = { |
| 1627 AUTOMATIC, |
| 1628 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, |
| 1629 DownloadFileType::NOT_DANGEROUS, |
| 1630 "http://example.com/foo.txt", |
| 1631 "", |
| 1632 FILE_PATH_LITERAL(""), |
| 1633 FILE_PATH_LITERAL("target-foo.txt"), |
| 1634 DownloadItem::TARGET_DISPOSITION_OVERWRITE, |
| 1635 EXPECT_CRDOWNLOAD}; |
| 1636 |
| 1637 const DownloadTestCase& test_case = kResumedDownload; |
| 1638 base::FilePath expected_path = |
| 1639 GetPathInDownloadDir(test_case.expected_local_path); |
| 1640 std::unique_ptr<content::MockDownloadItem> item( |
| 1641 CreateActiveDownloadItem(0, test_case)); |
| 1642 ON_CALL(*item.get(), GetTargetFilePath()) |
| 1643 .WillByDefault(ReturnRefOfCopy(expected_path)); |
| 1644 EXPECT_CALL(*delegate(), NotifyExtensions(_, _, _)).Times(0); |
| 1645 EXPECT_CALL(*delegate(), ReserveVirtualPath(_, expected_path, false, _, _)); |
| 1646 EXPECT_CALL(*delegate(), PromptUserForDownloadPath(_, _, _)).Times(0); |
| 1647 EXPECT_CALL(*delegate(), DetermineLocalPath(_, expected_path, _)); |
| 1648 EXPECT_CALL(*delegate(), CheckDownloadUrl(_, expected_path, _)); |
| 1649 RunTestCase(test_case, GetPathInDownloadDir(kInitialPath), item.get()); |
| 1650 } |
| 1651 |
| 1621 // Prompting behavior for resumed downloads is based on the last interrupt | 1652 // Prompting behavior for resumed downloads is based on the last interrupt |
| 1622 // reason. If the reason indicates that the target path may not be suitable for | 1653 // reason. If the reason indicates that the target path may not be suitable for |
| 1623 // the download (ACCESS_DENIED, NO_SPACE, etc..), then the user should be | 1654 // the download (ACCESS_DENIED, NO_SPACE, etc..), then the user should be |
| 1624 // prompted, and not otherwise. These test cases result in prompting since the | 1655 // prompted, and not otherwise. These test cases result in prompting since the |
| 1625 // error is set to NO_SPACE. | 1656 // error is set to NO_SPACE. |
| 1626 TEST_F(DownloadTargetDeterminerTest, ResumedWithPrompt) { | 1657 TEST_F(DownloadTargetDeterminerTest, ResumedWithPrompt) { |
| 1627 // All test cases run with GetPathInDownloadDir(kInitialPath) as the inital | 1658 // All test cases run with GetPathInDownloadDir(kInitialPath) as the inital |
| 1628 // path. | 1659 // path. |
| 1629 const base::FilePath::CharType* kInitialPath = | 1660 const base::FilePath::CharType* kInitialPath = |
| 1630 FILE_PATH_LITERAL("some_path/bar.txt"); | 1661 FILE_PATH_LITERAL("some_path/bar.txt"); |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2160 EXPECT_CALL(mock_plugin_filter_, MockPluginAvailable(browser_plugin.path())) | 2191 EXPECT_CALL(mock_plugin_filter_, MockPluginAvailable(browser_plugin.path())) |
| 2161 .WillRepeatedly(Return(false)); | 2192 .WillRepeatedly(Return(false)); |
| 2162 target_info = RunDownloadTargetDeterminer( | 2193 target_info = RunDownloadTargetDeterminer( |
| 2163 GetPathInDownloadDir(kInitialPath), item.get()); | 2194 GetPathInDownloadDir(kInitialPath), item.get()); |
| 2164 EXPECT_FALSE(target_info->is_filetype_handled_safely); | 2195 EXPECT_FALSE(target_info->is_filetype_handled_safely); |
| 2165 } | 2196 } |
| 2166 | 2197 |
| 2167 #endif // BUILDFLAG(ENABLE_PLUGINS) | 2198 #endif // BUILDFLAG(ENABLE_PLUGINS) |
| 2168 | 2199 |
| 2169 } // namespace | 2200 } // namespace |
| OLD | NEW |