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

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
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..0be81edfa4a66ebe00bb6a8d7848270fd0b68918 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,13 @@ 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);
- MatchesProxyServerHelper("Bad fallback_proxy", fallback_proxy,
eroman 2013/03/06 23:26:32 Is it intentional that you removed the check on fa
marq_use_my_chromium_address 2013/03/07 00:34:29 That was a mistake; fixed.
- rules.fallback_proxy, &failure_details, &failed);
+ rules.proxies_for_https, &failure_details,
+ &failed);
std::string actual_flattened_bypass = FlattenProxyBypass(rules.bypass_rules);
if (std::string(flattened_bypass_rules) != actual_flattened_bypass) {

Powered by Google App Engine
This is Rietveld 408576698