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

Side by Side Diff: components/sync_driver/sync_prefs_unittest.cc

Issue 340703002: Add user_prefs::TestPrefServiceSyncable (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use TEST_F Created 6 years, 6 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 | « components/sync_driver/DEPS ('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 "components/sync_driver/sync_prefs.h" 5 #include "components/sync_driver/sync_prefs.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/prefs/pref_notifier_impl.h" 9 #include "base/prefs/pref_notifier_impl.h"
10 #include "base/prefs/pref_value_store.h" 10 #include "base/prefs/pref_value_store.h"
11 #include "base/prefs/testing_pref_service.h" 11 #include "base/prefs/testing_pref_service.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "components/pref_registry/pref_registry_syncable.h" 13 #include "components/pref_registry/testing_pref_service_syncable.h"
14 #include "components/sync_driver/pref_names.h" 14 #include "components/sync_driver/pref_names.h"
15 #include "sync/internal_api/public/base/model_type.h" 15 #include "sync/internal_api/public/base/model_type.h"
16 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 18
19 template <>
20 TestingPrefServiceBase<PrefService, user_prefs::PrefRegistrySyncable>::
21 TestingPrefServiceBase(TestingPrefStore* managed_prefs,
22 TestingPrefStore* user_prefs,
23 TestingPrefStore* recommended_prefs,
24 user_prefs::PrefRegistrySyncable* pref_registry,
25 PrefNotifierImpl* pref_notifier)
26 : PrefService(
27 pref_notifier,
28 new PrefValueStore(managed_prefs,
29 NULL, // supervised_user_prefs
30 NULL, // extension_prefs
31 NULL, // command_line_prefs
32 user_prefs,
33 recommended_prefs,
34 pref_registry->defaults().get(),
35 pref_notifier),
36 user_prefs,
37 pref_registry,
38 base::Bind(&TestingPrefServiceBase<
39 PrefService,
40 user_prefs::PrefRegistrySyncable>::HandleReadError),
41 false),
42 managed_prefs_(managed_prefs),
43 user_prefs_(user_prefs),
44 recommended_prefs_(recommended_prefs) {}
45
46 namespace sync_driver { 19 namespace sync_driver {
47 20
48 namespace { 21 namespace {
49 22
50 using ::testing::InSequence; 23 using ::testing::InSequence;
51 using ::testing::StrictMock; 24 using ::testing::StrictMock;
52 25
53 // Test version of PrefServiceSyncable.
54 class TestingPrefServiceSyncable
55 : public TestingPrefServiceBase<PrefService,
56 user_prefs::PrefRegistrySyncable> {
57 public:
58 TestingPrefServiceSyncable();
59 virtual ~TestingPrefServiceSyncable();
60
61 user_prefs::PrefRegistrySyncable* registry();
62
63 private:
64 DISALLOW_COPY_AND_ASSIGN(TestingPrefServiceSyncable);
65 };
66
67 TestingPrefServiceSyncable::TestingPrefServiceSyncable()
68 : TestingPrefServiceBase<PrefService, user_prefs::PrefRegistrySyncable>(
69 new TestingPrefStore(),
70 new TestingPrefStore(),
71 new TestingPrefStore(),
72 new user_prefs::PrefRegistrySyncable(),
73 new PrefNotifierImpl()) {}
74
75 TestingPrefServiceSyncable::~TestingPrefServiceSyncable() {}
76
77 user_prefs::PrefRegistrySyncable* TestingPrefServiceSyncable::registry() {
78 return static_cast<user_prefs::PrefRegistrySyncable*>(
79 DeprecatedGetPrefRegistry());
80 }
81
82 class SyncPrefsTest : public testing::Test { 26 class SyncPrefsTest : public testing::Test {
83 protected: 27 protected:
84 virtual void SetUp() OVERRIDE { 28 virtual void SetUp() OVERRIDE {
85 SyncPrefs::RegisterProfilePrefs(pref_service_.registry()); 29 SyncPrefs::RegisterProfilePrefs(pref_service_.registry());
86 } 30 }
87 31
88 TestingPrefServiceSyncable pref_service_; 32 user_prefs::TestingPrefServiceSyncable pref_service_;
89 33
90 private: 34 private:
91 base::MessageLoop loop_; 35 base::MessageLoop loop_;
92 }; 36 };
93 37
94 TEST_F(SyncPrefsTest, Basic) { 38 TEST_F(SyncPrefsTest, Basic) {
95 SyncPrefs sync_prefs(&pref_service_); 39 SyncPrefs sync_prefs(&pref_service_);
96 40
97 EXPECT_FALSE(sync_prefs.HasSyncSetupCompleted()); 41 EXPECT_FALSE(sync_prefs.HasSyncSetupCompleted());
98 sync_prefs.SetSyncSetupCompleted(); 42 sync_prefs.SetSyncSetupCompleted();
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 sync_prefs.ClearPreferences(); 228 sync_prefs.ClearPreferences();
285 229
286 EXPECT_FALSE(sync_prefs.HasSyncSetupCompleted()); 230 EXPECT_FALSE(sync_prefs.HasSyncSetupCompleted());
287 EXPECT_EQ(base::Time(), sync_prefs.GetLastSyncedTime()); 231 EXPECT_EQ(base::Time(), sync_prefs.GetLastSyncedTime());
288 EXPECT_TRUE(sync_prefs.GetEncryptionBootstrapToken().empty()); 232 EXPECT_TRUE(sync_prefs.GetEncryptionBootstrapToken().empty());
289 } 233 }
290 234
291 } // namespace 235 } // namespace
292 236
293 } // namespace browser_sync 237 } // namespace browser_sync
OLDNEW
« no previous file with comments | « components/sync_driver/DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698