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

Unified Diff: net/proxy/proxy_config_service_common_unittest.cc

Issue 12315019: Change ProxyRules to handle ProxyLists rather than just single ProxyServer instances. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/proxy/proxy_config_service_android.cc ('k') | net/proxy/proxy_config_service_ios.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/proxy/proxy_config_service_common_unittest.cc
diff --git a/net/proxy/proxy_config_service_common_unittest.cc b/net/proxy/proxy_config_service_common_unittest.cc
index 429abc560b86bed3ee1862b1124574c640c18a79..3835bb1ad201f745943395552d625f1c9d033938 100644
--- a/net/proxy/proxy_config_service_common_unittest.cc
+++ b/net/proxy/proxy_config_service_common_unittest.cc
@@ -15,14 +15,37 @@ namespace net {
namespace {
-// Helper to verify that |expected_proxy| matches |actual_proxy|. If it does
-// not, then |*did_fail| is set to true, and |*failure_details| is filled with
-// a description of the failure.
+// Helper to verify that |expected_proxy| matches the first proxy conatined in
+// |actual_proxies|, and that |actual_proxies| contains exactly one proxy. If
+// either condition is untrue, then |*did_fail| is set to true, and
+// |*failure_details| is filled with a description of the failure.
void MatchesProxyServerHelper(const char* failure_message,
const char* expected_proxy,
- const ProxyServer& actual_proxy,
+ const ProxyList& actual_proxies,
::testing::AssertionResult* failure_details,
bool* did_fail) {
+ // If |expected_proxy| is empty, then we expect |actual_proxies| to be so as
+ // well.
+ if (strlen(expected_proxy) == 0) {
+ if (!actual_proxies.IsEmpty()) {
+ *did_fail = true;
+ *failure_details
+ << failure_message << ". Was expecting no proxies but got "
+ << actual_proxies.size() << ".";
+ }
+ return;
+ }
+
+ // Otherwise we check that |actual_proxies| holds a single matching proxy.
+ if (actual_proxies.size() != 1) {
+ *did_fail = true;
+ *failure_details
+ << failure_message << ". Was expecting exactly one proxy but got "
+ << actual_proxies.size() << ".";
+ return;
+ }
+
+ ProxyServer actual_proxy = actual_proxies.Get();
std::string actual_proxy_string;
if (actual_proxy.is_valid())
actual_proxy_string = actual_proxy.ToURI();
@@ -81,13 +104,15 @@ ProxyRulesExpectation::ProxyRulesExpectation(
}
MatchesProxyServerHelper("Bad single_proxy", single_proxy,
- rules.single_proxy, &failure_details, &failed);
+ rules.single_proxies, &failure_details, &failed);
MatchesProxyServerHelper("Bad proxy_for_http", proxy_for_http,
- rules.proxy_for_http, &failure_details, &failed);
+ rules.proxies_for_http, &failure_details,
+ &failed);
MatchesProxyServerHelper("Bad proxy_for_https", proxy_for_https,
- rules.proxy_for_https, &failure_details, &failed);
+ rules.proxies_for_https, &failure_details,
+ &failed);
MatchesProxyServerHelper("Bad fallback_proxy", fallback_proxy,
- rules.fallback_proxy, &failure_details, &failed);
+ rules.fallback_proxies, &failure_details, &failed);
std::string actual_flattened_bypass = FlattenProxyBypass(rules.bypass_rules);
if (std::string(flattened_bypass_rules) != actual_flattened_bypass) {
« no previous file with comments | « net/proxy/proxy_config_service_android.cc ('k') | net/proxy/proxy_config_service_ios.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698