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

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

Issue 545633002: Don't preresolve DNS if a fixed proxy configuration is in place. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Undo no-longer-needed virtual marking Created 6 years, 2 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 <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"
(...skipping 3063 matching lines...) Expand 10 before | Expand all | Expand 10 after
3074 // since the PAC script poller experienced a failure. 3074 // since the PAC script poller experienced a failure.
3075 ProxyInfo info3; 3075 ProxyInfo info3;
3076 TestCompletionCallback callback3; 3076 TestCompletionCallback callback3;
3077 rv = service.ResolveProxy( 3077 rv = service.ResolveProxy(
3078 GURL("http://request3"), net::LOAD_NORMAL, &info3, callback3.callback(), 3078 GURL("http://request3"), net::LOAD_NORMAL, &info3, callback3.callback(),
3079 NULL, NULL, BoundNetLog()); 3079 NULL, NULL, BoundNetLog());
3080 EXPECT_EQ(OK, rv); 3080 EXPECT_EQ(OK, rv);
3081 EXPECT_TRUE(info3.is_direct()); 3081 EXPECT_TRUE(info3.is_direct());
3082 } 3082 }
3083 3083
3084 // Test that the PAC script is not evaluated if a null callback is supplied.
3085 TEST_F(ProxyServiceTest, PACWithNullCallback) {
3086 MockProxyConfigService* config_service =
3087 new MockProxyConfigService("http://foopy/proxy.pac");
3088
3089 MockAsyncProxyResolver* resolver = new MockAsyncProxyResolver;
3090
3091 ProxyService service(config_service, resolver, NULL);
3092
3093 GURL url("http://www.google.com/");
3094
3095 ProxyInfo info;
3096 info.UseDirect();
3097 net::CompletionCallback null_callback;
3098 ASSERT_TRUE(null_callback.is_null());
3099 ProxyService::PacRequest* request = NULL;
3100 CapturingBoundNetLog log;
3101
3102 int rv = service.ResolveProxy(
3103 url, net::LOAD_NORMAL, &info, null_callback, &request, NULL, log.bound());
3104 EXPECT_EQ(ERR_IO_PENDING, rv);
3105
3106 // No request should have been queued.
3107 EXPECT_EQ(0u, resolver->pending_requests().size());
3108
3109 // |request| should not have been unmodified.
3110 EXPECT_EQ(NULL, request);
3111
3112 // |info| should not have been modified.
3113 EXPECT_TRUE(info.is_direct());
3114 }
3115
3116 // Test that the PAC script is not evaluated if a null callback and request are
3117 // supplied.
3118 TEST_F(ProxyServiceTest, PACWithNullCallbackAndRequest) {
3119 MockProxyConfigService* config_service =
3120 new MockProxyConfigService("http://foopy/proxy.pac");
3121
3122 MockAsyncProxyResolver* resolver = new MockAsyncProxyResolver;
3123
3124 ProxyService service(config_service, resolver, NULL);
3125
3126 GURL url("http://www.google.com/");
3127
3128 ProxyInfo info;
3129 info.UseDirect();
3130 net::CompletionCallback null_callback;
3131 ASSERT_TRUE(null_callback.is_null());
3132 CapturingBoundNetLog log;
3133
3134 int rv = service.ResolveProxy(
3135 url, net::LOAD_NORMAL, &info, null_callback, NULL, NULL, log.bound());
3136 EXPECT_EQ(ERR_IO_PENDING, rv);
3137
3138 // No request should have been queued.
3139 EXPECT_EQ(0u, resolver->pending_requests().size());
3140
3141 // |info| should not have been modified.
3142 EXPECT_TRUE(info.is_direct());
3143 }
3144
3145 // Test that synchronous results are returned correctly if a null callback is
3146 // supplied
3147 TEST_F(ProxyServiceTest, SynchronousResponseWithNullCallbackAndRequest) {
3148 ProxyConfig config;
3149 config.proxy_rules().ParseFromString("foopy1:8080");
3150 config.set_auto_detect(false);
3151
3152 ProxyService service(
3153 new MockProxyConfigService(config), new MockAsyncProxyResolver, NULL);
3154
3155 GURL url("http://www.google.com/");
3156
3157 ProxyInfo info;
3158 net::CompletionCallback null_callback;
3159 ASSERT_TRUE(null_callback.is_null());
3160 CapturingBoundNetLog log;
3161
3162 int rv = service.ResolveProxy(
3163 url, net::LOAD_NORMAL, &info, null_callback, NULL, NULL, log.bound());
3164 EXPECT_EQ(OK, rv);
3165 EXPECT_FALSE(info.is_direct());
3166 EXPECT_EQ("foopy1", info.proxy_server().host_port_pair().host());
3167 }
3168
3084 } // namespace net 3169 } // 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