Index: chrome/browser/prefs/command_line_pref_store_unittest.cc |
diff --git a/chrome/browser/prefs/command_line_pref_store_unittest.cc b/chrome/browser/prefs/command_line_pref_store_unittest.cc |
index 790f52b3bf0538378d8d87b8301b38d727614348..2518ff9595377056f2e101e64f7fc0aadb6f3ba1 100644 |
--- a/chrome/browser/prefs/command_line_pref_store_unittest.cc |
+++ b/chrome/browser/prefs/command_line_pref_store_unittest.cc |
@@ -1,4 +1,4 @@ |
-// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
@@ -6,6 +6,7 @@ |
#include "app/app_switches.h" |
#include "base/command_line.h" |
+#include "base/ref_counted.h" |
#include "base/string_util.h" |
#include "base/values.h" |
#include "chrome/browser/prefs/command_line_pref_store.h" |
@@ -41,11 +42,11 @@ const char unknown_string[] = "unknown_other_switch"; |
TEST(CommandLinePrefStoreTest, SimpleStringPref) { |
CommandLine cl(CommandLine::NO_PROGRAM); |
cl.AppendSwitchASCII(switches::kLang, "hi-MOM"); |
- CommandLinePrefStore store(&cl); |
+ scoped_refptr<CommandLinePrefStore> store = new CommandLinePrefStore(&cl); |
Value* actual = NULL; |
EXPECT_EQ(PrefStore::READ_OK, |
- store.GetValue(prefs::kApplicationLocale, &actual)); |
+ store->GetValue(prefs::kApplicationLocale, &actual)); |
std::string result; |
EXPECT_TRUE(actual->GetAsString(&result)); |
EXPECT_EQ("hi-MOM", result); |
@@ -55,9 +56,10 @@ TEST(CommandLinePrefStoreTest, SimpleStringPref) { |
TEST(CommandLinePrefStoreTest, SimpleBooleanPref) { |
CommandLine cl(CommandLine::NO_PROGRAM); |
cl.AppendSwitch(switches::kNoProxyServer); |
- TestCommandLinePrefStore store(&cl); |
+ scoped_refptr<TestCommandLinePrefStore> store = |
+ new TestCommandLinePrefStore(&cl); |
- store.VerifyIntPref(prefs::kProxyMode, ProxyPrefs::MODE_DIRECT); |
+ store->VerifyIntPref(prefs::kProxyMode, ProxyPrefs::MODE_DIRECT); |
} |
// Tests a command line with no recognized prefs. |
@@ -65,11 +67,11 @@ TEST(CommandLinePrefStoreTest, NoPrefs) { |
CommandLine cl(CommandLine::NO_PROGRAM); |
cl.AppendSwitch(unknown_string); |
cl.AppendSwitchASCII(unknown_bool, "a value"); |
- CommandLinePrefStore store(&cl); |
+ scoped_refptr<CommandLinePrefStore> store = new CommandLinePrefStore(&cl); |
Value* actual = NULL; |
- EXPECT_EQ(PrefStore::READ_NO_VALUE, store.GetValue(unknown_bool, &actual)); |
- EXPECT_EQ(PrefStore::READ_NO_VALUE, store.GetValue(unknown_string, &actual)); |
+ EXPECT_EQ(PrefStore::READ_NO_VALUE, store->GetValue(unknown_bool, &actual)); |
+ EXPECT_EQ(PrefStore::READ_NO_VALUE, store->GetValue(unknown_string, &actual)); |
} |
// Tests a complex command line with multiple known and unknown switches. |
@@ -80,19 +82,20 @@ TEST(CommandLinePrefStoreTest, MultipleSwitches) { |
cl.AppendSwitchASCII(switches::kProxyServer, "proxy"); |
cl.AppendSwitchASCII(switches::kProxyBypassList, "list"); |
cl.AppendSwitchASCII(unknown_bool, "a value"); |
- TestCommandLinePrefStore store(&cl); |
+ scoped_refptr<TestCommandLinePrefStore> store = |
+ new TestCommandLinePrefStore(&cl); |
Value* actual = NULL; |
- EXPECT_EQ(PrefStore::READ_NO_VALUE, store.GetValue(unknown_bool, &actual)); |
- store.VerifyIntPref(prefs::kProxyMode, ProxyPrefs::MODE_AUTO_DETECT); |
+ EXPECT_EQ(PrefStore::READ_NO_VALUE, store->GetValue(unknown_bool, &actual)); |
+ store->VerifyIntPref(prefs::kProxyMode, ProxyPrefs::MODE_AUTO_DETECT); |
- EXPECT_EQ(PrefStore::READ_NO_VALUE, store.GetValue(unknown_string, &actual)); |
+ EXPECT_EQ(PrefStore::READ_NO_VALUE, store->GetValue(unknown_string, &actual)); |
std::string string_result = ""; |
- ASSERT_EQ(PrefStore::READ_OK, store.GetValue(prefs::kProxyServer, &actual)); |
+ ASSERT_EQ(PrefStore::READ_OK, store->GetValue(prefs::kProxyServer, &actual)); |
EXPECT_TRUE(actual->GetAsString(&string_result)); |
EXPECT_EQ("proxy", string_result); |
ASSERT_EQ(PrefStore::READ_OK, |
- store.GetValue(prefs::kProxyBypassList, &actual)); |
+ store->GetValue(prefs::kProxyBypassList, &actual)); |
EXPECT_TRUE(actual->GetAsString(&string_result)); |
EXPECT_EQ("list", string_result); |
} |
@@ -102,18 +105,21 @@ TEST(CommandLinePrefStoreTest, ProxySwitchValidation) { |
CommandLine cl(CommandLine::NO_PROGRAM); |
// No switches. |
- TestCommandLinePrefStore store(&cl); |
- EXPECT_TRUE(store.ProxySwitchesAreValid()); |
+ scoped_refptr<TestCommandLinePrefStore> store = |
+ new TestCommandLinePrefStore(&cl); |
+ EXPECT_TRUE(store->ProxySwitchesAreValid()); |
// Only no-proxy. |
cl.AppendSwitch(switches::kNoProxyServer); |
- TestCommandLinePrefStore store2(&cl); |
- EXPECT_TRUE(store2.ProxySwitchesAreValid()); |
+ scoped_refptr<TestCommandLinePrefStore> store2 = |
+ new TestCommandLinePrefStore(&cl); |
+ EXPECT_TRUE(store2->ProxySwitchesAreValid()); |
// Another proxy switch too. |
cl.AppendSwitch(switches::kProxyAutoDetect); |
- TestCommandLinePrefStore store3(&cl); |
- EXPECT_FALSE(store3.ProxySwitchesAreValid()); |
+ scoped_refptr<TestCommandLinePrefStore> store3 = |
+ new TestCommandLinePrefStore(&cl); |
+ EXPECT_FALSE(store3->ProxySwitchesAreValid()); |
// All proxy switches except no-proxy. |
CommandLine cl2(CommandLine::NO_PROGRAM); |
@@ -121,19 +127,22 @@ TEST(CommandLinePrefStoreTest, ProxySwitchValidation) { |
cl2.AppendSwitchASCII(switches::kProxyServer, "server"); |
cl2.AppendSwitchASCII(switches::kProxyPacUrl, "url"); |
cl2.AppendSwitchASCII(switches::kProxyBypassList, "list"); |
- TestCommandLinePrefStore store4(&cl2); |
- EXPECT_TRUE(store4.ProxySwitchesAreValid()); |
+ scoped_refptr<TestCommandLinePrefStore> store4 = |
+ new TestCommandLinePrefStore(&cl2); |
+ EXPECT_TRUE(store4->ProxySwitchesAreValid()); |
} |
TEST(CommandLinePrefStoreTest, ManualProxyModeInference) { |
CommandLine cl1(CommandLine::NO_PROGRAM); |
cl1.AppendSwitch(unknown_string); |
cl1.AppendSwitchASCII(switches::kProxyServer, "proxy"); |
- TestCommandLinePrefStore store1(&cl1); |
- store1.VerifyIntPref(prefs::kProxyMode, ProxyPrefs::MODE_FIXED_SERVERS); |
+ scoped_refptr<TestCommandLinePrefStore> store1 = |
+ new TestCommandLinePrefStore(&cl1); |
+ store1->VerifyIntPref(prefs::kProxyMode, ProxyPrefs::MODE_FIXED_SERVERS); |
CommandLine cl2(CommandLine::NO_PROGRAM); |
cl2.AppendSwitchASCII(switches::kProxyPacUrl, "proxy"); |
- TestCommandLinePrefStore store2(&cl2); |
- store2.VerifyIntPref(prefs::kProxyMode, ProxyPrefs::MODE_PAC_SCRIPT); |
+ scoped_refptr<TestCommandLinePrefStore> store2 = |
+ new TestCommandLinePrefStore(&cl2); |
+ store2->VerifyIntPref(prefs::kProxyMode, ProxyPrefs::MODE_PAC_SCRIPT); |
} |