OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/proxy/proxy_service_mojo.h" | 5 #include "net/proxy/proxy_service_mojo.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 } // namespace | 125 } // namespace |
126 | 126 |
127 class ProxyServiceMojoTest : public testing::Test, | 127 class ProxyServiceMojoTest : public testing::Test, |
128 public MojoProxyResolverFactory { | 128 public MojoProxyResolverFactory { |
129 protected: | 129 protected: |
130 void SetUp() override { | 130 void SetUp() override { |
131 mock_host_resolver_.rules()->AddRule("example.com", "1.2.3.4"); | 131 mock_host_resolver_.rules()->AddRule("example.com", "1.2.3.4"); |
132 | 132 |
133 fetcher_ = new MockProxyScriptFetcher; | 133 fetcher_ = new MockProxyScriptFetcher; |
134 proxy_service_ = CreateProxyServiceUsingMojoFactory( | 134 proxy_service_ = CreateProxyServiceUsingMojoFactory( |
135 this, base::WrapUnique(new ProxyConfigServiceFixed( | 135 this, base::MakeUnique<ProxyConfigServiceFixed>( |
136 ProxyConfig::CreateFromCustomPacURL(GURL(kPacUrl)))), | 136 ProxyConfig::CreateFromCustomPacURL(GURL(kPacUrl))), |
137 fetcher_, base::WrapUnique(new DoNothingDhcpProxyScriptFetcher()), | 137 fetcher_, base::MakeUnique<DoNothingDhcpProxyScriptFetcher>(), |
138 &mock_host_resolver_, &net_log_, &network_delegate_); | 138 &mock_host_resolver_, &net_log_, &network_delegate_); |
139 } | 139 } |
140 | 140 |
141 std::unique_ptr<base::ScopedClosureRunner> CreateResolver( | 141 std::unique_ptr<base::ScopedClosureRunner> CreateResolver( |
142 const mojo::String& pac_script, | 142 const mojo::String& pac_script, |
143 mojo::InterfaceRequest<interfaces::ProxyResolver> req, | 143 mojo::InterfaceRequest<interfaces::ProxyResolver> req, |
144 interfaces::ProxyResolverFactoryRequestClientPtr client) override { | 144 interfaces::ProxyResolverFactoryRequestClientPtr client) override { |
145 InProcessMojoProxyResolverFactory::GetInstance()->CreateResolver( | 145 InProcessMojoProxyResolverFactory::GetInstance()->CreateResolver( |
146 pac_script, std::move(req), std::move(client)); | 146 pac_script, std::move(req), std::move(client)); |
147 return base::WrapUnique( | 147 return base::MakeUnique<base::ScopedClosureRunner>( |
148 new base::ScopedClosureRunner(on_delete_closure_.closure())); | 148 on_delete_closure_.closure()); |
149 } | 149 } |
150 | 150 |
151 TestNetworkDelegate network_delegate_; | 151 TestNetworkDelegate network_delegate_; |
152 LoggingMockHostResolver mock_host_resolver_; | 152 LoggingMockHostResolver mock_host_resolver_; |
153 MockProxyScriptFetcher* fetcher_; // Owned by |proxy_service_|. | 153 MockProxyScriptFetcher* fetcher_; // Owned by |proxy_service_|. |
154 TestNetLog net_log_; | 154 TestNetLog net_log_; |
155 TestClosure on_delete_closure_; | 155 TestClosure on_delete_closure_; |
156 std::unique_ptr<ProxyService> proxy_service_; | 156 std::unique_ptr<ProxyService> proxy_service_; |
157 }; | 157 }; |
158 | 158 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 258 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
259 EXPECT_EQ("DIRECT", info.ToPacString()); | 259 EXPECT_EQ("DIRECT", info.ToPacString()); |
260 EXPECT_EQ(0u, mock_host_resolver_.num_resolve()); | 260 EXPECT_EQ(0u, mock_host_resolver_.num_resolve()); |
261 | 261 |
262 TestNetLogEntry::List entries; | 262 TestNetLogEntry::List entries; |
263 net_log_.GetEntries(&entries); | 263 net_log_.GetEntries(&entries); |
264 CheckCapturedNetLogEntries(entries); | 264 CheckCapturedNetLogEntries(entries); |
265 } | 265 } |
266 | 266 |
267 } // namespace net | 267 } // namespace net |
OLD | NEW |