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 <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 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1190 // directory and does not end with a slash. Ensure that following such | 1190 // directory and does not end with a slash. Ensure that following such |
| 1191 // redirects does not crash. See http://crbug.com/18686. | 1191 // redirects does not crash. See http://crbug.com/18686. |
| 1192 | 1192 |
| 1193 base::FilePath path; | 1193 base::FilePath path; |
| 1194 PathService::Get(base::DIR_SOURCE_ROOT, &path); | 1194 PathService::Get(base::DIR_SOURCE_ROOT, &path); |
| 1195 path = path.Append(kTestFilePath); | 1195 path = path.Append(kTestFilePath); |
| 1196 | 1196 |
| 1197 TestDelegate d; | 1197 TestDelegate d; |
| 1198 std::unique_ptr<URLRequest> req( | 1198 std::unique_ptr<URLRequest> req( |
| 1199 default_context_.CreateRequest(FilePathToFileURL(path), DEFAULT_PRIORITY, | 1199 default_context_.CreateRequest(FilePathToFileURL(path), DEFAULT_PRIORITY, |
| 1200 &d, TRAFFIC_ANNOTATION_FOR_TESTS)); | 1200 &d, TRAFFIC_ANNOTATION_FOR_TESTS)); |
|
Randy Smith (Not in Mondays)
2017/05/21 21:32:02
Note for future CLs/PSs: I presume this means that
shivanisha
2017/05/26 16:26:17
Acknowledged. Sorry for any confusions.
| |
| 1201 req->Start(); | 1201 req->Start(); |
| 1202 base::RunLoop().Run(); | 1202 base::RunLoop().Run(); |
| 1203 | 1203 |
| 1204 ASSERT_EQ(1, d.received_redirect_count()); | 1204 ASSERT_EQ(1, d.received_redirect_count()); |
| 1205 ASSERT_LT(0, d.bytes_received()); | 1205 ASSERT_LT(0, d.bytes_received()); |
| 1206 ASSERT_FALSE(d.request_failed()); | 1206 ASSERT_FALSE(d.request_failed()); |
| 1207 EXPECT_EQ(OK, d.request_status()); | 1207 EXPECT_EQ(OK, d.request_status()); |
| 1208 } | 1208 } |
| 1209 | 1209 |
| 1210 #if defined(OS_WIN) | 1210 #if defined(OS_WIN) |
| (...skipping 2978 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 |