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 4178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4189 context.Init(); | 4189 context.Init(); |
4190 | 4190 |
4191 d.set_credentials(AuthCredentials(kUser, kSecret)); | 4191 d.set_credentials(AuthCredentials(kUser, kSecret)); |
4192 | 4192 |
4193 { | 4193 { |
4194 GURL url(http_test_server()->GetURL("/auth-basic")); | 4194 GURL url(http_test_server()->GetURL("/auth-basic")); |
4195 std::unique_ptr<URLRequest> r(context.CreateRequest( | 4195 std::unique_ptr<URLRequest> r(context.CreateRequest( |
4196 url, DEFAULT_PRIORITY, &d, TRAFFIC_ANNOTATION_FOR_TESTS)); | 4196 url, DEFAULT_PRIORITY, &d, TRAFFIC_ANNOTATION_FOR_TESTS)); |
4197 r->Start(); | 4197 r->Start(); |
4198 | 4198 |
| 4199 base::RunLoop().Run(); |
| 4200 |
4199 { | 4201 { |
4200 HttpRequestHeaders headers; | 4202 HttpRequestHeaders headers; |
4201 EXPECT_TRUE(r->GetFullRequestHeaders(&headers)); | 4203 EXPECT_TRUE(r->GetFullRequestHeaders(&headers)); |
4202 EXPECT_FALSE(headers.HasHeader("Authorization")); | 4204 EXPECT_TRUE(headers.HasHeader("Authorization")); |
4203 } | 4205 } |
4204 | 4206 |
4205 base::RunLoop().Run(); | |
4206 | |
4207 EXPECT_EQ(OK, d.request_status()); | 4207 EXPECT_EQ(OK, d.request_status()); |
4208 EXPECT_EQ(200, r->GetResponseCode()); | 4208 EXPECT_EQ(200, r->GetResponseCode()); |
4209 EXPECT_TRUE(d.auth_required_called()); | 4209 EXPECT_TRUE(d.auth_required_called()); |
4210 EXPECT_EQ(1, network_delegate.created_requests()); | 4210 EXPECT_EQ(1, network_delegate.created_requests()); |
4211 EXPECT_EQ(0, network_delegate.destroyed_requests()); | 4211 EXPECT_EQ(0, network_delegate.destroyed_requests()); |
4212 } | 4212 } |
4213 EXPECT_EQ(1, network_delegate.destroyed_requests()); | 4213 EXPECT_EQ(1, network_delegate.destroyed_requests()); |
4214 } | 4214 } |
4215 | 4215 |
4216 // Tests that the network delegate can synchronously complete OnAuthRequired | 4216 // Tests that the network delegate can synchronously complete OnAuthRequired |
(...skipping 6858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11075 AddTestInterceptor()->set_main_intercept_job(std::move(job)); | 11075 AddTestInterceptor()->set_main_intercept_job(std::move(job)); |
11076 | 11076 |
11077 req->Start(); | 11077 req->Start(); |
11078 req->Cancel(); | 11078 req->Cancel(); |
11079 base::RunLoop().RunUntilIdle(); | 11079 base::RunLoop().RunUntilIdle(); |
11080 EXPECT_EQ(ERR_ABORTED, d.request_status()); | 11080 EXPECT_EQ(ERR_ABORTED, d.request_status()); |
11081 EXPECT_EQ(0, d.received_redirect_count()); | 11081 EXPECT_EQ(0, d.received_redirect_count()); |
11082 } | 11082 } |
11083 | 11083 |
11084 } // namespace net | 11084 } // namespace net |
OLD | NEW |