OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/base/test_proxy_delegate.h" | 5 #include "net/base/test_proxy_delegate.h" |
6 | 6 |
7 #include "net/http/http_request_headers.h" | 7 #include "net/http/http_request_headers.h" |
8 #include "net/http/http_response_headers.h" | 8 #include "net/http/http_response_headers.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
11 namespace net { | 11 namespace net { |
12 | 12 |
13 TestProxyDelegate::TestProxyDelegate() | 13 TestProxyDelegate::TestProxyDelegate() |
14 : on_before_tunnel_request_called_(false), | 14 : on_before_tunnel_request_called_(false), |
15 on_tunnel_request_completed_called_(false), | 15 on_tunnel_request_completed_called_(false), |
16 on_tunnel_headers_received_called_(false) {} | 16 on_tunnel_headers_received_called_(false), |
| 17 get_alternative_proxy_invocations_(0) {} |
17 | 18 |
18 TestProxyDelegate::~TestProxyDelegate() {} | 19 TestProxyDelegate::~TestProxyDelegate() {} |
19 | 20 |
20 void TestProxyDelegate::VerifyOnTunnelRequestCompleted( | 21 void TestProxyDelegate::VerifyOnTunnelRequestCompleted( |
21 const std::string& endpoint, | 22 const std::string& endpoint, |
22 const std::string& proxy_server) const { | 23 const std::string& proxy_server) const { |
23 EXPECT_TRUE(on_tunnel_request_completed_called_); | 24 EXPECT_TRUE(on_tunnel_request_completed_called_); |
24 EXPECT_TRUE(HostPortPair::FromString(endpoint).Equals( | 25 EXPECT_TRUE(HostPortPair::FromString(endpoint).Equals( |
25 on_tunnel_request_completed_endpoint_)); | 26 on_tunnel_request_completed_endpoint_)); |
26 EXPECT_TRUE(HostPortPair::FromString(proxy_server) | 27 EXPECT_TRUE(HostPortPair::FromString(proxy_server) |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 on_tunnel_headers_received_origin_ = origin; | 73 on_tunnel_headers_received_origin_ = origin; |
73 on_tunnel_headers_received_proxy_server_ = proxy_server; | 74 on_tunnel_headers_received_proxy_server_ = proxy_server; |
74 on_tunnel_headers_received_status_line_ = response_headers.GetStatusLine(); | 75 on_tunnel_headers_received_status_line_ = response_headers.GetStatusLine(); |
75 } | 76 } |
76 | 77 |
77 bool TestProxyDelegate::IsTrustedSpdyProxy( | 78 bool TestProxyDelegate::IsTrustedSpdyProxy( |
78 const net::ProxyServer& proxy_server) { | 79 const net::ProxyServer& proxy_server) { |
79 return proxy_server.is_valid() && trusted_spdy_proxy_ == proxy_server; | 80 return proxy_server.is_valid() && trusted_spdy_proxy_ == proxy_server; |
80 } | 81 } |
81 | 82 |
| 83 void TestProxyDelegate::GetAlternativeProxy( |
| 84 const GURL& url, |
| 85 const ProxyServer& resolved_proxy_server, |
| 86 ProxyServer* alternative_proxy_server) const { |
| 87 EXPECT_TRUE(resolved_proxy_server.is_valid()); |
| 88 EXPECT_FALSE(alternative_proxy_server->is_valid()); |
| 89 *alternative_proxy_server = alternative_proxy_server_; |
| 90 get_alternative_proxy_invocations_++; |
| 91 } |
| 92 |
| 93 void TestProxyDelegate::OnAlternativeProxyBroken( |
| 94 const ProxyServer& alternative_proxy_server) { |
| 95 EXPECT_TRUE(alternative_proxy_server.is_valid()); |
| 96 EXPECT_EQ(alternative_proxy_server_, alternative_proxy_server); |
| 97 alternative_proxy_server_ = ProxyServer(); |
| 98 } |
| 99 |
82 } // namespace net | 100 } // namespace net |
OLD | NEW |