| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_service.h" |
| 6 |
| 5 #include <vector> | 7 #include <vector> |
| 6 | 8 |
| 9 #include "base/format_macros.h" |
| 7 #include "base/logging.h" | 10 #include "base/logging.h" |
| 8 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 9 #include "googleurl/src/gurl.h" | 12 #include "googleurl/src/gurl.h" |
| 10 #include "net/base/load_log.h" | 13 #include "net/base/load_log.h" |
| 11 #include "net/base/load_log_unittest.h" | 14 #include "net/base/load_log_unittest.h" |
| 12 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
| 13 #include "net/base/test_completion_callback.h" | 16 #include "net/base/test_completion_callback.h" |
| 14 #include "net/proxy/mock_proxy_resolver.h" | 17 #include "net/proxy/mock_proxy_resolver.h" |
| 15 #include "net/proxy/proxy_config_service.h" | 18 #include "net/proxy/proxy_config_service.h" |
| 16 #include "net/proxy/proxy_resolver.h" | 19 #include "net/proxy/proxy_resolver.h" |
| 17 #include "net/proxy/proxy_script_fetcher.h" | 20 #include "net/proxy/proxy_script_fetcher.h" |
| 18 #include "net/proxy/proxy_service.h" | |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 22 |
| 21 // TODO(eroman): Write a test which exercises | 23 // TODO(eroman): Write a test which exercises |
| 22 // ProxyService::SuspendAllPendingRequests(). | 24 // ProxyService::SuspendAllPendingRequests(). |
| 23 namespace net { | 25 namespace net { |
| 24 namespace { | 26 namespace { |
| 25 | 27 |
| 26 class MockProxyConfigService: public ProxyConfigService { | 28 class MockProxyConfigService: public ProxyConfigService { |
| 27 public: | 29 public: |
| 28 MockProxyConfigService() {} // Direct connect. | 30 MockProxyConfigService() {} // Direct connect. |
| (...skipping 1381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1410 {"ftp://127.0.0.1/x", true}, | 1412 {"ftp://127.0.0.1/x", true}, |
| 1411 {"ftp://foobar.com/x", false}, | 1413 {"ftp://foobar.com/x", false}, |
| 1412 | 1414 |
| 1413 // This is a bit of a gray-area, but GURL does not strip trailing dots | 1415 // This is a bit of a gray-area, but GURL does not strip trailing dots |
| 1414 // in host-names, so the following are considered non-local. | 1416 // in host-names, so the following are considered non-local. |
| 1415 {"http://www./x", false}, | 1417 {"http://www./x", false}, |
| 1416 {"http://localhost./x", false}, | 1418 {"http://localhost./x", false}, |
| 1417 }; | 1419 }; |
| 1418 | 1420 |
| 1419 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | 1421 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { |
| 1420 SCOPED_TRACE(StringPrintf("Test[%d]: %s", i, tests[i].url)); | 1422 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s", i, tests[i].url)); |
| 1421 bool is_local = ProxyService::IsLocalName(GURL(tests[i].url)); | 1423 bool is_local = ProxyService::IsLocalName(GURL(tests[i].url)); |
| 1422 EXPECT_EQ(tests[i].expected_is_local, is_local); | 1424 EXPECT_EQ(tests[i].expected_is_local, is_local); |
| 1423 } | 1425 } |
| 1424 } | 1426 } |
| 1425 | 1427 |
| 1426 // Check that after we have done the auto-detect test, and the configuration | 1428 // Check that after we have done the auto-detect test, and the configuration |
| 1427 // is updated (with no change), we don't re-try the autodetect test. | 1429 // is updated (with no change), we don't re-try the autodetect test. |
| 1428 // Regression test for http://crbug.com/18526 -- the configuration was being | 1430 // Regression test for http://crbug.com/18526 -- the configuration was being |
| 1429 // mutated to cancel out the automatic settings, which meant UpdateConfig() | 1431 // mutated to cancel out the automatic settings, which meant UpdateConfig() |
| 1430 // thought it had received a new configuration. | 1432 // thought it had received a new configuration. |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1520 ProxyInfo info2; | 1522 ProxyInfo info2; |
| 1521 TestCompletionCallback callback2; | 1523 TestCompletionCallback callback2; |
| 1522 rv = service->ResolveProxy( | 1524 rv = service->ResolveProxy( |
| 1523 GURL("http://www.google.com"), &info2, &callback2, NULL, NULL); | 1525 GURL("http://www.google.com"), &info2, &callback2, NULL, NULL); |
| 1524 EXPECT_EQ(OK, rv); | 1526 EXPECT_EQ(OK, rv); |
| 1525 | 1527 |
| 1526 EXPECT_TRUE(info2.is_direct()); | 1528 EXPECT_TRUE(info2.is_direct()); |
| 1527 } | 1529 } |
| 1528 | 1530 |
| 1529 } // namespace net | 1531 } // namespace net |
| OLD | NEW |