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

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

Issue 1126413006: Temporary fix to prevent the DRP from being activated improperly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« net/proxy/proxy_service.cc ('K') | « net/proxy/proxy_service.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_service.h" 5 #include "net/proxy/proxy_service.h"
6 6
7 #include <string>
7 #include <vector> 8 #include <vector>
8 9
9 #include "base/format_macros.h" 10 #include "base/format_macros.h"
10 #include "base/logging.h" 11 #include "base/logging.h"
11 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
12 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
13 #include "net/base/load_flags.h" 14 #include "net/base/load_flags.h"
14 #include "net/base/net_errors.h" 15 #include "net/base/net_errors.h"
15 #include "net/base/network_delegate_impl.h" 16 #include "net/base/network_delegate_impl.h"
16 #include "net/base/test_completion_callback.h" 17 #include "net/base/test_completion_callback.h"
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 int proxy_fallback_net_error() const { 233 int proxy_fallback_net_error() const {
233 return proxy_fallback_net_error_; 234 return proxy_fallback_net_error_;
234 } 235 }
235 236
236 private: 237 private:
237 bool on_proxy_fallback_called_; 238 bool on_proxy_fallback_called_;
238 ProxyServer proxy_server_; 239 ProxyServer proxy_server_;
239 int proxy_fallback_net_error_; 240 int proxy_fallback_net_error_;
240 }; 241 };
241 242
243 void CheckResolvedProxyMatches(ProxyService* service,
244 const GURL& url,
245 const std::string& result_string) {
246 ProxyInfo expected_result;
247 expected_result.UseNamedProxy(result_string);
248
249 ProxyInfo result;
250 BoundTestNetLog log;
251 EXPECT_TRUE(service->TryResolveProxySynchronously(url, LOAD_NORMAL, &result,
252 nullptr, log.bound()));
253
254 EXPECT_TRUE(expected_result.proxy_list().Equals(result.proxy_list()))
255 << "expected: " << expected_result.proxy_list().ToPacString()
256 << "\nactual: " << result.proxy_list().ToPacString();
257 }
258
242 } // namespace 259 } // namespace
243 260
244 TEST_F(ProxyServiceTest, Direct) { 261 TEST_F(ProxyServiceTest, Direct) {
245 MockAsyncProxyResolverFactory* factory = 262 MockAsyncProxyResolverFactory* factory =
246 new MockAsyncProxyResolverFactory(false); 263 new MockAsyncProxyResolverFactory(false);
247 ProxyService service(new MockProxyConfigService(ProxyConfig::CreateDirect()), 264 ProxyService service(new MockProxyConfigService(ProxyConfig::CreateDirect()),
248 make_scoped_ptr(factory), NULL); 265 make_scoped_ptr(factory), NULL);
249 266
250 GURL url("http://www.google.com/"); 267 GURL url("http://www.google.com/");
251 268
(...skipping 2987 matching lines...) Expand 10 before | Expand all | Expand 10 after
3239 bool synchronous_success = service.TryResolveProxySynchronously( 3256 bool synchronous_success = service.TryResolveProxySynchronously(
3240 url, LOAD_NORMAL, &info, NULL, log.bound()); 3257 url, LOAD_NORMAL, &info, NULL, log.bound());
3241 EXPECT_TRUE(synchronous_success); 3258 EXPECT_TRUE(synchronous_success);
3242 EXPECT_FALSE(info.is_direct()); 3259 EXPECT_FALSE(info.is_direct());
3243 EXPECT_EQ("foopy1", info.proxy_server().host_port_pair().host()); 3260 EXPECT_EQ("foopy1", info.proxy_server().host_port_pair().host());
3244 3261
3245 // No request should have been queued. 3262 // No request should have been queued.
3246 EXPECT_EQ(0u, factory->pending_requests().size()); 3263 EXPECT_EQ(0u, factory->pending_requests().size());
3247 } 3264 }
3248 3265
3266 TEST_F(ProxyServiceTest, ExcludeGooglezipDataReductionProxiesFromRules) {
3267 const std::string kDataReductionProxies =
3268 "https://proxy.googlezip.net:443,compress.googlezip.net,"
3269 "https://proxy-dev.googlezip.net:443,proxy-dev.googlezip.net,"
3270 "quic://proxy.googlezip.net";
3271
3272 struct {
3273 std::string initial_proxy_rules;
3274 const char* http_proxy_info;
3275 const char* https_proxy_info;
3276 const char* ftp_proxy_info;
3277 } test_cases[] = {
3278 {"http=foopyhttp," + kDataReductionProxies +
3279 ",direct://;https=foopyhttps," + kDataReductionProxies +
3280 ",direct://;ftp=foopyftp," + kDataReductionProxies + ",direct://",
3281 "foopyhttp;direct://",
3282 "foopyhttps;direct://",
3283 "foopyftp;direct://"},
3284
3285 {"foopy," + kDataReductionProxies + ",direct://",
3286 "foopy;direct://",
3287 "foopy;direct://",
3288 "foopy;direct://"},
3289
3290 {"http=" + kDataReductionProxies + ";https=" + kDataReductionProxies +
3291 ";ftp=" + kDataReductionProxies,
3292 "direct://",
3293 "direct://",
3294 "direct://"},
3295
3296 {"http=" + kDataReductionProxies + ",foopy,direct://",
3297 "foopy;direct://",
3298 "direct://",
3299 "direct://"},
3300 };
3301
3302 for (const auto& test : test_cases) {
3303 scoped_ptr<ProxyService> service(
3304 ProxyService::CreateFixed(test.initial_proxy_rules));
3305
3306 CheckResolvedProxyMatches(service.get(), GURL("http://google.com"),
3307 test.http_proxy_info);
3308 CheckResolvedProxyMatches(service.get(), GURL("https://google.com"),
3309 test.https_proxy_info);
3310 CheckResolvedProxyMatches(service.get(), GURL("ftp://google.com"),
3311 test.ftp_proxy_info);
3312 }
3313 }
3314
3249 } // namespace net 3315 } // namespace net
OLDNEW
« net/proxy/proxy_service.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