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

Side by Side Diff: chrome/browser/prefs/pref_value_store_unittest.cc

Issue 6894020: Adds async interface method to PersistentPrefStore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 2010->2011 Created 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/prefs/pref_value_store.cc ('k') | chrome/browser/prefs/testing_pref_store.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <set> 5 #include <set>
6 #include <string> 6 #include <string>
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/policy/configuration_policy_pref_store.h" 10 #include "chrome/browser/policy/configuration_policy_pref_store.h"
(...skipping 11 matching lines...) Expand all
22 using testing::AnyNumber; 22 using testing::AnyNumber;
23 using testing::Mock; 23 using testing::Mock;
24 using testing::Invoke; 24 using testing::Invoke;
25 25
26 namespace { 26 namespace {
27 27
28 // Allows to capture pref notifications through gmock. 28 // Allows to capture pref notifications through gmock.
29 class MockPrefNotifier : public PrefNotifier { 29 class MockPrefNotifier : public PrefNotifier {
30 public: 30 public:
31 MOCK_METHOD1(OnPreferenceChanged, void(const std::string&)); 31 MOCK_METHOD1(OnPreferenceChanged, void(const std::string&));
32 MOCK_METHOD0(OnInitializationCompleted, void()); 32 MOCK_METHOD1(OnInitializationCompleted, void(bool));
33 }; 33 };
34 34
35 // Allows to capture sync model associator interaction. 35 // Allows to capture sync model associator interaction.
36 class MockPrefModelAssociator : public PrefModelAssociator { 36 class MockPrefModelAssociator : public PrefModelAssociator {
37 public: 37 public:
38 MOCK_METHOD1(ProcessPrefChange, void(const std::string&)); 38 MOCK_METHOD1(ProcessPrefChange, void(const std::string&));
39 }; 39 };
40 40
41 } // namespace 41 } // namespace
42 42
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 Mock::VerifyAndClearExpectations(sync_associator_.get()); 487 Mock::VerifyAndClearExpectations(sync_associator_.get());
488 488
489 EXPECT_CALL(pref_notifier_, OnPreferenceChanged(prefs::kDefaultPref)); 489 EXPECT_CALL(pref_notifier_, OnPreferenceChanged(prefs::kDefaultPref));
490 EXPECT_CALL(*sync_associator_, ProcessPrefChange(prefs::kDefaultPref)); 490 EXPECT_CALL(*sync_associator_, ProcessPrefChange(prefs::kDefaultPref));
491 default_pref_store_->NotifyPrefValueChanged(prefs::kDefaultPref); 491 default_pref_store_->NotifyPrefValueChanged(prefs::kDefaultPref);
492 Mock::VerifyAndClearExpectations(&pref_notifier_); 492 Mock::VerifyAndClearExpectations(&pref_notifier_);
493 Mock::VerifyAndClearExpectations(sync_associator_.get()); 493 Mock::VerifyAndClearExpectations(sync_associator_.get());
494 } 494 }
495 495
496 TEST_F(PrefValueStoreTest, OnInitializationCompleted) { 496 TEST_F(PrefValueStoreTest, OnInitializationCompleted) {
497 EXPECT_CALL(pref_notifier_, OnInitializationCompleted()).Times(0); 497 EXPECT_CALL(pref_notifier_, OnInitializationCompleted(true)).Times(0);
498 managed_platform_pref_store_->SetInitializationCompleted(); 498 managed_platform_pref_store_->SetInitializationCompleted();
499 managed_cloud_pref_store_->SetInitializationCompleted(); 499 managed_cloud_pref_store_->SetInitializationCompleted();
500 extension_pref_store_->SetInitializationCompleted(); 500 extension_pref_store_->SetInitializationCompleted();
501 command_line_pref_store_->SetInitializationCompleted(); 501 command_line_pref_store_->SetInitializationCompleted();
502 recommended_platform_pref_store_->SetInitializationCompleted(); 502 recommended_platform_pref_store_->SetInitializationCompleted();
503 recommended_cloud_pref_store_->SetInitializationCompleted(); 503 recommended_cloud_pref_store_->SetInitializationCompleted();
504 default_pref_store_->SetInitializationCompleted(); 504 default_pref_store_->SetInitializationCompleted();
505 Mock::VerifyAndClearExpectations(&pref_notifier_); 505 Mock::VerifyAndClearExpectations(&pref_notifier_);
506 506
507 // The notification should only be triggered after the last store is done. 507 // The notification should only be triggered after the last store is done.
508 EXPECT_CALL(pref_notifier_, OnInitializationCompleted()).Times(1); 508 EXPECT_CALL(pref_notifier_, OnInitializationCompleted(true)).Times(1);
509 user_pref_store_->SetInitializationCompleted(); 509 user_pref_store_->SetInitializationCompleted();
510 Mock::VerifyAndClearExpectations(&pref_notifier_); 510 Mock::VerifyAndClearExpectations(&pref_notifier_);
511 } 511 }
512 512
513 TEST_F(PrefValueStoreTest, PrefValueInManagedStore) { 513 TEST_F(PrefValueStoreTest, PrefValueInManagedStore) {
514 EXPECT_TRUE(pref_value_store_->PrefValueInManagedStore( 514 EXPECT_TRUE(pref_value_store_->PrefValueInManagedStore(
515 prefs::kManagedPlatformPref)); 515 prefs::kManagedPlatformPref));
516 EXPECT_TRUE(pref_value_store_->PrefValueInManagedStore( 516 EXPECT_TRUE(pref_value_store_->PrefValueInManagedStore(
517 prefs::kManagedCloudPref)); 517 prefs::kManagedCloudPref));
518 EXPECT_FALSE(pref_value_store_->PrefValueInManagedStore( 518 EXPECT_FALSE(pref_value_store_->PrefValueInManagedStore(
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 prefs::kUserPref)); 670 prefs::kUserPref));
671 EXPECT_TRUE(pref_value_store_->PrefValueExtensionModifiable( 671 EXPECT_TRUE(pref_value_store_->PrefValueExtensionModifiable(
672 prefs::kRecommendedPlatformPref)); 672 prefs::kRecommendedPlatformPref));
673 EXPECT_TRUE(pref_value_store_->PrefValueExtensionModifiable( 673 EXPECT_TRUE(pref_value_store_->PrefValueExtensionModifiable(
674 prefs::kRecommendedCloudPref)); 674 prefs::kRecommendedCloudPref));
675 EXPECT_TRUE(pref_value_store_->PrefValueExtensionModifiable( 675 EXPECT_TRUE(pref_value_store_->PrefValueExtensionModifiable(
676 prefs::kDefaultPref)); 676 prefs::kDefaultPref));
677 EXPECT_TRUE(pref_value_store_->PrefValueExtensionModifiable( 677 EXPECT_TRUE(pref_value_store_->PrefValueExtensionModifiable(
678 prefs::kMissingPref)); 678 prefs::kMissingPref));
679 } 679 }
OLDNEW
« no previous file with comments | « chrome/browser/prefs/pref_value_store.cc ('k') | chrome/browser/prefs/testing_pref_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698