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

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

Issue 473513002: Keep track of network error in ProxyRetryInfo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor formatting Created 6 years, 4 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_list.cc ('k') | net/proxy/proxy_retry_info.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/base/net_errors.h"
7 #include "net/base/net_log.h" 8 #include "net/base/net_log.h"
8 #include "net/proxy/proxy_retry_info.h" 9 #include "net/proxy/proxy_retry_info.h"
9 #include "net/proxy/proxy_server.h" 10 #include "net/proxy/proxy_server.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 12
12 namespace net { 13 namespace net {
13 14
14 namespace { 15 namespace {
15 16
16 // Test parsing from a PAC string. 17 // Test parsing from a PAC string.
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 } 166 }
166 } 167 }
167 168
168 TEST(ProxyListTest, UpdateRetryInfoOnFallback) { 169 TEST(ProxyListTest, UpdateRetryInfoOnFallback) {
169 ProxyRetryInfo proxy_retry_info; 170 ProxyRetryInfo proxy_retry_info;
170 // Retrying should put the first proxy on the retry list. 171 // Retrying should put the first proxy on the retry list.
171 { 172 {
172 ProxyList list; 173 ProxyList list;
173 ProxyRetryInfoMap retry_info_map; 174 ProxyRetryInfoMap retry_info_map;
174 BoundNetLog net_log; 175 BoundNetLog net_log;
176 ProxyServer proxy_server(
177 ProxyServer::FromURI("foopy1:80", ProxyServer::SCHEME_HTTP));
175 list.SetFromPacString("PROXY foopy1:80;PROXY foopy2:80;PROXY foopy3:80"); 178 list.SetFromPacString("PROXY foopy1:80;PROXY foopy2:80;PROXY foopy3:80");
176 list.UpdateRetryInfoOnFallback(&retry_info_map, 179 list.UpdateRetryInfoOnFallback(&retry_info_map,
177 base::TimeDelta::FromSeconds(60), 180 base::TimeDelta::FromSeconds(60),
178 true, 181 true,
179 ProxyServer(), 182 proxy_server,
183 ERR_PROXY_CONNECTION_FAILED,
180 net_log); 184 net_log);
181 EXPECT_TRUE(retry_info_map.end() != retry_info_map.find("foopy1:80")); 185 EXPECT_TRUE(retry_info_map.end() != retry_info_map.find("foopy1:80"));
186 EXPECT_EQ(ERR_PROXY_CONNECTION_FAILED,
187 retry_info_map[proxy_server.ToURI()].net_error);
182 EXPECT_TRUE(retry_info_map.end() == retry_info_map.find("foopy2:80")); 188 EXPECT_TRUE(retry_info_map.end() == retry_info_map.find("foopy2:80"));
183 EXPECT_TRUE(retry_info_map.end() == retry_info_map.find("foopy3:80")); 189 EXPECT_TRUE(retry_info_map.end() == retry_info_map.find("foopy3:80"));
184 } 190 }
191 // Retrying should put the first proxy on the retry list, even if there
192 // was no network error.
193 {
194 ProxyList list;
195 ProxyRetryInfoMap retry_info_map;
196 BoundNetLog net_log;
197 ProxyServer proxy_server(
198 ProxyServer::FromURI("foopy1:80", ProxyServer::SCHEME_HTTP));
199 list.SetFromPacString("PROXY foopy1:80;PROXY foopy2:80;PROXY foopy3:80");
200 list.UpdateRetryInfoOnFallback(&retry_info_map,
201 base::TimeDelta::FromSeconds(60),
202 true,
203 proxy_server,
204 OK,
205 net_log);
206 EXPECT_TRUE(retry_info_map.end() != retry_info_map.find("foopy1:80"));
207 EXPECT_EQ(OK, retry_info_map[proxy_server.ToURI()].net_error);
208 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"));
210 }
185 // Including another bad proxy should put both the first and the specified 211 // Including another bad proxy should put both the first and the specified
186 // proxy on the retry list. 212 // proxy on the retry list.
187 { 213 {
188 ProxyList list; 214 ProxyList list;
189 ProxyRetryInfoMap retry_info_map; 215 ProxyRetryInfoMap retry_info_map;
190 BoundNetLog net_log; 216 BoundNetLog net_log;
191 ProxyServer proxy_server = ProxyServer::FromURI("foopy3:80", 217 ProxyServer proxy_server = ProxyServer::FromURI("foopy3:80",
192 ProxyServer::SCHEME_HTTP); 218 ProxyServer::SCHEME_HTTP);
193 list.SetFromPacString("PROXY foopy1:80;PROXY foopy2:80;PROXY foopy3:80"); 219 list.SetFromPacString("PROXY foopy1:80;PROXY foopy2:80;PROXY foopy3:80");
194 list.UpdateRetryInfoOnFallback(&retry_info_map, 220 list.UpdateRetryInfoOnFallback(&retry_info_map,
195 base::TimeDelta::FromSeconds(60), 221 base::TimeDelta::FromSeconds(60),
196 true, 222 true,
197 proxy_server, 223 proxy_server,
224 ERR_NAME_RESOLUTION_FAILED,
198 net_log); 225 net_log);
199 EXPECT_TRUE(retry_info_map.end() != retry_info_map.find("foopy1:80")); 226 EXPECT_TRUE(retry_info_map.end() != retry_info_map.find("foopy1:80"));
227 EXPECT_EQ(ERR_NAME_RESOLUTION_FAILED,
228 retry_info_map[proxy_server.ToURI()].net_error);
200 EXPECT_TRUE(retry_info_map.end() == retry_info_map.find("foopy2:80")); 229 EXPECT_TRUE(retry_info_map.end() == retry_info_map.find("foopy2:80"));
201 EXPECT_TRUE(retry_info_map.end() != retry_info_map.find("foopy3:80")); 230 EXPECT_TRUE(retry_info_map.end() != retry_info_map.find("foopy3:80"));
202 } 231 }
203 // If the first proxy is DIRECT, nothing is added to the retry list, even 232 // If the first proxy is DIRECT, nothing is added to the retry list, even
204 // if another bad proxy is specified. 233 // if another bad proxy is specified.
205 { 234 {
206 ProxyList list; 235 ProxyList list;
207 ProxyRetryInfoMap retry_info_map; 236 ProxyRetryInfoMap retry_info_map;
208 BoundNetLog net_log; 237 BoundNetLog net_log;
209 ProxyServer proxy_server = ProxyServer::FromURI("foopy2:80", 238 ProxyServer proxy_server = ProxyServer::FromURI("foopy2:80",
210 ProxyServer::SCHEME_HTTP); 239 ProxyServer::SCHEME_HTTP);
211 list.SetFromPacString("DIRECT;PROXY foopy2:80;PROXY foopy3:80"); 240 list.SetFromPacString("DIRECT;PROXY foopy2:80;PROXY foopy3:80");
212 list.UpdateRetryInfoOnFallback(&retry_info_map, 241 list.UpdateRetryInfoOnFallback(&retry_info_map,
213 base::TimeDelta::FromSeconds(60), 242 base::TimeDelta::FromSeconds(60),
214 true, 243 true,
215 proxy_server, 244 proxy_server,
245 OK,
216 net_log); 246 net_log);
217 EXPECT_TRUE(retry_info_map.end() == retry_info_map.find("foopy2:80")); 247 EXPECT_TRUE(retry_info_map.end() == retry_info_map.find("foopy2:80"));
218 EXPECT_TRUE(retry_info_map.end() == retry_info_map.find("foopy3:80")); 248 EXPECT_TRUE(retry_info_map.end() == retry_info_map.find("foopy3:80"));
219 } 249 }
220 } 250 }
221 251
222 } // namesapce 252 } // namesapce
223 253
224 } // namespace net 254 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/proxy_list.cc ('k') | net/proxy/proxy_retry_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698