OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "net/base/net_errors.h" | |
6 #include "net/proxy/proxy_config.h" | |
7 #include "net/proxy/proxy_info.h" | |
8 #include "net/proxy/proxy_list.h" | |
9 #include "testing/gtest/include/gtest/gtest.h" | |
10 | |
11 namespace net { | |
12 namespace { | |
13 | |
14 TEST(ProxyInfoTest, ProxyInfoIsDirectOnly) { | |
15 // Test the is_direct_only() predicate. | |
16 ProxyInfo info; | |
17 | |
18 // An empty ProxyInfo is not considered direct. | |
19 EXPECT_FALSE(info.is_direct_only()); | |
20 | |
21 info.UseDirect(); | |
22 EXPECT_TRUE(info.is_direct_only()); | |
23 | |
24 info.UsePacString("DIRECT"); | |
25 EXPECT_TRUE(info.is_direct_only()); | |
26 | |
27 info.UsePacString("PROXY myproxy:80"); | |
28 EXPECT_FALSE(info.is_direct_only()); | |
29 | |
30 info.UsePacString("DIRECT; PROXY myproxy:80"); | |
31 EXPECT_TRUE(info.is_direct()); | |
32 EXPECT_FALSE(info.is_direct_only()); | |
33 | |
34 info.UsePacString("PROXY myproxy:80; DIRECT"); | |
35 EXPECT_FALSE(info.is_direct()); | |
36 EXPECT_FALSE(info.is_direct_only()); | |
37 EXPECT_EQ(2u, info.proxy_list().size()); | |
38 EXPECT_EQ("PROXY myproxy:80;DIRECT", info.proxy_list().ToPacString()); | |
39 // After falling back to direct, we shouldn't consider it DIRECT only. | |
40 EXPECT_TRUE(info.Fallback(ERR_PROXY_CONNECTION_FAILED, BoundNetLog())); | |
41 EXPECT_TRUE(info.is_direct()); | |
42 EXPECT_FALSE(info.is_direct_only()); | |
43 } | |
44 | |
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 | |
61 } // namespace net | |
OLD | NEW |