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

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

Issue 3034038: GTTF: Move more test server code from net/url_request/url_request_unittest.h (Closed)
Patch Set: hopefully final Created 10 years, 4 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
« no previous file with comments | « chrome_frame/test/test_with_web_server.cc ('k') | net/test/test_server.h » ('j') | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "base/base_paths.h"
6 #include "base/file_util.h"
7 #include "base/path_service.h"
5 #include "base/perftimer.h" 8 #include "base/perftimer.h"
6 #include "base/string_util.h" 9 #include "base/string_util.h"
7 #include "net/base/mock_host_resolver.h" 10 #include "net/base/mock_host_resolver.h"
11 #include "net/base/net_errors.h"
12 #include "net/proxy/proxy_info.h"
8 #include "net/proxy/proxy_resolver_js_bindings.h" 13 #include "net/proxy/proxy_resolver_js_bindings.h"
9 #include "net/proxy/proxy_resolver_v8.h" 14 #include "net/proxy/proxy_resolver_v8.h"
10 #include "net/url_request/url_request_unittest.h" 15 #include "net/test/test_server.h"
11 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
12 17
13 #if defined(OS_WIN) 18 #if defined(OS_WIN)
14 #include "net/proxy/proxy_resolver_winhttp.h" 19 #include "net/proxy/proxy_resolver_winhttp.h"
15 #elif defined(OS_MACOSX) 20 #elif defined(OS_MACOSX)
16 #include "net/proxy/proxy_resolver_mac.h" 21 #include "net/proxy/proxy_resolver_mac.h"
17 #endif 22 #endif
18 23
19 // This class holds the URL to use for resolving, and the expected result. 24 // This class holds the URL to use for resolving, and the expected result.
20 // We track the expected result in order to make sure the performance 25 // We track the expected result in order to make sure the performance
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } 142 }
138 143
139 // Print how long the test ran for. 144 // Print how long the test ran for.
140 timer.Done(); 145 timer.Done();
141 } 146 }
142 147
143 // Lazily startup an HTTP server (to serve the PAC script). 148 // Lazily startup an HTTP server (to serve the PAC script).
144 void InitHttpServer() { 149 void InitHttpServer() {
145 DCHECK(!resolver_->expects_pac_bytes()); 150 DCHECK(!resolver_->expects_pac_bytes());
146 if (!server_) { 151 if (!server_) {
147 server_ = HTTPTestServer::CreateServer( 152 server_ = net::HTTPTestServer::CreateServer(
148 L"net/data/proxy_resolver_perftest"); 153 L"net/data/proxy_resolver_perftest");
149 } 154 }
150 ASSERT_TRUE(server_.get() != NULL); 155 ASSERT_TRUE(server_.get() != NULL);
151 } 156 }
152 157
153 // Read the PAC script from disk and initialize the proxy resolver with it. 158 // Read the PAC script from disk and initialize the proxy resolver with it.
154 void LoadPacScriptIntoResolver(const std::string& script_name) { 159 void LoadPacScriptIntoResolver(const std::string& script_name) {
155 FilePath path; 160 FilePath path;
156 PathService::Get(base::DIR_SOURCE_ROOT, &path); 161 PathService::Get(base::DIR_SOURCE_ROOT, &path);
157 path = path.AppendASCII("net"); 162 path = path.AppendASCII("net");
(...skipping 10 matching lines...) Expand all
168 ASSERT_TRUE(ok); 173 ASSERT_TRUE(ok);
169 174
170 // Load the PAC script into the ProxyResolver. 175 // Load the PAC script into the ProxyResolver.
171 int rv = resolver_->SetPacScript( 176 int rv = resolver_->SetPacScript(
172 net::ProxyResolverScriptData::FromUTF8(file_contents), NULL); 177 net::ProxyResolverScriptData::FromUTF8(file_contents), NULL);
173 EXPECT_EQ(net::OK, rv); 178 EXPECT_EQ(net::OK, rv);
174 } 179 }
175 180
176 net::ProxyResolver* resolver_; 181 net::ProxyResolver* resolver_;
177 std::string resolver_name_; 182 std::string resolver_name_;
178 scoped_refptr<HTTPTestServer> server_; 183 scoped_refptr<net::HTTPTestServer> server_;
179 }; 184 };
180 185
181 #if defined(OS_WIN) 186 #if defined(OS_WIN)
182 TEST(ProxyResolverPerfTest, ProxyResolverWinHttp) { 187 TEST(ProxyResolverPerfTest, ProxyResolverWinHttp) {
183 net::ProxyResolverWinHttp resolver; 188 net::ProxyResolverWinHttp resolver;
184 PacPerfSuiteRunner runner(&resolver, "ProxyResolverWinHttp"); 189 PacPerfSuiteRunner runner(&resolver, "ProxyResolverWinHttp");
185 runner.RunAllTests(); 190 runner.RunAllTests();
186 } 191 }
187 #elif defined(OS_MACOSX) 192 #elif defined(OS_MACOSX)
188 TEST(ProxyResolverPerfTest, ProxyResolverMac) { 193 TEST(ProxyResolverPerfTest, ProxyResolverMac) {
189 net::ProxyResolverMac resolver; 194 net::ProxyResolverMac resolver;
190 PacPerfSuiteRunner runner(&resolver, "ProxyResolverMac"); 195 PacPerfSuiteRunner runner(&resolver, "ProxyResolverMac");
191 runner.RunAllTests(); 196 runner.RunAllTests();
192 } 197 }
193 #endif 198 #endif
194 199
195 TEST(ProxyResolverPerfTest, ProxyResolverV8) { 200 TEST(ProxyResolverPerfTest, ProxyResolverV8) {
196 net::ProxyResolverJSBindings* js_bindings = 201 net::ProxyResolverJSBindings* js_bindings =
197 net::ProxyResolverJSBindings::CreateDefault( 202 net::ProxyResolverJSBindings::CreateDefault(
198 new net::MockHostResolver, NULL); 203 new net::MockHostResolver, NULL);
199 204
200 net::ProxyResolverV8 resolver(js_bindings); 205 net::ProxyResolverV8 resolver(js_bindings);
201 PacPerfSuiteRunner runner(&resolver, "ProxyResolverV8"); 206 PacPerfSuiteRunner runner(&resolver, "ProxyResolverV8");
202 runner.RunAllTests(); 207 runner.RunAllTests();
203 } 208 }
204 209
OLDNEW
« no previous file with comments | « chrome_frame/test/test_with_web_server.cc ('k') | net/test/test_server.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698