OLD | NEW |
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_resolver_v8.h" | |
6 #include "base/compiler_specific.h" | 5 #include "base/compiler_specific.h" |
7 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
8 #include "base/path_service.h" | 7 #include "base/path_service.h" |
9 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
10 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
11 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
12 #include "base/test/scoped_async_task_scheduler.h" | |
13 #include "net/base/completion_callback.h" | 11 #include "net/base/completion_callback.h" |
14 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
15 #include "net/proxy/proxy_info.h" | 13 #include "net/proxy/proxy_info.h" |
16 #include "net/proxy/proxy_resolver_script_data.h" | 14 #include "net/proxy/proxy_resolver_script_data.h" |
| 15 #include "net/proxy/proxy_resolver_v8.h" |
17 #include "net/test/gtest_util.h" | 16 #include "net/test/gtest_util.h" |
18 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
20 #include "url/gurl.h" | 19 #include "url/gurl.h" |
21 | 20 |
22 using net::test::IsError; | 21 using net::test::IsError; |
23 using net::test::IsOk; | 22 using net::test::IsOk; |
24 | 23 |
25 namespace net { | 24 namespace net { |
26 namespace { | 25 namespace { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 } | 129 } |
131 | 130 |
132 ProxyResolverV8& resolver() { | 131 ProxyResolverV8& resolver() { |
133 DCHECK(resolver_); | 132 DCHECK(resolver_); |
134 return *resolver_; | 133 return *resolver_; |
135 } | 134 } |
136 | 135 |
137 MockJSBindings* bindings() { return &js_bindings_; } | 136 MockJSBindings* bindings() { return &js_bindings_; } |
138 | 137 |
139 private: | 138 private: |
140 // Required by gin::V8Platform::CallOnBackgroundThread(). Can't be a | |
141 // ScopedTaskScheduler because v8 synchronously waits for tasks to run. | |
142 base::test::ScopedAsyncTaskScheduler scoped_async_task_scheduler; | |
143 | |
144 MockJSBindings js_bindings_; | 139 MockJSBindings js_bindings_; |
145 std::unique_ptr<ProxyResolverV8> resolver_; | 140 std::unique_ptr<ProxyResolverV8> resolver_; |
146 }; | 141 }; |
147 | 142 |
148 // Doesn't really matter what these values are for many of the tests. | 143 // Doesn't really matter what these values are for many of the tests. |
149 const GURL kQueryUrl("http://www.google.com"); | 144 const GURL kQueryUrl("http://www.google.com"); |
150 const GURL kPacUrl; | 145 const GURL kPacUrl; |
151 | 146 |
152 TEST_F(ProxyResolverV8Test, Direct) { | 147 TEST_F(ProxyResolverV8Test, Direct) { |
153 ASSERT_THAT(CreateResolver("direct.js"), IsOk()); | 148 ASSERT_THAT(CreateResolver("direct.js"), IsOk()); |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 result = resolver().GetProxyForURL(GURL("http://kittens/"), &proxy_info, | 535 result = resolver().GetProxyForURL(GURL("http://kittens/"), &proxy_info, |
541 bindings()); | 536 bindings()); |
542 | 537 |
543 EXPECT_THAT(result, IsOk()); | 538 EXPECT_THAT(result, IsOk()); |
544 EXPECT_EQ(0u, bindings()->errors.size()); | 539 EXPECT_EQ(0u, bindings()->errors.size()); |
545 EXPECT_EQ("kittens:88", proxy_info.proxy_server().ToURI()); | 540 EXPECT_EQ("kittens:88", proxy_info.proxy_server().ToURI()); |
546 } | 541 } |
547 | 542 |
548 } // namespace | 543 } // namespace |
549 } // namespace net | 544 } // namespace net |
OLD | NEW |