| 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 "net/url_request/url_request_context_builder.h" | 5 #include "net/url_request/url_request_context_builder.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/message_loop/message_loop.h" | |
| 11 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 12 #include "base/test/scoped_task_scheduler.h" | |
| 13 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 14 #include "net/base/request_priority.h" | 12 #include "net/base/request_priority.h" |
| 15 #include "net/http/http_auth_challenge_tokenizer.h" | 13 #include "net/http/http_auth_challenge_tokenizer.h" |
| 16 #include "net/http/http_auth_handler.h" | 14 #include "net/http/http_auth_handler.h" |
| 17 #include "net/http/http_auth_handler_factory.h" | 15 #include "net/http/http_auth_handler_factory.h" |
| 18 #include "net/log/net_log_with_source.h" | 16 #include "net/log/net_log_with_source.h" |
| 19 #include "net/ssl/ssl_info.h" | 17 #include "net/ssl/ssl_info.h" |
| 20 #include "net/test/embedded_test_server/embedded_test_server.h" | 18 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 21 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" | 19 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" |
| 22 #include "net/url_request/url_request.h" | 20 #include "net/url_request/url_request.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 : ERR_UNSUPPORTED_AUTH_SCHEME; | 52 : ERR_UNSUPPORTED_AUTH_SCHEME; |
| 55 } | 53 } |
| 56 | 54 |
| 57 private: | 55 private: |
| 58 int return_code_; | 56 int return_code_; |
| 59 std::string supported_scheme_; | 57 std::string supported_scheme_; |
| 60 }; | 58 }; |
| 61 | 59 |
| 62 class URLRequestContextBuilderTest : public PlatformTest { | 60 class URLRequestContextBuilderTest : public PlatformTest { |
| 63 protected: | 61 protected: |
| 64 URLRequestContextBuilderTest() | 62 URLRequestContextBuilderTest() { |
| 65 : scoped_task_scheduler_(base::MessageLoop::current()) { | |
| 66 test_server_.AddDefaultHandlers( | 63 test_server_.AddDefaultHandlers( |
| 67 base::FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest"))); | 64 base::FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest"))); |
| 68 #if defined(OS_LINUX) || defined(OS_ANDROID) | 65 #if defined(OS_LINUX) || defined(OS_ANDROID) |
| 69 builder_.set_proxy_config_service( | 66 builder_.set_proxy_config_service( |
| 70 base::MakeUnique<ProxyConfigServiceFixed>(ProxyConfig::CreateDirect())); | 67 base::MakeUnique<ProxyConfigServiceFixed>(ProxyConfig::CreateDirect())); |
| 71 #endif // defined(OS_LINUX) || defined(OS_ANDROID) | 68 #endif // defined(OS_LINUX) || defined(OS_ANDROID) |
| 72 } | 69 } |
| 73 | 70 |
| 74 EmbeddedTestServer test_server_; | 71 EmbeddedTestServer test_server_; |
| 75 URLRequestContextBuilder builder_; | 72 URLRequestContextBuilder builder_; |
| 76 | |
| 77 private: | |
| 78 base::test::ScopedTaskScheduler scoped_task_scheduler_; | |
| 79 }; | 73 }; |
| 80 | 74 |
| 81 TEST_F(URLRequestContextBuilderTest, DefaultSettings) { | 75 TEST_F(URLRequestContextBuilderTest, DefaultSettings) { |
| 82 ASSERT_TRUE(test_server_.Start()); | 76 ASSERT_TRUE(test_server_.Start()); |
| 83 | 77 |
| 84 std::unique_ptr<URLRequestContext> context(builder_.Build()); | 78 std::unique_ptr<URLRequestContext> context(builder_.Build()); |
| 85 TestDelegate delegate; | 79 TestDelegate delegate; |
| 86 std::unique_ptr<URLRequest> request(context->CreateRequest( | 80 std::unique_ptr<URLRequest> request(context->CreateRequest( |
| 87 test_server_.GetURL("/echoheader?Foo"), DEFAULT_PRIORITY, &delegate, | 81 test_server_.GetURL("/echoheader?Foo"), DEFAULT_PRIORITY, &delegate, |
| 88 TRAFFIC_ANNOTATION_FOR_TESTS)); | 82 TRAFFIC_ANNOTATION_FOR_TESTS)); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 // Verify that a handler isn't returned for a bogus scheme. | 139 // Verify that a handler isn't returned for a bogus scheme. |
| 146 EXPECT_EQ(ERR_UNSUPPORTED_AUTH_SCHEME, | 140 EXPECT_EQ(ERR_UNSUPPORTED_AUTH_SCHEME, |
| 147 context->http_auth_handler_factory()->CreateAuthHandlerFromString( | 141 context->http_auth_handler_factory()->CreateAuthHandlerFromString( |
| 148 "Bogus", HttpAuth::AUTH_SERVER, null_ssl_info, gurl, | 142 "Bogus", HttpAuth::AUTH_SERVER, null_ssl_info, gurl, |
| 149 NetLogWithSource(), &handler)); | 143 NetLogWithSource(), &handler)); |
| 150 } | 144 } |
| 151 | 145 |
| 152 } // namespace | 146 } // namespace |
| 153 | 147 |
| 154 } // namespace net | 148 } // namespace net |
| OLD | NEW |