Chromium Code Reviews| OLD | NEW | 
|---|---|
| 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 <string> | 5 #include <string> | 
| 6 | 6 | 
| 7 #include "app/test/data/resource.h" | 7 #include "app/test/data/resource.h" | 
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" | 
| 9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" | 
| 10 #include "base/values.h" | 10 #include "base/values.h" | 
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 // Make sure obs2 still works after removing obs. | 139 // Make sure obs2 still works after removing obs. | 
| 140 registrar.Remove(pref_name, &obs); | 140 registrar.Remove(pref_name, &obs); | 
| 141 EXPECT_CALL(obs, Observe(_, _, _)).Times(0); | 141 EXPECT_CALL(obs, Observe(_, _, _)).Times(0); | 
| 142 obs2.Expect(&prefs, pref_name, &expected_new_pref_value); | 142 obs2.Expect(&prefs, pref_name, &expected_new_pref_value); | 
| 143 // This should only fire the observer in obs2. | 143 // This should only fire the observer in obs2. | 
| 144 prefs.SetString(pref_name, new_pref_value); | 144 prefs.SetString(pref_name, new_pref_value); | 
| 145 Mock::VerifyAndClearExpectations(&obs); | 145 Mock::VerifyAndClearExpectations(&obs); | 
| 146 Mock::VerifyAndClearExpectations(&obs2); | 146 Mock::VerifyAndClearExpectations(&obs2); | 
| 147 } | 147 } | 
| 148 | 148 | 
| 149 #if 0 | |
| 
 
Paweł Hajdan Jr.
2010/12/07 17:30:00
Please DISABLE the test if needed. Otherwise bit r
 
Mattias Nissler (ping if slow)
2010/12/08 09:22:39
Actually, I intended to temporary disable them for
 
 | |
