| 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/base/net_errors.h" | 5 #include "net/base/net_errors.h" |
| 6 #include "net/proxy/proxy_config.h" |
| 6 #include "net/proxy/proxy_info.h" | 7 #include "net/proxy/proxy_info.h" |
| 8 #include "net/proxy/proxy_list.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 10 |
| 9 namespace net { | 11 namespace net { |
| 10 namespace { | 12 namespace { |
| 11 | 13 |
| 12 TEST(ProxyInfoTest, ProxyInfoIsDirectOnly) { | 14 TEST(ProxyInfoTest, ProxyInfoIsDirectOnly) { |
| 13 // Test the is_direct_only() predicate. | 15 // Test the is_direct_only() predicate. |
| 14 ProxyInfo info; | 16 ProxyInfo info; |
| 15 | 17 |
| 16 // An empty ProxyInfo is not considered direct. | 18 // An empty ProxyInfo is not considered direct. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 34 EXPECT_FALSE(info.is_direct_only()); | 36 EXPECT_FALSE(info.is_direct_only()); |
| 35 EXPECT_EQ(2u, info.proxy_list().size()); | 37 EXPECT_EQ(2u, info.proxy_list().size()); |
| 36 EXPECT_EQ("PROXY myproxy:80;DIRECT", info.proxy_list().ToPacString()); | 38 EXPECT_EQ("PROXY myproxy:80;DIRECT", info.proxy_list().ToPacString()); |
| 37 // After falling back to direct, we shouldn't consider it DIRECT only. | 39 // After falling back to direct, we shouldn't consider it DIRECT only. |
| 38 EXPECT_TRUE(info.Fallback(ERR_PROXY_CONNECTION_FAILED, BoundNetLog())); | 40 EXPECT_TRUE(info.Fallback(ERR_PROXY_CONNECTION_FAILED, BoundNetLog())); |
| 39 EXPECT_TRUE(info.is_direct()); | 41 EXPECT_TRUE(info.is_direct()); |
| 40 EXPECT_FALSE(info.is_direct_only()); | 42 EXPECT_FALSE(info.is_direct_only()); |
| 41 } | 43 } |
| 42 | 44 |
| 43 } // namespace | 45 } // namespace |
| 46 |
| 47 TEST(ProxyInfoTest, UseVsOverrideProxyList) { |
| 48 ProxyInfo info; |
| 49 info.config_id_ = 99; |
| 50 ProxyList proxy_list; |
| 51 proxy_list.Set("http://foo.com"); |
| 52 info.OverrideProxyList(proxy_list); |
| 53 EXPECT_EQ(99, info.config_id_); |
| 54 EXPECT_EQ("PROXY foo.com:80", info.proxy_list().ToPacString()); |
| 55 proxy_list.Set("http://bar.com"); |
| 56 info.UseProxyList(proxy_list); |
| 57 EXPECT_EQ(0, info.config_id_); |
| 58 EXPECT_EQ("PROXY bar.com:80", info.proxy_list().ToPacString()); |
| 59 } |
| 60 |
| 44 } // namespace net | 61 } // namespace net |
| OLD | NEW |