Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / net / proxy / proxy_info_unittest.cc
blob06a0497e4f940cd2c3b3aa783e620bfac9fe56e4
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.
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"
11 namespace net {
12 namespace {
14 TEST(ProxyInfoTest, ProxyInfoIsDirectOnly) {
15 // Test the is_direct_only() predicate.
16 ProxyInfo info;
18 // An empty ProxyInfo is not considered direct.
19 EXPECT_FALSE(info.is_direct_only());
21 info.UseDirect();
22 EXPECT_TRUE(info.is_direct_only());
24 info.UsePacString("DIRECT");
25 EXPECT_TRUE(info.is_direct_only());
27 info.UsePacString("PROXY myproxy:80");
28 EXPECT_FALSE(info.is_direct_only());
30 info.UsePacString("DIRECT; PROXY myproxy:80");
31 EXPECT_TRUE(info.is_direct());
32 EXPECT_FALSE(info.is_direct_only());
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());
45 } // namespace
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());
61 } // namespace net