| 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 "chrome/browser/download/download_browsertest.h" | 5 #include "chrome/browser/download/download_browsertest.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <sstream> | 8 #include <sstream> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 | 965 |
| 966 for (size_t i = 0; i < count; ++i) { | 966 for (size_t i = 0; i < count; ++i) { |
| 967 DownloadFilesCheckErrorsLoopBody(download_info[i], i); | 967 DownloadFilesCheckErrorsLoopBody(download_info[i], i); |
| 968 } | 968 } |
| 969 } | 969 } |
| 970 | 970 |
| 971 void DownloadInsertFilesErrorCheckErrorsLoopBody( | 971 void DownloadInsertFilesErrorCheckErrorsLoopBody( |
| 972 scoped_refptr<content::TestFileErrorInjector> injector, | 972 scoped_refptr<content::TestFileErrorInjector> injector, |
| 973 const FileErrorInjectInfo& info, | 973 const FileErrorInjectInfo& info, |
| 974 size_t i) { | 974 size_t i) { |
| 975 std::stringstream s; | 975 SCOPED_TRACE( |
| 976 s << " " << __FUNCTION__ << "()" | 976 ::testing::Message() |
| 977 << " index = " << i | 977 << " " << __FUNCTION__ << "()" |
| 978 << " url = " << info.error_info.url | 978 << " index = " << i << " operation code = " |
| 979 << " operation code = " | 979 << content::TestFileErrorInjector::DebugString(info.error_info.code) |
| 980 << content::TestFileErrorInjector::DebugString(info.error_info.code) | 980 << " instance = " << info.error_info.operation_instance << " error = " |
| 981 << " instance = " << info.error_info.operation_instance | 981 << content::DownloadInterruptReasonToString(info.error_info.error)); |
| 982 << " error = " | |
| 983 << content::DownloadInterruptReasonToString(info.error_info.error); | |
| 984 | 982 |
| 985 injector->ClearErrors(); | 983 injector->InjectError(info.error_info); |
| 986 injector->AddError(info.error_info); | |
| 987 | |
| 988 injector->InjectErrors(); | |
| 989 | 984 |
| 990 DownloadFilesCheckErrorsLoopBody(info.download_info, i); | 985 DownloadFilesCheckErrorsLoopBody(info.download_info, i); |
| 991 | 986 |
| 992 size_t expected_successes = info.download_info.show_download_item ? 1u : 0u; | 987 size_t expected_successes = info.download_info.show_download_item ? 1u : 0u; |
| 993 EXPECT_EQ(expected_successes, injector->TotalFileCount()) << s.str(); | 988 EXPECT_EQ(expected_successes, injector->TotalFileCount()); |
| 994 EXPECT_EQ(0u, injector->CurrentFileCount()) << s.str(); | 989 EXPECT_EQ(0u, injector->CurrentFileCount()); |
| 995 | |
| 996 if (info.download_info.show_download_item) | |
| 997 EXPECT_TRUE(injector->HadFile(GURL(info.error_info.url))) << s.str(); | |
| 998 } | 990 } |
| 999 | 991 |
| 1000 void DownloadInsertFilesErrorCheckErrors(size_t count, | 992 void DownloadInsertFilesErrorCheckErrors(size_t count, |
| 1001 FileErrorInjectInfo* info) { | 993 FileErrorInjectInfo* info) { |
| 1002 DownloadFilesCheckErrorsSetup(); | 994 DownloadFilesCheckErrorsSetup(); |
| 1003 | 995 |
| 1004 // Set up file failures. | 996 // Set up file failures. |
| 1005 scoped_refptr<content::TestFileErrorInjector> injector( | 997 scoped_refptr<content::TestFileErrorInjector> injector( |
| 1006 content::TestFileErrorInjector::Create( | 998 content::TestFileErrorInjector::Create( |
| 1007 DownloadManagerForBrowser(browser()))); | 999 DownloadManagerForBrowser(browser()))); |
| 1008 | 1000 |
| 1009 for (size_t i = 0; i < count; ++i) { | 1001 for (size_t i = 0; i < count; ++i) { |
| 1010 // Set up the full URL, for download file tracking. | |
| 1011 std::string server_path = "/downloads/"; | |
| 1012 server_path += info[i].download_info.starting_url; | |
| 1013 GURL url = embedded_test_server()->GetURL(server_path); | |
| 1014 info[i].error_info.url = url.spec(); | |
| 1015 | |
| 1016 DownloadInsertFilesErrorCheckErrorsLoopBody(injector, info[i], i); | 1002 DownloadInsertFilesErrorCheckErrorsLoopBody(injector, info[i], i); |
| 1017 } | 1003 } |
| 1018 } | 1004 } |
| 1019 | 1005 |
| 1020 // Attempts to download a file to a read-only folder, based on information | 1006 // Attempts to download a file to a read-only folder, based on information |
| 1021 // in |download_info|. | 1007 // in |download_info|. |
| 1022 void DownloadFilesToReadonlyFolder(size_t count, | 1008 void DownloadFilesToReadonlyFolder(size_t count, |
| 1023 DownloadInfo* download_info) { | 1009 DownloadInfo* download_info) { |
| 1024 DownloadFilesCheckErrorsSetup(); | 1010 DownloadFilesCheckErrorsSetup(); |
| 1025 | 1011 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1038 // This method: | 1024 // This method: |
| 1039 // * Starts a mock download by navigating browser() to a URLRequestMockHTTPJob | 1025 // * Starts a mock download by navigating browser() to a URLRequestMockHTTPJob |
| 1040 // mock URL. | 1026 // mock URL. |
| 1041 // * Injects |error| on the first write using |error_injector|. | 1027 // * Injects |error| on the first write using |error_injector|. |
| 1042 // * Waits for the download to be interrupted. | 1028 // * Waits for the download to be interrupted. |
| 1043 // * Clears the errors on |error_injector|. | 1029 // * Clears the errors on |error_injector|. |
| 1044 // * Returns the resulting interrupted download. | 1030 // * Returns the resulting interrupted download. |
| 1045 DownloadItem* StartMockDownloadAndInjectError( | 1031 DownloadItem* StartMockDownloadAndInjectError( |
| 1046 content::TestFileErrorInjector* error_injector, | 1032 content::TestFileErrorInjector* error_injector, |
| 1047 content::DownloadInterruptReason error) { | 1033 content::DownloadInterruptReason error) { |
| 1048 GURL url = URLRequestMockHTTPJob::GetMockUrl(kDownloadTest1Path); | |
| 1049 | |
| 1050 content::TestFileErrorInjector::FileErrorInfo error_info; | 1034 content::TestFileErrorInjector::FileErrorInfo error_info; |
| 1051 error_info.url = url.spec(); | |
| 1052 error_info.code = content::TestFileErrorInjector::FILE_OPERATION_WRITE; | 1035 error_info.code = content::TestFileErrorInjector::FILE_OPERATION_WRITE; |
| 1053 error_info.operation_instance = 0; | 1036 error_info.operation_instance = 0; |
| 1054 error_info.error = error; | 1037 error_info.error = error; |
| 1055 error_injector->ClearErrors(); | 1038 error_injector->InjectError(error_info); |
| 1056 error_injector->AddError(error_info); | |
| 1057 error_injector->InjectErrors(); | |
| 1058 | 1039 |
| 1059 scoped_ptr<content::DownloadTestObserver> observer( | 1040 scoped_ptr<content::DownloadTestObserver> observer( |
| 1060 new DownloadTestObserverResumable( | 1041 new DownloadTestObserverResumable( |
| 1061 DownloadManagerForBrowser(browser()), 1)); | 1042 DownloadManagerForBrowser(browser()), 1)); |
| 1043 |
| 1044 GURL url = URLRequestMockHTTPJob::GetMockUrl(kDownloadTest1Path); |
| 1062 ui_test_utils::NavigateToURL(browser(), url); | 1045 ui_test_utils::NavigateToURL(browser(), url); |
| 1063 observer->WaitForFinished(); | 1046 observer->WaitForFinished(); |
| 1064 | 1047 |
| 1065 content::DownloadManager::DownloadVector downloads; | 1048 content::DownloadManager::DownloadVector downloads; |
| 1066 DownloadManagerForBrowser(browser())->GetAllDownloads(&downloads); | 1049 DownloadManagerForBrowser(browser())->GetAllDownloads(&downloads); |
| 1067 EXPECT_EQ(1u, downloads.size()); | 1050 EXPECT_EQ(1u, downloads.size()); |
| 1068 | 1051 |
| 1069 if (downloads.size() != 1) | 1052 if (downloads.size() != 1) |
| 1070 return NULL; | 1053 return NULL; |
| 1071 | 1054 |
| 1072 error_injector->ClearErrors(); | 1055 error_injector->ClearError(); |
| 1073 error_injector->InjectErrors(); | |
| 1074 DownloadItem* download = downloads[0]; | 1056 DownloadItem* download = downloads[0]; |
| 1075 EXPECT_EQ(DownloadItem::INTERRUPTED, download->GetState()); | 1057 EXPECT_EQ(DownloadItem::INTERRUPTED, download->GetState()); |
| 1076 EXPECT_EQ(error, download->GetLastReason()); | 1058 EXPECT_EQ(error, download->GetLastReason()); |
| 1077 return download; | 1059 return download; |
| 1078 } | 1060 } |
| 1079 | 1061 |
| 1080 private: | 1062 private: |
| 1081 static void EnsureNoPendingDownloadJobsOnIO(bool* result) { | 1063 static void EnsureNoPendingDownloadJobsOnIO(bool* result) { |
| 1082 if (net::URLRequestSlowDownloadJob::NumberOutstandingRequests()) | 1064 if (net::URLRequestSlowDownloadJob::NumberOutstandingRequests()) |
| 1083 *result = false; | 1065 *result = false; |
| (...skipping 1253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2337 | 2319 |
| 2338 DownloadFilesCheckErrors(arraysize(download_info), download_info); | 2320 DownloadFilesCheckErrors(arraysize(download_info), download_info); |
| 2339 } | 2321 } |
| 2340 | 2322 |
| 2341 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadErrorsFile) { | 2323 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadErrorsFile) { |
| 2342 FileErrorInjectInfo error_info[] = { | 2324 FileErrorInjectInfo error_info[] = { |
| 2343 {// Navigated download with injected "Disk full" error in Initialize(). | 2325 {// Navigated download with injected "Disk full" error in Initialize(). |
| 2344 {"a_zip_file.zip", "a_zip_file.zip", DOWNLOAD_NAVIGATE, | 2326 {"a_zip_file.zip", "a_zip_file.zip", DOWNLOAD_NAVIGATE, |
| 2345 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, true, false}, | 2327 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, true, false}, |
| 2346 { | 2328 { |
| 2347 "", content::TestFileErrorInjector::FILE_OPERATION_INITIALIZE, 0, | 2329 content::TestFileErrorInjector::FILE_OPERATION_INITIALIZE, 0, |
| 2348 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, | 2330 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, |
| 2349 }}, | 2331 }}, |
| 2350 {// Direct download with injected "Disk full" error in Initialize(). | 2332 {// Direct download with injected "Disk full" error in Initialize(). |
| 2351 {"a_zip_file.zip", "a_zip_file.zip", DOWNLOAD_DIRECT, | 2333 {"a_zip_file.zip", "a_zip_file.zip", DOWNLOAD_DIRECT, |
| 2352 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, true, false}, | 2334 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, true, false}, |
| 2353 { | 2335 { |
| 2354 "", content::TestFileErrorInjector::FILE_OPERATION_INITIALIZE, 0, | 2336 content::TestFileErrorInjector::FILE_OPERATION_INITIALIZE, 0, |
| 2355 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, | 2337 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, |
| 2356 }}, | 2338 }}, |
| 2357 {// Navigated download with injected "Disk full" error in Write(). | 2339 {// Navigated download with injected "Disk full" error in Write(). |
| 2358 {"a_zip_file.zip", "a_zip_file.zip", DOWNLOAD_NAVIGATE, | 2340 {"a_zip_file.zip", "a_zip_file.zip", DOWNLOAD_NAVIGATE, |
| 2359 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, true, false}, | 2341 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, true, false}, |
| 2360 { | 2342 { |
| 2361 "", content::TestFileErrorInjector::FILE_OPERATION_WRITE, 0, | 2343 content::TestFileErrorInjector::FILE_OPERATION_WRITE, 0, |
| 2362 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, | 2344 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, |
| 2363 }}, | 2345 }}, |
| 2364 {// Direct download with injected "Disk full" error in Write(). | 2346 {// Direct download with injected "Disk full" error in Write(). |
| 2365 {"a_zip_file.zip", "a_zip_file.zip", DOWNLOAD_DIRECT, | 2347 {"a_zip_file.zip", "a_zip_file.zip", DOWNLOAD_DIRECT, |
| 2366 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, true, false}, | 2348 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, true, false}, |
| 2367 { | 2349 { |
| 2368 "", content::TestFileErrorInjector::FILE_OPERATION_WRITE, 0, | 2350 content::TestFileErrorInjector::FILE_OPERATION_WRITE, 0, |
| 2369 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, | 2351 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, |
| 2370 }}, | 2352 }}, |
| 2371 {// Navigated download with injected "Failed" error in Initialize(). | 2353 {// Navigated download with injected "Failed" error in Initialize(). |
| 2372 {"a_zip_file.zip", "a_zip_file.zip", DOWNLOAD_NAVIGATE, | 2354 {"a_zip_file.zip", "a_zip_file.zip", DOWNLOAD_NAVIGATE, |
| 2373 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, true, false}, | 2355 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, true, false}, |
| 2374 { | 2356 { |
| 2375 "", content::TestFileErrorInjector::FILE_OPERATION_INITIALIZE, 0, | 2357 content::TestFileErrorInjector::FILE_OPERATION_INITIALIZE, 0, |
| 2376 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, | 2358 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, |
| 2377 }}, | 2359 }}, |
| 2378 {// Direct download with injected "Failed" error in Initialize(). | 2360 {// Direct download with injected "Failed" error in Initialize(). |
| 2379 {"a_zip_file.zip", "a_zip_file.zip", DOWNLOAD_DIRECT, | 2361 {"a_zip_file.zip", "a_zip_file.zip", DOWNLOAD_DIRECT, |
| 2380 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, true, false}, | 2362 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, true, false}, |
| 2381 { | 2363 { |
| 2382 "", content::TestFileErrorInjector::FILE_OPERATION_INITIALIZE, 0, | 2364 content::TestFileErrorInjector::FILE_OPERATION_INITIALIZE, 0, |
| 2383 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, | 2365 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, |
| 2384 }}, | 2366 }}, |
| 2385 {// Navigated download with injected "Failed" error in Write(). | 2367 {// Navigated download with injected "Failed" error in Write(). |
| 2386 {"a_zip_file.zip", "a_zip_file.zip", DOWNLOAD_NAVIGATE, | 2368 {"a_zip_file.zip", "a_zip_file.zip", DOWNLOAD_NAVIGATE, |
| 2387 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, true, false}, | 2369 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, true, false}, |
| 2388 { | 2370 { |
| 2389 "", content::TestFileErrorInjector::FILE_OPERATION_WRITE, 0, | 2371 content::TestFileErrorInjector::FILE_OPERATION_WRITE, 0, |
| 2390 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, | 2372 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, |
| 2391 }}, | 2373 }}, |
| 2392 {// Direct download with injected "Failed" error in Write(). | 2374 {// Direct download with injected "Failed" error in Write(). |
| 2393 {"a_zip_file.zip", "a_zip_file.zip", DOWNLOAD_DIRECT, | 2375 {"a_zip_file.zip", "a_zip_file.zip", DOWNLOAD_DIRECT, |
| 2394 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, true, false}, | 2376 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, true, false}, |
| 2395 { | 2377 { |
| 2396 "", content::TestFileErrorInjector::FILE_OPERATION_WRITE, 0, | 2378 content::TestFileErrorInjector::FILE_OPERATION_WRITE, 0, |
| 2397 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, | 2379 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, |
| 2398 }}, | 2380 }}, |
| 2399 {// Navigated download with injected "Name too long" error in | 2381 {// Navigated download with injected "Name too long" error in |
| 2400 // Initialize(). | 2382 // Initialize(). |
| 2401 {"a_zip_file.zip", "a_zip_file.zip", DOWNLOAD_NAVIGATE, | 2383 {"a_zip_file.zip", "a_zip_file.zip", DOWNLOAD_NAVIGATE, |
| 2402 content::DOWNLOAD_INTERRUPT_REASON_FILE_NAME_TOO_LONG, true, false}, | 2384 content::DOWNLOAD_INTERRUPT_REASON_FILE_NAME_TOO_LONG, true, false}, |
| 2403 { | 2385 { |
| 2404 "", content::TestFileErrorInjector::FILE_OPERATION_INITIALIZE, 0, | 2386 content::TestFileErrorInjector::FILE_OPERATION_INITIALIZE, 0, |
| 2405 content::DOWNLOAD_INTERRUPT_REASON_FILE_NAME_TOO_LONG, | 2387 content::DOWNLOAD_INTERRUPT_REASON_FILE_NAME_TOO_LONG, |
| 2406 }}, | 2388 }}, |
| 2407 {// Direct download with injected "Name too long" error in Initialize(). | 2389 {// Direct download with injected "Name too long" error in Initialize(). |
| 2408 {"a_zip_file.zip", "a_zip_file.zip", DOWNLOAD_DIRECT, | 2390 {"a_zip_file.zip", "a_zip_file.zip", DOWNLOAD_DIRECT, |
| 2409 content::DOWNLOAD_INTERRUPT_REASON_FILE_NAME_TOO_LONG, true, false}, | 2391 content::DOWNLOAD_INTERRUPT_REASON_FILE_NAME_TOO_LONG, true, false}, |
| 2410 { | 2392 { |
| 2411 "", content::TestFileErrorInjector::FILE_OPERATION_INITIALIZE, 0, | 2393 content::TestFileErrorInjector::FILE_OPERATION_INITIALIZE, 0, |
| 2412 content::DOWNLOAD_INTERRUPT_REASON_FILE_NAME_TOO_LONG, | 2394 content::DOWNLOAD_INTERRUPT_REASON_FILE_NAME_TOO_LONG, |
| 2413 }}, | 2395 }}, |
| 2414 {// Navigated download with injected "Name too long" error in Write(). | 2396 {// Navigated download with injected "Name too long" error in Write(). |
| 2415 {"a_zip_file.zip", "a_zip_file.zip", DOWNLOAD_NAVIGATE, | 2397 {"a_zip_file.zip", "a_zip_file.zip", DOWNLOAD_NAVIGATE, |
| 2416 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, true, false}, | 2398 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, true, false}, |
| 2417 { | 2399 { |
| 2418 "", content::TestFileErrorInjector::FILE_OPERATION_WRITE, 0, | 2400 content::TestFileErrorInjector::FILE_OPERATION_WRITE, 0, |
| 2419 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, | 2401 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, |
| 2420 }}, | 2402 }}, |
| 2421 {// Direct download with injected "Name too long" error in Write(). | 2403 {// Direct download with injected "Name too long" error in Write(). |
| 2422 {"a_zip_file.zip", "a_zip_file.zip", DOWNLOAD_DIRECT, | 2404 {"a_zip_file.zip", "a_zip_file.zip", DOWNLOAD_DIRECT, |
| 2423 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, true, false}, | 2405 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, true, false}, |
| 2424 { | 2406 { |
| 2425 "", content::TestFileErrorInjector::FILE_OPERATION_WRITE, 0, | 2407 content::TestFileErrorInjector::FILE_OPERATION_WRITE, 0, |
| 2426 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, | 2408 content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, |
| 2427 }}, | 2409 }}, |
| 2428 {// Direct download with injected "Disk full" error in 2nd Write(). | 2410 {// Direct download with injected "Disk full" error in 2nd Write(). |
| 2429 {"06bESSE21Evolution.ppt", "06bESSE21Evolution.ppt", DOWNLOAD_DIRECT, | 2411 {"06bESSE21Evolution.ppt", "06bESSE21Evolution.ppt", DOWNLOAD_DIRECT, |
| 2430 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, true, false}, | 2412 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, true, false}, |
| 2431 { | 2413 { |
| 2432 "", content::TestFileErrorInjector::FILE_OPERATION_WRITE, 1, | 2414 content::TestFileErrorInjector::FILE_OPERATION_WRITE, 1, |
| 2433 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, | 2415 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, |
| 2434 }}}; | 2416 }}}; |
| 2435 | 2417 |
| 2436 DownloadInsertFilesErrorCheckErrors(arraysize(error_info), error_info); | 2418 DownloadInsertFilesErrorCheckErrors(arraysize(error_info), error_info); |
| 2437 } | 2419 } |
| 2438 | 2420 |
| 2439 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadErrorReadonlyFolder) { | 2421 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadErrorReadonlyFolder) { |
| 2440 DownloadInfo download_info[] = { | 2422 DownloadInfo download_info[] = { |
| 2441 {"a_zip_file.zip", "a_zip_file.zip", DOWNLOAD_DIRECT, | 2423 {"a_zip_file.zip", "a_zip_file.zip", DOWNLOAD_DIRECT, |
| 2442 // This passes because we switch to the My Documents folder. | 2424 // This passes because we switch to the My Documents folder. |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3057 scoped_ptr<content::DownloadTestObserver> resumable_observer( | 3039 scoped_ptr<content::DownloadTestObserver> resumable_observer( |
| 3058 new DownloadTestObserverResumable( | 3040 new DownloadTestObserverResumable( |
| 3059 DownloadManagerForBrowser(browser()), 2)); | 3041 DownloadManagerForBrowser(browser()), 2)); |
| 3060 | 3042 |
| 3061 EnableFileChooser(true); | 3043 EnableFileChooser(true); |
| 3062 DownloadItem* download = StartMockDownloadAndInjectError( | 3044 DownloadItem* download = StartMockDownloadAndInjectError( |
| 3063 error_injector.get(), content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED); | 3045 error_injector.get(), content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED); |
| 3064 ASSERT_TRUE(download); | 3046 ASSERT_TRUE(download); |
| 3065 | 3047 |
| 3066 content::TestFileErrorInjector::FileErrorInfo error_info; | 3048 content::TestFileErrorInjector::FileErrorInfo error_info; |
| 3067 error_info.url = download->GetOriginalUrl().spec(); | |
| 3068 error_info.code = content::TestFileErrorInjector::FILE_OPERATION_WRITE; | 3049 error_info.code = content::TestFileErrorInjector::FILE_OPERATION_WRITE; |
| 3069 error_info.operation_instance = 0; | 3050 error_info.operation_instance = 0; |
| 3070 error_info.error = content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED; | 3051 error_info.error = content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED; |
| 3071 error_injector->AddError(error_info); | 3052 error_injector->InjectError(error_info); |
| 3072 error_injector->InjectErrors(); | |
| 3073 | 3053 |
| 3074 // Resuming should cause the download to be interrupted again due to the | 3054 // Resuming should cause the download to be interrupted again due to the |
| 3075 // errors we are injecting. | 3055 // errors we are injecting. |
| 3076 download->Resume(); | 3056 download->Resume(); |
| 3077 resumable_observer->WaitForFinished(); | 3057 resumable_observer->WaitForFinished(); |
| 3078 ASSERT_EQ(DownloadItem::INTERRUPTED, download->GetState()); | 3058 ASSERT_EQ(DownloadItem::INTERRUPTED, download->GetState()); |
| 3079 ASSERT_EQ(content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, | 3059 ASSERT_EQ(content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, |
| 3080 download->GetLastReason()); | 3060 download->GetLastReason()); |
| 3081 | 3061 |
| 3082 error_injector->ClearErrors(); | 3062 error_injector->ClearError(); |
| 3083 error_injector->InjectErrors(); | |
| 3084 | 3063 |
| 3085 // No errors this time. The download should complete successfully. | 3064 // No errors this time. The download should complete successfully. |
| 3086 EXPECT_FALSE(completion_observer->IsFinished()); | 3065 EXPECT_FALSE(completion_observer->IsFinished()); |
| 3087 completion_observer->StartObserving(); | 3066 completion_observer->StartObserving(); |
| 3088 download->Resume(); | 3067 download->Resume(); |
| 3089 completion_observer->WaitForFinished(); | 3068 completion_observer->WaitForFinished(); |
| 3090 EXPECT_EQ(DownloadItem::COMPLETE, download->GetState()); | 3069 EXPECT_EQ(DownloadItem::COMPLETE, download->GetState()); |
| 3091 | 3070 |
| 3092 EXPECT_FALSE(DidShowFileChooser()); | 3071 EXPECT_FALSE(DidShowFileChooser()); |
| 3093 } | 3072 } |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3546 | 3525 |
| 3547 scoped_ptr<content::DownloadTestObserver> observer(DangerousDownloadWaiter( | 3526 scoped_ptr<content::DownloadTestObserver> observer(DangerousDownloadWaiter( |
| 3548 browser(), 1, content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); | 3527 browser(), 1, content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); |
| 3549 ui_test_utils::NavigateToURL(browser(), extension_url); | 3528 ui_test_utils::NavigateToURL(browser(), extension_url); |
| 3550 | 3529 |
| 3551 observer->WaitForFinished(); | 3530 observer->WaitForFinished(); |
| 3552 | 3531 |
| 3553 // Download shelf should close. | 3532 // Download shelf should close. |
| 3554 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); | 3533 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); |
| 3555 } | 3534 } |
| OLD | NEW |