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

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: nits 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
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 10 matching lines...) Expand all
21 using testing::AnyNumber; 21 using testing::AnyNumber;
22 using testing::Mock; 22 using testing::Mock;
23 using testing::Invoke; 23 using testing::Invoke;
24 24
25 namespace { 25 namespace {
26 26
27 // Allows to capture pref notifications through gmock. 27 // Allows to capture pref notifications through gmock.
28 class MockPrefNotifier : public PrefNotifier { 28 class MockPrefNotifier : public PrefNotifier {
29 public: 29 public:
30 MOCK_METHOD1(OnPreferenceChanged, void(const std::string&)); 30 MOCK_METHOD1(OnPreferenceChanged, void(const std::string&));
31 MOCK_METHOD0(OnInitializationCompleted, void()); 31 MOCK_METHOD1(OnInitializationCompleted, void(bool));
32 }; 32 };
33 33
34 } // namespace 34 } // namespace
35 35
36 // Names of the preferences used in this test. 36 // Names of the preferences used in this test.
37 namespace prefs { 37 namespace prefs {
38 const char kManagedPlatformPref[] = "this.pref.managed_platform"; 38 const char kManagedPlatformPref[] = "this.pref.managed_platform";
39 const char kManagedCloudPref[] = "this.pref.managed_cloud"; 39 const char kManagedCloudPref[] = "this.pref.managed_cloud";
40 const char kCommandLinePref[] = "this.pref.command_line"; 40 const char kCommandLinePref[] = "this.pref.command_line";
41 const char kExtensionPref[] = "this.pref.extension"; 41 const char kExtensionPref[] = "this.pref.extension";
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 EXPECT_CALL(pref_notifier_, OnPreferenceChanged(prefs::kDefaultPref)); 444 EXPECT_CALL(pref_notifier_, OnPreferenceChanged(prefs::kDefaultPref));
445 recommended_cloud_pref_store_->NotifyPrefValueChanged(prefs::kDefaultPref); 445 recommended_cloud_pref_store_->NotifyPrefValueChanged(prefs::kDefaultPref);
446 Mock::VerifyAndClearExpectations(&pref_notifier_); 446 Mock::VerifyAndClearExpectations(&pref_notifier_);
447 447
448 EXPECT_CALL(pref_notifier_, OnPreferenceChanged(prefs::kDefaultPref)); 448 EXPECT_CALL(pref_notifier_, OnPreferenceChanged(prefs::kDefaultPref));
449 default_pref_store_->NotifyPrefValueChanged(prefs::kDefaultPref); 449 default_pref_store_->NotifyPrefValueChanged(prefs::kDefaultPref);
450 Mock::VerifyAndClearExpectations(&pref_notifier_); 450 Mock::VerifyAndClearExpectations(&pref_notifier_);
451 } 451 }
452 452
453 TEST_F(PrefValueStoreTest, OnInitializationCompleted) { 453 TEST_F(PrefValueStoreTest, OnInitializationCompleted) {
454 EXPECT_CALL(pref_notifier_, OnInitializationCompleted()).Times(0); 454 EXPECT_CALL(pref_notifier_, OnInitializationCompleted(true)).Times(0);
455 managed_platform_pref_store_->SetInitializationCompleted(); 455 managed_platform_pref_store_->SetInitializationCompleted();
456 managed_cloud_pref_store_->SetInitializationCompleted(); 456 managed_cloud_pref_store_->SetInitializationCompleted();
457 extension_pref_store_->SetInitializationCompleted(); 457 extension_pref_store_->SetInitializationCompleted();
458 command_line_pref_store_->SetInitializationCompleted(); 458 command_line_pref_store_->SetInitializationCompleted();
459 recommended_platform_pref_store_->SetInitializationCompleted(); 459 recommended_platform_pref_store_->SetInitializationCompleted();
460 recommended_cloud_pref_store_->SetInitializationCompleted(); 460 recommended_cloud_pref_store_->SetInitializationCompleted();
461 default_pref_store_->SetInitializationCompleted(); 461 default_pref_store_->SetInitializationCompleted();
462 Mock::VerifyAndClearExpectations(&pref_notifier_); 462 Mock::VerifyAndClearExpectations(&pref_notifier_);
463 463
464 // The notification should only be triggered after the last store is done. 464 // The notification should only be triggered after the last store is done.
465 EXPECT_CALL(pref_notifier_, OnInitializationCompleted()).Times(1); 465 EXPECT_CALL(pref_notifier_, OnInitializationCompleted(true)).Times(1);
466 user_pref_store_->SetInitializationCompleted(); 466 user_pref_store_->SetInitializationCompleted();
467 Mock::VerifyAndClearExpectations(&pref_notifier_); 467 Mock::VerifyAndClearExpectations(&pref_notifier_);
468 } 468 }
469 469
470 TEST_F(PrefValueStoreTest, PrefValueInManagedStore) { 470 TEST_F(PrefValueStoreTest, PrefValueInManagedStore) {
471 EXPECT_TRUE(pref_value_store_->PrefValueInManagedStore( 471 EXPECT_TRUE(pref_value_store_->PrefValueInManagedStore(
472 prefs::kManagedPlatformPref)); 472 prefs::kManagedPlatformPref));
473 EXPECT_TRUE(pref_value_store_->PrefValueInManagedStore( 473 EXPECT_TRUE(pref_value_store_->PrefValueInManagedStore(
474 prefs::kManagedCloudPref)); 474 prefs::kManagedCloudPref));
475 EXPECT_FALSE(pref_value_store_->PrefValueInManagedStore( 475 EXPECT_FALSE(pref_value_store_->PrefValueInManagedStore(
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 prefs::kUserPref)); 627 prefs::kUserPref));
628 EXPECT_TRUE(pref_value_store_->PrefValueExtensionModifiable( 628 EXPECT_TRUE(pref_value_store_->PrefValueExtensionModifiable(
629 prefs::kRecommendedPlatformPref)); 629 prefs::kRecommendedPlatformPref));
630 EXPECT_TRUE(pref_value_store_->PrefValueExtensionModifiable( 630 EXPECT_TRUE(pref_value_store_->PrefValueExtensionModifiable(
631 prefs::kRecommendedCloudPref)); 631 prefs::kRecommendedCloudPref));
632 EXPECT_TRUE(pref_value_store_->PrefValueExtensionModifiable( 632 EXPECT_TRUE(pref_value_store_->PrefValueExtensionModifiable(
633 prefs::kDefaultPref)); 633 prefs::kDefaultPref));
634 EXPECT_TRUE(pref_value_store_->PrefValueExtensionModifiable( 634 EXPECT_TRUE(pref_value_store_->PrefValueExtensionModifiable(
635 prefs::kMissingPref)); 635 prefs::kMissingPref));
636 } 636 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698