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

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

Issue 6831025: Adds support for the DHCP portion of the WPAD (proxy auto-discovery) protocol. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix memory leaks in unit test. Created 9 years, 7 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_service.h" 5 #include "net/proxy/proxy_service.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "googleurl/src/gurl.h" 13 #include "googleurl/src/gurl.h"
14 #include "net/base/net_errors.h" 14 #include "net/base/net_errors.h"
15 #include "net/base/net_log.h" 15 #include "net/base/net_log.h"
16 #include "net/base/net_log_unittest.h" 16 #include "net/base/net_log_unittest.h"
17 #include "net/base/test_completion_callback.h" 17 #include "net/base/test_completion_callback.h"
18 #include "net/proxy/dhcp_proxy_script_fetcher.h"
18 #include "net/proxy/mock_proxy_resolver.h" 19 #include "net/proxy/mock_proxy_resolver.h"
20 #include "net/proxy/mock_proxy_script_fetcher.h"
19 #include "net/proxy/proxy_config_service.h" 21 #include "net/proxy/proxy_config_service.h"
20 #include "net/proxy/proxy_resolver.h" 22 #include "net/proxy/proxy_resolver.h"
21 #include "net/proxy/proxy_script_fetcher.h" 23 #include "net/proxy/proxy_script_fetcher.h"
22 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
23 25
24 // TODO(eroman): Write a test which exercises 26 // TODO(eroman): Write a test which exercises
25 // ProxyService::SuspendAllPendingRequests(). 27 // ProxyService::SuspendAllPendingRequests().
26 namespace net { 28 namespace net {
27 namespace { 29 namespace {
28 30
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 } 62 }
61 63
62 private: 64 private:
63 ConfigAvailability availability_; 65 ConfigAvailability availability_;
64 ProxyConfig config_; 66 ProxyConfig config_;
65 ObserverList<Observer, true> observers_; 67 ObserverList<Observer, true> observers_;
66 }; 68 };
67 69
68 } // namespace 70 } // namespace
69 71
70 // A mock ProxyScriptFetcher. No result will be returned to the fetch client
71 // until we call NotifyFetchCompletion() to set the results.
72 class MockProxyScriptFetcher : public ProxyScriptFetcher {
73 public:
74 MockProxyScriptFetcher()
75 : pending_request_callback_(NULL), pending_request_text_(NULL) {
76 }
77
78 // ProxyScriptFetcher implementation.
79 virtual int Fetch(const GURL& url,
80 string16* text,
81 CompletionCallback* callback) {
82 DCHECK(!has_pending_request());
83
84 // Save the caller's information, and have them wait.
85 pending_request_url_ = url;
86 pending_request_callback_ = callback;
87 pending_request_text_ = text;
88 return ERR_IO_PENDING;
89 }
90
91 void NotifyFetchCompletion(int result, const std::string& ascii_text) {
92 DCHECK(has_pending_request());
93 *pending_request_text_ = ASCIIToUTF16(ascii_text);
94 CompletionCallback* callback = pending_request_callback_;
95 pending_request_callback_ = NULL;
96 callback->Run(result);
97 }
98
99 virtual void Cancel() {}
100
101 virtual URLRequestContext* GetRequestContext() { return NULL; }
102
103 const GURL& pending_request_url() const {
104 return pending_request_url_;
105 }
106
107 bool has_pending_request() const {
108 return pending_request_callback_ != NULL;
109 }
110
111 private:
112 GURL pending_request_url_;
113 CompletionCallback* pending_request_callback_;
114 string16* pending_request_text_;
115 };
116
117 TEST(ProxyServiceTest, Direct) { 72 TEST(ProxyServiceTest, Direct) {
118 MockAsyncProxyResolver* resolver = new MockAsyncProxyResolver; 73 MockAsyncProxyResolver* resolver = new MockAsyncProxyResolver;
119 ProxyService service(new MockProxyConfigService( 74 ProxyService service(new MockProxyConfigService(
120 ProxyConfig::CreateDirect()), resolver, NULL); 75 ProxyConfig::CreateDirect()), resolver, NULL);
121 76
122 GURL url("http://www.google.com/"); 77 GURL url("http://www.google.com/");
123 78
124 ProxyInfo info; 79 ProxyInfo info;
125 TestCompletionCallback callback; 80 TestCompletionCallback callback;
126 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); 81 CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 config.set_pac_mandatory(true); 397 config.set_pac_mandatory(true);
443 398
444 MockProxyConfigService* config_service = new MockProxyConfigService(config); 399 MockProxyConfigService* config_service = new MockProxyConfigService(config);
445 400
446 MockAsyncProxyResolverExpectsBytes* resolver = 401 MockAsyncProxyResolverExpectsBytes* resolver =
447 new MockAsyncProxyResolverExpectsBytes; 402 new MockAsyncProxyResolverExpectsBytes;
448 403
449 ProxyService service(config_service, resolver, NULL); 404 ProxyService service(config_service, resolver, NULL);
450 405
451 MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; 406 MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
452 service.SetProxyScriptFetcher(fetcher); 407 DhcpProxyScriptFetcher* dhcp_fetcher = new DoNothingDhcpProxyScriptFetcher();
408 service.SetProxyScriptFetchers(fetcher, dhcp_fetcher);
453 409
454 // Start resolve request. 410 // Start resolve request.
455 GURL url("http://www.google.com/"); 411 GURL url("http://www.google.com/");
456 ProxyInfo info; 412 ProxyInfo info;
457 TestCompletionCallback callback; 413 TestCompletionCallback callback;
458 int rv = service.ResolveProxy(url, &info, &callback, NULL, BoundNetLog()); 414 int rv = service.ResolveProxy(url, &info, &callback, NULL, BoundNetLog());
459 EXPECT_EQ(ERR_IO_PENDING, rv); 415 EXPECT_EQ(ERR_IO_PENDING, rv);
460 416
461 // Check that nothing has been sent to the proxy resolver yet. 417 // Check that nothing has been sent to the proxy resolver yet.
462 ASSERT_EQ(0u, resolver->pending_requests().size()); 418 ASSERT_EQ(0u, resolver->pending_requests().size());
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 TEST(ProxyServiceTest, InitialPACScriptDownload) { 1132 TEST(ProxyServiceTest, InitialPACScriptDownload) {
1177 MockProxyConfigService* config_service = 1133 MockProxyConfigService* config_service =
1178 new MockProxyConfigService("http://foopy/proxy.pac"); 1134 new MockProxyConfigService("http://foopy/proxy.pac");
1179 1135
1180 MockAsyncProxyResolverExpectsBytes* resolver = 1136 MockAsyncProxyResolverExpectsBytes* resolver =
1181 new MockAsyncProxyResolverExpectsBytes; 1137 new MockAsyncProxyResolverExpectsBytes;
1182 1138
1183 ProxyService service(config_service, resolver, NULL); 1139 ProxyService service(config_service, resolver, NULL);
1184 1140
1185 MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; 1141 MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
1186 service.SetProxyScriptFetcher(fetcher); 1142 service.SetProxyScriptFetchers(fetcher,
1143 new DoNothingDhcpProxyScriptFetcher());
1187 1144
1188 // Start 3 requests. 1145 // Start 3 requests.
1189 1146
1190 ProxyInfo info1; 1147 ProxyInfo info1;
1191 TestCompletionCallback callback1; 1148 TestCompletionCallback callback1;
1192 int rv = service.ResolveProxy( 1149 int rv = service.ResolveProxy(
1193 GURL("http://request1"), &info1, &callback1, NULL, BoundNetLog()); 1150 GURL("http://request1"), &info1, &callback1, NULL, BoundNetLog());
1194 EXPECT_EQ(ERR_IO_PENDING, rv); 1151 EXPECT_EQ(ERR_IO_PENDING, rv);
1195 1152
1196 // The first request should have triggered download of PAC script. 1153 // The first request should have triggered download of PAC script.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 TEST(ProxyServiceTest, ChangeScriptFetcherWhilePACDownloadInProgress) { 1212 TEST(ProxyServiceTest, ChangeScriptFetcherWhilePACDownloadInProgress) {
1256 MockProxyConfigService* config_service = 1213 MockProxyConfigService* config_service =
1257 new MockProxyConfigService("http://foopy/proxy.pac"); 1214 new MockProxyConfigService("http://foopy/proxy.pac");
1258 1215
1259 MockAsyncProxyResolverExpectsBytes* resolver = 1216 MockAsyncProxyResolverExpectsBytes* resolver =
1260 new MockAsyncProxyResolverExpectsBytes; 1217 new MockAsyncProxyResolverExpectsBytes;
1261 1218
1262 ProxyService service(config_service, resolver, NULL); 1219 ProxyService service(config_service, resolver, NULL);
1263 1220
1264 MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; 1221 MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
1265 service.SetProxyScriptFetcher(fetcher); 1222 service.SetProxyScriptFetchers(fetcher,
1223 new DoNothingDhcpProxyScriptFetcher());
1266 1224
1267 // Start 2 requests. 1225 // Start 2 requests.
1268 1226
1269 ProxyInfo info1; 1227 ProxyInfo info1;
1270 TestCompletionCallback callback1; 1228 TestCompletionCallback callback1;
1271 int rv = service.ResolveProxy( 1229 int rv = service.ResolveProxy(
1272 GURL("http://request1"), &info1, &callback1, NULL, BoundNetLog()); 1230 GURL("http://request1"), &info1, &callback1, NULL, BoundNetLog());
1273 EXPECT_EQ(ERR_IO_PENDING, rv); 1231 EXPECT_EQ(ERR_IO_PENDING, rv);
1274 1232
1275 // The first request should have triggered download of PAC script. 1233 // The first request should have triggered download of PAC script.
1276 EXPECT_TRUE(fetcher->has_pending_request()); 1234 EXPECT_TRUE(fetcher->has_pending_request());
1277 EXPECT_EQ(GURL("http://foopy/proxy.pac"), fetcher->pending_request_url()); 1235 EXPECT_EQ(GURL("http://foopy/proxy.pac"), fetcher->pending_request_url());
1278 1236
1279 ProxyInfo info2; 1237 ProxyInfo info2;
1280 TestCompletionCallback callback2; 1238 TestCompletionCallback callback2;
1281 rv = service.ResolveProxy( 1239 rv = service.ResolveProxy(
1282 GURL("http://request2"), &info2, &callback2, NULL, BoundNetLog()); 1240 GURL("http://request2"), &info2, &callback2, NULL, BoundNetLog());
1283 EXPECT_EQ(ERR_IO_PENDING, rv); 1241 EXPECT_EQ(ERR_IO_PENDING, rv);
1284 1242
1285 // At this point the ProxyService should be waiting for the 1243 // At this point the ProxyService should be waiting for the
1286 // ProxyScriptFetcher to invoke its completion callback, notifying it of 1244 // ProxyScriptFetcher to invoke its completion callback, notifying it of
1287 // PAC script download completion. 1245 // PAC script download completion.
1288 1246
1289 // We now change out the ProxyService's script fetcher. We should restart 1247 // We now change out the ProxyService's script fetcher. We should restart
1290 // the initialization with the new fetcher. 1248 // the initialization with the new fetcher.
1291 1249
1292 fetcher = new MockProxyScriptFetcher; 1250 fetcher = new MockProxyScriptFetcher;
1293 service.SetProxyScriptFetcher(fetcher); 1251 service.SetProxyScriptFetchers(fetcher,
1252 new DoNothingDhcpProxyScriptFetcher());
1294 1253
1295 // Nothing has been sent to the resolver yet. 1254 // Nothing has been sent to the resolver yet.
1296 EXPECT_TRUE(resolver->pending_requests().empty()); 1255 EXPECT_TRUE(resolver->pending_requests().empty());
1297 1256
1298 fetcher->NotifyFetchCompletion(OK, "pac-v1"); 1257 fetcher->NotifyFetchCompletion(OK, "pac-v1");
1299 1258
1300 // Now that the PAC script is downloaded, it will have been sent to the proxy 1259 // Now that the PAC script is downloaded, it will have been sent to the proxy
1301 // resolver. 1260 // resolver.
1302 EXPECT_EQ(ASCIIToUTF16("pac-v1"), 1261 EXPECT_EQ(ASCIIToUTF16("pac-v1"),
1303 resolver->pending_set_pac_script_request()->script_data()->utf16()); 1262 resolver->pending_set_pac_script_request()->script_data()->utf16());
1304 resolver->pending_set_pac_script_request()->CompleteNow(OK); 1263 resolver->pending_set_pac_script_request()->CompleteNow(OK);
1305 1264
1306 ASSERT_EQ(2u, resolver->pending_requests().size()); 1265 ASSERT_EQ(2u, resolver->pending_requests().size());
1307 EXPECT_EQ(GURL("http://request1"), resolver->pending_requests()[0]->url()); 1266 EXPECT_EQ(GURL("http://request1"), resolver->pending_requests()[0]->url());
1308 EXPECT_EQ(GURL("http://request2"), resolver->pending_requests()[1]->url()); 1267 EXPECT_EQ(GURL("http://request2"), resolver->pending_requests()[1]->url());
1309 } 1268 }
1310 1269
1311 // Test cancellation of a request, while the PAC script is being fetched. 1270 // Test cancellation of a request, while the PAC script is being fetched.
1312 TEST(ProxyServiceTest, CancelWhilePACFetching) { 1271 TEST(ProxyServiceTest, CancelWhilePACFetching) {
1313 MockProxyConfigService* config_service = 1272 MockProxyConfigService* config_service =
1314 new MockProxyConfigService("http://foopy/proxy.pac"); 1273 new MockProxyConfigService("http://foopy/proxy.pac");
1315 1274
1316 MockAsyncProxyResolverExpectsBytes* resolver = 1275 MockAsyncProxyResolverExpectsBytes* resolver =
1317 new MockAsyncProxyResolverExpectsBytes; 1276 new MockAsyncProxyResolverExpectsBytes;
1318 1277
1319 ProxyService service(config_service, resolver, NULL); 1278 ProxyService service(config_service, resolver, NULL);
1320 1279
1321 MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; 1280 MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
1322 service.SetProxyScriptFetcher(fetcher); 1281 service.SetProxyScriptFetchers(fetcher,
1282 new DoNothingDhcpProxyScriptFetcher());
1323 1283
1324 // Start 3 requests. 1284 // Start 3 requests.
1325 ProxyInfo info1; 1285 ProxyInfo info1;
1326 TestCompletionCallback callback1; 1286 TestCompletionCallback callback1;
1327 ProxyService::PacRequest* request1; 1287 ProxyService::PacRequest* request1;
1328 CapturingBoundNetLog log1(CapturingNetLog::kUnbounded); 1288 CapturingBoundNetLog log1(CapturingNetLog::kUnbounded);
1329 int rv = service.ResolveProxy( 1289 int rv = service.ResolveProxy(
1330 GURL("http://request1"), &info1, &callback1, &request1, log1.bound()); 1290 GURL("http://request1"), &info1, &callback1, &request1, log1.bound());
1331 EXPECT_EQ(ERR_IO_PENDING, rv); 1291 EXPECT_EQ(ERR_IO_PENDING, rv);
1332 1292
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1403 config.set_auto_detect(true); 1363 config.set_auto_detect(true);
1404 config.set_pac_url(GURL("http://foopy/proxy.pac")); 1364 config.set_pac_url(GURL("http://foopy/proxy.pac"));
1405 config.proxy_rules().ParseFromString("http=foopy:80"); // Won't be used. 1365 config.proxy_rules().ParseFromString("http=foopy:80"); // Won't be used.
1406 1366
1407 MockProxyConfigService* config_service = new MockProxyConfigService(config); 1367 MockProxyConfigService* config_service = new MockProxyConfigService(config);
1408 MockAsyncProxyResolverExpectsBytes* resolver = 1368 MockAsyncProxyResolverExpectsBytes* resolver =
1409 new MockAsyncProxyResolverExpectsBytes; 1369 new MockAsyncProxyResolverExpectsBytes;
1410 ProxyService service(config_service, resolver, NULL); 1370 ProxyService service(config_service, resolver, NULL);
1411 1371
1412 MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; 1372 MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
1413 service.SetProxyScriptFetcher(fetcher); 1373 service.SetProxyScriptFetchers(fetcher,
1374 new DoNothingDhcpProxyScriptFetcher());
1414 1375
1415 // Start 2 requests. 1376 // Start 2 requests.
1416 1377
1417 ProxyInfo info1; 1378 ProxyInfo info1;
1418 TestCompletionCallback callback1; 1379 TestCompletionCallback callback1;
1419 int rv = service.ResolveProxy( 1380 int rv = service.ResolveProxy(
1420 GURL("http://request1"), &info1, &callback1, NULL, BoundNetLog()); 1381 GURL("http://request1"), &info1, &callback1, NULL, BoundNetLog());
1421 EXPECT_EQ(ERR_IO_PENDING, rv); 1382 EXPECT_EQ(ERR_IO_PENDING, rv);
1422 1383
1423 ProxyInfo info2; 1384 ProxyInfo info2;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1473 config.set_auto_detect(true); 1434 config.set_auto_detect(true);
1474 config.set_pac_url(GURL("http://foopy/proxy.pac")); 1435 config.set_pac_url(GURL("http://foopy/proxy.pac"));
1475 config.proxy_rules().ParseFromString("http=foopy:80"); // Won't be used. 1436 config.proxy_rules().ParseFromString("http=foopy:80"); // Won't be used.
1476 1437
1477 MockProxyConfigService* config_service = new MockProxyConfigService(config); 1438 MockProxyConfigService* config_service = new MockProxyConfigService(config);
1478 MockAsyncProxyResolverExpectsBytes* resolver = 1439 MockAsyncProxyResolverExpectsBytes* resolver =
1479 new MockAsyncProxyResolverExpectsBytes; 1440 new MockAsyncProxyResolverExpectsBytes;
1480 ProxyService service(config_service, resolver, NULL); 1441 ProxyService service(config_service, resolver, NULL);
1481 1442
1482 MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; 1443 MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
1483 service.SetProxyScriptFetcher(fetcher); 1444 service.SetProxyScriptFetchers(fetcher,
1445 new DoNothingDhcpProxyScriptFetcher());
1484 1446
1485 // Start 2 requests. 1447 // Start 2 requests.
1486 1448
1487 ProxyInfo info1; 1449 ProxyInfo info1;
1488 TestCompletionCallback callback1; 1450 TestCompletionCallback callback1;
1489 int rv = service.ResolveProxy( 1451 int rv = service.ResolveProxy(
1490 GURL("http://request1"), &info1, &callback1, NULL, BoundNetLog()); 1452 GURL("http://request1"), &info1, &callback1, NULL, BoundNetLog());
1491 EXPECT_EQ(ERR_IO_PENDING, rv); 1453 EXPECT_EQ(ERR_IO_PENDING, rv);
1492 1454
1493 ProxyInfo info2; 1455 ProxyInfo info2;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1548 config.set_auto_detect(true); 1510 config.set_auto_detect(true);
1549 config.set_pac_url(GURL("http://foopy/proxy.pac")); 1511 config.set_pac_url(GURL("http://foopy/proxy.pac"));
1550 config.proxy_rules().ParseFromString("http=foopy:80"); 1512 config.proxy_rules().ParseFromString("http=foopy:80");
1551 1513
1552 MockProxyConfigService* config_service = new MockProxyConfigService(config); 1514 MockProxyConfigService* config_service = new MockProxyConfigService(config);
1553 MockAsyncProxyResolverExpectsBytes* resolver = 1515 MockAsyncProxyResolverExpectsBytes* resolver =
1554 new MockAsyncProxyResolverExpectsBytes; 1516 new MockAsyncProxyResolverExpectsBytes;
1555 ProxyService service(config_service, resolver, NULL); 1517 ProxyService service(config_service, resolver, NULL);
1556 1518
1557 MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; 1519 MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
1558 service.SetProxyScriptFetcher(fetcher); 1520 service.SetProxyScriptFetchers(fetcher,
1521 new DoNothingDhcpProxyScriptFetcher());
1559 1522
1560 // Start 2 requests. 1523 // Start 2 requests.
1561 1524
1562 ProxyInfo info1; 1525 ProxyInfo info1;
1563 TestCompletionCallback callback1; 1526 TestCompletionCallback callback1;
1564 int rv = service.ResolveProxy( 1527 int rv = service.ResolveProxy(
1565 GURL("http://request1"), &info1, &callback1, NULL, BoundNetLog()); 1528 GURL("http://request1"), &info1, &callback1, NULL, BoundNetLog());
1566 EXPECT_EQ(ERR_IO_PENDING, rv); 1529 EXPECT_EQ(ERR_IO_PENDING, rv);
1567 1530
1568 ProxyInfo info2; 1531 ProxyInfo info2;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1605 config.set_pac_url(GURL("http://foopy/proxy.pac")); 1568 config.set_pac_url(GURL("http://foopy/proxy.pac"));
1606 config.proxy_rules().ParseFromString("http=foopy:80"); // Not used. 1569 config.proxy_rules().ParseFromString("http=foopy:80"); // Not used.
1607 config.proxy_rules().bypass_rules.ParseFromString("www.google.com"); 1570 config.proxy_rules().bypass_rules.ParseFromString("www.google.com");
1608 1571
1609 MockProxyConfigService* config_service = new MockProxyConfigService(config); 1572 MockProxyConfigService* config_service = new MockProxyConfigService(config);
1610 MockAsyncProxyResolverExpectsBytes* resolver = 1573 MockAsyncProxyResolverExpectsBytes* resolver =
1611 new MockAsyncProxyResolverExpectsBytes; 1574 new MockAsyncProxyResolverExpectsBytes;
1612 ProxyService service(config_service, resolver, NULL); 1575 ProxyService service(config_service, resolver, NULL);
1613 1576
1614 MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; 1577 MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
1615 service.SetProxyScriptFetcher(fetcher); 1578 service.SetProxyScriptFetchers(fetcher,
1579 new DoNothingDhcpProxyScriptFetcher());
1616 1580
1617 // Start 1 requests. 1581 // Start 1 requests.
1618 1582
1619 ProxyInfo info1; 1583 ProxyInfo info1;
1620 TestCompletionCallback callback1; 1584 TestCompletionCallback callback1;
1621 int rv = service.ResolveProxy( 1585 int rv = service.ResolveProxy(
1622 GURL("http://www.google.com"), &info1, &callback1, NULL, BoundNetLog()); 1586 GURL("http://www.google.com"), &info1, &callback1, NULL, BoundNetLog());
1623 EXPECT_EQ(ERR_IO_PENDING, rv); 1587 EXPECT_EQ(ERR_IO_PENDING, rv);
1624 1588
1625 // Check that nothing has been sent to the proxy resolver yet. 1589 // Check that nothing has been sent to the proxy resolver yet.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1672 TEST(ProxyServiceTest, DeleteWhileInitProxyResolverHasOutstandingFetch) { 1636 TEST(ProxyServiceTest, DeleteWhileInitProxyResolverHasOutstandingFetch) {
1673 ProxyConfig config = 1637 ProxyConfig config =
1674 ProxyConfig::CreateFromCustomPacURL(GURL("http://foopy/proxy.pac")); 1638 ProxyConfig::CreateFromCustomPacURL(GURL("http://foopy/proxy.pac"));
1675 1639
1676 MockProxyConfigService* config_service = new MockProxyConfigService(config); 1640 MockProxyConfigService* config_service = new MockProxyConfigService(config);
1677 MockAsyncProxyResolverExpectsBytes* resolver = 1641 MockAsyncProxyResolverExpectsBytes* resolver =
1678 new MockAsyncProxyResolverExpectsBytes; 1642 new MockAsyncProxyResolverExpectsBytes;
1679 ProxyService service(config_service, resolver, NULL); 1643 ProxyService service(config_service, resolver, NULL);
1680 1644
1681 MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; 1645 MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
1682 service.SetProxyScriptFetcher(fetcher); 1646 service.SetProxyScriptFetchers(fetcher,
1647 new DoNothingDhcpProxyScriptFetcher());
1683 1648
1684 // Start 1 request. 1649 // Start 1 request.
1685 1650
1686 ProxyInfo info1; 1651 ProxyInfo info1;
1687 TestCompletionCallback callback1; 1652 TestCompletionCallback callback1;
1688 int rv = service.ResolveProxy( 1653 int rv = service.ResolveProxy(
1689 GURL("http://www.google.com"), &info1, &callback1, NULL, BoundNetLog()); 1654 GURL("http://www.google.com"), &info1, &callback1, NULL, BoundNetLog());
1690 EXPECT_EQ(ERR_IO_PENDING, rv); 1655 EXPECT_EQ(ERR_IO_PENDING, rv);
1691 1656
1692 // Check that nothing has been sent to the proxy resolver yet. 1657 // Check that nothing has been sent to the proxy resolver yet.
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1803 new MockProxyConfigService("http://foopy/proxy.pac"); 1768 new MockProxyConfigService("http://foopy/proxy.pac");
1804 1769
1805 MockAsyncProxyResolverExpectsBytes* resolver = 1770 MockAsyncProxyResolverExpectsBytes* resolver =
1806 new MockAsyncProxyResolverExpectsBytes; 1771 new MockAsyncProxyResolverExpectsBytes;
1807 1772
1808 CapturingNetLog log(CapturingNetLog::kUnbounded); 1773 CapturingNetLog log(CapturingNetLog::kUnbounded);
1809 1774
1810 ProxyService service(config_service, resolver, &log); 1775 ProxyService service(config_service, resolver, &log);
1811 1776
1812 MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; 1777 MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
1813 service.SetProxyScriptFetcher(fetcher); 1778 service.SetProxyScriptFetchers(fetcher,
1779 new DoNothingDhcpProxyScriptFetcher());
1814 1780
1815 // Disable the "wait after IP address changes" hack, so this unit-test can 1781 // Disable the "wait after IP address changes" hack, so this unit-test can
1816 // complete quickly. 1782 // complete quickly.
1817 service.set_stall_proxy_auto_config_delay(base::TimeDelta()); 1783 service.set_stall_proxy_auto_config_delay(base::TimeDelta());
1818 1784
1819 // Start 1 request. 1785 // Start 1 request.
1820 1786
1821 ProxyInfo info1; 1787 ProxyInfo info1;
1822 TestCompletionCallback callback1; 1788 TestCompletionCallback callback1;
1823 int rv = service.ResolveProxy( 1789 int rv = service.ResolveProxy(
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1903 log.GetEntries(&entries); 1869 log.GetEntries(&entries);
1904 1870
1905 EXPECT_TRUE(LogContainsEntryWithType(entries, 0, 1871 EXPECT_TRUE(LogContainsEntryWithType(entries, 0,
1906 NetLog::TYPE_PROXY_CONFIG_CHANGED)); 1872 NetLog::TYPE_PROXY_CONFIG_CHANGED));
1907 ASSERT_EQ(13u, entries.size()); 1873 ASSERT_EQ(13u, entries.size());
1908 for (size_t i = 1; i < entries.size(); ++i) 1874 for (size_t i = 1; i < entries.size(); ++i)
1909 EXPECT_NE(NetLog::TYPE_PROXY_CONFIG_CHANGED, entries[i].type); 1875 EXPECT_NE(NetLog::TYPE_PROXY_CONFIG_CHANGED, entries[i].type);
1910 } 1876 }
1911 1877
1912 } // namespace net 1878 } // namespace net
OLDNEW
« net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc ('K') | « net/proxy/proxy_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698