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

Side by Side Diff: chrome/browser/prefs/proxy_config_dictionary_unittest.cc

Issue 6240013: Make proxy settings one atomic dictionary in the PrefStores such that modifications are atomic. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/out/Debug
Patch Set: Fixed Lint comment Created 9 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/prefs/proxy_config_dictionary.cc ('k') | chrome/browser/prefs/proxy_prefs.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include <string>
6
7 #include "base/scoped_ptr.h"
8 #include "base/values.h"
9 #include "chrome/browser/prefs/proxy_config_dictionary.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 struct ProxyConfigHolder {
13 ProxyPrefs::ProxyMode mode;
14 std::string pac_url;
15 std::string proxy_server;
16 std::string bypass_list;
17 };
18
19 TEST(ProxyConfigDictionaryTest, CreateDirect) {
20 scoped_ptr<DictionaryValue> dict_value(ProxyConfigDictionary::CreateDirect());
21 ProxyConfigDictionary dict(dict_value.get());
22 ProxyConfigHolder h;
23
24 ASSERT_TRUE(dict.GetMode(&h.mode));
25 EXPECT_EQ(ProxyPrefs::MODE_DIRECT, h.mode);
26 ASSERT_FALSE(dict.GetPacUrl(&h.bypass_list));
27 ASSERT_FALSE(dict.GetProxyServer(&h.proxy_server));
28 ASSERT_FALSE(dict.GetBypassList(&h.bypass_list));
29 }
30
31 TEST(ProxyConfigDictionaryTest, CreateAutoDetect) {
32 scoped_ptr<DictionaryValue> dict_value(
33 ProxyConfigDictionary::CreateAutoDetect());
34 ProxyConfigDictionary dict(dict_value.get());
35 ProxyConfigHolder h;
36
37 ASSERT_TRUE(dict.GetMode(&h.mode));
38 EXPECT_EQ(ProxyPrefs::MODE_AUTO_DETECT, h.mode);
39 ASSERT_FALSE(dict.GetPacUrl(&h.bypass_list));
40 ASSERT_FALSE(dict.GetProxyServer(&h.proxy_server));
41 ASSERT_FALSE(dict.GetBypassList(&h.bypass_list));
42 }
43
44 TEST(ProxyConfigDictionaryTest, CreatePacScript) {
45 scoped_ptr<DictionaryValue> dict_value(
46 ProxyConfigDictionary::CreatePacScript("pac"));
47 ProxyConfigDictionary dict(dict_value.get());
48 ProxyConfigHolder h;
49
50 ASSERT_TRUE(dict.GetMode(&h.mode));
51 EXPECT_EQ(ProxyPrefs::MODE_PAC_SCRIPT, h.mode);
52 ASSERT_TRUE(dict.GetPacUrl(&h.bypass_list));
53 EXPECT_EQ("pac", h.bypass_list);
54 ASSERT_FALSE(dict.GetProxyServer(&h.proxy_server));
55 ASSERT_FALSE(dict.GetBypassList(&h.bypass_list));
56 }
57
58 TEST(ProxyConfigDictionaryTest, CreateFixedServers) {
59 scoped_ptr<DictionaryValue> dict_value(
60 ProxyConfigDictionary::CreateFixedServers("http://1.2.3.4",
61 "http://foo"));
62 ProxyConfigDictionary dict(dict_value.get());
63 ProxyConfigHolder h;
64
65 ASSERT_TRUE(dict.GetMode(&h.mode));
66 EXPECT_EQ(ProxyPrefs::MODE_FIXED_SERVERS, h.mode);
67 ASSERT_FALSE(dict.GetPacUrl(&h.bypass_list));
68 ASSERT_TRUE(dict.GetProxyServer(&h.proxy_server));
69 EXPECT_EQ("http://1.2.3.4", h.proxy_server);
70 ASSERT_TRUE(dict.GetBypassList(&h.bypass_list));
71 EXPECT_EQ("http://foo", h.bypass_list);
72 }
73
74 TEST(ProxyConfigDictionaryTest, CreateSystem) {
75 scoped_ptr<DictionaryValue> dict_value(ProxyConfigDictionary::CreateSystem());
76 ProxyConfigDictionary dict(dict_value.get());
77 ProxyConfigHolder h;
78
79 ASSERT_TRUE(dict.GetMode(&h.mode));
80 EXPECT_EQ(ProxyPrefs::MODE_SYSTEM, h.mode);
81 ASSERT_FALSE(dict.GetPacUrl(&h.bypass_list));
82 ASSERT_FALSE(dict.GetProxyServer(&h.proxy_server));
83 ASSERT_FALSE(dict.GetBypassList(&h.bypass_list));
84 }
OLDNEW
« no previous file with comments | « chrome/browser/prefs/proxy_config_dictionary.cc ('k') | chrome/browser/prefs/proxy_prefs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698