OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/perftimer.h" | 5 #include "base/perftimer.h" |
| 6 #include "base/string_util.h" |
6 #include "net/base/mock_host_resolver.h" | 7 #include "net/base/mock_host_resolver.h" |
7 #include "net/proxy/proxy_resolver_js_bindings.h" | 8 #include "net/proxy/proxy_resolver_js_bindings.h" |
8 #include "net/proxy/proxy_resolver_v8.h" | 9 #include "net/proxy/proxy_resolver_v8.h" |
9 #include "net/url_request/url_request_unittest.h" | 10 #include "net/url_request/url_request_unittest.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
11 | 12 |
12 #if defined(OS_WIN) | 13 #if defined(OS_WIN) |
13 #include "net/proxy/proxy_resolver_winhttp.h" | 14 #include "net/proxy/proxy_resolver_winhttp.h" |
14 #elif defined(OS_MACOSX) | 15 #elif defined(OS_MACOSX) |
15 #include "net/proxy/proxy_resolver_mac.h" | 16 #include "net/proxy/proxy_resolver_mac.h" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 | 160 |
160 // Try to read the file from disk. | 161 // Try to read the file from disk. |
161 std::string file_contents; | 162 std::string file_contents; |
162 bool ok = file_util::ReadFileToString(path, &file_contents); | 163 bool ok = file_util::ReadFileToString(path, &file_contents); |
163 | 164 |
164 // If we can't load the file from disk, something is misconfigured. | 165 // If we can't load the file from disk, something is misconfigured. |
165 LOG_IF(ERROR, !ok) << "Failed to read file: " << path.value(); | 166 LOG_IF(ERROR, !ok) << "Failed to read file: " << path.value(); |
166 ASSERT_TRUE(ok); | 167 ASSERT_TRUE(ok); |
167 | 168 |
168 // Load the PAC script into the ProxyResolver. | 169 // Load the PAC script into the ProxyResolver. |
169 int rv = resolver_->SetPacScriptByData(file_contents, NULL); | 170 int rv = resolver_->SetPacScriptByData(ASCIIToUTF16(file_contents), NULL); |
170 EXPECT_EQ(net::OK, rv); | 171 EXPECT_EQ(net::OK, rv); |
171 } | 172 } |
172 | 173 |
173 net::ProxyResolver* resolver_; | 174 net::ProxyResolver* resolver_; |
174 std::string resolver_name_; | 175 std::string resolver_name_; |
175 scoped_refptr<HTTPTestServer> server_; | 176 scoped_refptr<HTTPTestServer> server_; |
176 }; | 177 }; |
177 | 178 |
178 #if defined(OS_WIN) | 179 #if defined(OS_WIN) |
179 TEST(ProxyResolverPerfTest, ProxyResolverWinHttp) { | 180 TEST(ProxyResolverPerfTest, ProxyResolverWinHttp) { |
(...skipping 10 matching lines...) Expand all Loading... |
190 #endif | 191 #endif |
191 | 192 |
192 TEST(ProxyResolverPerfTest, ProxyResolverV8) { | 193 TEST(ProxyResolverPerfTest, ProxyResolverV8) { |
193 net::ProxyResolverJSBindings* js_bindings = | 194 net::ProxyResolverJSBindings* js_bindings = |
194 net::ProxyResolverJSBindings::CreateDefault(new net::MockHostResolver); | 195 net::ProxyResolverJSBindings::CreateDefault(new net::MockHostResolver); |
195 | 196 |
196 net::ProxyResolverV8 resolver(js_bindings); | 197 net::ProxyResolverV8 resolver(js_bindings); |
197 PacPerfSuiteRunner runner(&resolver, "ProxyResolverV8"); | 198 PacPerfSuiteRunner runner(&resolver, "ProxyResolverV8"); |
198 runner.RunAllTests(); | 199 runner.RunAllTests(); |
199 } | 200 } |
OLD | NEW |