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 <sstream> | |
cbentzel
2012/03/02 20:07:57
Why not just use stringprintf to create this?
| |
6 | |
5 #include "base/bind.h" | 7 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
7 #include "base/file_path.h" | 9 #include "base/file_path.h" |
8 #include "base/file_util.h" | 10 #include "base/file_util.h" |
9 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
10 #include "base/path_service.h" | 12 #include "base/path_service.h" |
11 #include "base/scoped_temp_dir.h" | 13 #include "base/scoped_temp_dir.h" |
12 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
13 #include "base/stringprintf.h" | 15 #include "base/stringprintf.h" |
14 #include "base/test/test_file_util.h" | 16 #include "base/test/test_file_util.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
48 #include "content/browser/net/url_request_mock_http_job.h" | 50 #include "content/browser/net/url_request_mock_http_job.h" |
49 #include "content/browser/net/url_request_slow_download_job.h" | 51 #include "content/browser/net/url_request_slow_download_job.h" |
50 #include "content/browser/renderer_host/render_view_host.h" | 52 #include "content/browser/renderer_host/render_view_host.h" |
51 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 53 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
52 #include "content/public/browser/download_item.h" | 54 #include "content/public/browser/download_item.h" |
53 #include "content/public/browser/download_manager.h" | 55 #include "content/public/browser/download_manager.h" |
54 #include "content/public/browser/notification_source.h" | 56 #include "content/public/browser/notification_source.h" |
55 #include "content/public/browser/web_contents.h" | 57 #include "content/public/browser/web_contents.h" |
56 #include "content/public/common/context_menu_params.h" | 58 #include "content/public/common/context_menu_params.h" |
57 #include "content/public/common/page_transition_types.h" | 59 #include "content/public/common/page_transition_types.h" |
60 #include "content/test/test_file_error_injector.h" | |
58 #include "content/test/test_navigation_observer.h" | 61 #include "content/test/test_navigation_observer.h" |
59 #include "net/base/net_util.h" | 62 #include "net/base/net_util.h" |
60 #include "testing/gtest/include/gtest/gtest.h" | 63 #include "testing/gtest/include/gtest/gtest.h" |
61 | 64 |
62 using content::BrowserThread; | 65 using content::BrowserThread; |
63 using content::DownloadItem; | 66 using content::DownloadItem; |
64 using content::DownloadManager; | 67 using content::DownloadManager; |
65 using content::WebContents; | 68 using content::WebContents; |
66 | 69 |
67 namespace { | 70 namespace { |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
299 }; | 302 }; |
300 | 303 |
301 // Information passed in to |DownloadFileCheckErrors()|. | 304 // Information passed in to |DownloadFileCheckErrors()|. |
302 struct DownloadInfo { | 305 struct DownloadInfo { |
303 const char* url_name; // URL for the download. | 306 const char* url_name; // URL for the download. |
304 DownloadMethod download_method; // Navigation or Direct. | 307 DownloadMethod download_method; // Navigation or Direct. |
305 InterruptReason reason; // Download interrupt reason (NONE is OK). | 308 InterruptReason reason; // Download interrupt reason (NONE is OK). |
306 bool show_download_item; // True if the download item appears on the shelf. | 309 bool show_download_item; // True if the download item appears on the shelf. |
307 }; | 310 }; |
308 | 311 |
312 struct FileErrorInjectInfo { | |
313 DownloadInfo download_info; | |
314 content::TestFileErrorInjector::FileErrorInfo error_info; | |
315 }; | |
316 | |
309 DownloadTest() { | 317 DownloadTest() { |
310 EnableDOMAutomation(); | 318 EnableDOMAutomation(); |
311 } | 319 } |
312 | 320 |
313 void SetUpOnMainThread() OVERRIDE { | 321 void SetUpOnMainThread() OVERRIDE { |
314 BrowserThread::PostTask( | 322 BrowserThread::PostTask( |
315 BrowserThread::IO, FROM_HERE, | 323 BrowserThread::IO, FROM_HERE, |
316 base::Bind(&chrome_browser_net::SetUrlRequestMocksEnabled, true)); | 324 base::Bind(&chrome_browser_net::SetUrlRequestMocksEnabled, true)); |
317 } | 325 } |
318 | 326 |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
673 return false; | 681 return false; |
674 | 682 |
675 // Check the contents. | 683 // Check the contents. |
676 EXPECT_EQ(value, file_contents); | 684 EXPECT_EQ(value, file_contents); |
677 if (memcmp(file_contents.c_str(), value.c_str(), expected_size) != 0) | 685 if (memcmp(file_contents.c_str(), value.c_str(), expected_size) != 0) |
678 return false; | 686 return false; |
679 | 687 |
680 return true; | 688 return true; |
681 } | 689 } |
682 | 690 |
683 // Attempts to download a file, based on information in |download_info|. | 691 void DownloadFilesCheckErrorsSetup() { |
684 void DownloadFileCheckErrors(const DownloadInfo& download_info) { | |
685 ASSERT_TRUE(test_server()->Start()); | 692 ASSERT_TRUE(test_server()->Start()); |
686 std::vector<DownloadItem*> download_items; | 693 std::vector<DownloadItem*> download_items; |
687 GetDownloads(browser(), &download_items); | 694 GetDownloads(browser(), &download_items); |
688 ASSERT_TRUE(download_items.empty()); | 695 ASSERT_TRUE(download_items.empty()); |
689 | 696 |
690 NullSelectFile(browser()); | 697 NullSelectFile(browser()); |
698 } | |
699 | |
700 void DownloadFilesCheckErrorsLoop(const DownloadInfo& download_info, | |
701 size_t i) { | |
702 std::stringstream s; | |
703 s << " " << __FUNCTION__ << "()" | |
cbentzel
2012/03/02 20:45:19
I guess stringstream makes sense here.
| |
704 << " index = " << i | |
705 << " url = '" << download_info.url_name << "'" | |
706 << " method = " | |
707 << ((download_info.download_method == DOWNLOAD_DIRECT) ? | |
708 "DOWNLOAD_DIRECT" : "DOWNLOAD_NAVIGATE") | |
709 << " show_item = " << download_info.show_download_item | |
710 << " reason = " | |
711 << InterruptReasonDebugString(download_info.reason); | |
712 | |
713 std::vector<DownloadItem*> download_items; | |
714 GetDownloads(browser(), &download_items); | |
715 size_t downloads_expected = download_items.size(); | |
691 | 716 |
692 std::string server_path = "files/downloads/"; | 717 std::string server_path = "files/downloads/"; |
693 server_path += download_info.url_name; | 718 server_path += download_info.url_name; |
694 GURL url = test_server()->GetURL(server_path); | 719 GURL url = test_server()->GetURL(server_path); |
695 ASSERT_TRUE(url.is_valid()); | 720 ASSERT_TRUE(url.is_valid()) << s.str(); |
696 | 721 |
697 DownloadManager* download_manager = DownloadManagerForBrowser(browser()); | 722 DownloadManager* download_manager = DownloadManagerForBrowser(browser()); |
723 WebContents* web_contents = browser()->GetSelectedWebContents(); | |
724 ASSERT_TRUE(web_contents) << s.str(); | |
725 | |
726 size_t direct_downloads_expected = 0; | |
698 scoped_ptr<DownloadTestObserver> observer( | 727 scoped_ptr<DownloadTestObserver> observer( |
699 new DownloadTestObserver( | 728 new DownloadTestObserver( |
700 download_manager, | 729 download_manager, |
701 1, | 730 1, |
702 download_info.reason == DOWNLOAD_INTERRUPT_REASON_NONE ? | 731 download_info.reason == DOWNLOAD_INTERRUPT_REASON_NONE ? |
703 DownloadItem::COMPLETE : // Really done | 732 DownloadItem::COMPLETE : // Really done. |
704 DownloadItem::INTERRUPTED, | 733 DownloadItem::INTERRUPTED, // Error detected. |
705 false, // Don't bail on select file. | 734 false, // Don't bail on select file. |
706 DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL)); | 735 DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL)); |
707 | 736 |
708 if (download_info.download_method == DOWNLOAD_DIRECT) { | 737 if (download_info.download_method == DOWNLOAD_DIRECT) { |
709 // Go directly to download. | 738 // Go directly to download. Don't wait until it's done. |
710 WebContents* web_contents = browser()->GetSelectedWebContents(); | |
711 ASSERT_TRUE(web_contents); | |
712 DownloadSaveInfo save_info; | 739 DownloadSaveInfo save_info; |
740 // NOTE: |prompt_for_save_location| may change during the download. | |
713 save_info.prompt_for_save_location = false; | 741 save_info.prompt_for_save_location = false; |
714 | 742 |
715 scoped_refptr<DownloadTestItemCreationObserver> creation_observer( | 743 scoped_refptr<DownloadTestItemCreationObserver> creation_observer( |
716 new DownloadTestItemCreationObserver); | 744 new DownloadTestItemCreationObserver); |
717 | 745 |
718 DownloadManagerForBrowser(browser())->DownloadUrl( | 746 DownloadManagerForBrowser(browser())->DownloadUrl( |
719 url, GURL(""), "", false, -1, save_info, web_contents, | 747 url, GURL(""), "", false, -1, save_info, web_contents, |
720 creation_observer->callback()); | 748 creation_observer->callback()); |
721 | 749 |
722 // Wait until the item is created, or we have determined that it | 750 // Wait until the item is created, or we have determined that it |
723 // won't be. | 751 // won't be. |
724 creation_observer->WaitForDownloadItemCreation(); | 752 creation_observer->WaitForDownloadItemCreation(); |
725 | 753 |
726 EXPECT_EQ(download_info.show_download_item, creation_observer->started()); | 754 EXPECT_EQ(download_info.show_download_item, creation_observer->started()); |
727 } else { | 755 } else { |
728 // Navigate to URL normally, wait until done. | 756 // Navigate to URL normally, wait until done. |
729 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(browser(), | 757 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(browser(), |
730 url, | 758 url, |
731 1); | 759 1); |
732 } | 760 } |
733 | 761 |
734 if (download_info.show_download_item) { | 762 if (download_info.show_download_item) { |
763 downloads_expected++; | |
735 observer->WaitForFinished(); | 764 observer->WaitForFinished(); |
736 DCHECK_EQ(0u, observer->NumOtherDownloadsSeen()); | 765 DCHECK_EQ(0u, observer->NumOtherDownloadsSeen()); |
737 } | 766 } |
738 | 767 |
739 // Validate that the correct file was downloaded. | 768 // Wait till the download files are destroyed. |
769 ui_test_utils::RunAllPendingInMessageLoop(content::BrowserThread::FILE); | |
770 ui_test_utils::RunAllPendingInMessageLoop(content::BrowserThread::UI); | |
771 | |
772 // Validate that the correct files were downloaded. | |
740 download_items.clear(); | 773 download_items.clear(); |
741 GetDownloads(browser(), &download_items); | 774 GetDownloads(browser(), &download_items); |
742 size_t item_count = download_info.show_download_item ? 1 : 0; | 775 ASSERT_EQ(downloads_expected, download_items.size()) << s.str(); |
743 ASSERT_EQ(item_count, download_items.size()); | |
744 | 776 |
745 if (download_info.show_download_item) { | 777 if (download_info.show_download_item) { |
778 // Find the last download item. | |
746 DownloadItem* item = download_items[0]; | 779 DownloadItem* item = download_items[0]; |
747 ASSERT_EQ(url, item->GetOriginalUrl()); | 780 for (size_t d = 1; d < downloads_expected; ++d) { |
781 if (download_items[d]->GetStartTime() > item->GetStartTime()) | |
782 item = download_items[d]; | |
783 } | |
748 | 784 |
749 ASSERT_EQ(download_info.reason, item->GetLastReason()); | 785 ASSERT_EQ(url, item->GetOriginalUrl()) << s.str(); |
786 | |
787 ASSERT_EQ(download_info.reason, item->GetLastReason()) << s.str(); | |
750 } | 788 } |
751 } | 789 } |
752 | 790 |
791 // Attempts to download a set of files, based on information in the | |
792 // |download_info| array. |count| is the number of files. | |
793 // If a Select File dialog appears, it will choose the default and return | |
794 // immediately. | |
795 void DownloadFilesCheckErrors(size_t count, DownloadInfo* download_info) { | |
796 DownloadFilesCheckErrorsSetup(); | |
797 | |
798 for (size_t i = 0; i < count; ++i) { | |
799 DownloadFilesCheckErrorsLoop(download_info[i], i); | |
800 } | |
801 } | |
802 | |
803 void DownloadInsertFilesErrorCheckErrorsLoop( | |
804 scoped_refptr<content::TestFileErrorInjector> injector, | |
805 const FileErrorInjectInfo& info, | |
806 size_t i) { | |
807 std::stringstream s; | |
808 s << " " << __FUNCTION__ << "()" | |
809 << " index = " << i | |
810 << " url = " << info.error_info.url | |
811 << " operation code = " << | |
812 content::TestFileErrorInjector::DebugString( | |
813 info.error_info.code) | |
814 << " instance = " << info.error_info.operation_instance | |
815 << " error = " << net::ErrorToString( | |
816 info.error_info.net_error); | |
817 | |
818 injector->ClearErrors(); | |
819 injector->AddError(info.error_info); | |
820 | |
821 injector->InjectErrors(); | |
822 | |
823 DownloadFilesCheckErrorsLoop(info.download_info, i); | |
824 | |
825 size_t expected_successes = info.download_info.show_download_item ? 1u : 0u; | |
826 EXPECT_EQ(expected_successes, injector->TotalFileCount()) << s.str(); | |
827 EXPECT_EQ(0u, injector->CurrentFileCount()) << s.str(); | |
828 | |
829 if (info.download_info.show_download_item) | |
830 EXPECT_TRUE(injector->HadFile(GURL(info.error_info.url))) << s.str(); | |
831 } | |
832 | |
833 void DownloadInsertFilesErrorCheckErrors(size_t count, | |
834 FileErrorInjectInfo* info) { | |
835 DownloadFilesCheckErrorsSetup(); | |
836 | |
837 // Set up file failures. | |
838 scoped_refptr<content::TestFileErrorInjector> injector( | |
839 content::TestFileErrorInjector::Get()); | |
840 | |
841 for (size_t i = 0; i < count; ++i) { | |
842 // Set up the full URL, for download file tracking. | |
843 std::string server_path = "files/downloads/"; | |
844 server_path += info[i].download_info.url_name; | |
845 GURL url = test_server()->GetURL(server_path); | |
846 info[i].error_info.url = url.spec(); | |
847 | |
848 DownloadInsertFilesErrorCheckErrorsLoop(injector, info[i], i); | |
849 } | |
850 } | |
851 | |
753 private: | 852 private: |
754 // Location of the test data. | 853 // Location of the test data. |
755 FilePath test_dir_; | 854 FilePath test_dir_; |
756 | 855 |
757 // Location of the downloads directory for these tests | 856 // Location of the downloads directory for these tests |
758 ScopedTempDir downloads_directory_; | 857 ScopedTempDir downloads_directory_; |
759 }; | 858 }; |
760 | 859 |
761 // NOTES: | 860 // NOTES: |
762 // | 861 // |
(...skipping 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2013 | 2112 |
2014 // Validate that the correct file was downloaded via the context menu. | 2113 // Validate that the correct file was downloaded via the context menu. |
2015 download_items.clear(); | 2114 download_items.clear(); |
2016 GetDownloads(browser(), &download_items); | 2115 GetDownloads(browser(), &download_items); |
2017 EXPECT_TRUE(waiter_context_menu->select_file_dialog_seen()); | 2116 EXPECT_TRUE(waiter_context_menu->select_file_dialog_seen()); |
2018 ASSERT_EQ(2u, download_items.size()); | 2117 ASSERT_EQ(2u, download_items.size()); |
2019 ASSERT_EQ(jpeg_url, download_items[0]->GetOriginalUrl()); | 2118 ASSERT_EQ(jpeg_url, download_items[0]->GetOriginalUrl()); |
2020 ASSERT_EQ(jpeg_url, download_items[1]->GetOriginalUrl()); | 2119 ASSERT_EQ(jpeg_url, download_items[1]->GetOriginalUrl()); |
2021 } | 2120 } |
2022 | 2121 |
2023 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadNavigate) { | 2122 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadErrorsServer) { |
2024 DownloadInfo download_info = { | 2123 DownloadInfo download_info[] = { |
2025 "a_zip_file.zip", | 2124 { // Normal navigated download. |
2026 DOWNLOAD_NAVIGATE, | 2125 "a_zip_file.zip", |
2027 DOWNLOAD_INTERRUPT_REASON_NONE, | 2126 DOWNLOAD_NAVIGATE, |
2028 true | 2127 DOWNLOAD_INTERRUPT_REASON_NONE, |
2128 true | |
2129 }, | |
2130 { // Normal direct download. | |
2131 "a_zip_file.zip", | |
2132 DOWNLOAD_DIRECT, | |
2133 DOWNLOAD_INTERRUPT_REASON_NONE, | |
2134 true | |
2135 }, | |
2136 { // Direct download with 404 error. | |
2137 "there_IS_no_spoon.zip", | |
2138 DOWNLOAD_DIRECT, | |
2139 DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT, | |
2140 true | |
2141 }, | |
2142 { // Navigated download with 404 error. | |
2143 "there_IS_no_spoon.zip", | |
2144 DOWNLOAD_NAVIGATE, | |
2145 DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT, | |
2146 false | |
2147 }, | |
2148 { // Direct download with 400 error. | |
2149 "zip_file_not_found.zip", | |
2150 DOWNLOAD_DIRECT, | |
2151 DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED, | |
2152 true | |
2153 }, | |
2154 { // Navigated download with 400 error. | |
2155 "zip_file_not_found.zip", | |
2156 DOWNLOAD_NAVIGATE, | |
2157 DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED, | |
2158 false | |
2159 } | |
2029 }; | 2160 }; |
2030 | 2161 |
2031 // Do initial setup. | 2162 // Do initial setup. |
2032 ASSERT_TRUE(InitialSetup(false)); | 2163 ASSERT_TRUE(InitialSetup(false)); |
2033 DownloadFileCheckErrors(download_info); | 2164 |
2165 DownloadFilesCheckErrors(ARRAYSIZE_UNSAFE(download_info), download_info); | |
2034 } | 2166 } |
2035 | 2167 |
2036 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadDirect) { | 2168 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadErrorsFile) { |
2037 DownloadInfo download_info = { | 2169 FileErrorInjectInfo error_info[] = { |
2038 "a_zip_file.zip", | 2170 { // Navigated download with injected "Disk full" error in Initialize(). |
2039 DOWNLOAD_DIRECT, | 2171 { "a_zip_file.zip", |
2040 DOWNLOAD_INTERRUPT_REASON_NONE, | 2172 DOWNLOAD_NAVIGATE, |
2041 true | 2173 DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, |
2174 1 | |
2175 }, | |
2176 { | |
2177 "", | |
2178 content::TestFileErrorInjector::FILE_OPERATION_INITIALIZE, | |
2179 0, | |
2180 net::ERR_FILE_NO_SPACE | |
2181 } | |
2182 }, | |
2183 { // Direct download with injected "Disk full" error in Initialize(). | |
2184 { "a_zip_file.zip", | |
2185 DOWNLOAD_DIRECT, | |
2186 DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, | |
2187 1 | |
2188 }, | |
2189 { | |
2190 "", | |
2191 content::TestFileErrorInjector::FILE_OPERATION_INITIALIZE, | |
2192 0, | |
2193 net::ERR_FILE_NO_SPACE | |
2194 } | |
2195 }, | |
2196 { // Navigated download with injected "Disk full" error in Write(). | |
2197 { "a_zip_file.zip", | |
2198 DOWNLOAD_NAVIGATE, | |
2199 DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, | |
2200 1 | |
2201 }, | |
2202 { | |
2203 "", | |
2204 content::TestFileErrorInjector::FILE_OPERATION_WRITE, | |
2205 0, | |
2206 net::ERR_FILE_NO_SPACE | |
2207 } | |
2208 }, | |
2209 { // Direct download with injected "Disk full" error in Write(). | |
2210 { "a_zip_file.zip", | |
2211 DOWNLOAD_DIRECT, | |
2212 DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, | |
2213 1 | |
2214 }, | |
2215 { | |
2216 "", | |
2217 content::TestFileErrorInjector::FILE_OPERATION_WRITE, | |
2218 0, | |
2219 net::ERR_FILE_NO_SPACE | |
2220 } | |
2221 }, | |
2222 { // Navigated download with injected "Failed" error in Initialize(). | |
2223 { "a_zip_file.zip", | |
2224 DOWNLOAD_NAVIGATE, | |
2225 DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, | |
2226 1 | |
2227 }, | |
2228 { | |
2229 "", | |
2230 content::TestFileErrorInjector::FILE_OPERATION_INITIALIZE, | |
2231 0, | |
2232 net::ERR_FAILED | |
2233 } | |
2234 }, | |
2235 { // Direct download with injected "Failed" error in Initialize(). | |
2236 { "a_zip_file.zip", | |
2237 DOWNLOAD_DIRECT, | |
2238 DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, | |
2239 1 | |
2240 }, | |
2241 { | |
2242 "", | |
2243 content::TestFileErrorInjector::FILE_OPERATION_INITIALIZE, | |
2244 0, | |
2245 net::ERR_FAILED | |
2246 } | |
2247 }, | |
2248 { // Navigated download with injected "Failed" error in Write(). | |
2249 { "a_zip_file.zip", | |
2250 DOWNLOAD_NAVIGATE, | |
2251 DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, | |
2252 1 | |
2253 }, | |
2254 { | |
2255 "", | |
2256 content::TestFileErrorInjector::FILE_OPERATION_WRITE, | |
2257 0, | |
2258 net::ERR_FAILED | |
2259 } | |
2260 }, | |
2261 { // Direct download with injected "Failed" error in Write(). | |
2262 { "a_zip_file.zip", | |
2263 DOWNLOAD_DIRECT, | |
2264 DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, | |
2265 1 | |
2266 }, | |
2267 { | |
2268 "", | |
2269 content::TestFileErrorInjector::FILE_OPERATION_WRITE, | |
2270 0, | |
2271 net::ERR_FAILED | |
2272 } | |
2273 }, | |
2274 { // Navigated download with injected "Name too long" error in | |
2275 // Initialize(). | |
2276 { "a_zip_file.zip", | |
2277 DOWNLOAD_NAVIGATE, | |
2278 DOWNLOAD_INTERRUPT_REASON_FILE_NAME_TOO_LONG, | |
2279 1 | |
2280 }, | |
2281 { | |
2282 "", | |
2283 content::TestFileErrorInjector::FILE_OPERATION_INITIALIZE, | |
2284 0, | |
2285 net::ERR_FILE_PATH_TOO_LONG | |
2286 } | |
2287 }, | |
2288 { // Direct download with injected "Name too long" error in Initialize(). | |
2289 { "a_zip_file.zip", | |
2290 DOWNLOAD_DIRECT, | |
2291 DOWNLOAD_INTERRUPT_REASON_FILE_NAME_TOO_LONG, | |
2292 1 | |
2293 }, | |
2294 { | |
2295 "", | |
2296 content::TestFileErrorInjector::FILE_OPERATION_INITIALIZE, | |
2297 0, | |
2298 net::ERR_FILE_PATH_TOO_LONG | |
2299 } | |
2300 }, | |
2301 { // Navigated download with injected "Name too long" error in Write(). | |
2302 { "a_zip_file.zip", | |
2303 DOWNLOAD_NAVIGATE, | |
2304 DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, | |
2305 1 | |
2306 }, | |
2307 { | |
2308 "", | |
2309 content::TestFileErrorInjector::FILE_OPERATION_WRITE, | |
2310 0, | |
2311 net::ERR_INVALID_HANDLE | |
2312 } | |
2313 }, | |
2314 { // Direct download with injected "Name too long" error in Write(). | |
2315 { "a_zip_file.zip", | |
2316 DOWNLOAD_DIRECT, | |
2317 DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, | |
2318 1 | |
2319 }, | |
2320 { | |
2321 "", | |
2322 content::TestFileErrorInjector::FILE_OPERATION_WRITE, | |
2323 0, | |
2324 net::ERR_INVALID_HANDLE | |
2325 } | |
2326 }, | |
2327 { // Direct download with injected "Disk full" error in 2nd Write(). | |
2328 { "06bESSE21Evolution.ppt", | |
2329 DOWNLOAD_DIRECT, | |
2330 DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, | |
2331 1 | |
2332 }, | |
2333 { | |
2334 "", | |
2335 content::TestFileErrorInjector::FILE_OPERATION_WRITE, | |
2336 1, | |
2337 net::ERR_FILE_NO_SPACE | |
2338 } | |
2339 } | |
2042 }; | 2340 }; |
2043 | 2341 |
2044 // Do initial setup. | 2342 DownloadInsertFilesErrorCheckErrors(ARRAYSIZE_UNSAFE(error_info), error_info); |
2045 ASSERT_TRUE(InitialSetup(false)); | |
2046 DownloadFileCheckErrors(download_info); | |
2047 } | 2343 } |
2048 | |
2049 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadError404Direct) { | |
2050 DownloadInfo download_info = { | |
2051 "there_IS_no_spoon.zip", | |
2052 DOWNLOAD_DIRECT, | |
2053 DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT, | |
2054 true | |
2055 }; | |
2056 | |
2057 // Do initial setup. | |
2058 ASSERT_TRUE(InitialSetup(false)); | |
2059 DownloadFileCheckErrors(download_info); | |
2060 } | |
2061 | |
2062 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadError404Navigate) { | |
2063 DownloadInfo download_info = { | |
2064 "there_IS_no_spoon.zip", | |
2065 DOWNLOAD_NAVIGATE, | |
2066 DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT, | |
2067 false | |
2068 }; | |
2069 | |
2070 // Do initial setup. | |
2071 ASSERT_TRUE(InitialSetup(false)); | |
2072 DownloadFileCheckErrors(download_info); | |
2073 } | |
2074 | |
2075 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadError400Direct) { | |
2076 DownloadInfo download_info = { | |
2077 "zip_file_not_found.zip", | |
2078 DOWNLOAD_DIRECT, | |
2079 DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED, | |
2080 true | |
2081 }; | |
2082 | |
2083 // Do initial setup. | |
2084 ASSERT_TRUE(InitialSetup(false)); | |
2085 DownloadFileCheckErrors(download_info); | |
2086 } | |
2087 | |
2088 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadError400Navigate) { | |
2089 DownloadInfo download_info = { | |
2090 "zip_file_not_found.zip", | |
2091 DOWNLOAD_NAVIGATE, | |
2092 DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED, | |
2093 false | |
2094 }; | |
2095 | |
2096 // Do initial setup. | |
2097 ASSERT_TRUE(InitialSetup(false)); | |
2098 DownloadFileCheckErrors(download_info); | |
2099 } | |
OLD | NEW |