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

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

Issue 11636018: Remove PrefValueStore's dependency on PrefModelAssociator. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix DEPS 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
« no previous file with comments | « chrome/browser/prefs/pref_value_store.cc ('k') | no next file » | 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) 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 <string> 5 #include <string>
6 6
7 #include "base/bind.h"
7 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
8 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
9 #include "base/prefs/pref_notifier.h" 10 #include "base/prefs/pref_notifier.h"
10 #include "base/prefs/testing_pref_store.h" 11 #include "base/prefs/testing_pref_store.h"
11 #include "base/values.h" 12 #include "base/values.h"
12 #include "chrome/browser/prefs/pref_model_associator.h"
13 #include "chrome/browser/prefs/pref_value_store.h" 13 #include "chrome/browser/prefs/pref_value_store.h"
14 #include "chrome/common/pref_names.h" 14 #include "chrome/common/pref_names.h"
15 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 17
18 using testing::Mock; 18 using testing::Mock;
19 using testing::_; 19 using testing::_;
20 20
21 namespace { 21 namespace {
22 22
23 // Allows to capture pref notifications through gmock. 23 // Allows to capture pref notifications through gmock.
24 class MockPrefNotifier : public PrefNotifier { 24 class MockPrefNotifier : public PrefNotifier {
25 public: 25 public:
26 MOCK_METHOD1(OnPreferenceChanged, void(const std::string&)); 26 MOCK_METHOD1(OnPreferenceChanged, void(const std::string&));
27 MOCK_METHOD1(OnInitializationCompleted, void(bool)); 27 MOCK_METHOD1(OnInitializationCompleted, void(bool));
28 }; 28 };
29 29
30 // Allows to capture sync model associator interaction. 30 // Allows to capture sync model associator interaction.
31 class MockPrefModelAssociator : public PrefModelAssociator { 31 class MockPrefModelAssociator {
32 public: 32 public:
33 MOCK_METHOD1(ProcessPrefChange, void(const std::string&)); 33 MOCK_METHOD1(ProcessPrefChange, void(const std::string&));
34 }; 34 };
35 35
36 } // namespace 36 } // namespace
37 37
38 // Names of the preferences used in this test. 38 // Names of the preferences used in this test.
39 namespace prefs { 39 namespace prefs {
40 const char kManagedPref[] = "this.pref.managed"; 40 const char kManagedPref[] = "this.pref.managed";
41 const char kCommandLinePref[] = "this.pref.command_line"; 41 const char kCommandLinePref[] = "this.pref.command_line";
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 // Create a fresh PrefValueStore. 101 // Create a fresh PrefValueStore.
102 pref_value_store_.reset(new PrefValueStore( 102 pref_value_store_.reset(new PrefValueStore(
103 managed_pref_store_, 103 managed_pref_store_,
104 extension_pref_store_, 104 extension_pref_store_,
105 command_line_pref_store_, 105 command_line_pref_store_,
106 user_pref_store_, 106 user_pref_store_,
107 recommended_pref_store_, 107 recommended_pref_store_,
108 default_pref_store_, 108 default_pref_store_,
109 &pref_notifier_)); 109 &pref_notifier_));
110 110
111 pref_value_store_->set_sync_associator(sync_associator_.get()); 111 pref_value_store_->set_callback(
112 base::Bind(&MockPrefModelAssociator::ProcessPrefChange,
113 base::Unretained(sync_associator_.get())));
112 } 114 }
113 115
114 void CreateManagedPrefs() { 116 void CreateManagedPrefs() {
115 managed_pref_store_ = new TestingPrefStore; 117 managed_pref_store_ = new TestingPrefStore;
116 managed_pref_store_->SetString( 118 managed_pref_store_->SetString(
117 prefs::kManagedPref, 119 prefs::kManagedPref,
118 managed_pref::kManagedValue); 120 managed_pref::kManagedValue);
119 } 121 }
120 122
121 void CreateExtensionPrefs() { 123 void CreateExtensionPrefs() {
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 prefs::kCommandLinePref)); 585 prefs::kCommandLinePref));
584 EXPECT_TRUE(pref_value_store_->PrefValueExtensionModifiable( 586 EXPECT_TRUE(pref_value_store_->PrefValueExtensionModifiable(
585 prefs::kUserPref)); 587 prefs::kUserPref));
586 EXPECT_TRUE(pref_value_store_->PrefValueExtensionModifiable( 588 EXPECT_TRUE(pref_value_store_->PrefValueExtensionModifiable(
587 prefs::kRecommendedPref)); 589 prefs::kRecommendedPref));
588 EXPECT_TRUE(pref_value_store_->PrefValueExtensionModifiable( 590 EXPECT_TRUE(pref_value_store_->PrefValueExtensionModifiable(
589 prefs::kDefaultPref)); 591 prefs::kDefaultPref));
590 EXPECT_TRUE(pref_value_store_->PrefValueExtensionModifiable( 592 EXPECT_TRUE(pref_value_store_->PrefValueExtensionModifiable(
591 prefs::kMissingPref)); 593 prefs::kMissingPref));
592 } 594 }
OLDNEW
« no previous file with comments | « chrome/browser/prefs/pref_value_store.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698