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 "base/compiler_specific.h" | 5 #include "base/compiler_specific.h" |
6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
| 12 #include "net/log/captured_net_log_entry.h" |
12 #include "net/log/net_log_unittest.h" | 13 #include "net/log/net_log_unittest.h" |
| 14 #include "net/log/test_net_log.h" |
13 #include "net/proxy/proxy_info.h" | 15 #include "net/proxy/proxy_info.h" |
14 #include "net/proxy/proxy_resolver_v8.h" | 16 #include "net/proxy/proxy_resolver_v8.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
16 #include "url/gurl.h" | 18 #include "url/gurl.h" |
17 | 19 |
18 namespace net { | 20 namespace net { |
19 namespace { | 21 namespace { |
20 | 22 |
21 // Javascript bindings for ProxyResolverV8, which returns mock values. | 23 // Javascript bindings for ProxyResolverV8, which returns mock values. |
22 // Each time one of the bindings is called into, we push the input into a | 24 // Each time one of the bindings is called into, we push the input into a |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 BoundTestNetLog log; | 150 BoundTestNetLog log; |
149 result = resolver.GetProxyForURL( | 151 result = resolver.GetProxyForURL( |
150 kQueryUrl, &proxy_info, CompletionCallback(), NULL, log.bound()); | 152 kQueryUrl, &proxy_info, CompletionCallback(), NULL, log.bound()); |
151 | 153 |
152 EXPECT_EQ(OK, result); | 154 EXPECT_EQ(OK, result); |
153 EXPECT_TRUE(proxy_info.is_direct()); | 155 EXPECT_TRUE(proxy_info.is_direct()); |
154 | 156 |
155 EXPECT_EQ(0U, resolver.mock_js_bindings()->alerts.size()); | 157 EXPECT_EQ(0U, resolver.mock_js_bindings()->alerts.size()); |
156 EXPECT_EQ(0U, resolver.mock_js_bindings()->errors.size()); | 158 EXPECT_EQ(0U, resolver.mock_js_bindings()->errors.size()); |
157 | 159 |
158 TestNetLog::CapturedEntryList entries; | 160 CapturedNetLogEntry::List entries; |
159 log.GetEntries(&entries); | 161 log.GetEntries(&entries); |
160 // No bindings were called, so no log entries. | 162 // No bindings were called, so no log entries. |
161 EXPECT_EQ(0u, entries.size()); | 163 EXPECT_EQ(0u, entries.size()); |
162 } | 164 } |
163 | 165 |
164 TEST(ProxyResolverV8Test, ReturnEmptyString) { | 166 TEST(ProxyResolverV8Test, ReturnEmptyString) { |
165 ProxyResolverV8WithMockBindings resolver; | 167 ProxyResolverV8WithMockBindings resolver; |
166 int result = resolver.SetPacScriptFromDisk("return_empty_string.js"); | 168 int result = resolver.SetPacScriptFromDisk("return_empty_string.js"); |
167 EXPECT_EQ(OK, result); | 169 EXPECT_EQ(OK, result); |
168 | 170 |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 GURL("http://kittens/"), &proxy_info, | 664 GURL("http://kittens/"), &proxy_info, |
663 CompletionCallback(), NULL, BoundNetLog()); | 665 CompletionCallback(), NULL, BoundNetLog()); |
664 | 666 |
665 EXPECT_EQ(OK, result); | 667 EXPECT_EQ(OK, result); |
666 EXPECT_EQ(0u, bindings->errors.size()); | 668 EXPECT_EQ(0u, bindings->errors.size()); |
667 EXPECT_EQ("kittens:88", proxy_info.proxy_server().ToURI()); | 669 EXPECT_EQ("kittens:88", proxy_info.proxy_server().ToURI()); |
668 } | 670 } |
669 | 671 |
670 } // namespace | 672 } // namespace |
671 } // namespace net | 673 } // namespace net |
OLD | NEW |