| 149 TEST(PrefServiceTest, ProxyFromCommandLineNotPolicy) { | 150 TEST(PrefServiceTest, ProxyFromCommandLineNotPolicy) { | 
| 
 
danno
2010/12/08 09:32:50
This test can be removed. It is covered by the Com
 
Mattias Nissler (ping if slow)
2010/12/09 10:20:20
Done.
 
 | |
| 150 CommandLine command_line(CommandLine::NO_PROGRAM); | 151 CommandLine command_line(CommandLine::NO_PROGRAM); | 
| 151 command_line.AppendSwitch(switches::kProxyAutoDetect); | 152 command_line.AppendSwitch(switches::kProxyAutoDetect); | 
| 152 TestingPrefService prefs(NULL, NULL, &command_line); | 153 PrefService prefs(NULL, NULL, &command_line); | 
| 153 browser::RegisterUserPrefs(&prefs); | 154 browser::RegisterUserPrefs(&prefs); | 
| 154 EXPECT_TRUE(prefs.GetBoolean(prefs::kProxyAutoDetect)); | 155 EXPECT_TRUE(prefs.GetBoolean(prefs::kProxyAutoDetect)); | 
| 155 const PrefService::Preference* pref = | 156 const PrefService::Preference* pref = | 
| 156 prefs.FindPreference(prefs::kProxyAutoDetect); | 157 prefs.FindPreference(prefs::kProxyAutoDetect); | 
| 157 ASSERT_TRUE(pref); | 158 ASSERT_TRUE(pref); | 
| 158 EXPECT_FALSE(pref->IsManaged()); | 159 EXPECT_FALSE(pref->IsManaged()); | 
| 159 } | 160 } | 
| 160 | 161 | 
| 161 TEST(PrefServiceTest, ProxyPolicyOverridesCommandLineOptions) { | 162 TEST(PrefServiceTest, ProxyPolicyOverridesCommandLineOptions) { | 
| 
 
danno
2010/12/08 09:32:50
This test shouldn't be removed, it should be re-wr
 
Mattias Nissler (ping if slow)
2010/12/09 10:20:20
Done.
 
 | |
| 162 CommandLine command_line(CommandLine::NO_PROGRAM); | 163 CommandLine command_line(CommandLine::NO_PROGRAM); | 
| 163 command_line.AppendSwitchASCII(switches::kProxyBypassList, "123"); | 164 command_line.AppendSwitchASCII(switches::kProxyBypassList, "123"); | 
| 164 command_line.AppendSwitchASCII(switches::kProxyPacUrl, "456"); | 165 command_line.AppendSwitchASCII(switches::kProxyPacUrl, "456"); | 
| 165 command_line.AppendSwitchASCII(switches::kProxyServer, "789"); | 166 command_line.AppendSwitchASCII(switches::kProxyServer, "789"); | 
| 166 scoped_ptr<policy::MockConfigurationPolicyProvider> provider( | 167 scoped_ptr<policy::MockConfigurationPolicyProvider> provider( | 
| 167 new policy::MockConfigurationPolicyProvider()); | 168 new policy::MockConfigurationPolicyProvider()); | 
| 168 Value* mode_value = Value::CreateIntegerValue( | 169 Value* mode_value = Value::CreateIntegerValue( | 
| 169 policy::kPolicyManuallyConfiguredProxyMode); | 170 policy::kPolicyManuallyConfiguredProxyMode); | 
| 170 provider->AddPolicy(policy::kPolicyProxyServerMode, mode_value); | 171 provider->AddPolicy(policy::kPolicyProxyServerMode, mode_value); | 
| 171 provider->AddPolicy(policy::kPolicyProxyBypassList, | 172 provider->AddPolicy(policy::kPolicyProxyBypassList, | 
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 285 // auto-detect should be overridden. The default pref store must be | 286 // auto-detect should be overridden. The default pref store must be | 
| 286 // in place with the appropriate default value for this to work. | 287 // in place with the appropriate default value for this to work. | 
| 287 TestingPrefService prefs2(provider.get(), NULL, &command_line); | 288 TestingPrefService prefs2(provider.get(), NULL, &command_line); | 
| 288 browser::RegisterUserPrefs(&prefs2); | 289 browser::RegisterUserPrefs(&prefs2); | 
| 289 EXPECT_FALSE(prefs2.GetBoolean(prefs::kProxyAutoDetect)); | 290 EXPECT_FALSE(prefs2.GetBoolean(prefs::kProxyAutoDetect)); | 
| 290 EXPECT_TRUE(prefs2.GetBoolean(prefs::kNoProxyServer)); | 291 EXPECT_TRUE(prefs2.GetBoolean(prefs::kNoProxyServer)); | 
| 291 EXPECT_EQ(std::string(), prefs2.GetString(prefs::kProxyServer)); | 292 EXPECT_EQ(std::string(), prefs2.GetString(prefs::kProxyServer)); | 
| 292 EXPECT_EQ(std::string(), prefs2.GetString(prefs::kProxyPacUrl)); | 293 EXPECT_EQ(std::string(), prefs2.GetString(prefs::kProxyPacUrl)); | 
| 293 EXPECT_EQ(std::string(), prefs2.GetString(prefs::kProxyBypassList)); | 294 EXPECT_EQ(std::string(), prefs2.GetString(prefs::kProxyBypassList)); | 
| 294 } | 295 } | 
| 296 #endif | |
| 295 | 297 | 
| 296 class PrefServiceSetValueTest : public testing::Test { | 298 class PrefServiceSetValueTest : public testing::Test { | 
| 297 protected: | 299 protected: | 
| 298 static const char kName[]; | 300 static const char kName[]; | 
| 299 static const char kValue[]; | 301 static const char kValue[]; | 
| 300 | 302 | 
| 301 PrefServiceSetValueTest() | 303 PrefServiceSetValueTest() | 
| 302 : null_value_(Value::CreateNullValue()) {} | 304 : null_value_(Value::CreateNullValue()) {} | 
| 303 | 305 | 
| 304 TestingPrefService prefs_; | 306 TestingPrefService prefs_; | 
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 379 Mock::VerifyAndClearExpectations(&observer_); | 381 Mock::VerifyAndClearExpectations(&observer_); | 
| 380 | 382 | 
| 381 EXPECT_CALL(observer_, Observe(_, _, _)).Times(0); | 383 EXPECT_CALL(observer_, Observe(_, _, _)).Times(0); | 
| 382 prefs_.Set(kName, new_value); | 384 prefs_.Set(kName, new_value); | 
| 383 Mock::VerifyAndClearExpectations(&observer_); | 385 Mock::VerifyAndClearExpectations(&observer_); | 
| 384 | 386 | 
| 385 observer_.Expect(&prefs_, kName, null_value_.get()); | 387 observer_.Expect(&prefs_, kName, null_value_.get()); | 
| 386 prefs_.Set(kName, *null_value_); | 388 prefs_.Set(kName, *null_value_); | 
| 387 Mock::VerifyAndClearExpectations(&observer_); | 389 Mock::VerifyAndClearExpectations(&observer_); | 
| 388 } | 390 } | 
| OLD | NEW |