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