| 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 031a7c9cba96b8967ae6b24499f57bf5d4e84078..372ffbf46a5c7dd246200772ac065c075325247f 100644
|
| --- a/chrome/browser/prefs/command_line_pref_store_unittest.cc
|
| +++ b/chrome/browser/prefs/command_line_pref_store_unittest.cc
|
| @@ -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"
|
| @@ -33,11 +34,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);
|
| @@ -47,10 +48,11 @@ TEST(CommandLinePrefStoreTest, SimpleStringPref) {
|
| TEST(CommandLinePrefStoreTest, SimpleBooleanPref) {
|
| CommandLine cl(CommandLine::NO_PROGRAM);
|
| cl.AppendSwitch(switches::kNoProxyServer);
|
| - CommandLinePrefStore store(&cl);
|
| + scoped_refptr<CommandLinePrefStore> store = new CommandLinePrefStore(&cl);
|
|
|
| Value* actual = NULL;
|
| - ASSERT_EQ(PrefStore::READ_OK, store.GetValue(prefs::kNoProxyServer, &actual));
|
| + ASSERT_EQ(PrefStore::READ_OK, store->GetValue(prefs::kNoProxyServer,
|
| + &actual));
|
| bool result;
|
| EXPECT_TRUE(actual->GetAsBoolean(&result));
|
| EXPECT_TRUE(result);
|
| @@ -61,11 +63,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.
|
| @@ -76,23 +78,23 @@ TEST(CommandLinePrefStoreTest, MultipleSwitches) {
|
| cl.AppendSwitchASCII(switches::kProxyServer, "proxy");
|
| cl.AppendSwitchASCII(switches::kProxyBypassList, "list");
|
| 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_bool, &actual));
|
| ASSERT_EQ(PrefStore::READ_OK,
|
| - store.GetValue(prefs::kProxyAutoDetect, &actual));
|
| + store->GetValue(prefs::kProxyAutoDetect, &actual));
|
| bool bool_result = false;
|
| EXPECT_TRUE(actual->GetAsBoolean(&bool_result));
|
| EXPECT_TRUE(bool_result);
|
|
|
| - 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 +104,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,6 +126,7 @@ 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());
|
| }
|
|
|