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 "net/proxy/proxy_server.h" | 7 #include "net/proxy/proxy_server.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace net { | 10 namespace net { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 }; | 82 }; |
83 | 83 |
84 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | 84 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { |
85 ProxyList list; | 85 ProxyList list; |
86 list.SetFromPacString(tests[i].pac_input); | 86 list.SetFromPacString(tests[i].pac_input); |
87 list.RemoveProxiesWithoutScheme(tests[i].filter); | 87 list.RemoveProxiesWithoutScheme(tests[i].filter); |
88 EXPECT_EQ(tests[i].filtered_pac_output, list.ToPacString()); | 88 EXPECT_EQ(tests[i].filtered_pac_output, list.ToPacString()); |
89 } | 89 } |
90 } | 90 } |
91 | 91 |
92 TEST(ProxyListTest, HasUntriedProxies) { | |
93 // As in DeprioritizeBadProxies, we use a lengthy timeout to avoid depending | |
94 // on the current time. | |
95 ProxyRetryInfo proxy_retry_info; | |
96 proxy_retry_info.bad_until = | |
97 base::TimeTicks::Now() + base::TimeDelta::FromDays(1); | |
98 | |
99 // An empty list has nothing to try. | |
100 { | |
101 ProxyList list; | |
102 ProxyRetryInfoMap proxy_retry_info; | |
103 EXPECT_FALSE(list.HasUntriedProxies(proxy_retry_info)); | |
104 } | |
105 | |
106 // A list with one bad proxy has something to try. With two bad proxies, | |
107 // there's nothing to try. | |
108 { | |
109 ProxyList list; | |
110 list.SetFromPacString("PROXY bad1:80; PROXY bad2:80"); | |
eroman
2012/10/12 18:30:58
Also consider adding a test with PAC string that c
Michael Piatek
2012/10/15 17:10:16
Done.
| |
111 ProxyRetryInfoMap retry_info_map; | |
112 retry_info_map["bad1:80"] = proxy_retry_info; | |
113 EXPECT_TRUE(list.HasUntriedProxies(retry_info_map)); | |
114 retry_info_map["bad2:80"] = proxy_retry_info; | |
115 EXPECT_FALSE(list.HasUntriedProxies(retry_info_map)); | |
116 } | |
117 } | |
118 | |
92 TEST(ProxyListTest, DeprioritizeBadProxies) { | 119 TEST(ProxyListTest, DeprioritizeBadProxies) { |
93 // Retry info that marks a proxy as being bad for a *very* long time (to avoid | 120 // Retry info that marks a proxy as being bad for a *very* long time (to avoid |
94 // the test depending on the current time.) | 121 // the test depending on the current time.) |
95 ProxyRetryInfo proxy_retry_info; | 122 ProxyRetryInfo proxy_retry_info; |
96 proxy_retry_info.bad_until = | 123 proxy_retry_info.bad_until = |
97 base::TimeTicks::Now() + base::TimeDelta::FromDays(1); | 124 base::TimeTicks::Now() + base::TimeDelta::FromDays(1); |
98 | 125 |
99 // Call DeprioritizeBadProxies with an empty map -- should have no effect. | 126 // Call DeprioritizeBadProxies with an empty map -- should have no effect. |
100 { | 127 { |
101 ProxyList list; | 128 ProxyList list; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
138 list.DeprioritizeBadProxies(retry_info_map); | 165 list.DeprioritizeBadProxies(retry_info_map); |
139 | 166 |
140 EXPECT_EQ("PROXY foopy1:80;PROXY foopy2:80;PROXY foopy3:80", | 167 EXPECT_EQ("PROXY foopy1:80;PROXY foopy2:80;PROXY foopy3:80", |
141 list.ToPacString()); | 168 list.ToPacString()); |
142 } | 169 } |
143 } | 170 } |
144 | 171 |
145 } // namesapce | 172 } // namesapce |
146 | 173 |
147 } // namespace net | 174 } // namespace net |
OLD | NEW |