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/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 int return_code_; | 54 int return_code_; |
55 std::string supported_scheme_; | 55 std::string supported_scheme_; |
56 }; | 56 }; |
57 | 57 |
58 class URLRequestContextBuilderTest : public PlatformTest { | 58 class URLRequestContextBuilderTest : public PlatformTest { |
59 protected: | 59 protected: |
60 URLRequestContextBuilderTest() { | 60 URLRequestContextBuilderTest() { |
61 test_server_.AddDefaultHandlers( | 61 test_server_.AddDefaultHandlers( |
62 base::FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest"))); | 62 base::FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest"))); |
63 #if defined(OS_LINUX) || defined(OS_ANDROID) | 63 #if defined(OS_LINUX) || defined(OS_ANDROID) |
64 builder_.set_proxy_config_service(base::WrapUnique( | 64 builder_.set_proxy_config_service( |
65 new ProxyConfigServiceFixed(ProxyConfig::CreateDirect()))); | 65 base::MakeUnique<ProxyConfigServiceFixed>(ProxyConfig::CreateDirect())); |
66 #endif // defined(OS_LINUX) || defined(OS_ANDROID) | 66 #endif // defined(OS_LINUX) || defined(OS_ANDROID) |
67 } | 67 } |
68 | 68 |
69 EmbeddedTestServer test_server_; | 69 EmbeddedTestServer test_server_; |
70 URLRequestContextBuilder builder_; | 70 URLRequestContextBuilder builder_; |
71 }; | 71 }; |
72 | 72 |
73 TEST_F(URLRequestContextBuilderTest, DefaultSettings) { | 73 TEST_F(URLRequestContextBuilderTest, DefaultSettings) { |
74 ASSERT_TRUE(test_server_.Start()); | 74 ASSERT_TRUE(test_server_.Start()); |
75 | 75 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 EXPECT_EQ(OK, | 109 EXPECT_EQ(OK, |
110 context->http_auth_handler_factory()->CreateAuthHandlerFromString( | 110 context->http_auth_handler_factory()->CreateAuthHandlerFromString( |
111 "basic", HttpAuth::AUTH_SERVER, null_ssl_info, gurl, | 111 "basic", HttpAuth::AUTH_SERVER, null_ssl_info, gurl, |
112 BoundNetLog(), &handler)); | 112 BoundNetLog(), &handler)); |
113 } | 113 } |
114 | 114 |
115 TEST_F(URLRequestContextBuilderTest, CustomHttpAuthHandlerFactory) { | 115 TEST_F(URLRequestContextBuilderTest, CustomHttpAuthHandlerFactory) { |
116 GURL gurl("www.google.com"); | 116 GURL gurl("www.google.com"); |
117 const int kBasicReturnCode = OK; | 117 const int kBasicReturnCode = OK; |
118 std::unique_ptr<HttpAuthHandler> handler; | 118 std::unique_ptr<HttpAuthHandler> handler; |
119 builder_.SetHttpAuthHandlerFactory(base::WrapUnique( | 119 builder_.SetHttpAuthHandlerFactory( |
120 new MockHttpAuthHandlerFactory("ExtraScheme", kBasicReturnCode))); | 120 base::MakeUnique<MockHttpAuthHandlerFactory>("ExtraScheme", |
| 121 kBasicReturnCode)); |
121 std::unique_ptr<URLRequestContext> context(builder_.Build()); | 122 std::unique_ptr<URLRequestContext> context(builder_.Build()); |
122 SSLInfo null_ssl_info; | 123 SSLInfo null_ssl_info; |
123 // Verify that a handler is returned for a custom scheme. | 124 // Verify that a handler is returned for a custom scheme. |
124 EXPECT_EQ(kBasicReturnCode, | 125 EXPECT_EQ(kBasicReturnCode, |
125 context->http_auth_handler_factory()->CreateAuthHandlerFromString( | 126 context->http_auth_handler_factory()->CreateAuthHandlerFromString( |
126 "ExtraScheme", HttpAuth::AUTH_SERVER, null_ssl_info, gurl, | 127 "ExtraScheme", HttpAuth::AUTH_SERVER, null_ssl_info, gurl, |
127 BoundNetLog(), &handler)); | 128 BoundNetLog(), &handler)); |
128 | 129 |
129 // Verify that the default basic handler isn't present | 130 // Verify that the default basic handler isn't present |
130 EXPECT_EQ(ERR_UNSUPPORTED_AUTH_SCHEME, | 131 EXPECT_EQ(ERR_UNSUPPORTED_AUTH_SCHEME, |
131 context->http_auth_handler_factory()->CreateAuthHandlerFromString( | 132 context->http_auth_handler_factory()->CreateAuthHandlerFromString( |
132 "basic", HttpAuth::AUTH_SERVER, null_ssl_info, gurl, | 133 "basic", HttpAuth::AUTH_SERVER, null_ssl_info, gurl, |
133 BoundNetLog(), &handler)); | 134 BoundNetLog(), &handler)); |
134 | 135 |
135 // Verify that a handler isn't returned for a bogus scheme. | 136 // Verify that a handler isn't returned for a bogus scheme. |
136 EXPECT_EQ(ERR_UNSUPPORTED_AUTH_SCHEME, | 137 EXPECT_EQ(ERR_UNSUPPORTED_AUTH_SCHEME, |
137 context->http_auth_handler_factory()->CreateAuthHandlerFromString( | 138 context->http_auth_handler_factory()->CreateAuthHandlerFromString( |
138 "Bogus", HttpAuth::AUTH_SERVER, null_ssl_info, gurl, | 139 "Bogus", HttpAuth::AUTH_SERVER, null_ssl_info, gurl, |
139 BoundNetLog(), &handler)); | 140 BoundNetLog(), &handler)); |
140 } | 141 } |
141 | 142 |
142 } // namespace | 143 } // namespace |
143 | 144 |
144 } // namespace net | 145 } // namespace net |
OLD | NEW |