| 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/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "googleurl/src/gurl.h" | 9 #include "googleurl/src/gurl.h" |
| 10 #include "net/base/net_log_unittest.h" | 10 #include "net/base/net_log_unittest.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 std::string file_contents; | 102 std::string file_contents; |
| 103 bool ok = file_util::ReadFileToString(path, &file_contents); | 103 bool ok = file_util::ReadFileToString(path, &file_contents); |
| 104 | 104 |
| 105 // If we can't load the file from disk, something is misconfigured. | 105 // If we can't load the file from disk, something is misconfigured. |
| 106 if (!ok) { | 106 if (!ok) { |
| 107 LOG(ERROR) << "Failed to read file: " << path.value(); | 107 LOG(ERROR) << "Failed to read file: " << path.value(); |
| 108 return ERR_UNEXPECTED; | 108 return ERR_UNEXPECTED; |
| 109 } | 109 } |
| 110 | 110 |
| 111 // Load the PAC script into the ProxyResolver. | 111 // Load the PAC script into the ProxyResolver. |
| 112 return SetPacScriptByData(file_contents, NULL); | 112 return SetPacScriptByData(UTF8ToUTF16(file_contents), NULL); |
| 113 } | 113 } |
| 114 }; | 114 }; |
| 115 | 115 |
| 116 // Doesn't really matter what these values are for many of the tests. | 116 // Doesn't really matter what these values are for many of the tests. |
| 117 const GURL kQueryUrl("http://www.google.com"); | 117 const GURL kQueryUrl("http://www.google.com"); |
| 118 const GURL kPacUrl; | 118 const GURL kPacUrl; |
| 119 | 119 |
| 120 | 120 |
| 121 TEST(ProxyResolverV8Test, Direct) { | 121 TEST(ProxyResolverV8Test, Direct) { |
| 122 ProxyResolverV8WithMockBindings resolver; | 122 ProxyResolverV8WithMockBindings resolver; |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 // Initialize it. | 359 // Initialize it. |
| 360 result = resolver.SetPacScriptFromDisk("direct.js"); | 360 result = resolver.SetPacScriptFromDisk("direct.js"); |
| 361 EXPECT_EQ(OK, result); | 361 EXPECT_EQ(OK, result); |
| 362 | 362 |
| 363 // Resolve should now succeed. | 363 // Resolve should now succeed. |
| 364 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL, | 364 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL, |
| 365 BoundNetLog()); | 365 BoundNetLog()); |
| 366 EXPECT_EQ(OK, result); | 366 EXPECT_EQ(OK, result); |
| 367 | 367 |
| 368 // Clear it, by initializing with an empty string. | 368 // Clear it, by initializing with an empty string. |
| 369 resolver.SetPacScriptByData(std::string(), NULL); | 369 resolver.SetPacScriptByData(string16(), NULL); |
| 370 | 370 |
| 371 // Resolve should fail again now. | 371 // Resolve should fail again now. |
| 372 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL, | 372 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL, |
| 373 BoundNetLog()); | 373 BoundNetLog()); |
| 374 EXPECT_EQ(ERR_FAILED, result); | 374 EXPECT_EQ(ERR_FAILED, result); |
| 375 | 375 |
| 376 // Load a good script once more. | 376 // Load a good script once more. |
| 377 result = resolver.SetPacScriptFromDisk("direct.js"); | 377 result = resolver.SetPacScriptFromDisk("direct.js"); |
| 378 EXPECT_EQ(OK, result); | 378 EXPECT_EQ(OK, result); |
| 379 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL, | 379 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL, |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 | 567 |
| 568 ASSERT_EQ(1u, bindings->dns_resolves.size()); | 568 ASSERT_EQ(1u, bindings->dns_resolves.size()); |
| 569 EXPECT_EQ("xn--bcher-kva.ch", bindings->dns_resolves[0]); | 569 EXPECT_EQ("xn--bcher-kva.ch", bindings->dns_resolves[0]); |
| 570 | 570 |
| 571 ASSERT_EQ(1u, bindings->dns_resolves_ex.size()); | 571 ASSERT_EQ(1u, bindings->dns_resolves_ex.size()); |
| 572 EXPECT_EQ("xn--bcher-kva.ch", bindings->dns_resolves_ex[0]); | 572 EXPECT_EQ("xn--bcher-kva.ch", bindings->dns_resolves_ex[0]); |
| 573 } | 573 } |
| 574 | 574 |
| 575 } // namespace | 575 } // namespace |
| 576 } // namespace net | 576 } // namespace net |
| OLD | NEW |