Chromium Code Reviews| 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 4279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4290 path = path.Append(FILE_PATH_LITERAL("data")); | 4290 path = path.Append(FILE_PATH_LITERAL("data")); |
| 4291 path = path.Append(FILE_PATH_LITERAL("url_request_unittest")); | 4291 path = path.Append(FILE_PATH_LITERAL("url_request_unittest")); |
| 4292 path = path.Append(FILE_PATH_LITERAL("with-headers.html")); | 4292 path = path.Append(FILE_PATH_LITERAL("with-headers.html")); |
| 4293 | 4293 |
| 4294 std::string contents; | 4294 std::string contents; |
| 4295 EXPECT_TRUE(base::ReadFileToString(path, &contents)); | 4295 EXPECT_TRUE(base::ReadFileToString(path, &contents)); |
| 4296 EXPECT_EQ(contents, d.data_received()); | 4296 EXPECT_EQ(contents, d.data_received()); |
| 4297 } | 4297 } |
| 4298 } | 4298 } |
| 4299 | 4299 |
| 4300 // Tests that a deferred redirect releases its lock on the cache. | |
| 4301 TEST_F(URLRequestTestHTTP, DeferredRedirect_ReleaseCacheEntry) { | |
|
rvargas (doing something else)
2013/09/18 18:37:10
Yes, I meant removing this test.
davidben
2013/09/18 19:35:43
Done.
| |
| 4302 ASSERT_TRUE(test_server_.Start()); | |
| 4303 | |
| 4304 // First test the cold cache case. | |
| 4305 { | |
| 4306 // First, fire a request and (indefinitely) pause its redirect. | |
| 4307 TestDelegate pausing_delegate; | |
| 4308 pausing_delegate.set_quit_on_redirect(true); | |
| 4309 GURL test_url(test_server_.GetURL("files/redirect-test.html")); | |
| 4310 URLRequest paused_req(test_url, &pausing_delegate, &default_context_); | |
| 4311 paused_req.Start(); | |
| 4312 base::RunLoop().Run(); | |
| 4313 EXPECT_EQ(1, pausing_delegate.received_redirect_count()); | |
| 4314 | |
| 4315 // This should test the cold cache case. | |
| 4316 EXPECT_FALSE(paused_req.was_cached()); | |
| 4317 | |
| 4318 // Now, fire a second at the same. It should not get stuck. | |
| 4319 TestDelegate delegate; | |
| 4320 URLRequest req(test_url, &delegate, &default_context_); | |
| 4321 req.Start(); | |
| 4322 base::RunLoop().Run(); | |
| 4323 EXPECT_EQ(1, delegate.response_started_count()); | |
| 4324 EXPECT_FALSE(delegate.received_data_before_response()); | |
| 4325 EXPECT_EQ(URLRequestStatus::SUCCESS, req.status().status()); | |
| 4326 } | |
| 4327 | |
| 4328 // Repeat, now with the cache warmed from the last run. | |
| 4329 { | |
| 4330 // First, fire a request and (indefinitely) pause its redirect. | |
| 4331 TestDelegate pausing_delegate; | |
| 4332 pausing_delegate.set_quit_on_redirect(true); | |
| 4333 GURL test_url(test_server_.GetURL("files/redirect-test.html")); | |
| 4334 URLRequest paused_req(test_url, &pausing_delegate, &default_context_); | |
| 4335 paused_req.Start(); | |
| 4336 base::RunLoop().Run(); | |
| 4337 EXPECT_EQ(1, pausing_delegate.received_redirect_count()); | |
| 4338 | |
| 4339 // This should test the cold cache case. | |
| 4340 EXPECT_TRUE(paused_req.was_cached()); | |
| 4341 | |
| 4342 // Now, fire a second at the same. It should not get stuck. | |
| 4343 TestDelegate delegate; | |
| 4344 URLRequest req(test_url, &delegate, &default_context_); | |
| 4345 req.Start(); | |
| 4346 base::RunLoop().Run(); | |
| 4347 EXPECT_EQ(1, delegate.response_started_count()); | |
| 4348 EXPECT_FALSE(delegate.received_data_before_response()); | |
| 4349 EXPECT_EQ(URLRequestStatus::SUCCESS, req.status().status()); | |
| 4350 } | |
| 4351 } | |
| 4352 | |
| 4300 TEST_F(URLRequestTestHTTP, CancelDeferredRedirect) { | 4353 TEST_F(URLRequestTestHTTP, CancelDeferredRedirect) { |
| 4301 ASSERT_TRUE(test_server_.Start()); | 4354 ASSERT_TRUE(test_server_.Start()); |
| 4302 | 4355 |
| 4303 TestDelegate d; | 4356 TestDelegate d; |
| 4304 { | 4357 { |
| 4305 d.set_quit_on_redirect(true); | 4358 d.set_quit_on_redirect(true); |
| 4306 URLRequest req( | 4359 URLRequest req( |
| 4307 test_server_.GetURL("files/redirect-test.html"), &d, &default_context_); | 4360 test_server_.GetURL("files/redirect-test.html"), &d, &default_context_); |
| 4308 req.Start(); | 4361 req.Start(); |
| 4309 base::RunLoop().Run(); | 4362 base::RunLoop().Run(); |
| (...skipping 1976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6286 | 6339 |
| 6287 EXPECT_FALSE(r.is_pending()); | 6340 EXPECT_FALSE(r.is_pending()); |
| 6288 EXPECT_EQ(1, d->response_started_count()); | 6341 EXPECT_EQ(1, d->response_started_count()); |
| 6289 EXPECT_FALSE(d->received_data_before_response()); | 6342 EXPECT_FALSE(d->received_data_before_response()); |
| 6290 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); | 6343 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); |
| 6291 } | 6344 } |
| 6292 } | 6345 } |
| 6293 #endif // !defined(DISABLE_FTP_SUPPORT) | 6346 #endif // !defined(DISABLE_FTP_SUPPORT) |
| 6294 | 6347 |
| 6295 } // namespace net | 6348 } // namespace net |
| OLD | NEW |