| 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> | 5 #include <sstream> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 const FileErrorInjectInfo& info, | 769 const FileErrorInjectInfo& info, |
| 770 size_t i) { | 770 size_t i) { |
| 771 std::stringstream s; | 771 std::stringstream s; |
| 772 s << " " << __FUNCTION__ << "()" | 772 s << " " << __FUNCTION__ << "()" |
| 773 << " index = " << i | 773 << " index = " << i |
| 774 << " url = " << info.error_info.url | 774 << " url = " << info.error_info.url |
| 775 << " operation code = " << | 775 << " operation code = " << |
| 776 content::TestFileErrorInjector::DebugString( | 776 content::TestFileErrorInjector::DebugString( |
| 777 info.error_info.code) | 777 info.error_info.code) |
| 778 << " instance = " << info.error_info.operation_instance | 778 << " instance = " << info.error_info.operation_instance |
| 779 << " error = " << net::ErrorToString( | 779 << " error = " << content::InterruptReasonDebugString( |
| 780 info.error_info.net_error); | 780 info.error_info.error); |
| 781 | 781 |
| 782 injector->ClearErrors(); | 782 injector->ClearErrors(); |
| 783 injector->AddError(info.error_info); | 783 injector->AddError(info.error_info); |
| 784 | 784 |
| 785 injector->InjectErrors(); | 785 injector->InjectErrors(); |
| 786 | 786 |
| 787 DownloadFilesCheckErrorsLoopBody(info.download_info, i); | 787 DownloadFilesCheckErrorsLoopBody(info.download_info, i); |
| 788 | 788 |
| 789 size_t expected_successes = info.download_info.show_download_item ? 1u : 0u; | 789 size_t expected_successes = info.download_info.show_download_item ? 1u : 0u; |
| 790 EXPECT_EQ(expected_successes, injector->TotalFileCount()) << s.str(); | 790 EXPECT_EQ(expected_successes, injector->TotalFileCount()) << s.str(); |
| (...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2183 { // Navigated download with injected "Disk full" error in Initialize(). | 2183 { // Navigated download with injected "Disk full" error in Initialize(). |
| 2184 { "a_zip_file.zip", | 2184 { "a_zip_file.zip", |
| 2185 DOWNLOAD_NAVIGATE, | 2185 DOWNLOAD_NAVIGATE, |
| 2186 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, | 2186 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, |
| 2187 1 | 2187 1 |
| 2188 }, | 2188 }, |
| 2189 { | 2189 { |
| 2190 "", | 2190 "", |
| 2191 content::TestFileErrorInjector::FILE_OPERATION_INITIALIZE, | 2191 content::TestFileErrorInjector::FILE_OPERATION_INITIALIZE, |
| 2192 0, | 2192 0, |
| 2193 net::ERR_FILE_NO_SPACE | 2193 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, |
| 2194 } | 2194 } |
| 2195 }, | 2195 }, |
| 2196 { // Direct download with injected "Disk full" error in Initialize(). | 2196 { // Direct download with injected "Disk full" error in Initialize(). |
| 2197 { "a_zip_file.zip", | 2197 { "a_zip_file.zip", |
| 2198 DOWNLOAD_DIRECT, | 2198 DOWNLOAD_DIRECT, |
| 2199 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, | 2199 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, |
| 2200 1 | 2200 1 |
| 2201 }, | 2201 }, |
| 2202 { | 2202 { |
| 2203 "", | 2203 "", |
| 2204 content::TestFileErrorInjector::FILE_OPERATION_INITIALIZE, | 2204 content::TestFileErrorInjector::FILE_OPERATION_INITIALIZE, |
| 2205 0, | 2205 0, |
| 2206 net::ERR_FILE_NO_SPACE | 2206 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, |
| 2207 } | 2207 } |
| 2208 }, | 2208 }, |
| 2209 { // Navigated download with injected "Disk full" error in Write(). | 2209 { // Navigated download with injected "Disk full" error in Write(). |
| 2210 { "a_zip_file.zip", | 2210 { "a_zip_file.zip", |
| 2211 DOWNLOAD_NAVIGATE, | 2211 DOWNLOAD_NAVIGATE, |
| 2212 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, | 2212 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, |
| 2213 1 | 2213 1 |
| 2214 }, | 2214 }, |
| 2215 { | 2215 { |
| 2216 "", | 2216 "", |
| 2217 content::TestFileErrorInjector::FILE_OPERATION_WRITE, | 2217 content::TestFileErrorInjector::FILE_OPERATION_WRITE, |
| 2218 0, | 2218 0, |
| 2219 net::ERR_FILE_NO_SPACE | 2219 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, |
| 2220 } | 2220 } |
| 2221 }, | 2221 }, |
| 2222 { // Direct download with injected "Disk full" error in Write(). | 2222 { // Direct download with injected "Disk full" error in Write(). |
| 2223 { "a_zip_file.zip", | 2223 { "a_zip_file.zip", |
| 2224 DOWNLOAD_DIRECT, | 2224 DOWNLOAD_DIRECT, |
| 2225 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, | 2225 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, |
| 2226 1 | 2226 1 |
| 2227 }, | 2227 }, |
| 2228 { | 2228 { |
| 2229 "", | 2229 "", |
| 2230 content::TestFileErrorInjector::FILE_OPERATION_WRITE, | 2230 content::TestFileErrorInjector::FILE_OPERATION_WRITE, |
| 2231 0, | 2231 0, |
| 2232 net::ERR_FILE_NO_SPACE | 2232 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, |
| 2233 } | 2233 } |
| 2234 }, | 2234 }, |
| 2235 { // Navigated download with injected "Failed" error in Initialize(). | 2235 { // Navigated download with injected "Failed" error in Initialize(). |
| 2236 { "a_zip_file.zip", | 2236 { "a_zip_file.zip", |
| 2237 DOWNLOAD_NAVIGATE, | 2237 DOWNLOAD_NAVIGATE, |
| 2238 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, | 2238 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, |
| 2239 1 | 2239 1 |
| 2240 }, | 2240 }, |
| 2241 { | 2241 { |
| 2242 "", | 2242 "", |
| 2243 content::TestFileErrorInjector::FILE_OPERATION_INITIALIZE, | 2243 content::TestFileErrorInjector::FILE_OPERATION_INITIALIZE, |
| 2244 0, | 2244 0, |
| 2245 net::ERR_FAILED | 2245 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, |
| 2246 } | 2246 } |
| 2247 }, | 2247 }, |
| 2248 { // Direct download with injected "Failed" error in Initialize(). | 2248 { // Direct download with injected "Failed" error in Initialize(). |
| 2249 { "a_zip_file.zip", | 2249 { "a_zip_file.zip", |
| 2250 DOWNLOAD_DIRECT, | 2250 DOWNLOAD_DIRECT, |
| 2251 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, | 2251 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, |
| 2252 1 | 2252 1 |
| 2253 }, | 2253 }, |
| 2254 { | 2254 { |
| 2255 "", | 2255 "", |
| 2256 content::TestFileErrorInjector::FILE_OPERATION_INITIALIZE, | 2256 content::TestFileErrorInjector::FILE_OPERATION_INITIALIZE, |
| 2257 0, | 2257 0, |
| 2258 net::ERR_FAILED | 2258 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, |
| 2259 } | 2259 } |
| 2260 }, | 2260 }, |
| 2261 { // Navigated download with injected "Failed" error in Write(). | 2261 { // Navigated download with injected "Failed" error in Write(). |
| 2262 { "a_zip_file.zip", | 2262 { "a_zip_file.zip", |
| 2263 DOWNLOAD_NAVIGATE, | 2263 DOWNLOAD_NAVIGATE, |
| 2264 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, | 2264 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, |
| 2265 1 | 2265 1 |
| 2266 }, | 2266 }, |
| 2267 { | 2267 { |
| 2268 "", | 2268 "", |
| 2269 content::TestFileErrorInjector::FILE_OPERATION_WRITE, | 2269 content::TestFileErrorInjector::FILE_OPERATION_WRITE, |
| 2270 0, | 2270 0, |
| 2271 net::ERR_FAILED | 2271 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, |
| 2272 } | 2272 } |
| 2273 }, | 2273 }, |
| 2274 { // Direct download with injected "Failed" error in Write(). | 2274 { // Direct download with injected "Failed" error in Write(). |
| 2275 { "a_zip_file.zip", | 2275 { "a_zip_file.zip", |
| 2276 DOWNLOAD_DIRECT, | 2276 DOWNLOAD_DIRECT, |
| 2277 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, | 2277 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, |
| 2278 1 | 2278 1 |
| 2279 }, | 2279 }, |
| 2280 { | 2280 { |
| 2281 "", | 2281 "", |
| 2282 content::TestFileErrorInjector::FILE_OPERATION_WRITE, | 2282 content::TestFileErrorInjector::FILE_OPERATION_WRITE, |
| 2283 0, | 2283 0, |
| 2284 net::ERR_FAILED | 2284 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, |
| 2285 } | 2285 } |
| 2286 }, | 2286 }, |
| 2287 { // Navigated download with injected "Name too long" error in | 2287 { // Navigated download with injected "Name too long" error in |
| 2288 // Initialize(). | 2288 // Initialize(). |
| 2289 { "a_zip_file.zip", | 2289 { "a_zip_file.zip", |
| 2290 DOWNLOAD_NAVIGATE, | 2290 DOWNLOAD_NAVIGATE, |
| 2291 content::DOWNLOAD_INTERRUPT_REASON_FILE_NAME_TOO_LONG, | 2291 content::DOWNLOAD_INTERRUPT_REASON_FILE_NAME_TOO_LONG, |
| 2292 1 | 2292 1 |
| 2293 }, | 2293 }, |
| 2294 { | 2294 { |
| 2295 "", | 2295 "", |
| 2296 content::TestFileErrorInjector::FILE_OPERATION_INITIALIZE, | 2296 content::TestFileErrorInjector::FILE_OPERATION_INITIALIZE, |
| 2297 0, | 2297 0, |
| 2298 net::ERR_FILE_PATH_TOO_LONG | 2298 content::DOWNLOAD_INTERRUPT_REASON_FILE_NAME_TOO_LONG, |
| 2299 } | 2299 } |
| 2300 }, | 2300 }, |
| 2301 { // Direct download with injected "Name too long" error in Initialize(). | 2301 { // Direct download with injected "Name too long" error in Initialize(). |
| 2302 { "a_zip_file.zip", | 2302 { "a_zip_file.zip", |
| 2303 DOWNLOAD_DIRECT, | 2303 DOWNLOAD_DIRECT, |
| 2304 content::DOWNLOAD_INTERRUPT_REASON_FILE_NAME_TOO_LONG, | 2304 content::DOWNLOAD_INTERRUPT_REASON_FILE_NAME_TOO_LONG, |
| 2305 1 | 2305 1 |
| 2306 }, | 2306 }, |
| 2307 { | 2307 { |
| 2308 "", | 2308 "", |
| 2309 content::TestFileErrorInjector::FILE_OPERATION_INITIALIZE, | 2309 content::TestFileErrorInjector::FILE_OPERATION_INITIALIZE, |
| 2310 0, | 2310 0, |
| 2311 net::ERR_FILE_PATH_TOO_LONG | 2311 content::DOWNLOAD_INTERRUPT_REASON_FILE_NAME_TOO_LONG, |
| 2312 } | 2312 } |
| 2313 }, | 2313 }, |
| 2314 { // Navigated download with injected "Name too long" error in Write(). | 2314 { // Navigated download with injected "Name too long" error in Write(). |
| 2315 { "a_zip_file.zip", | 2315 { "a_zip_file.zip", |
| 2316 DOWNLOAD_NAVIGATE, | 2316 DOWNLOAD_NAVIGATE, |
| 2317 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, | 2317 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, |
| 2318 1 | 2318 1 |
| 2319 }, | 2319 }, |
| 2320 { | 2320 { |
| 2321 "", | 2321 "", |
| 2322 content::TestFileErrorInjector::FILE_OPERATION_WRITE, | 2322 content::TestFileErrorInjector::FILE_OPERATION_WRITE, |
| 2323 0, | 2323 0, |
| 2324 net::ERR_INVALID_HANDLE | 2324 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, |
| 2325 } | 2325 } |
| 2326 }, | 2326 }, |
| 2327 { // Direct download with injected "Name too long" error in Write(). | 2327 { // Direct download with injected "Name too long" error in Write(). |
| 2328 { "a_zip_file.zip", | 2328 { "a_zip_file.zip", |
| 2329 DOWNLOAD_DIRECT, | 2329 DOWNLOAD_DIRECT, |
| 2330 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, | 2330 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, |
| 2331 1 | 2331 1 |
| 2332 }, | 2332 }, |
| 2333 { | 2333 { |
| 2334 "", | 2334 "", |
| 2335 content::TestFileErrorInjector::FILE_OPERATION_WRITE, | 2335 content::TestFileErrorInjector::FILE_OPERATION_WRITE, |
| 2336 0, | 2336 0, |
| 2337 net::ERR_INVALID_HANDLE | 2337 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, |
| 2338 } | 2338 } |
| 2339 }, | 2339 }, |
| 2340 { // Direct download with injected "Disk full" error in 2nd Write(). | 2340 { // Direct download with injected "Disk full" error in 2nd Write(). |
| 2341 { "06bESSE21Evolution.ppt", | 2341 { "06bESSE21Evolution.ppt", |
| 2342 DOWNLOAD_DIRECT, | 2342 DOWNLOAD_DIRECT, |
| 2343 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, | 2343 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, |
| 2344 1 | 2344 1 |
| 2345 }, | 2345 }, |
| 2346 { | 2346 { |
| 2347 "", | 2347 "", |
| 2348 content::TestFileErrorInjector::FILE_OPERATION_WRITE, | 2348 content::TestFileErrorInjector::FILE_OPERATION_WRITE, |
| 2349 1, | 2349 1, |
| 2350 net::ERR_FILE_NO_SPACE | 2350 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, |
| 2351 } | 2351 } |
| 2352 } | 2352 } |
| 2353 }; | 2353 }; |
| 2354 | 2354 |
| 2355 DownloadInsertFilesErrorCheckErrors(ARRAYSIZE_UNSAFE(error_info), error_info); | 2355 DownloadInsertFilesErrorCheckErrors(ARRAYSIZE_UNSAFE(error_info), error_info); |
| 2356 } | 2356 } |
| 2357 | 2357 |
| 2358 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadErrorReadonlyFolder) { | 2358 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadErrorReadonlyFolder) { |
| 2359 DownloadInfo download_info[] = { | 2359 DownloadInfo download_info[] = { |
| 2360 { | 2360 { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2450 GetDownloads(browser(), &download_items); | 2450 GetDownloads(browser(), &download_items); |
| 2451 ASSERT_EQ(1u, download_items.size()); | 2451 ASSERT_EQ(1u, download_items.size()); |
| 2452 ASSERT_EQ(test_server()->GetURL("echoheader?Referer"), | 2452 ASSERT_EQ(test_server()->GetURL("echoheader?Referer"), |
| 2453 download_items[0]->GetOriginalUrl()); | 2453 download_items[0]->GetOriginalUrl()); |
| 2454 | 2454 |
| 2455 // Check that the file contains the expected referrer. | 2455 // Check that the file contains the expected referrer. |
| 2456 FilePath file(download_items[0]->GetFullPath()); | 2456 FilePath file(download_items[0]->GetFullPath()); |
| 2457 std::string expected_contents = test_server()->GetURL("").spec(); | 2457 std::string expected_contents = test_server()->GetURL("").spec(); |
| 2458 ASSERT_TRUE(VerifyFile(file, expected_contents, expected_contents.length())); | 2458 ASSERT_TRUE(VerifyFile(file, expected_contents, expected_contents.length())); |
| 2459 } | 2459 } |
| OLD | NEW |