Blink roll 25b6bd3a7a131ffe68d809546ad1a20707915cdc:3a503f41ae42e5b79cfcd2ff10e65afde...
[chromium-blink-merge.git] / net / proxy / proxy_info_unittest.cc
blob09f5ef60b1f52bb7c0c97c51f5bca086f41a0586
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_info.h"
7 #include "testing/gtest/include/gtest/gtest.h"
9 namespace net {
10 namespace {
12 TEST(ProxyInfoTest, ProxyInfoIsDirectOnly) {
13 // Test the is_direct_only() predicate.
14 ProxyInfo info;
16 // An empty ProxyInfo is not considered direct.
17 EXPECT_FALSE(info.is_direct_only());
19 info.UseDirect();
20 EXPECT_TRUE(info.is_direct_only());
22 info.UsePacString("DIRECT");
23 EXPECT_TRUE(info.is_direct_only());
25 info.UsePacString("PROXY myproxy:80");
26 EXPECT_FALSE(info.is_direct_only());
28 info.UsePacString("DIRECT; PROXY myproxy:80");
29 EXPECT_TRUE(info.is_direct());
30 EXPECT_FALSE(info.is_direct_only());
32 info.UsePacString("PROXY myproxy:80; DIRECT");
33 EXPECT_FALSE(info.is_direct());
34 EXPECT_FALSE(info.is_direct_only());
35 EXPECT_EQ(2u, info.proxy_list().size());
36 EXPECT_EQ("PROXY myproxy:80;DIRECT", info.proxy_list().ToPacString());
37 // After falling back to direct, we shouldn't consider it DIRECT only.
38 EXPECT_TRUE(info.Fallback(ERR_PROXY_CONNECTION_FAILED, BoundNetLog()));
39 EXPECT_TRUE(info.is_direct());
40 EXPECT_FALSE(info.is_direct_only());
43 } // namespace
44 } // namespace net