Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: components/proxy_config/proxy_config_dictionary_unittest.cc

Issue 1921923002: Convert //components/[o-t]* from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/proxy_config/proxy_config_dictionary.h ('k') | components/query_parser/snippet.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "components/proxy_config/proxy_config_dictionary.h"
6
7 #include <memory>
5 #include <string> 8 #include <string>
6 9
7 #include "base/memory/scoped_ptr.h"
8 #include "base/values.h" 10 #include "base/values.h"
9 #include "components/proxy_config/proxy_config_dictionary.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 12
12 struct ProxyConfigHolder { 13 struct ProxyConfigHolder {
13 ProxyPrefs::ProxyMode mode; 14 ProxyPrefs::ProxyMode mode;
14 std::string pac_url; 15 std::string pac_url;
15 std::string proxy_server; 16 std::string proxy_server;
16 std::string bypass_list; 17 std::string bypass_list;
17 }; 18 };
18 19
19 TEST(ProxyConfigDictionaryTest, CreateDirect) { 20 TEST(ProxyConfigDictionaryTest, CreateDirect) {
20 scoped_ptr<base::DictionaryValue> dict_value( 21 std::unique_ptr<base::DictionaryValue> dict_value(
21 ProxyConfigDictionary::CreateDirect()); 22 ProxyConfigDictionary::CreateDirect());
22 ProxyConfigDictionary dict(dict_value.get()); 23 ProxyConfigDictionary dict(dict_value.get());
23 ProxyConfigHolder h; 24 ProxyConfigHolder h;
24 25
25 ASSERT_TRUE(dict.GetMode(&h.mode)); 26 ASSERT_TRUE(dict.GetMode(&h.mode));
26 EXPECT_EQ(ProxyPrefs::MODE_DIRECT, h.mode); 27 EXPECT_EQ(ProxyPrefs::MODE_DIRECT, h.mode);
27 ASSERT_FALSE(dict.GetPacUrl(&h.bypass_list)); 28 ASSERT_FALSE(dict.GetPacUrl(&h.bypass_list));
28 ASSERT_FALSE(dict.GetProxyServer(&h.proxy_server)); 29 ASSERT_FALSE(dict.GetProxyServer(&h.proxy_server));
29 ASSERT_FALSE(dict.GetBypassList(&h.bypass_list)); 30 ASSERT_FALSE(dict.GetBypassList(&h.bypass_list));
30 } 31 }
31 32
32 TEST(ProxyConfigDictionaryTest, CreateAutoDetect) { 33 TEST(ProxyConfigDictionaryTest, CreateAutoDetect) {
33 scoped_ptr<base::DictionaryValue> dict_value( 34 std::unique_ptr<base::DictionaryValue> dict_value(
34 ProxyConfigDictionary::CreateAutoDetect()); 35 ProxyConfigDictionary::CreateAutoDetect());
35 ProxyConfigDictionary dict(dict_value.get()); 36 ProxyConfigDictionary dict(dict_value.get());
36 ProxyConfigHolder h; 37 ProxyConfigHolder h;
37 38
38 ASSERT_TRUE(dict.GetMode(&h.mode)); 39 ASSERT_TRUE(dict.GetMode(&h.mode));
39 EXPECT_EQ(ProxyPrefs::MODE_AUTO_DETECT, h.mode); 40 EXPECT_EQ(ProxyPrefs::MODE_AUTO_DETECT, h.mode);
40 ASSERT_FALSE(dict.GetPacUrl(&h.bypass_list)); 41 ASSERT_FALSE(dict.GetPacUrl(&h.bypass_list));
41 ASSERT_FALSE(dict.GetProxyServer(&h.proxy_server)); 42 ASSERT_FALSE(dict.GetProxyServer(&h.proxy_server));
42 ASSERT_FALSE(dict.GetBypassList(&h.bypass_list)); 43 ASSERT_FALSE(dict.GetBypassList(&h.bypass_list));
43 } 44 }
44 45
45 TEST(ProxyConfigDictionaryTest, CreatePacScript) { 46 TEST(ProxyConfigDictionaryTest, CreatePacScript) {
46 scoped_ptr<base::DictionaryValue> dict_value( 47 std::unique_ptr<base::DictionaryValue> dict_value(
47 ProxyConfigDictionary::CreatePacScript("pac", false)); 48 ProxyConfigDictionary::CreatePacScript("pac", false));
48 ProxyConfigDictionary dict(dict_value.get()); 49 ProxyConfigDictionary dict(dict_value.get());
49 ProxyConfigHolder h; 50 ProxyConfigHolder h;
50 51
51 ASSERT_TRUE(dict.GetMode(&h.mode)); 52 ASSERT_TRUE(dict.GetMode(&h.mode));
52 EXPECT_EQ(ProxyPrefs::MODE_PAC_SCRIPT, h.mode); 53 EXPECT_EQ(ProxyPrefs::MODE_PAC_SCRIPT, h.mode);
53 ASSERT_TRUE(dict.GetPacUrl(&h.bypass_list)); 54 ASSERT_TRUE(dict.GetPacUrl(&h.bypass_list));
54 EXPECT_EQ("pac", h.bypass_list); 55 EXPECT_EQ("pac", h.bypass_list);
55 ASSERT_FALSE(dict.GetProxyServer(&h.proxy_server)); 56 ASSERT_FALSE(dict.GetProxyServer(&h.proxy_server));
56 ASSERT_FALSE(dict.GetBypassList(&h.bypass_list)); 57 ASSERT_FALSE(dict.GetBypassList(&h.bypass_list));
57 } 58 }
58 59
59 TEST(ProxyConfigDictionaryTest, CreateFixedServers) { 60 TEST(ProxyConfigDictionaryTest, CreateFixedServers) {
60 scoped_ptr<base::DictionaryValue> dict_value( 61 std::unique_ptr<base::DictionaryValue> dict_value(
61 ProxyConfigDictionary::CreateFixedServers("http://1.2.3.4", 62 ProxyConfigDictionary::CreateFixedServers("http://1.2.3.4",
62 "http://foo")); 63 "http://foo"));
63 ProxyConfigDictionary dict(dict_value.get()); 64 ProxyConfigDictionary dict(dict_value.get());
64 ProxyConfigHolder h; 65 ProxyConfigHolder h;
65 66
66 ASSERT_TRUE(dict.GetMode(&h.mode)); 67 ASSERT_TRUE(dict.GetMode(&h.mode));
67 EXPECT_EQ(ProxyPrefs::MODE_FIXED_SERVERS, h.mode); 68 EXPECT_EQ(ProxyPrefs::MODE_FIXED_SERVERS, h.mode);
68 ASSERT_FALSE(dict.GetPacUrl(&h.bypass_list)); 69 ASSERT_FALSE(dict.GetPacUrl(&h.bypass_list));
69 ASSERT_TRUE(dict.GetProxyServer(&h.proxy_server)); 70 ASSERT_TRUE(dict.GetProxyServer(&h.proxy_server));
70 EXPECT_EQ("http://1.2.3.4", h.proxy_server); 71 EXPECT_EQ("http://1.2.3.4", h.proxy_server);
71 ASSERT_TRUE(dict.GetBypassList(&h.bypass_list)); 72 ASSERT_TRUE(dict.GetBypassList(&h.bypass_list));
72 EXPECT_EQ("http://foo", h.bypass_list); 73 EXPECT_EQ("http://foo", h.bypass_list);
73 } 74 }
74 75
75 TEST(ProxyConfigDictionaryTest, CreateSystem) { 76 TEST(ProxyConfigDictionaryTest, CreateSystem) {
76 scoped_ptr<base::DictionaryValue> dict_value( 77 std::unique_ptr<base::DictionaryValue> dict_value(
77 ProxyConfigDictionary::CreateSystem()); 78 ProxyConfigDictionary::CreateSystem());
78 ProxyConfigDictionary dict(dict_value.get()); 79 ProxyConfigDictionary dict(dict_value.get());
79 ProxyConfigHolder h; 80 ProxyConfigHolder h;
80 81
81 ASSERT_TRUE(dict.GetMode(&h.mode)); 82 ASSERT_TRUE(dict.GetMode(&h.mode));
82 EXPECT_EQ(ProxyPrefs::MODE_SYSTEM, h.mode); 83 EXPECT_EQ(ProxyPrefs::MODE_SYSTEM, h.mode);
83 ASSERT_FALSE(dict.GetPacUrl(&h.bypass_list)); 84 ASSERT_FALSE(dict.GetPacUrl(&h.bypass_list));
84 ASSERT_FALSE(dict.GetProxyServer(&h.proxy_server)); 85 ASSERT_FALSE(dict.GetProxyServer(&h.proxy_server));
85 ASSERT_FALSE(dict.GetBypassList(&h.bypass_list)); 86 ASSERT_FALSE(dict.GetBypassList(&h.bypass_list));
86 } 87 }
OLDNEW
« no previous file with comments | « components/proxy_config/proxy_config_dictionary.h ('k') | components/query_parser/snippet.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698