| 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 "base/at_exit.h" | 5 #include "base/at_exit.h" |
| 6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
| 7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/observer_list.h" | 9 #include "base/observer_list.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 916 // Test that an inactive download will still get a virtual or local download | 916 // Test that an inactive download will still get a virtual or local download |
| 917 // path. | 917 // path. |
| 918 TEST_F(DownloadTargetDeterminerTest, TargetDeterminer_InactiveDownload) { | 918 TEST_F(DownloadTargetDeterminerTest, TargetDeterminer_InactiveDownload) { |
| 919 const DownloadTestCase kInactiveTestCases[] = { | 919 const DownloadTestCase kInactiveTestCases[] = { |
| 920 { | 920 { |
| 921 AUTOMATIC, | 921 AUTOMATIC, |
| 922 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, | 922 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, |
| 923 "http://example.com/foo.txt", "text/plain", | 923 "http://example.com/foo.txt", "text/plain", |
| 924 FILE_PATH_LITERAL(""), | 924 FILE_PATH_LITERAL(""), |
| 925 | 925 |
| 926 FILE_PATH_LITERAL(""), | 926 FILE_PATH_LITERAL("foo.txt"), |
| 927 DownloadItem::TARGET_DISPOSITION_OVERWRITE, | 927 DownloadItem::TARGET_DISPOSITION_OVERWRITE, |
| 928 | 928 |
| 929 EXPECT_LOCAL_PATH | 929 EXPECT_CRDOWNLOAD |
| 930 }, | 930 }, |
| 931 | 931 |
| 932 { | 932 { |
| 933 SAVE_AS, | 933 SAVE_AS, |
| 934 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, | 934 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, |
| 935 "http://example.com/foo.txt", "text/plain", | 935 "http://example.com/foo.txt", "text/plain", |
| 936 FILE_PATH_LITERAL(""), | 936 FILE_PATH_LITERAL(""), |
| 937 | 937 |
| 938 FILE_PATH_LITERAL(""), | 938 FILE_PATH_LITERAL("foo.txt"), |
| 939 DownloadItem::TARGET_DISPOSITION_PROMPT, | 939 DownloadItem::TARGET_DISPOSITION_PROMPT, |
| 940 | 940 |
| 941 EXPECT_LOCAL_PATH | 941 EXPECT_CRDOWNLOAD |
| 942 } | 942 } |
| 943 }; | 943 }; |
| 944 | 944 |
| 945 for (size_t i = 0; i < arraysize(kInactiveTestCases); ++i) { | 945 for (size_t i = 0; i < arraysize(kInactiveTestCases); ++i) { |
| 946 SCOPED_TRACE(testing::Message() << "Running test case " << i); | 946 SCOPED_TRACE(testing::Message() << "Running test case " << i); |
| 947 const DownloadTestCase& test_case = kInactiveTestCases[i]; | 947 const DownloadTestCase& test_case = kInactiveTestCases[i]; |
| 948 scoped_ptr<content::MockDownloadItem> item( | 948 scoped_ptr<content::MockDownloadItem> item( |
| 949 CreateActiveDownloadItem(i, test_case)); | 949 CreateActiveDownloadItem(i, test_case)); |
| 950 EXPECT_CALL(*item.get(), GetState()) | 950 EXPECT_CALL(*item.get(), GetState()) |
| 951 .WillRepeatedly(Return(content::DownloadItem::CANCELLED)); | 951 .WillRepeatedly(Return(content::DownloadItem::CANCELLED)); |
| 952 // Even though one is a SAVE_AS download, no prompt will be displayed to | 952 |
| 953 // the user because the download is inactive. | 953 // The following delegate methods should not be invoked for an inactive |
| 954 EXPECT_CALL(*delegate(), PromptUserForDownloadPath(_, _, _)) | 954 // download. |
| 955 .Times(0); | 955 EXPECT_CALL(*delegate(), PromptUserForDownloadPath(_, _, _)).Times(0); |
| 956 EXPECT_CALL(*delegate(), NotifyExtensions(_, _, _)).Times(0); |
| 957 EXPECT_CALL(*delegate(), ReserveVirtualPath(_, _, _, _, _)).Times(0); |
| 958 EXPECT_CALL(*delegate(), DetermineLocalPath(_, _, _)).Times(1); |
| 956 RunTestCase(test_case, base::FilePath(), item.get()); | 959 RunTestCase(test_case, base::FilePath(), item.get()); |
| 957 } | 960 } |
| 958 } | 961 } |
| 959 | 962 |
| 960 // If the reserved path could not be verified, then the user should see a | 963 // If the reserved path could not be verified, then the user should see a |
| 961 // prompt. | 964 // prompt. |
| 962 TEST_F(DownloadTargetDeterminerTest, TargetDeterminer_ReservationFailed) { | 965 TEST_F(DownloadTargetDeterminerTest, TargetDeterminer_ReservationFailed) { |
| 963 const DownloadTestCase kReservationFailedCases[] = { | 966 const DownloadTestCase kReservationFailedCases[] = { |
| 964 { | 967 { |
| 965 // 0: Automatic download. Since the reservation fails, the disposition of | 968 // 0: Automatic download. Since the reservation fails, the disposition of |
| (...skipping 1213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2179 EXPECT_CALL(mock_plugin_filter_, MockPluginAvailable(npapi_plugin.path())) | 2182 EXPECT_CALL(mock_plugin_filter_, MockPluginAvailable(npapi_plugin.path())) |
| 2180 .WillRepeatedly(Return(true)); | 2183 .WillRepeatedly(Return(true)); |
| 2181 | 2184 |
| 2182 target_info = RunDownloadTargetDeterminer( | 2185 target_info = RunDownloadTargetDeterminer( |
| 2183 GetPathInDownloadDir(kInitialPath), item.get()); | 2186 GetPathInDownloadDir(kInitialPath), item.get()); |
| 2184 EXPECT_FALSE(target_info->is_filetype_handled_safely); | 2187 EXPECT_FALSE(target_info->is_filetype_handled_safely); |
| 2185 } | 2188 } |
| 2186 #endif // defined(ENABLE_PLUGINS) | 2189 #endif // defined(ENABLE_PLUGINS) |
| 2187 | 2190 |
| 2188 } // namespace | 2191 } // namespace |
| OLD | NEW |