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

Side by Side Diff: chrome/browser/content_settings/content_settings_pref_provider_unittest.cc

Issue 11570009: Split PrefService into PrefService, PrefServiceSimple and PrefServiceSyncable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head again, previous had unrelated broken win_rel test. Created 7 years, 12 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 | 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/content_settings/content_settings_pref_provider.h" 5 #include "chrome/browser/content_settings/content_settings_pref_provider.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 } 126 }
127 127
128 // Test for regression in which the PrefProvider modified the user pref store 128 // Test for regression in which the PrefProvider modified the user pref store
129 // of the OTR unintentionally: http://crbug.com/74466. 129 // of the OTR unintentionally: http://crbug.com/74466.
130 TEST_F(PrefProviderTest, Incognito) { 130 TEST_F(PrefProviderTest, Incognito) {
131 PersistentPrefStore* user_prefs = new TestingPrefStore(); 131 PersistentPrefStore* user_prefs = new TestingPrefStore();
132 OverlayUserPrefStore* otr_user_prefs = 132 OverlayUserPrefStore* otr_user_prefs =
133 new OverlayUserPrefStore(user_prefs); 133 new OverlayUserPrefStore(user_prefs);
134 134
135 PrefServiceMockBuilder builder; 135 PrefServiceMockBuilder builder;
136 PrefService* regular_prefs = builder.WithUserPrefs(user_prefs).Create(); 136 builder.WithUserPrefs(user_prefs);
137 PrefServiceSyncable* regular_prefs = builder.CreateSyncable();
137 138
138 Profile::RegisterUserPrefs(regular_prefs); 139 Profile::RegisterUserPrefs(regular_prefs);
139 chrome::RegisterUserPrefs(regular_prefs); 140 chrome::RegisterUserPrefs(regular_prefs);
140 141
141 PrefService* otr_prefs = builder.WithUserPrefs(otr_user_prefs).Create(); 142 builder.WithUserPrefs(otr_user_prefs);
143 PrefServiceSyncable* otr_prefs = builder.CreateSyncable();
142 144
143 Profile::RegisterUserPrefs(otr_prefs); 145 Profile::RegisterUserPrefs(otr_prefs);
144 chrome::RegisterUserPrefs(otr_prefs); 146 chrome::RegisterUserPrefs(otr_prefs);
145 147
146 TestingProfile profile; 148 TestingProfile profile;
147 TestingProfile* otr_profile = new TestingProfile; 149 TestingProfile* otr_profile = new TestingProfile;
148 profile.SetOffTheRecordProfile(otr_profile); 150 profile.SetOffTheRecordProfile(otr_profile);
149 profile.SetPrefService(regular_prefs); 151 profile.SetPrefService(regular_prefs);
150 otr_profile->set_incognito(true); 152 otr_profile->set_incognito(true);
151 otr_profile->SetPrefService(otr_prefs); 153 otr_profile->SetPrefService(otr_prefs);
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 GetContentSetting( 326 GetContentSetting(
325 &pref_content_settings_provider, 327 &pref_content_settings_provider,
326 host, host, CONTENT_SETTINGS_TYPE_PLUGINS, 328 host, host, CONTENT_SETTINGS_TYPE_PLUGINS,
327 resource2, false)); 329 resource2, false));
328 330
329 pref_content_settings_provider.ShutdownOnUIThread(); 331 pref_content_settings_provider.ShutdownOnUIThread();
330 } 332 }
331 333
332 TEST_F(PrefProviderTest, AutoSubmitCertificateContentSetting) { 334 TEST_F(PrefProviderTest, AutoSubmitCertificateContentSetting) {
333 TestingProfile profile; 335 TestingProfile profile;
334 TestingPrefService* prefs = profile.GetTestingPrefService(); 336 TestingPrefServiceSyncable* prefs = profile.GetTestingPrefService();
335 GURL primary_url("https://www.example.com"); 337 GURL primary_url("https://www.example.com");
336 GURL secondary_url("https://www.sample.com"); 338 GURL secondary_url("https://www.sample.com");
337 339
338 PrefProvider provider(prefs, false); 340 PrefProvider provider(prefs, false);
339 341
340 EXPECT_EQ(CONTENT_SETTING_DEFAULT, 342 EXPECT_EQ(CONTENT_SETTING_DEFAULT,
341 GetContentSetting( 343 GetContentSetting(
342 &provider, 344 &provider,
343 primary_url, 345 primary_url,
344 primary_url, 346 primary_url,
(...skipping 13 matching lines...) Expand all
358 primary_url, 360 primary_url,
359 secondary_url, 361 secondary_url,
360 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, 362 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE,
361 std::string(), 363 std::string(),
362 false)); 364 false));
363 provider.ShutdownOnUIThread(); 365 provider.ShutdownOnUIThread();
364 } 366 }
365 367
366 // http://crosbug.com/17760 368 // http://crosbug.com/17760
367 TEST_F(PrefProviderTest, Deadlock) { 369 TEST_F(PrefProviderTest, Deadlock) {
368 TestingPrefService prefs; 370 TestingPrefServiceSyncable prefs;
369 PrefProvider::RegisterUserPrefs(&prefs); 371 PrefProvider::RegisterUserPrefs(&prefs);
370 372
371 // Chain of events: a preference changes, |PrefProvider| notices it, and reads 373 // Chain of events: a preference changes, |PrefProvider| notices it, and reads
372 // and writes the preference. When the preference is written, a notification 374 // and writes the preference. When the preference is written, a notification
373 // is sent, and this used to happen when |PrefProvider| was still holding its 375 // is sent, and this used to happen when |PrefProvider| was still holding its
374 // lock. 376 // lock.
375 377
376 PrefProvider provider(&prefs, false); 378 PrefProvider provider(&prefs, false);
377 DeadlockCheckerObserver observer(&prefs, &provider); 379 DeadlockCheckerObserver observer(&prefs, &provider);
378 { 380 {
379 DictionaryPrefUpdate update(&prefs, 381 DictionaryPrefUpdate update(&prefs,
380 prefs::kContentSettingsPatternPairs); 382 prefs::kContentSettingsPatternPairs);
381 DictionaryValue* mutable_settings = update.Get(); 383 DictionaryValue* mutable_settings = update.Get();
382 mutable_settings->SetWithoutPathExpansion("www.example.com,*", 384 mutable_settings->SetWithoutPathExpansion("www.example.com,*",
383 new base::DictionaryValue()); 385 new base::DictionaryValue());
384 } 386 }
385 EXPECT_TRUE(observer.notification_received()); 387 EXPECT_TRUE(observer.notification_received());
386 388
387 provider.ShutdownOnUIThread(); 389 provider.ShutdownOnUIThread();
388 } 390 }
389 391
390 } // namespace content_settings 392 } // namespace content_settings
OLDNEW
« no previous file with comments | « chrome/browser/content_settings/content_settings_pref_provider.cc ('k') | chrome/browser/content_settings/cookie_settings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698