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

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

Issue 2968573002: Check the return value of base::StringToInt() in (Closed)
Patch Set: address mmenke's comments Created 3 years, 5 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_config_service_linux.cc ('k') | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_config_service_linux.h" 5 #include "net/proxy/proxy_config_service_linux.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 11 matching lines...) Expand all
22 #include "base/strings/stringprintf.h" 22 #include "base/strings/stringprintf.h"
23 #include "base/synchronization/lock.h" 23 #include "base/synchronization/lock.h"
24 #include "base/synchronization/waitable_event.h" 24 #include "base/synchronization/waitable_event.h"
25 #include "base/threading/thread.h" 25 #include "base/threading/thread.h"
26 #include "base/threading/thread_task_runner_handle.h" 26 #include "base/threading/thread_task_runner_handle.h"
27 #include "net/proxy/proxy_config.h" 27 #include "net/proxy/proxy_config.h"
28 #include "net/proxy/proxy_config_service_common_unittest.h" 28 #include "net/proxy/proxy_config_service_common_unittest.h"
29 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
30 #include "testing/platform_test.h" 30 #include "testing/platform_test.h"
31 31
32 // TODO(eroman): Convert these to parameterized tests using TEST_P().
33
32 namespace net { 34 namespace net {
33 namespace { 35 namespace {
34 36
35 // Set of values for all environment variables that we might 37 // Set of values for all environment variables that we might
36 // query. NULL represents an unset variable. 38 // query. NULL represents an unset variable.
37 struct EnvVarValues { 39 struct EnvVarValues {
38 // The strange capitalization is so that the field matches the 40 // The strange capitalization is so that the field matches the
39 // environment variable name exactly. 41 // environment variable name exactly.
40 const char* DESKTOP_SESSION; 42 const char* DESKTOP_SESSION;
41 const char* HOME; 43 const char* HOME;
(...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 // Input. 1152 // Input.
1151 "[Proxy Settings]\nProxyType=0\n", 1153 "[Proxy Settings]\nProxyType=0\n",
1152 {}, // env_values 1154 {}, // env_values
1153 1155
1154 // Expected result. 1156 // Expected result.
1155 ProxyConfigService::CONFIG_VALID, 1157 ProxyConfigService::CONFIG_VALID,
1156 false, // auto_detect 1158 false, // auto_detect
1157 GURL(), // pac_url 1159 GURL(), // pac_url
1158 ProxyRulesExpectation::Empty(), 1160 ProxyRulesExpectation::Empty(),
1159 }, 1161 },
1162 {
1163 TEST_DESC("Invalid proxy type (ProxyType=-3)"),
1164
1165 // Input.
1166 "[Proxy Settings]\nProxyType=-3\n",
1167 {}, // env_values
1168
1169 // Expected result.
1170 ProxyConfigService::CONFIG_VALID,
1171 false, // auto_detect
1172 GURL(), // pac_url
1173 ProxyRulesExpectation::Empty(),
1174 },
1175
1176 {
1177 TEST_DESC("Invalid proxy type (ProxyType=AB-)"),
1178
1179 // Input.
1180 "[Proxy Settings]\nProxyType=AB-\n",
1181 {}, // env_values
1182
1183 // Expected result.
1184 ProxyConfigService::CONFIG_VALID,
1185 false, // auto_detect
1186 GURL(), // pac_url
1187 ProxyRulesExpectation::Empty(),
1188 },
1160 1189
1161 { 1190 {
1162 TEST_DESC("Auto detect"), 1191 TEST_DESC("Auto detect"),
1163 1192
1164 // Input. 1193 // Input.
1165 "[Proxy Settings]\nProxyType=3\n", 1194 "[Proxy Settings]\nProxyType=3\n",
1166 {}, // env_values 1195 {}, // env_values
1167 1196
1168 // Expected result. 1197 // Expected result.
1169 ProxyConfigService::CONFIG_VALID, 1198 ProxyConfigService::CONFIG_VALID,
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 false, // auto_detect 1335 false, // auto_detect
1307 GURL(), // pac_url 1336 GURL(), // pac_url
1308 ProxyRulesExpectation::PerScheme( 1337 ProxyRulesExpectation::PerScheme(
1309 "www.google.com:80", // http 1338 "www.google.com:80", // http
1310 "", // https 1339 "", // https
1311 "", // ftp 1340 "", // ftp
1312 "*.google.com,*.kde.org"), // bypass rules 1341 "*.google.com,*.kde.org"), // bypass rules
1313 }, 1342 },
1314 1343
1315 { 1344 {
1316 TEST_DESC("Correctly parse bypass list with ReversedException"), 1345 TEST_DESC("Correctly parse bypass list with ReversedException=true"),
1317 1346
1318 // Input. 1347 // Input.
1319 "[Proxy Settings]\nProxyType=1\nhttpProxy=www.google.com\n" 1348 "[Proxy Settings]\nProxyType=1\nhttpProxy=www.google.com\n"
1320 "NoProxyFor=.google.com\nReversedException=true\n", 1349 "NoProxyFor=.google.com\nReversedException=true\n",
1321 {}, // env_values 1350 {}, // env_values
1322 1351
1323 // Expected result. 1352 // Expected result.
1324 ProxyConfigService::CONFIG_VALID, 1353 ProxyConfigService::CONFIG_VALID,
1325 false, // auto_detect 1354 false, // auto_detect
1326 GURL(), // pac_url 1355 GURL(), // pac_url
1327 ProxyRulesExpectation::PerSchemeWithBypassReversed( 1356 ProxyRulesExpectation::PerSchemeWithBypassReversed(
1328 "www.google.com:80", // http 1357 "www.google.com:80", // http
1329 "", // https 1358 "", // https
1330 "", // ftp 1359 "", // ftp
1331 "*.google.com"), // bypass rules 1360 "*.google.com"), // bypass rules
1332 }, 1361 },
1333 1362
1334 { 1363 {
1364 TEST_DESC("Correctly parse bypass list with ReversedException=false"),
1365
1366 // Input.
1367 "[Proxy Settings]\nProxyType=1\nhttpProxy=www.google.com\n"
1368 "NoProxyFor=.google.com\nReversedException=false\n",
1369 {}, // env_values
1370
1371 // Expected result.
1372 ProxyConfigService::CONFIG_VALID,
1373 false, // auto_detect
1374 GURL(), // pac_url
1375 ProxyRulesExpectation::PerScheme("www.google.com:80", // http
1376 "", // https
1377 "", // ftp
1378 "*.google.com"), // bypass rules
1379 },
1380
1381 {
1382 TEST_DESC("Correctly parse bypass list with ReversedException=1"),
1383
1384 // Input.
1385 "[Proxy Settings]\nProxyType=1\nhttpProxy=www.google.com\n"
1386 "NoProxyFor=.google.com\nReversedException=1\n",
1387 {}, // env_values
1388
1389 // Expected result.
1390 ProxyConfigService::CONFIG_VALID,
1391 false, // auto_detect
1392 GURL(), // pac_url
1393 ProxyRulesExpectation::PerSchemeWithBypassReversed(
1394 "www.google.com:80", // http
1395 "", // https
1396 "", // ftp
1397 "*.google.com"), // bypass rules
1398 },
1399
1400 {
1401 TEST_DESC("Overflow: ReversedException=18446744073709551617"),
1402
1403 // Input.
1404 "[Proxy Settings]\nProxyType=1\nhttpProxy=www.google.com\n"
1405 "NoProxyFor=.google.com\nReversedException=18446744073709551617\n",
1406 {}, // env_values
1407
1408 // Expected result.
1409 ProxyConfigService::CONFIG_VALID,
1410 false, // auto_detect
1411 GURL(), // pac_url
1412 ProxyRulesExpectation::PerScheme("www.google.com:80", // http
1413 "", // https
1414 "", // ftp
1415 "*.google.com"), // bypass rules
1416 },
1417
1418 {
1419 TEST_DESC("Not a number: ReversedException=noitpecxE"),
1420
1421 // Input.
1422 "[Proxy Settings]\nProxyType=1\nhttpProxy=www.google.com\n"
1423 "NoProxyFor=.google.com\nReversedException=noitpecxE\n",
1424 {}, // env_values
1425
1426 // Expected result.
1427 ProxyConfigService::CONFIG_VALID,
1428 false, // auto_detect
1429 GURL(), // pac_url
1430 ProxyRulesExpectation::PerScheme("www.google.com:80", // http
1431 "", // https
1432 "", // ftp
1433 "*.google.com"), // bypass rules
1434 },
1435
1436 {
1335 TEST_DESC("socks"), 1437 TEST_DESC("socks"),
1336 1438
1337 // Input. 1439 // Input.
1338 "[Proxy Settings]\nProxyType=1\nsocksProxy=socks.com 888\n", 1440 "[Proxy Settings]\nProxyType=1\nsocksProxy=socks.com 888\n",
1339 {}, // env_values 1441 {}, // env_values
1340 1442
1341 // Expected result. 1443 // Expected result.
1342 ProxyConfigService::CONFIG_VALID, 1444 ProxyConfigService::CONFIG_VALID,
1343 false, // auto_detect 1445 false, // auto_detect
1344 GURL(), // pac_url 1446 GURL(), // pac_url
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
1801 1903
1802 //----------------------------------------------------- 1904 //-----------------------------------------------------
1803 1905
1804 // TODO(eroman): Add a test where kioslaverc is deleted next. Currently this 1906 // TODO(eroman): Add a test where kioslaverc is deleted next. Currently this
1805 // doesn't trigger any notifications, but it probably should. 1907 // doesn't trigger any notifications, but it probably should.
1806 } 1908 }
1807 1909
1808 } // namespace 1910 } // namespace
1809 1911
1810 } // namespace net 1912 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/proxy_config_service_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698