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

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

Issue 1086733002: Ensure tests have an active task runner (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 7 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
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 "components/content_settings/core/browser/content_settings_pref_provide r.h" 5 #include "components/content_settings/core/browser/content_settings_pref_provide r.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/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 13 matching lines...) Expand all
24 #include "chrome/common/chrome_switches.h" 24 #include "chrome/common/chrome_switches.h"
25 #include "chrome/common/pref_names.h" 25 #include "chrome/common/pref_names.h"
26 #include "chrome/common/url_constants.h" 26 #include "chrome/common/url_constants.h"
27 #include "chrome/test/base/testing_pref_service_syncable.h" 27 #include "chrome/test/base/testing_pref_service_syncable.h"
28 #include "chrome/test/base/testing_profile.h" 28 #include "chrome/test/base/testing_profile.h"
29 #include "components/content_settings/core/browser/content_settings_pref.h" 29 #include "components/content_settings/core/browser/content_settings_pref.h"
30 #include "components/content_settings/core/browser/content_settings_rule.h" 30 #include "components/content_settings/core/browser/content_settings_rule.h"
31 #include "components/content_settings/core/browser/content_settings_utils.h" 31 #include "components/content_settings/core/browser/content_settings_utils.h"
32 #include "components/content_settings/core/test/content_settings_test_utils.h" 32 #include "components/content_settings/core/test/content_settings_test_utils.h"
33 #include "components/pref_registry/pref_registry_syncable.h" 33 #include "components/pref_registry/pref_registry_syncable.h"
34 #include "content/public/test/test_browser_thread_bundle.h"
34 #include "testing/gtest/include/gtest/gtest.h" 35 #include "testing/gtest/include/gtest/gtest.h"
35 #include "url/gurl.h" 36 #include "url/gurl.h"
36 37
37 using ::testing::_; 38 using ::testing::_;
38 39
39 namespace content_settings { 40 namespace content_settings {
40 41
41 class DeadlockCheckerThread : public base::PlatformThread::Delegate { 42 class DeadlockCheckerThread : public base::PlatformThread::Delegate {
42 public: 43 public:
43 explicit DeadlockCheckerThread(PrefProvider* provider) 44 explicit DeadlockCheckerThread(PrefProvider* provider)
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 base::PlatformThread::Join(handle); 84 base::PlatformThread::Join(handle);
84 notification_received_ = true; 85 notification_received_ = true;
85 } 86 }
86 87
87 PrefProvider* provider_; 88 PrefProvider* provider_;
88 PrefChangeRegistrar pref_change_registrar_; 89 PrefChangeRegistrar pref_change_registrar_;
89 bool notification_received_; 90 bool notification_received_;
90 DISALLOW_COPY_AND_ASSIGN(DeadlockCheckerObserver); 91 DISALLOW_COPY_AND_ASSIGN(DeadlockCheckerObserver);
91 }; 92 };
92 93
93 TEST(PrefProviderTest, Observer) { 94 class PrefProviderTest : public testing::Test {
95 content::TestBrowserThreadBundle thread_bundle_;
96 };
97
98 TEST_F(PrefProviderTest, Observer) {
94 TestingProfile profile; 99 TestingProfile profile;
95 PrefProvider pref_content_settings_provider(profile.GetPrefs(), false); 100 PrefProvider pref_content_settings_provider(profile.GetPrefs(), false);
96 101
97 ContentSettingsPattern pattern = 102 ContentSettingsPattern pattern =
98 ContentSettingsPattern::FromString("[*.]example.com"); 103 ContentSettingsPattern::FromString("[*.]example.com");
99 content_settings::MockObserver mock_observer; 104 content_settings::MockObserver mock_observer;
100 EXPECT_CALL(mock_observer, 105 EXPECT_CALL(mock_observer,
101 OnContentSettingChanged(pattern, 106 OnContentSettingChanged(pattern,
102 ContentSettingsPattern::Wildcard(), 107 ContentSettingsPattern::Wildcard(),
103 CONTENT_SETTINGS_TYPE_IMAGES, 108 CONTENT_SETTINGS_TYPE_IMAGES,
104 "")); 109 ""));
105 110
106 pref_content_settings_provider.AddObserver(&mock_observer); 111 pref_content_settings_provider.AddObserver(&mock_observer);
107 112
108 pref_content_settings_provider.SetWebsiteSetting( 113 pref_content_settings_provider.SetWebsiteSetting(
109 pattern, 114 pattern,
110 ContentSettingsPattern::Wildcard(), 115 ContentSettingsPattern::Wildcard(),
111 CONTENT_SETTINGS_TYPE_IMAGES, 116 CONTENT_SETTINGS_TYPE_IMAGES,
112 std::string(), 117 std::string(),
113 new base::FundamentalValue(CONTENT_SETTING_ALLOW)); 118 new base::FundamentalValue(CONTENT_SETTING_ALLOW));
114 119
115 pref_content_settings_provider.ShutdownOnUIThread(); 120 pref_content_settings_provider.ShutdownOnUIThread();
116 } 121 }
117 122
118 // Test for regression in which the PrefProvider modified the user pref store 123 // Test for regression in which the PrefProvider modified the user pref store
119 // of the OTR unintentionally: http://crbug.com/74466. 124 // of the OTR unintentionally: http://crbug.com/74466.
120 TEST(PrefProviderTest, Incognito) { 125 TEST_F(PrefProviderTest, Incognito) {
121 PersistentPrefStore* user_prefs = new TestingPrefStore(); 126 PersistentPrefStore* user_prefs = new TestingPrefStore();
122 OverlayUserPrefStore* otr_user_prefs = 127 OverlayUserPrefStore* otr_user_prefs =
123 new OverlayUserPrefStore(user_prefs); 128 new OverlayUserPrefStore(user_prefs);
124 129
125 PrefServiceMockFactory factory; 130 PrefServiceMockFactory factory;
126 factory.set_user_prefs(make_scoped_refptr(user_prefs)); 131 factory.set_user_prefs(make_scoped_refptr(user_prefs));
127 scoped_refptr<user_prefs::PrefRegistrySyncable> registry( 132 scoped_refptr<user_prefs::PrefRegistrySyncable> registry(
128 new user_prefs::PrefRegistrySyncable); 133 new user_prefs::PrefRegistrySyncable);
129 PrefServiceSyncable* regular_prefs = 134 PrefServiceSyncable* regular_prefs =
130 factory.CreateSyncable(registry.get()).release(); 135 factory.CreateSyncable(registry.get()).release();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 std::string(), 182 std::string(),
178 false)); 183 false));
179 // But the value should not be overridden in the OTR user prefs accidentally. 184 // But the value should not be overridden in the OTR user prefs accidentally.
180 EXPECT_FALSE(otr_user_prefs->IsSetInOverlay( 185 EXPECT_FALSE(otr_user_prefs->IsSetInOverlay(
181 prefs::kContentSettingsPatternPairs)); 186 prefs::kContentSettingsPatternPairs));
182 187
183 pref_content_settings_provider.ShutdownOnUIThread(); 188 pref_content_settings_provider.ShutdownOnUIThread();
184 pref_content_settings_provider_incognito.ShutdownOnUIThread(); 189 pref_content_settings_provider_incognito.ShutdownOnUIThread();
185 } 190 }
186 191
187 TEST(PrefProviderTest, GetContentSettingsValue) { 192 TEST_F(PrefProviderTest, GetContentSettingsValue) {
188 TestingProfile testing_profile; 193 TestingProfile testing_profile;
189 PrefProvider provider(testing_profile.GetPrefs(), false); 194 PrefProvider provider(testing_profile.GetPrefs(), false);
190 195
191 GURL primary_url("http://example.com/"); 196 GURL primary_url("http://example.com/");
192 ContentSettingsPattern primary_pattern = 197 ContentSettingsPattern primary_pattern =
193 ContentSettingsPattern::FromString("[*.]example.com"); 198 ContentSettingsPattern::FromString("[*.]example.com");
194 199
195 EXPECT_EQ(CONTENT_SETTING_DEFAULT, 200 EXPECT_EQ(CONTENT_SETTING_DEFAULT,
196 GetContentSetting(&provider, 201 GetContentSetting(&provider,
197 primary_url, 202 primary_url,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 EXPECT_EQ(NULL, 244 EXPECT_EQ(NULL,
240 GetContentSettingValue(&provider, 245 GetContentSettingValue(&provider,
241 primary_url, 246 primary_url,
242 primary_url, 247 primary_url,
243 CONTENT_SETTINGS_TYPE_IMAGES, 248 CONTENT_SETTINGS_TYPE_IMAGES,
244 std::string(), 249 std::string(),
245 false)); 250 false));
246 provider.ShutdownOnUIThread(); 251 provider.ShutdownOnUIThread();
247 } 252 }
248 253
249 TEST(PrefProviderTest, Patterns) { 254 TEST_F(PrefProviderTest, Patterns) {
250 TestingProfile testing_profile; 255 TestingProfile testing_profile;
251 PrefProvider pref_content_settings_provider(testing_profile.GetPrefs(), 256 PrefProvider pref_content_settings_provider(testing_profile.GetPrefs(),
252 false); 257 false);
253 258
254 GURL host1("http://example.com/"); 259 GURL host1("http://example.com/");
255 GURL host2("http://www.example.com/"); 260 GURL host2("http://www.example.com/");
256 GURL host3("http://example.org/"); 261 GURL host3("http://example.org/");
257 GURL host4("file:///tmp/test.html"); 262 GURL host4("file:///tmp/test.html");
258 ContentSettingsPattern pattern1 = 263 ContentSettingsPattern pattern1 =
259 ContentSettingsPattern::FromString("[*.]example.com"); 264 ContentSettingsPattern::FromString("[*.]example.com");
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 GetContentSetting(&pref_content_settings_provider, 333 GetContentSetting(&pref_content_settings_provider,
329 host4, 334 host4,
330 host4, 335 host4,
331 CONTENT_SETTINGS_TYPE_IMAGES, 336 CONTENT_SETTINGS_TYPE_IMAGES,
332 std::string(), 337 std::string(),
333 false)); 338 false));
334 339
335 pref_content_settings_provider.ShutdownOnUIThread(); 340 pref_content_settings_provider.ShutdownOnUIThread();
336 } 341 }
337 342
338 TEST(PrefProviderTest, ResourceIdentifier) { 343 TEST_F(PrefProviderTest, ResourceIdentifier) {
339 TestingProfile testing_profile; 344 TestingProfile testing_profile;
340 PrefProvider pref_content_settings_provider(testing_profile.GetPrefs(), 345 PrefProvider pref_content_settings_provider(testing_profile.GetPrefs(),
341 false); 346 false);
342 347
343 GURL host("http://example.com/"); 348 GURL host("http://example.com/");
344 ContentSettingsPattern pattern = 349 ContentSettingsPattern pattern =
345 ContentSettingsPattern::FromString("[*.]example.com"); 350 ContentSettingsPattern::FromString("[*.]example.com");
346 std::string resource1("someplugin"); 351 std::string resource1("someplugin");
347 std::string resource2("otherplugin"); 352 std::string resource2("otherplugin");
348 353
(...skipping 15 matching lines...) Expand all
364 resource1, false)); 369 resource1, false));
365 EXPECT_EQ(CONTENT_SETTING_DEFAULT, 370 EXPECT_EQ(CONTENT_SETTING_DEFAULT,
366 GetContentSetting( 371 GetContentSetting(
367 &pref_content_settings_provider, 372 &pref_content_settings_provider,
368 host, host, CONTENT_SETTINGS_TYPE_PLUGINS, 373 host, host, CONTENT_SETTINGS_TYPE_PLUGINS,
369 resource2, false)); 374 resource2, false));
370 375
371 pref_content_settings_provider.ShutdownOnUIThread(); 376 pref_content_settings_provider.ShutdownOnUIThread();
372 } 377 }
373 378
374 TEST(PrefProviderTest, AutoSubmitCertificateContentSetting) { 379 TEST_F(PrefProviderTest, AutoSubmitCertificateContentSetting) {
375 TestingProfile profile; 380 TestingProfile profile;
376 TestingPrefServiceSyncable* prefs = profile.GetTestingPrefService(); 381 TestingPrefServiceSyncable* prefs = profile.GetTestingPrefService();
377 GURL primary_url("https://www.example.com"); 382 GURL primary_url("https://www.example.com");
378 GURL secondary_url("https://www.sample.com"); 383 GURL secondary_url("https://www.sample.com");
379 384
380 PrefProvider provider(prefs, false); 385 PrefProvider provider(prefs, false);
381 386
382 EXPECT_EQ(CONTENT_SETTING_DEFAULT, 387 EXPECT_EQ(CONTENT_SETTING_DEFAULT,
383 GetContentSetting( 388 GetContentSetting(
384 &provider, 389 &provider,
(...skipping 13 matching lines...) Expand all
398 &provider, 403 &provider,
399 primary_url, 404 primary_url,
400 secondary_url, 405 secondary_url,
401 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, 406 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE,
402 std::string(), 407 std::string(),
403 false)); 408 false));
404 provider.ShutdownOnUIThread(); 409 provider.ShutdownOnUIThread();
405 } 410 }
406 411
407 // http://crosbug.com/17760 412 // http://crosbug.com/17760
408 TEST(PrefProviderTest, Deadlock) { 413 TEST_F(PrefProviderTest, Deadlock) {
409 TestingPrefServiceSyncable prefs; 414 TestingPrefServiceSyncable prefs;
410 PrefProvider::RegisterProfilePrefs(prefs.registry()); 415 PrefProvider::RegisterProfilePrefs(prefs.registry());
411 416
412 // Chain of events: a preference changes, |PrefProvider| notices it, and reads 417 // Chain of events: a preference changes, |PrefProvider| notices it, and reads
413 // and writes the preference. When the preference is written, a notification 418 // and writes the preference. When the preference is written, a notification
414 // is sent, and this used to happen when |PrefProvider| was still holding its 419 // is sent, and this used to happen when |PrefProvider| was still holding its
415 // lock. 420 // lock.
416 421
417 PrefProvider provider(&prefs, false); 422 PrefProvider provider(&prefs, false);
418 DeadlockCheckerObserver observer(&prefs, &provider); 423 DeadlockCheckerObserver observer(&prefs, &provider);
419 { 424 {
420 DictionaryPrefUpdate update(&prefs, 425 DictionaryPrefUpdate update(&prefs,
421 prefs::kContentSettingsPatternPairs); 426 prefs::kContentSettingsPatternPairs);
422 base::DictionaryValue* mutable_settings = update.Get(); 427 base::DictionaryValue* mutable_settings = update.Get();
423 mutable_settings->SetWithoutPathExpansion("www.example.com,*", 428 mutable_settings->SetWithoutPathExpansion("www.example.com,*",
424 new base::DictionaryValue()); 429 new base::DictionaryValue());
425 } 430 }
426 EXPECT_TRUE(observer.notification_received()); 431 EXPECT_TRUE(observer.notification_received());
427 432
428 provider.ShutdownOnUIThread(); 433 provider.ShutdownOnUIThread();
429 } 434 }
430 435
431 TEST(PrefProviderTest, LastUsage) { 436 TEST_F(PrefProviderTest, LastUsage) {
432 TestingProfile testing_profile; 437 TestingProfile testing_profile;
433 PrefProvider pref_content_settings_provider(testing_profile.GetPrefs(), 438 PrefProvider pref_content_settings_provider(testing_profile.GetPrefs(),
434 false); 439 false);
435 base::SimpleTestClock* test_clock = new base::SimpleTestClock; 440 base::SimpleTestClock* test_clock = new base::SimpleTestClock;
436 test_clock->SetNow(base::Time::Now()); 441 test_clock->SetNow(base::Time::Now());
437 442
438 pref_content_settings_provider.SetClockForTesting( 443 pref_content_settings_provider.SetClockForTesting(
439 scoped_ptr<base::Clock>(test_clock)); 444 scoped_ptr<base::Clock>(test_clock));
440 GURL host("http://example.com/"); 445 GURL host("http://example.com/");
441 ContentSettingsPattern pattern = 446 ContentSettingsPattern pattern =
(...skipping 19 matching lines...) Expand all
461 EXPECT_EQ(delta.InSeconds(), 10); 466 EXPECT_EQ(delta.InSeconds(), 10);
462 467
463 pref_content_settings_provider.ShutdownOnUIThread(); 468 pref_content_settings_provider.ShutdownOnUIThread();
464 } 469 }
465 470
466 471
467 // TODO(msramek): This tests the correct migration behavior between the old 472 // TODO(msramek): This tests the correct migration behavior between the old
468 // aggregate dictionary preferences for all content settings types and the new 473 // aggregate dictionary preferences for all content settings types and the new
469 // dictionary preferences for individual types. Remove this when the migration 474 // dictionary preferences for individual types. Remove this when the migration
470 // period is over. 475 // period is over.
471 TEST(PrefProviderTest, SyncingOldToNew) { 476 TEST_F(PrefProviderTest, SyncingOldToNew) {
472 TestingPrefServiceSyncable prefs; 477 TestingPrefServiceSyncable prefs;
473 PrefProvider::RegisterProfilePrefs(prefs.registry()); 478 PrefProvider::RegisterProfilePrefs(prefs.registry());
474 PrefProvider provider(&prefs, false); 479 PrefProvider provider(&prefs, false);
475 480
476 const std::string pattern = "google.com,*"; 481 const std::string pattern = "google.com,*";
477 const std::string resource_id = "abcde12345"; 482 const std::string resource_id = "abcde12345";
478 base::DictionaryValue* exceptions = new base::DictionaryValue(); 483 base::DictionaryValue* exceptions = new base::DictionaryValue();
479 base::DictionaryValue* plugin_resources = new base::DictionaryValue(); 484 base::DictionaryValue* plugin_resources = new base::DictionaryValue();
480 485
481 // Add exceptions for images and app banner. 486 // Add exceptions for images and app banner.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 EXPECT_TRUE(plugins_exception->GetDictionaryWithoutPathExpansion( 552 EXPECT_TRUE(plugins_exception->GetDictionaryWithoutPathExpansion(
548 "per_resource", &resource_exception)); 553 "per_resource", &resource_exception));
549 EXPECT_TRUE(resource_exception->GetIntegerWithoutPathExpansion( 554 EXPECT_TRUE(resource_exception->GetIntegerWithoutPathExpansion(
550 resource_id, &resource_exception_value)); 555 resource_id, &resource_exception_value));
551 EXPECT_EQ(CONTENT_SETTING_BLOCK, resource_exception_value); 556 EXPECT_EQ(CONTENT_SETTING_BLOCK, resource_exception_value);
552 } 557 }
553 558
554 provider.ShutdownOnUIThread(); 559 provider.ShutdownOnUIThread();
555 } 560 }
556 561
557 TEST(PrefProviderTest, SyncingNewToOld) { 562 TEST_F(PrefProviderTest, SyncingNewToOld) {
558 TestingPrefServiceSyncable prefs; 563 TestingPrefServiceSyncable prefs;
559 PrefProvider::RegisterProfilePrefs(prefs.registry()); 564 PrefProvider::RegisterProfilePrefs(prefs.registry());
560 PrefProvider provider(&prefs, false); 565 PrefProvider provider(&prefs, false);
561 566
562 const std::string pattern = "google.com,*"; 567 const std::string pattern = "google.com,*";
563 const std::string resource_id = "abcde12345"; 568 const std::string resource_id = "abcde12345";
564 base::DictionaryValue block_exception; 569 base::DictionaryValue block_exception;
565 block_exception.SetIntegerWithoutPathExpansion( 570 block_exception.SetIntegerWithoutPathExpansion(
566 "setting", CONTENT_SETTING_BLOCK); 571 "setting", CONTENT_SETTING_BLOCK);
567 572
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 "per_plugin", &resource_values); 641 "per_plugin", &resource_values);
637 resource_values->GetIntegerWithoutPathExpansion( 642 resource_values->GetIntegerWithoutPathExpansion(
638 resource_id, &resource_exception_value); 643 resource_id, &resource_exception_value);
639 DCHECK_EQ(CONTENT_SETTING_ALLOW, resource_exception_value); 644 DCHECK_EQ(CONTENT_SETTING_ALLOW, resource_exception_value);
640 } 645 }
641 646
642 provider.ShutdownOnUIThread(); 647 provider.ShutdownOnUIThread();
643 } 648 }
644 649
645 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) 650 #if defined(OS_CHROMEOS) || defined(OS_ANDROID)
646 TEST(PrefProviderTest, PMIMigrateOnlyAllow) { 651 TEST_F(PrefProviderTest, PMIMigrateOnlyAllow) {
647 TestingPrefServiceSyncable prefs; 652 TestingPrefServiceSyncable prefs;
648 PrefProvider::RegisterProfilePrefs(prefs.registry()); 653 PrefProvider::RegisterProfilePrefs(prefs.registry());
649 654
650 const std::string pattern_1 = "google.com,*"; 655 const std::string pattern_1 = "google.com,*";
651 const std::string pattern_2 = "www.google.com,*"; 656 const std::string pattern_2 = "www.google.com,*";
652 base::DictionaryValue* exception_1 = new base::DictionaryValue(); 657 base::DictionaryValue* exception_1 = new base::DictionaryValue();
653 base::DictionaryValue* exception_2 = new base::DictionaryValue(); 658 base::DictionaryValue* exception_2 = new base::DictionaryValue();
654 659
655 // Add both an "allow" and "block" exception for PMI. 660 // Add both an "allow" and "block" exception for PMI.
656 exception_1->SetIntegerWithoutPathExpansion( 661 exception_1->SetIntegerWithoutPathExpansion(
(...skipping 20 matching lines...) Expand all
677 &prefs, prefs::kContentSettingsProtectedMediaIdentifierPatternPairs); 682 &prefs, prefs::kContentSettingsProtectedMediaIdentifierPatternPairs);
678 const base::DictionaryValue* pmi_dictionary = update.Get(); 683 const base::DictionaryValue* pmi_dictionary = update.Get();
679 EXPECT_FALSE(pmi_dictionary->HasKey(pattern_1)); 684 EXPECT_FALSE(pmi_dictionary->HasKey(pattern_1));
680 EXPECT_TRUE(pmi_dictionary->HasKey(pattern_2)); 685 EXPECT_TRUE(pmi_dictionary->HasKey(pattern_2));
681 } 686 }
682 687
683 provider.ShutdownOnUIThread(); 688 provider.ShutdownOnUIThread();
684 } 689 }
685 #endif 690 #endif
686 691
687 TEST(PrefProviderTest, PrefsMigrateVerbatim) { 692 TEST_F(PrefProviderTest, PrefsMigrateVerbatim) {
688 TestingPrefServiceSyncable prefs; 693 TestingPrefServiceSyncable prefs;
689 PrefProvider::RegisterProfilePrefs(prefs.registry()); 694 PrefProvider::RegisterProfilePrefs(prefs.registry());
690 695
691 const std::string pattern_1 = "google.com,*"; 696 const std::string pattern_1 = "google.com,*";
692 const std::string pattern_2 = "www.google.com,*"; 697 const std::string pattern_2 = "www.google.com,*";
693 base::DictionaryValue* exception_1 = new base::DictionaryValue(); 698 base::DictionaryValue* exception_1 = new base::DictionaryValue();
694 base::DictionaryValue* exception_2 = new base::DictionaryValue(); 699 base::DictionaryValue* exception_2 = new base::DictionaryValue();
695 scoped_ptr<base::DictionaryValue> old_dictionary; 700 scoped_ptr<base::DictionaryValue> old_dictionary;
696 701
697 // Add two exceptions. 702 // Add two exceptions.
(...skipping 30 matching lines...) Expand all
728 // Test if the value after copying there and back is the same. 733 // Test if the value after copying there and back is the same.
729 { 734 {
730 DictionaryPrefUpdate update(&prefs, prefs::kContentSettingsPatternPairs); 735 DictionaryPrefUpdate update(&prefs, prefs::kContentSettingsPatternPairs);
731 base::DictionaryValue* new_dictionary = update.Get(); 736 base::DictionaryValue* new_dictionary = update.Get();
732 EXPECT_TRUE(old_dictionary->Equals(new_dictionary)); 737 EXPECT_TRUE(old_dictionary->Equals(new_dictionary));
733 } 738 }
734 739
735 provider.ShutdownOnUIThread(); 740 provider.ShutdownOnUIThread();
736 } 741 }
737 742
738 TEST(PrefProviderTest, IncognitoInheritsValueMap) { 743 TEST_F(PrefProviderTest, IncognitoInheritsValueMap) {
739 TestingPrefServiceSyncable prefs; 744 TestingPrefServiceSyncable prefs;
740 PrefProvider::RegisterProfilePrefs(prefs.registry()); 745 PrefProvider::RegisterProfilePrefs(prefs.registry());
741 746
742 ContentSettingsPattern pattern_1 = 747 ContentSettingsPattern pattern_1 =
743 ContentSettingsPattern::FromString("google.com"); 748 ContentSettingsPattern::FromString("google.com");
744 ContentSettingsPattern pattern_2 = 749 ContentSettingsPattern pattern_2 =
745 ContentSettingsPattern::FromString("www.google.com"); 750 ContentSettingsPattern::FromString("www.google.com");
746 ContentSettingsPattern wildcard = 751 ContentSettingsPattern wildcard =
747 ContentSettingsPattern::FromString("*"); 752 ContentSettingsPattern::FromString("*");
748 scoped_ptr<base::Value> value( 753 scoped_ptr<base::Value> value(
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 CONTENT_SETTINGS_TYPE_IMAGES, std::string(), true)); 800 CONTENT_SETTINGS_TYPE_IMAGES, std::string(), true));
796 EXPECT_TRUE(it->HasNext()); 801 EXPECT_TRUE(it->HasNext());
797 EXPECT_EQ(pattern_2, it->Next().primary_pattern); 802 EXPECT_EQ(pattern_2, it->Next().primary_pattern);
798 EXPECT_FALSE(it->HasNext()); 803 EXPECT_FALSE(it->HasNext());
799 } 804 }
800 805
801 incognito_provider.ShutdownOnUIThread(); 806 incognito_provider.ShutdownOnUIThread();
802 normal_provider.ShutdownOnUIThread(); 807 normal_provider.ShutdownOnUIThread();
803 } 808 }
804 809
805 TEST(PrefProviderTest, ClearAllContentSettingsRules) { 810 TEST_F(PrefProviderTest, ClearAllContentSettingsRules) {
806 TestingPrefServiceSyncable prefs; 811 TestingPrefServiceSyncable prefs;
807 PrefProvider::RegisterProfilePrefs(prefs.registry()); 812 PrefProvider::RegisterProfilePrefs(prefs.registry());
808 813
809 ContentSettingsPattern pattern = 814 ContentSettingsPattern pattern =
810 ContentSettingsPattern::FromString("google.com"); 815 ContentSettingsPattern::FromString("google.com");
811 ContentSettingsPattern wildcard = 816 ContentSettingsPattern wildcard =
812 ContentSettingsPattern::FromString("*"); 817 ContentSettingsPattern::FromString("*");
813 scoped_ptr<base::Value> value( 818 scoped_ptr<base::Value> value(
814 new base::FundamentalValue(CONTENT_SETTING_ALLOW)); 819 new base::FundamentalValue(CONTENT_SETTING_ALLOW));
815 ResourceIdentifier res_id("abcde"); 820 ResourceIdentifier res_id("abcde");
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 EXPECT_TRUE(exception->HasKey(GetTypeName(CONTENT_SETTINGS_TYPE_COOKIES))); 888 EXPECT_TRUE(exception->HasKey(GetTypeName(CONTENT_SETTINGS_TYPE_COOKIES)));
884 889
885 // The notification setting was not cleared, but it was also never written 890 // The notification setting was not cleared, but it was also never written
886 // to the old preference, as it is unsyncable. 891 // to the old preference, as it is unsyncable.
887 } 892 }
888 893
889 provider.ShutdownOnUIThread(); 894 provider.ShutdownOnUIThread();
890 } 895 }
891 896
892 } // namespace content_settings 897 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698