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

Side by Side Diff: chrome/browser/command_line_pref_store_unittest.cc

Issue 3117017: Remove deprecated wstring Get(As)String() methods from Value, etc. (Closed)
Patch Set: fix win Created 10 years, 4 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <gtest/gtest.h> 5 #include <gtest/gtest.h>
6 6
7 #include "app/app_switches.h" 7 #include "app/app_switches.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "chrome/browser/command_line_pref_store.h" 11 #include "chrome/browser/command_line_pref_store.h"
12 #include "chrome/common/chrome_switches.h" 12 #include "chrome/common/chrome_switches.h"
13 #include "chrome/common/pref_names.h" 13 #include "chrome/common/pref_names.h"
14 14
15 namespace { 15 namespace {
16 16
17 class TestCommandLinePrefStore : public CommandLinePrefStore { 17 class TestCommandLinePrefStore : public CommandLinePrefStore {
18 public: 18 public:
19 explicit TestCommandLinePrefStore(CommandLine* cl) 19 explicit TestCommandLinePrefStore(CommandLine* cl)
20 : CommandLinePrefStore(cl) {} 20 : CommandLinePrefStore(cl) {}
21 21
22 bool ProxySwitchesAreValid() { 22 bool ProxySwitchesAreValid() {
23 return ValidateProxySwitches(); 23 return ValidateProxySwitches();
24 } 24 }
25 }; 25 };
26 26
27 static const wchar_t* unknown_bool = L"unknown_switch"; 27 const char unknown_bool[] = "unknown_switch";
28 static const wchar_t* unknown_string = L"unknown_other_switch"; 28 const char unknown_string[] = "unknown_other_switch";
29 29
30 } // namespace 30 } // namespace
31 31
32 // Tests a simple string pref on the command line. 32 // Tests a simple string pref on the command line.
33 TEST(CommandLinePrefStoreTest, SimpleStringPref) { 33 TEST(CommandLinePrefStoreTest, SimpleStringPref) {
34 CommandLine cl(CommandLine::ARGUMENTS_ONLY); 34 CommandLine cl(CommandLine::ARGUMENTS_ONLY);
35 cl.AppendSwitchASCII(switches::kLang, "hi-MOM"); 35 cl.AppendSwitchASCII(switches::kLang, "hi-MOM");
36 CommandLinePrefStore store(&cl); 36 CommandLinePrefStore store(&cl);
37 EXPECT_EQ(store.ReadPrefs(), PrefStore::PREF_READ_ERROR_NONE); 37 EXPECT_EQ(store.ReadPrefs(), PrefStore::PREF_READ_ERROR_NONE);
38 38
(...skipping 10 matching lines...) Expand all
49 EXPECT_EQ(store.ReadPrefs(), PrefStore::PREF_READ_ERROR_NONE); 49 EXPECT_EQ(store.ReadPrefs(), PrefStore::PREF_READ_ERROR_NONE);
50 50
51 bool result; 51 bool result;
52 EXPECT_TRUE(store.prefs()->GetBoolean(prefs::kNoProxyServer, &result)); 52 EXPECT_TRUE(store.prefs()->GetBoolean(prefs::kNoProxyServer, &result));
53 EXPECT_TRUE(result); 53 EXPECT_TRUE(result);
54 } 54 }
55 55
56 // Tests a command line with no recognized prefs. 56 // Tests a command line with no recognized prefs.
57 TEST(CommandLinePrefStoreTest, NoPrefs) { 57 TEST(CommandLinePrefStoreTest, NoPrefs) {
58 CommandLine cl(CommandLine::ARGUMENTS_ONLY); 58 CommandLine cl(CommandLine::ARGUMENTS_ONLY);
59 cl.AppendSwitch(WideToASCII(unknown_string)); 59 cl.AppendSwitch(unknown_string);
60 cl.AppendSwitchASCII(WideToASCII(unknown_bool), "a value"); 60 cl.AppendSwitchASCII(unknown_bool, "a value");
61 CommandLinePrefStore store(&cl); 61 CommandLinePrefStore store(&cl);
62 EXPECT_EQ(store.ReadPrefs(), PrefStore::PREF_READ_ERROR_NONE); 62 EXPECT_EQ(store.ReadPrefs(), PrefStore::PREF_READ_ERROR_NONE);
63 63
64 bool bool_result = false; 64 bool bool_result = false;
65 EXPECT_FALSE(store.prefs()->GetBoolean(unknown_bool, &bool_result)); 65 EXPECT_FALSE(store.prefs()->GetBoolean(unknown_bool, &bool_result));
66 EXPECT_FALSE(bool_result); 66 EXPECT_FALSE(bool_result);
67 67
68 std::string string_result = ""; 68 std::string string_result = "";
69 EXPECT_FALSE(store.prefs()->GetString(unknown_string, &string_result)); 69 EXPECT_FALSE(store.prefs()->GetString(unknown_string, &string_result));
70 EXPECT_EQ("", string_result); 70 EXPECT_EQ("", string_result);
71 } 71 }
72 72
73 // Tests a complex command line with multiple known and unknown switches. 73 // Tests a complex command line with multiple known and unknown switches.
74 TEST(CommandLinePrefStoreTest, MultipleSwitches) { 74 TEST(CommandLinePrefStoreTest, MultipleSwitches) {
75 CommandLine cl(CommandLine::ARGUMENTS_ONLY); 75 CommandLine cl(CommandLine::ARGUMENTS_ONLY);
76 cl.AppendSwitch(WideToASCII(unknown_string)); 76 cl.AppendSwitch(unknown_string);
77 cl.AppendSwitch(switches::kProxyAutoDetect); 77 cl.AppendSwitch(switches::kProxyAutoDetect);
78 cl.AppendSwitchASCII(switches::kProxyServer, "proxy"); 78 cl.AppendSwitchASCII(switches::kProxyServer, "proxy");
79 cl.AppendSwitchASCII(switches::kProxyBypassList, "list"); 79 cl.AppendSwitchASCII(switches::kProxyBypassList, "list");
80 cl.AppendSwitchASCII(WideToASCII(unknown_bool), "a value"); 80 cl.AppendSwitchASCII(unknown_bool, "a value");
81 CommandLinePrefStore store(&cl); 81 CommandLinePrefStore store(&cl);
82 EXPECT_EQ(store.ReadPrefs(), PrefStore::PREF_READ_ERROR_NONE); 82 EXPECT_EQ(store.ReadPrefs(), PrefStore::PREF_READ_ERROR_NONE);
83 83
84 bool bool_result = false; 84 bool bool_result = false;
85 EXPECT_FALSE(store.prefs()->GetBoolean(unknown_bool, &bool_result)); 85 EXPECT_FALSE(store.prefs()->GetBoolean(unknown_bool, &bool_result));
86 EXPECT_FALSE(bool_result); 86 EXPECT_FALSE(bool_result);
87 EXPECT_TRUE(store.prefs()->GetBoolean(prefs::kProxyAutoDetect, &bool_result)); 87 EXPECT_TRUE(store.prefs()->GetBoolean(prefs::kProxyAutoDetect, &bool_result));
88 EXPECT_TRUE(bool_result); 88 EXPECT_TRUE(bool_result);
89 89
90 std::string string_result = ""; 90 std::string string_result = "";
(...skipping 30 matching lines...) Expand all
121 // All proxy switches except no-proxy. 121 // All proxy switches except no-proxy.
122 CommandLine cl2(CommandLine::ARGUMENTS_ONLY); 122 CommandLine cl2(CommandLine::ARGUMENTS_ONLY);
123 cl2.AppendSwitch(switches::kProxyAutoDetect); 123 cl2.AppendSwitch(switches::kProxyAutoDetect);
124 cl2.AppendSwitchASCII(switches::kProxyServer, "server"); 124 cl2.AppendSwitchASCII(switches::kProxyServer, "server");
125 cl2.AppendSwitchASCII(switches::kProxyPacUrl, "url"); 125 cl2.AppendSwitchASCII(switches::kProxyPacUrl, "url");
126 cl2.AppendSwitchASCII(switches::kProxyBypassList, "list"); 126 cl2.AppendSwitchASCII(switches::kProxyBypassList, "list");
127 TestCommandLinePrefStore store4(&cl2); 127 TestCommandLinePrefStore store4(&cl2);
128 EXPECT_EQ(store4.ReadPrefs(), PrefStore::PREF_READ_ERROR_NONE); 128 EXPECT_EQ(store4.ReadPrefs(), PrefStore::PREF_READ_ERROR_NONE);
129 EXPECT_TRUE(store4.ProxySwitchesAreValid()); 129 EXPECT_TRUE(store4.ProxySwitchesAreValid());
130 } 130 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/search_provider.cc ('k') | chrome/browser/debugger/debugger_remote_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698