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

Side by Side Diff: chrome/browser/net/ssl_config_service_manager_pref_unittest.cc

Issue 64193003: Clean up PrefServiceBuilder (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/net/ssl_config_service_manager.h" 5 #include "chrome/browser/net/ssl_config_service_manager.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/prefs/pref_registry_simple.h" 10 #include "base/prefs/pref_registry_simple.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 158
159 // Test that 159 // Test that
160 // * without command-line settings for minimum and maximum SSL versions, 160 // * without command-line settings for minimum and maximum SSL versions,
161 // SSL 3.0 ~ default_version_max() are enabled; 161 // SSL 3.0 ~ default_version_max() are enabled;
162 // * without --enable-unrestricted-ssl3-fallback, 162 // * without --enable-unrestricted-ssl3-fallback,
163 // |unrestricted_ssl3_fallback_enabled| is false. 163 // |unrestricted_ssl3_fallback_enabled| is false.
164 TEST_F(SSLConfigServiceManagerPrefTest, NoCommandLinePrefs) { 164 TEST_F(SSLConfigServiceManagerPrefTest, NoCommandLinePrefs) {
165 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore()); 165 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore());
166 166
167 PrefServiceMockBuilder builder; 167 PrefServiceMockBuilder builder;
168 builder.WithUserPrefs(local_state_store.get()); 168 builder.set_user_prefs(local_state_store);
169 scoped_refptr<PrefRegistrySimple> registry = new PrefRegistrySimple; 169 scoped_refptr<PrefRegistrySimple> registry = new PrefRegistrySimple;
170 scoped_ptr<PrefService> local_state(builder.Create(registry.get())); 170 scoped_ptr<PrefService> local_state(builder.Create(registry.get()));
171 171
172 SSLConfigServiceManager::RegisterPrefs(registry.get()); 172 SSLConfigServiceManager::RegisterPrefs(registry.get());
173 173
174 scoped_ptr<SSLConfigServiceManager> config_manager( 174 scoped_ptr<SSLConfigServiceManager> config_manager(
175 SSLConfigServiceManager::CreateDefaultManager(local_state.get())); 175 SSLConfigServiceManager::CreateDefaultManager(local_state.get()));
176 ASSERT_TRUE(config_manager.get()); 176 ASSERT_TRUE(config_manager.get());
177 scoped_refptr<SSLConfigService> config_service(config_manager->Get()); 177 scoped_refptr<SSLConfigService> config_service(config_manager->Get());
178 ASSERT_TRUE(config_service.get()); 178 ASSERT_TRUE(config_service.get());
(...skipping 30 matching lines...) Expand all
209 // respected and that they do not persist to the preferences files. 209 // respected and that they do not persist to the preferences files.
210 TEST_F(SSLConfigServiceManagerPrefTest, CommandLinePrefs) { 210 TEST_F(SSLConfigServiceManagerPrefTest, CommandLinePrefs) {
211 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore()); 211 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore());
212 212
213 CommandLine command_line(CommandLine::NO_PROGRAM); 213 CommandLine command_line(CommandLine::NO_PROGRAM);
214 command_line.AppendSwitchASCII(switches::kSSLVersionMin, "tls1"); 214 command_line.AppendSwitchASCII(switches::kSSLVersionMin, "tls1");
215 command_line.AppendSwitchASCII(switches::kSSLVersionMax, "ssl3"); 215 command_line.AppendSwitchASCII(switches::kSSLVersionMax, "ssl3");
216 command_line.AppendSwitch(switches::kEnableUnrestrictedSSL3Fallback); 216 command_line.AppendSwitch(switches::kEnableUnrestrictedSSL3Fallback);
217 217
218 PrefServiceMockBuilder builder; 218 PrefServiceMockBuilder builder;
219 builder.WithUserPrefs(local_state_store.get()); 219 builder.set_user_prefs(local_state_store);
220 builder.WithCommandLine(&command_line); 220 builder.SetCommandLine(&command_line);
221 scoped_refptr<PrefRegistrySimple> registry = new PrefRegistrySimple; 221 scoped_refptr<PrefRegistrySimple> registry = new PrefRegistrySimple;
222 scoped_ptr<PrefService> local_state(builder.Create(registry.get())); 222 scoped_ptr<PrefService> local_state(builder.Create(registry.get()));
223 223
224 SSLConfigServiceManager::RegisterPrefs(registry.get()); 224 SSLConfigServiceManager::RegisterPrefs(registry.get());
225 225
226 scoped_ptr<SSLConfigServiceManager> config_manager( 226 scoped_ptr<SSLConfigServiceManager> config_manager(
227 SSLConfigServiceManager::CreateDefaultManager(local_state.get())); 227 SSLConfigServiceManager::CreateDefaultManager(local_state.get()));
228 ASSERT_TRUE(config_manager.get()); 228 ASSERT_TRUE(config_manager.get());
229 scoped_refptr<SSLConfigService> config_service(config_manager->Get()); 229 scoped_refptr<SSLConfigService> config_service(config_manager->Get());
230 ASSERT_TRUE(config_service.get()); 230 ASSERT_TRUE(config_service.get());
(...skipping 22 matching lines...) Expand all
253 std::string version_max_str; 253 std::string version_max_str;
254 EXPECT_FALSE(local_state_store->GetString(prefs::kSSLVersionMin, 254 EXPECT_FALSE(local_state_store->GetString(prefs::kSSLVersionMin,
255 &version_min_str)); 255 &version_min_str));
256 EXPECT_FALSE(local_state_store->GetString(prefs::kSSLVersionMax, 256 EXPECT_FALSE(local_state_store->GetString(prefs::kSSLVersionMax,
257 &version_max_str)); 257 &version_max_str));
258 bool unrestricted_ssl3_fallback_enabled; 258 bool unrestricted_ssl3_fallback_enabled;
259 EXPECT_FALSE(local_state_store->GetBoolean( 259 EXPECT_FALSE(local_state_store->GetBoolean(
260 prefs::kEnableUnrestrictedSSL3Fallback, 260 prefs::kEnableUnrestrictedSSL3Fallback,
261 &unrestricted_ssl3_fallback_enabled)); 261 &unrestricted_ssl3_fallback_enabled));
262 } 262 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698