| 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #include <shlobj.h> | 9 #include <shlobj.h> |
| 10 #endif | 10 #endif |
| (...skipping 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1164 ASSERT_TRUE(test_server_.Start()); | 1164 ASSERT_TRUE(test_server_.Start()); |
| 1165 | 1165 |
| 1166 // Parameter that specifies the Content-Length field in the response: | 1166 // Parameter that specifies the Content-Length field in the response: |
| 1167 // C - Compressed length. | 1167 // C - Compressed length. |
| 1168 // U - Uncompressed length. | 1168 // U - Uncompressed length. |
| 1169 // L - Large length (larger than both C & U). | 1169 // L - Large length (larger than both C & U). |
| 1170 // M - Medium length (between C & U). | 1170 // M - Medium length (between C & U). |
| 1171 // S - Small length (smaller than both C & U). | 1171 // S - Small length (smaller than both C & U). |
| 1172 const char test_parameters[] = "CULMS"; | 1172 const char test_parameters[] = "CULMS"; |
| 1173 const int num_tests = arraysize(test_parameters)- 1; // Skip NULL. | 1173 const int num_tests = arraysize(test_parameters)- 1; // Skip NULL. |
| 1174 // C & U should be OK. | |
| 1175 // L & M are larger than the data sent, and show an error. | |
| 1176 // S has too little data, but we seem to accept it. | |
| 1177 const bool test_expect_success[num_tests] = | |
| 1178 { true, true, false, false, true }; | |
| 1179 | 1174 |
| 1180 for (int i = 0; i < num_tests ; i++) { | 1175 for (int i = 0; i < num_tests ; i++) { |
| 1181 TestDelegate d; | 1176 TestDelegate d; |
| 1182 { | 1177 { |
| 1183 std::string test_file = | 1178 std::string test_file = |
| 1184 base::StringPrintf("compressedfiles/BullRunSpeech.txt?%c", | 1179 base::StringPrintf("compressedfiles/BullRunSpeech.txt?%c", |
| 1185 test_parameters[i]); | 1180 test_parameters[i]); |
| 1186 | 1181 |
| 1187 TestNetworkDelegate network_delegate; // must outlive URLRequest | 1182 TestNetworkDelegate network_delegate; // must outlive URLRequest |
| 1188 scoped_refptr<TestURLRequestContext> context( | 1183 scoped_refptr<TestURLRequestContext> context( |
| 1189 new TestURLRequestContext(true)); | 1184 new TestURLRequestContext(true)); |
| 1190 context->set_network_delegate(&network_delegate); | 1185 context->set_network_delegate(&network_delegate); |
| 1191 context->Init(); | 1186 context->Init(); |
| 1192 | 1187 |
| 1193 TestURLRequest r(test_server_.GetURL(test_file), &d); | 1188 TestURLRequest r(test_server_.GetURL(test_file), &d); |
| 1194 r.set_context(context); | 1189 r.set_context(context); |
| 1195 r.Start(); | 1190 r.Start(); |
| 1196 EXPECT_TRUE(r.is_pending()); | 1191 EXPECT_TRUE(r.is_pending()); |
| 1197 | 1192 |
| 1198 MessageLoop::current()->Run(); | 1193 MessageLoop::current()->Run(); |
| 1199 | 1194 |
| 1200 EXPECT_EQ(1, d.response_started_count()); | 1195 EXPECT_EQ(1, d.response_started_count()); |
| 1201 EXPECT_FALSE(d.received_data_before_response()); | 1196 EXPECT_FALSE(d.received_data_before_response()); |
| 1202 VLOG(1) << " Received " << d.bytes_received() << " bytes" | 1197 VLOG(1) << " Received " << d.bytes_received() << " bytes" |
| 1203 << " status = " << r.status().status() | 1198 << " status = " << r.status().status() |
| 1204 << " error = " << r.status().error(); | 1199 << " error = " << r.status().error(); |
| 1205 if (test_expect_success[i]) { | 1200 EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status()) |
| 1206 EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status()) | 1201 << " Parameter = \"" << test_file << "\""; |
| 1207 << " Parameter = \"" << test_file << "\""; | |
| 1208 } else { | |
| 1209 EXPECT_EQ(URLRequestStatus::FAILED, r.status().status()); | |
| 1210 EXPECT_EQ(-100, r.status().error()) | |
| 1211 << " Parameter = \"" << test_file << "\""; | |
| 1212 } | |
| 1213 } | 1202 } |
| 1214 } | 1203 } |
| 1215 } | 1204 } |
| 1216 | 1205 |
| 1217 // This test was disabled because it made chrome_frame_net_tests hang | 1206 // This test was disabled because it made chrome_frame_net_tests hang |
| 1218 // (see bug 102991). | 1207 // (see bug 102991). |
| 1219 TEST_F(URLRequestTestHTTP, DISABLED_HTTPSToHTTPRedirectNoRefererTest) { | 1208 TEST_F(URLRequestTestHTTP, DISABLED_HTTPSToHTTPRedirectNoRefererTest) { |
| 1220 ASSERT_TRUE(test_server_.Start()); | 1209 ASSERT_TRUE(test_server_.Start()); |
| 1221 | 1210 |
| 1222 TestServer https_test_server(TestServer::TYPE_HTTPS, | 1211 TestServer https_test_server(TestServer::TYPE_HTTPS, |
| (...skipping 3292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4515 req.SetExtraRequestHeaders(headers); | 4504 req.SetExtraRequestHeaders(headers); |
| 4516 req.Start(); | 4505 req.Start(); |
| 4517 MessageLoop::current()->Run(); | 4506 MessageLoop::current()->Run(); |
| 4518 // If the net tests are being run with ChromeFrame then we need to allow for | 4507 // If the net tests are being run with ChromeFrame then we need to allow for |
| 4519 // the 'chromeframe' suffix which is added to the user agent before the | 4508 // the 'chromeframe' suffix which is added to the user agent before the |
| 4520 // closing parentheses. | 4509 // closing parentheses. |
| 4521 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); | 4510 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); |
| 4522 } | 4511 } |
| 4523 | 4512 |
| 4524 } // namespace net | 4513 } // namespace net |
| OLD | NEW |