| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_list.h" | 5 #include "net/proxy/proxy_list.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
| 10 #include "net/log/net_log.h" | 10 #include "net/log/net_log.h" |
| 11 #include "net/proxy/proxy_retry_info.h" | 11 #include "net/proxy/proxy_retry_info.h" |
| 12 #include "net/proxy/proxy_server.h" | 12 #include "net/proxy/proxy_server.h" |
| 13 #include "net/test/gtest_util.h" |
| 14 #include "testing/gmock/include/gmock/gmock.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 16 |
| 17 using net::test::IsOk; |
| 18 |
| 15 namespace net { | 19 namespace net { |
| 16 | 20 |
| 17 namespace { | 21 namespace { |
| 18 | 22 |
| 19 // Test parsing from a PAC string. | 23 // Test parsing from a PAC string. |
| 20 TEST(ProxyListTest, SetFromPacString) { | 24 TEST(ProxyListTest, SetFromPacString) { |
| 21 const struct { | 25 const struct { |
| 22 const char* pac_input; | 26 const char* pac_input; |
| 23 const char* pac_output; | 27 const char* pac_output; |
| 24 } tests[] = { | 28 } tests[] = { |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 BoundNetLog net_log; | 201 BoundNetLog net_log; |
| 198 ProxyServer proxy_server( | 202 ProxyServer proxy_server( |
| 199 ProxyServer::FromURI("foopy1:80", ProxyServer::SCHEME_HTTP)); | 203 ProxyServer::FromURI("foopy1:80", ProxyServer::SCHEME_HTTP)); |
| 200 std::vector<ProxyServer> bad_proxies; | 204 std::vector<ProxyServer> bad_proxies; |
| 201 bad_proxies.push_back(proxy_server); | 205 bad_proxies.push_back(proxy_server); |
| 202 list.SetFromPacString("PROXY foopy1:80;PROXY foopy2:80;PROXY foopy3:80"); | 206 list.SetFromPacString("PROXY foopy1:80;PROXY foopy2:80;PROXY foopy3:80"); |
| 203 list.UpdateRetryInfoOnFallback(&retry_info_map, | 207 list.UpdateRetryInfoOnFallback(&retry_info_map, |
| 204 base::TimeDelta::FromSeconds(60), true, | 208 base::TimeDelta::FromSeconds(60), true, |
| 205 bad_proxies, OK, net_log); | 209 bad_proxies, OK, net_log); |
| 206 EXPECT_TRUE(retry_info_map.end() != retry_info_map.find("foopy1:80")); | 210 EXPECT_TRUE(retry_info_map.end() != retry_info_map.find("foopy1:80")); |
| 207 EXPECT_EQ(OK, retry_info_map[proxy_server.ToURI()].net_error); | 211 EXPECT_THAT(retry_info_map[proxy_server.ToURI()].net_error, IsOk()); |
| 208 EXPECT_TRUE(retry_info_map.end() == retry_info_map.find("foopy2:80")); | 212 EXPECT_TRUE(retry_info_map.end() == retry_info_map.find("foopy2:80")); |
| 209 EXPECT_TRUE(retry_info_map.end() == retry_info_map.find("foopy3:80")); | 213 EXPECT_TRUE(retry_info_map.end() == retry_info_map.find("foopy3:80")); |
| 210 } | 214 } |
| 211 // Including another bad proxy should put both the first and the specified | 215 // Including another bad proxy should put both the first and the specified |
| 212 // proxy on the retry list. | 216 // proxy on the retry list. |
| 213 { | 217 { |
| 214 ProxyList list; | 218 ProxyList list; |
| 215 ProxyRetryInfoMap retry_info_map; | 219 ProxyRetryInfoMap retry_info_map; |
| 216 BoundNetLog net_log; | 220 BoundNetLog net_log; |
| 217 ProxyServer proxy_server = ProxyServer::FromURI("foopy3:80", | 221 ProxyServer proxy_server = ProxyServer::FromURI("foopy3:80", |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 EXPECT_GT(retry_info_map["foopy1:80"].bad_until, | 307 EXPECT_GT(retry_info_map["foopy1:80"].bad_until, |
| 304 base::TimeTicks::Now() + base::TimeDelta::FromSeconds(30)); | 308 base::TimeTicks::Now() + base::TimeDelta::FromSeconds(30)); |
| 305 EXPECT_TRUE(retry_info_map.end() == retry_info_map.find("foopy2:80")); | 309 EXPECT_TRUE(retry_info_map.end() == retry_info_map.find("foopy2:80")); |
| 306 EXPECT_TRUE(retry_info_map.end() == retry_info_map.find("foopy3:80")); | 310 EXPECT_TRUE(retry_info_map.end() == retry_info_map.find("foopy3:80")); |
| 307 } | 311 } |
| 308 } | 312 } |
| 309 | 313 |
| 310 } // namesapce | 314 } // namesapce |
| 311 | 315 |
| 312 } // namespace net | 316 } // namespace net |
| OLD | NEW |