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 <memory> | 5 #include <memory> |
6 #include <utility> | 6 #include <utility> |
7 | 7 |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 4173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4184 context.Init(); | 4184 context.Init(); |
4185 | 4185 |
4186 d.set_credentials(AuthCredentials(kUser, kSecret)); | 4186 d.set_credentials(AuthCredentials(kUser, kSecret)); |
4187 | 4187 |
4188 { | 4188 { |
4189 GURL url(http_test_server()->GetURL("/auth-basic")); | 4189 GURL url(http_test_server()->GetURL("/auth-basic")); |
4190 std::unique_ptr<URLRequest> r(context.CreateRequest( | 4190 std::unique_ptr<URLRequest> r(context.CreateRequest( |
4191 url, DEFAULT_PRIORITY, &d, TRAFFIC_ANNOTATION_FOR_TESTS)); | 4191 url, DEFAULT_PRIORITY, &d, TRAFFIC_ANNOTATION_FOR_TESTS)); |
4192 r->Start(); | 4192 r->Start(); |
4193 | 4193 |
| 4194 base::RunLoop().Run(); |
| 4195 |
4194 { | 4196 { |
4195 HttpRequestHeaders headers; | 4197 HttpRequestHeaders headers; |
4196 EXPECT_TRUE(r->GetFullRequestHeaders(&headers)); | 4198 EXPECT_TRUE(r->GetFullRequestHeaders(&headers)); |
4197 EXPECT_FALSE(headers.HasHeader("Authorization")); | 4199 EXPECT_TRUE(headers.HasHeader("Authorization")); |
4198 } | 4200 } |
4199 | 4201 |
4200 base::RunLoop().Run(); | |
4201 | |
4202 EXPECT_EQ(OK, d.request_status()); | 4202 EXPECT_EQ(OK, d.request_status()); |
4203 EXPECT_EQ(200, r->GetResponseCode()); | 4203 EXPECT_EQ(200, r->GetResponseCode()); |
4204 EXPECT_TRUE(d.auth_required_called()); | 4204 EXPECT_TRUE(d.auth_required_called()); |
4205 EXPECT_EQ(1, network_delegate.created_requests()); | 4205 EXPECT_EQ(1, network_delegate.created_requests()); |
4206 EXPECT_EQ(0, network_delegate.destroyed_requests()); | 4206 EXPECT_EQ(0, network_delegate.destroyed_requests()); |
4207 } | 4207 } |
4208 EXPECT_EQ(1, network_delegate.destroyed_requests()); | 4208 EXPECT_EQ(1, network_delegate.destroyed_requests()); |
4209 } | 4209 } |
4210 | 4210 |
4211 // Tests that the network delegate can synchronously complete OnAuthRequired | 4211 // Tests that the network delegate can synchronously complete OnAuthRequired |
(...skipping 6847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11059 AddTestInterceptor()->set_main_intercept_job(std::move(job)); | 11059 AddTestInterceptor()->set_main_intercept_job(std::move(job)); |
11060 | 11060 |
11061 req->Start(); | 11061 req->Start(); |
11062 req->Cancel(); | 11062 req->Cancel(); |
11063 base::RunLoop().RunUntilIdle(); | 11063 base::RunLoop().RunUntilIdle(); |
11064 EXPECT_EQ(ERR_ABORTED, d.request_status()); | 11064 EXPECT_EQ(ERR_ABORTED, d.request_status()); |
11065 EXPECT_EQ(0, d.received_redirect_count()); | 11065 EXPECT_EQ(0, d.received_redirect_count()); |
11066 } | 11066 } |
11067 | 11067 |
11068 } // namespace net | 11068 } // namespace net |
OLD | NEW |