| 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 // This file contains download browser tests that are known to be runnable | 5 // This file contains download browser tests that are known to be runnable |
| 6 // in a pure content context. Over time tests should be migrated here. | 6 // in a pure content context. Over time tests should be migrated here. |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1064 EXPECT_EQ(parameters.etag, value); | 1064 EXPECT_EQ(parameters.etag, value); |
| 1065 | 1065 |
| 1066 ASSERT_TRUE(requests[1].request_headers.GetHeader( | 1066 ASSERT_TRUE(requests[1].request_headers.GetHeader( |
| 1067 net::HttpRequestHeaders::kRange, &value)); | 1067 net::HttpRequestHeaders::kRange, &value)); |
| 1068 EXPECT_EQ(base::StringPrintf("bytes=%" PRId64 "-", interruption.offset), | 1068 EXPECT_EQ(base::StringPrintf("bytes=%" PRId64 "-", interruption.offset), |
| 1069 value); | 1069 value); |
| 1070 } | 1070 } |
| 1071 | 1071 |
| 1072 // Resumption should only attempt to contact the final URL if the download has a | 1072 // Resumption should only attempt to contact the final URL if the download has a |
| 1073 // URL chain. | 1073 // URL chain. |
| 1074 IN_PROC_BROWSER_TEST_F(DownloadContentTest, DISABLED_RedirectBeforeResume) { | 1074 #if defined(OS_WIN) |
| 1075 // Failing on Windows. http://crbug.com/598264 |
| 1076 #define MAYBE_RedirectBeforeResume DISABLED_RedirectBeforeResume |
| 1077 #else |
| 1078 #define MAYBE_RedirectBeforeResume RedirectBeforeResume |
| 1079 #endif |
| 1080 IN_PROC_BROWSER_TEST_F(DownloadContentTest, MAYBE_RedirectBeforeResume) { |
| 1075 TestDownloadRequestHandler request_handler_1( | 1081 TestDownloadRequestHandler request_handler_1( |
| 1076 GURL("http://example.com/first-url")); | 1082 GURL("http://example.com/first-url")); |
| 1077 request_handler_1.StartServingStaticResponse( | 1083 request_handler_1.StartServingStaticResponse( |
| 1078 "HTTP/1.1 302 Redirect\r\n" | 1084 "HTTP/1.1 302 Redirect\r\n" |
| 1079 "Location: http://example.com/second-url\r\n" | 1085 "Location: http://example.com/second-url\r\n" |
| 1080 "\r\n"); | 1086 "\r\n"); |
| 1081 | 1087 |
| 1082 TestDownloadRequestHandler request_handler_2( | 1088 TestDownloadRequestHandler request_handler_2( |
| 1083 GURL("http://example.com/second-url")); | 1089 GURL("http://example.com/second-url")); |
| 1084 request_handler_2.StartServingStaticResponse( | 1090 request_handler_2.StartServingStaticResponse( |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1118 download->Resume(); | 1124 download->Resume(); |
| 1119 WaitForCompletion(download); | 1125 WaitForCompletion(download); |
| 1120 | 1126 |
| 1121 ASSERT_NO_FATAL_FAILURE(ReadAndVerifyFileContents( | 1127 ASSERT_NO_FATAL_FAILURE(ReadAndVerifyFileContents( |
| 1122 parameters.pattern_generator_seed, parameters.size, | 1128 parameters.pattern_generator_seed, parameters.size, |
| 1123 download->GetTargetFilePath())); | 1129 download->GetTargetFilePath())); |
| 1124 } | 1130 } |
| 1125 | 1131 |
| 1126 // If a resumption request results in a redirect, the response should be ignored | 1132 // If a resumption request results in a redirect, the response should be ignored |
| 1127 // and the download should be marked as interrupted again. | 1133 // and the download should be marked as interrupted again. |
| 1128 IN_PROC_BROWSER_TEST_F(DownloadContentTest, RedirectWhileResume) { | 1134 #if defined(OS_WIN) |
| 1135 // Failing on Windows. http://crbug.com/598264 |
| 1136 #define MAYBE_RedirectWhileResume DISABLED_RedirectWhileResume |
| 1137 #else |
| 1138 #define MAYBE_RedirectWhileResume RedirectWhileResume |
| 1139 #endif |
| 1140 IN_PROC_BROWSER_TEST_F(DownloadContentTest, MAYBE_RedirectWhileResume) { |
| 1129 TestDownloadRequestHandler request_handler( | 1141 TestDownloadRequestHandler request_handler( |
| 1130 GURL("http://example.com/first-url")); | 1142 GURL("http://example.com/first-url")); |
| 1131 TestDownloadRequestHandler::Parameters parameters = | 1143 TestDownloadRequestHandler::Parameters parameters = |
| 1132 TestDownloadRequestHandler::Parameters::WithSingleInterruption(); | 1144 TestDownloadRequestHandler::Parameters::WithSingleInterruption(); |
| 1133 ++parameters.pattern_generator_seed; | 1145 ++parameters.pattern_generator_seed; |
| 1134 request_handler.StartServing(parameters); | 1146 request_handler.StartServing(parameters); |
| 1135 | 1147 |
| 1136 // We should never send a request to the decoy. If we do, the request will | 1148 // We should never send a request to the decoy. If we do, the request will |
| 1137 // always succeed, which results in behavior that diverges from what we want, | 1149 // always succeed, which results in behavior that diverges from what we want, |
| 1138 // which is for the download to return to being interrupted. | 1150 // which is for the download to return to being interrupted. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1180 // redirect response shows up as a response with 0 bytes transferred. | 1192 // redirect response shows up as a response with 0 bytes transferred. |
| 1181 EXPECT_GT(parameters.size, requests[0].transferred_byte_count); | 1193 EXPECT_GT(parameters.size, requests[0].transferred_byte_count); |
| 1182 EXPECT_EQ(0, requests[1].transferred_byte_count); | 1194 EXPECT_EQ(0, requests[1].transferred_byte_count); |
| 1183 EXPECT_GT(parameters.size, requests[2].transferred_byte_count); | 1195 EXPECT_GT(parameters.size, requests[2].transferred_byte_count); |
| 1184 } | 1196 } |
| 1185 | 1197 |
| 1186 // If the server response for the resumption request specifies a bad range (i.e. | 1198 // If the server response for the resumption request specifies a bad range (i.e. |
| 1187 // not the range that was requested or an invalid or missing Content-Range | 1199 // not the range that was requested or an invalid or missing Content-Range |
| 1188 // header), then the download should be marked as interrupted again without | 1200 // header), then the download should be marked as interrupted again without |
| 1189 // discarding the partial state. | 1201 // discarding the partial state. |
| 1190 IN_PROC_BROWSER_TEST_F(DownloadContentTest, BadRangeHeader) { | 1202 #if defined(OS_WIN) |
| 1203 // Failing on Windows. http://crbug.com/598264 |
| 1204 #define MAYBE_BadRangeHeader DISABLED_BadRangeHeader |
| 1205 #else |
| 1206 #define MAYBE_BadRangeHeader BadRangeHeader |
| 1207 #endif |
| 1208 IN_PROC_BROWSER_TEST_F(DownloadContentTest, MAYBE_BadRangeHeader) { |
| 1191 TestDownloadRequestHandler request_handler; | 1209 TestDownloadRequestHandler request_handler; |
| 1192 TestDownloadRequestHandler::Parameters parameters = | 1210 TestDownloadRequestHandler::Parameters parameters = |
| 1193 TestDownloadRequestHandler::Parameters::WithSingleInterruption(); | 1211 TestDownloadRequestHandler::Parameters::WithSingleInterruption(); |
| 1194 request_handler.StartServing(parameters); | 1212 request_handler.StartServing(parameters); |
| 1195 | 1213 |
| 1196 DownloadItem* download = | 1214 DownloadItem* download = |
| 1197 StartDownloadAndReturnItem(shell(), request_handler.url()); | 1215 StartDownloadAndReturnItem(shell(), request_handler.url()); |
| 1198 WaitForInterrupt(download); | 1216 WaitForInterrupt(download); |
| 1199 | 1217 |
| 1200 // Upon resumption, the server starts responding with a bad range header. | 1218 // Upon resumption, the server starts responding with a bad range header. |
| (...skipping 1253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2454 | 2472 |
| 2455 std::vector<DownloadItem*> downloads; | 2473 std::vector<DownloadItem*> downloads; |
| 2456 DownloadManagerForShell(shell())->GetAllDownloads(&downloads); | 2474 DownloadManagerForShell(shell())->GetAllDownloads(&downloads); |
| 2457 ASSERT_EQ(1u, downloads.size()); | 2475 ASSERT_EQ(1u, downloads.size()); |
| 2458 | 2476 |
| 2459 EXPECT_EQ(FILE_PATH_LITERAL("Jumboshrimp.txt"), | 2477 EXPECT_EQ(FILE_PATH_LITERAL("Jumboshrimp.txt"), |
| 2460 downloads[0]->GetTargetFilePath().BaseName().value()); | 2478 downloads[0]->GetTargetFilePath().BaseName().value()); |
| 2461 } | 2479 } |
| 2462 | 2480 |
| 2463 } // namespace content | 2481 } // namespace content |
| OLD | NEW |