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

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

Issue 518042: Log the results of proxy resolution to LoadLog when "full logging mode" is en... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Address wtc's comments Created 10 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 TestCompletionCallback callback; 99 TestCompletionCallback callback;
100 scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded)); 100 scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
101 int rv = service->ResolveProxy(url, &info, &callback, NULL, log); 101 int rv = service->ResolveProxy(url, &info, &callback, NULL, log);
102 EXPECT_EQ(OK, rv); 102 EXPECT_EQ(OK, rv);
103 EXPECT_TRUE(resolver->pending_requests().empty()); 103 EXPECT_TRUE(resolver->pending_requests().empty());
104 EXPECT_TRUE(NULL == service->init_proxy_resolver_log()); 104 EXPECT_TRUE(NULL == service->init_proxy_resolver_log());
105 105
106 EXPECT_TRUE(info.is_direct()); 106 EXPECT_TRUE(info.is_direct());
107 107
108 // Check the LoadLog was filled correctly. 108 // Check the LoadLog was filled correctly.
109 EXPECT_EQ(4u, log->entries().size()); 109 EXPECT_EQ(5u, log->entries().size());
110 ExpectLogContains(log, 0, LoadLog::TYPE_PROXY_SERVICE, LoadLog::PHASE_BEGIN); 110 ExpectLogContains(log, 0, LoadLog::TYPE_PROXY_SERVICE, LoadLog::PHASE_BEGIN);
111 ExpectLogContains(log, 3, LoadLog::TYPE_PROXY_SERVICE, LoadLog::PHASE_END); 111 ExpectLogContains(log, 4, LoadLog::TYPE_PROXY_SERVICE, LoadLog::PHASE_END);
112 } 112 }
113 113
114 TEST(ProxyServiceTest, PAC) { 114 TEST(ProxyServiceTest, PAC) {
115 MockProxyConfigService* config_service = 115 MockProxyConfigService* config_service =
116 new MockProxyConfigService("http://foopy/proxy.pac"); 116 new MockProxyConfigService("http://foopy/proxy.pac");
117 117
118 MockAsyncProxyResolver* resolver = new MockAsyncProxyResolver; 118 MockAsyncProxyResolver* resolver = new MockAsyncProxyResolver;
119 119
120 scoped_refptr<ProxyService> service( 120 scoped_refptr<ProxyService> service(
121 new ProxyService(config_service, resolver)); 121 new ProxyService(config_service, resolver));
(...skipping 16 matching lines...) Expand all
138 138
139 // Set the result in proxy resolver. 139 // Set the result in proxy resolver.
140 resolver->pending_requests()[0]->results()->UseNamedProxy("foopy"); 140 resolver->pending_requests()[0]->results()->UseNamedProxy("foopy");
141 resolver->pending_requests()[0]->CompleteNow(OK); 141 resolver->pending_requests()[0]->CompleteNow(OK);
142 142
143 EXPECT_EQ(OK, callback.WaitForResult()); 143 EXPECT_EQ(OK, callback.WaitForResult());
144 EXPECT_FALSE(info.is_direct()); 144 EXPECT_FALSE(info.is_direct());
145 EXPECT_EQ("foopy:80", info.proxy_server().ToURI()); 145 EXPECT_EQ("foopy:80", info.proxy_server().ToURI());
146 146
147 // Check the LoadLog was filled correctly. 147 // Check the LoadLog was filled correctly.
148 EXPECT_EQ(6u, log->entries().size()); 148 EXPECT_EQ(7u, log->entries().size());
149 ExpectLogContains(log, 0, LoadLog::TYPE_PROXY_SERVICE, LoadLog::PHASE_BEGIN); 149 ExpectLogContains(log, 0, LoadLog::TYPE_PROXY_SERVICE, LoadLog::PHASE_BEGIN);
150 ExpectLogContains(log, 3, LoadLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC, 150 ExpectLogContains(log, 3, LoadLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC,
151 LoadLog::PHASE_BEGIN); 151 LoadLog::PHASE_BEGIN);
152 ExpectLogContains(log, 4, LoadLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC, 152 ExpectLogContains(log, 4, LoadLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC,
153 LoadLog::PHASE_END); 153 LoadLog::PHASE_END);
154 ExpectLogContains(log, 5, LoadLog::TYPE_PROXY_SERVICE, LoadLog::PHASE_END); 154 ExpectLogContains(log, 6, LoadLog::TYPE_PROXY_SERVICE, LoadLog::PHASE_END);
155 } 155 }
156 156
157 // Test that the proxy resolver does not see the URL's username/password 157 // Test that the proxy resolver does not see the URL's username/password
158 // or its reference section. 158 // or its reference section.
159 TEST(ProxyServiceTest, PAC_NoIdentityOrHash) { 159 TEST(ProxyServiceTest, PAC_NoIdentityOrHash) {
160 MockProxyConfigService* config_service = 160 MockProxyConfigService* config_service =
161 new MockProxyConfigService("http://foopy/proxy.pac"); 161 new MockProxyConfigService("http://foopy/proxy.pac");
162 162
163 MockAsyncProxyResolver* resolver = new MockAsyncProxyResolver; 163 MockAsyncProxyResolver* resolver = new MockAsyncProxyResolver;
164 164
(...skipping 1533 matching lines...) Expand 10 before | Expand all | Expand 10 after
1698 ProxyInfo info2; 1698 ProxyInfo info2;
1699 TestCompletionCallback callback2; 1699 TestCompletionCallback callback2;
1700 rv = service->ResolveProxy( 1700 rv = service->ResolveProxy(
1701 GURL("http://www.google.com"), &info2, &callback2, NULL, NULL); 1701 GURL("http://www.google.com"), &info2, &callback2, NULL, NULL);
1702 EXPECT_EQ(OK, rv); 1702 EXPECT_EQ(OK, rv);
1703 1703
1704 EXPECT_TRUE(info2.is_direct()); 1704 EXPECT_TRUE(info2.is_direct());
1705 } 1705 }
1706 1706
1707 } // namespace net 1707 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/proxy_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698