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

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

Issue 10987043: Receiving Connection: Proxy-Bypass induces proxy fallback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Build fix for android_dbg. Created 8 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « net/proxy/proxy_list.cc ('k') | net/proxy/proxy_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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");
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 // A list with one bad proxy and a DIRECT entry has something to try.
119 {
120 ProxyList list;
121 list.SetFromPacString("PROXY bad1:80; DIRECT");
122 ProxyRetryInfoMap retry_info_map;
123 retry_info_map["bad1:80"] = proxy_retry_info;
124 EXPECT_TRUE(list.HasUntriedProxies(retry_info_map));
125 }
126 }
127
92 TEST(ProxyListTest, DeprioritizeBadProxies) { 128 TEST(ProxyListTest, DeprioritizeBadProxies) {
93 // Retry info that marks a proxy as being bad for a *very* long time (to avoid 129 // Retry info that marks a proxy as being bad for a *very* long time (to avoid
94 // the test depending on the current time.) 130 // the test depending on the current time.)
95 ProxyRetryInfo proxy_retry_info; 131 ProxyRetryInfo proxy_retry_info;
96 proxy_retry_info.bad_until = 132 proxy_retry_info.bad_until =
97 base::TimeTicks::Now() + base::TimeDelta::FromDays(1); 133 base::TimeTicks::Now() + base::TimeDelta::FromDays(1);
98 134
99 // Call DeprioritizeBadProxies with an empty map -- should have no effect. 135 // Call DeprioritizeBadProxies with an empty map -- should have no effect.
100 { 136 {
101 ProxyList list; 137 ProxyList list;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 list.DeprioritizeBadProxies(retry_info_map); 174 list.DeprioritizeBadProxies(retry_info_map);
139 175
140 EXPECT_EQ("PROXY foopy1:80;PROXY foopy2:80;PROXY foopy3:80", 176 EXPECT_EQ("PROXY foopy1:80;PROXY foopy2:80;PROXY foopy3:80",
141 list.ToPacString()); 177 list.ToPacString());
142 } 178 }
143 } 179 }
144 180
145 } // namesapce 181 } // namesapce
146 182
147 } // namespace net 183 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/proxy_list.cc ('k') | net/proxy/proxy_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698