Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2323)

Side by Side Diff: net/proxy/proxy_resolver_factory_mojo_unittest.cc

Issue 2083433002: Mojo: Remove url type converters. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/proxy/proxy_resolver_factory_mojo.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_resolver_factory_mojo.h" 5 #include "net/proxy/proxy_resolver_factory_mojo.h"
6 6
7 #include <list> 7 #include <list>
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <queue> 10 #include <queue>
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 185
186 void WaitForNextRequest(); 186 void WaitForNextRequest();
187 187
188 void ClearBlockedClients(); 188 void ClearBlockedClients();
189 189
190 void AddConnection(mojo::InterfaceRequest<interfaces::ProxyResolver> req); 190 void AddConnection(mojo::InterfaceRequest<interfaces::ProxyResolver> req);
191 191
192 private: 192 private:
193 // Overridden from interfaces::ProxyResolver: 193 // Overridden from interfaces::ProxyResolver:
194 void GetProxyForUrl( 194 void GetProxyForUrl(
195 const mojo::String& url, 195 const GURL& url,
196 interfaces::ProxyResolverRequestClientPtr client) override; 196 interfaces::ProxyResolverRequestClientPtr client) override;
197 197
198 void WakeWaiter(); 198 void WakeWaiter();
199 199
200 std::string pac_script_data_; 200 std::string pac_script_data_;
201 201
202 std::queue<GetProxyForUrlAction> get_proxy_actions_; 202 std::queue<GetProxyForUrlAction> get_proxy_actions_;
203 203
204 base::Closure quit_closure_; 204 base::Closure quit_closure_;
205 205
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 } 237 }
238 238
239 void MockMojoProxyResolver::AddConnection( 239 void MockMojoProxyResolver::AddConnection(
240 mojo::InterfaceRequest<interfaces::ProxyResolver> req) { 240 mojo::InterfaceRequest<interfaces::ProxyResolver> req) {
241 if (binding_.is_bound()) 241 if (binding_.is_bound())
242 binding_.Close(); 242 binding_.Close();
243 binding_.Bind(std::move(req)); 243 binding_.Bind(std::move(req));
244 } 244 }
245 245
246 void MockMojoProxyResolver::GetProxyForUrl( 246 void MockMojoProxyResolver::GetProxyForUrl(
247 const mojo::String& url, 247 const GURL& url,
248 interfaces::ProxyResolverRequestClientPtr client) { 248 interfaces::ProxyResolverRequestClientPtr client) {
249 ASSERT_FALSE(get_proxy_actions_.empty()); 249 ASSERT_FALSE(get_proxy_actions_.empty());
250 GetProxyForUrlAction action = get_proxy_actions_.front(); 250 GetProxyForUrlAction action = get_proxy_actions_.front();
251 get_proxy_actions_.pop(); 251 get_proxy_actions_.pop();
252 252
253 EXPECT_EQ(action.expected_url.spec(), url.To<std::string>()); 253 EXPECT_EQ(action.expected_url, url);
254 client->Alert(url); 254 client->Alert(url.spec());
255 client->OnError(12345, url); 255 client->OnError(12345, url.spec());
256 switch (action.action) { 256 switch (action.action) {
257 case GetProxyForUrlAction::COMPLETE: { 257 case GetProxyForUrlAction::COMPLETE: {
258 client->ReportResult(action.error, std::move(action.proxy_servers)); 258 client->ReportResult(action.error, std::move(action.proxy_servers));
259 break; 259 break;
260 } 260 }
261 case GetProxyForUrlAction::DROP: { 261 case GetProxyForUrlAction::DROP: {
262 client.reset(); 262 client.reset();
263 break; 263 break;
264 } 264 }
265 case GetProxyForUrlAction::DISCONNECT: { 265 case GetProxyForUrlAction::DISCONNECT: {
266 binding_.Close(); 266 binding_.Close();
267 break; 267 break;
268 } 268 }
269 case GetProxyForUrlAction::WAIT_FOR_CLIENT_DISCONNECT: { 269 case GetProxyForUrlAction::WAIT_FOR_CLIENT_DISCONNECT: {
270 ASSERT_FALSE(client.WaitForIncomingResponse()); 270 ASSERT_FALSE(client.WaitForIncomingResponse());
271 break; 271 break;
272 } 272 }
273 case GetProxyForUrlAction::MAKE_DNS_REQUEST: { 273 case GetProxyForUrlAction::MAKE_DNS_REQUEST: {
274 interfaces::HostResolverRequestInfoPtr request( 274 interfaces::HostResolverRequestInfoPtr request(
275 interfaces::HostResolverRequestInfo::New()); 275 interfaces::HostResolverRequestInfo::New());
276 request->host = url; 276 request->host = url.spec();
277 request->port = 12345; 277 request->port = 12345;
278 interfaces::HostResolverRequestClientPtr dns_client; 278 interfaces::HostResolverRequestClientPtr dns_client;
279 mojo::GetProxy(&dns_client); 279 mojo::GetProxy(&dns_client);
280 client->ResolveDns(std::move(request), std::move(dns_client)); 280 client->ResolveDns(std::move(request), std::move(dns_client));
281 blocked_clients_.push_back(base::WrapUnique( 281 blocked_clients_.push_back(base::WrapUnique(
282 new interfaces::ProxyResolverRequestClientPtr(std::move(client)))); 282 new interfaces::ProxyResolverRequestClientPtr(std::move(client))));
283 break; 283 break;
284 } 284 }
285 } 285 }
286 WakeWaiter(); 286 WakeWaiter();
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 mock_proxy_resolver_.ClearBlockedClients(); 891 mock_proxy_resolver_.ClearBlockedClients();
892 request->WaitForResult(); 892 request->WaitForResult();
893 } 893 }
894 894
895 TEST_F(ProxyResolverFactoryMojoTest, DeleteResolver) { 895 TEST_F(ProxyResolverFactoryMojoTest, DeleteResolver) {
896 CreateProxyResolver(); 896 CreateProxyResolver();
897 proxy_resolver_mojo_.reset(); 897 proxy_resolver_mojo_.reset();
898 on_delete_callback_.WaitForResult(); 898 on_delete_callback_.WaitForResult();
899 } 899 }
900 } // namespace net 900 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/proxy_resolver_factory_mojo.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698