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 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
871 } | 871 } |
872 | 872 |
873 // Test that an inactive download will still get a virtual or local download | 873 // Test that an inactive download will still get a virtual or local download |
874 // path. | 874 // path. |
875 TEST_F(DownloadTargetDeterminerTest, TargetDeterminer_InactiveDownload) { | 875 TEST_F(DownloadTargetDeterminerTest, TargetDeterminer_InactiveDownload) { |
876 const DownloadTestCase kInactiveTestCases[] = { | 876 const DownloadTestCase kInactiveTestCases[] = { |
877 {AUTOMATIC, content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, | 877 {AUTOMATIC, content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, |
878 download_util::NOT_DANGEROUS, "http://example.com/foo.txt", "text/plain", | 878 download_util::NOT_DANGEROUS, "http://example.com/foo.txt", "text/plain", |
879 FILE_PATH_LITERAL(""), | 879 FILE_PATH_LITERAL(""), |
880 | 880 |
881 FILE_PATH_LITERAL(""), DownloadItem::TARGET_DISPOSITION_OVERWRITE, | 881 FILE_PATH_LITERAL("foo.txt"), DownloadItem::TARGET_DISPOSITION_OVERWRITE, |
882 | 882 |
883 EXPECT_LOCAL_PATH}, | 883 EXPECT_CRDOWNLOAD}, |
884 | 884 |
885 {SAVE_AS, content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, | 885 {SAVE_AS, content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, |
886 download_util::NOT_DANGEROUS, "http://example.com/foo.txt", "text/plain", | 886 download_util::NOT_DANGEROUS, "http://example.com/foo.txt", "text/plain", |
887 FILE_PATH_LITERAL(""), | 887 FILE_PATH_LITERAL(""), |
888 | 888 |
889 FILE_PATH_LITERAL(""), DownloadItem::TARGET_DISPOSITION_PROMPT, | 889 FILE_PATH_LITERAL("foo.txt"), DownloadItem::TARGET_DISPOSITION_PROMPT, |
890 | 890 |
891 EXPECT_LOCAL_PATH}}; | 891 EXPECT_CRDOWNLOAD}}; |
892 | 892 |
893 for (size_t i = 0; i < arraysize(kInactiveTestCases); ++i) { | 893 for (size_t i = 0; i < arraysize(kInactiveTestCases); ++i) { |
894 SCOPED_TRACE(testing::Message() << "Running test case " << i); | 894 SCOPED_TRACE(testing::Message() << "Running test case " << i); |
895 const DownloadTestCase& test_case = kInactiveTestCases[i]; | 895 const DownloadTestCase& test_case = kInactiveTestCases[i]; |
896 scoped_ptr<content::MockDownloadItem> item( | 896 scoped_ptr<content::MockDownloadItem> item( |
897 CreateActiveDownloadItem(i, test_case)); | 897 CreateActiveDownloadItem(i, test_case)); |
898 EXPECT_CALL(*item.get(), GetState()) | 898 EXPECT_CALL(*item.get(), GetState()) |
899 .WillRepeatedly(Return(content::DownloadItem::CANCELLED)); | 899 .WillRepeatedly(Return(content::DownloadItem::CANCELLED)); |
900 // Even though one is a SAVE_AS download, no prompt will be displayed to | 900 |
901 // the user because the download is inactive. | 901 EXPECT_CALL(*delegate(), PromptUserForDownloadPath(_, _, _)).Times(0); |
902 EXPECT_CALL(*delegate(), PromptUserForDownloadPath(_, _, _)) | 902 EXPECT_CALL(*delegate(), NotifyExtensions(_, _, _)).Times(0); |
903 .Times(0); | 903 EXPECT_CALL(*delegate(), ReserveVirtualPath(_, _, _, _, _)).Times(0); |
| 904 EXPECT_CALL(*delegate(), DetermineLocalPath(_, _, _)).Times(1); |
904 RunTestCase(test_case, base::FilePath(), item.get()); | 905 RunTestCase(test_case, base::FilePath(), item.get()); |
905 } | 906 } |
906 } | 907 } |
907 | 908 |
908 // If the reserved path could not be verified, then the user should see a | 909 // If the reserved path could not be verified, then the user should see a |
909 // prompt. | 910 // prompt. |
910 TEST_F(DownloadTargetDeterminerTest, TargetDeterminer_ReservationFailed) { | 911 TEST_F(DownloadTargetDeterminerTest, TargetDeterminer_ReservationFailed) { |
911 const DownloadTestCase kReservationFailedCases[] = { | 912 const DownloadTestCase kReservationFailedCases[] = { |
912 {// 0: Automatic download. Since the reservation fails, the disposition of | 913 {// 0: Automatic download. Since the reservation fails, the disposition of |
913 // the target is to prompt, but the returned path is used. | 914 // the target is to prompt, but the returned path is used. |
(...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2080 EXPECT_CALL(mock_plugin_filter_, MockPluginAvailable(npapi_plugin.path())) | 2081 EXPECT_CALL(mock_plugin_filter_, MockPluginAvailable(npapi_plugin.path())) |
2081 .WillRepeatedly(Return(true)); | 2082 .WillRepeatedly(Return(true)); |
2082 | 2083 |
2083 target_info = RunDownloadTargetDeterminer( | 2084 target_info = RunDownloadTargetDeterminer( |
2084 GetPathInDownloadDir(kInitialPath), item.get()); | 2085 GetPathInDownloadDir(kInitialPath), item.get()); |
2085 EXPECT_FALSE(target_info->is_filetype_handled_safely); | 2086 EXPECT_FALSE(target_info->is_filetype_handled_safely); |
2086 } | 2087 } |
2087 #endif // defined(ENABLE_PLUGINS) | 2088 #endif // defined(ENABLE_PLUGINS) |
2088 | 2089 |
2089 } // namespace | 2090 } // namespace |
OLD | NEW |