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

Side by Side Diff: services/preferences/pref_service_factory_unittest.cc

Issue 2777483002: Pref service: Add initial support for pref registration. (Closed)
Patch Set: rebase Created 3 years, 8 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) 2017 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2017 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 "services/preferences/public/cpp/pref_service_factory.h" 5 #include "services/preferences/public/cpp/pref_service_factory.h"
6 6
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/test/sequenced_worker_pool_owner.h" 10 #include "base/test/sequenced_worker_pool_owner.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 base::ScopedTempDir profile_dir_; 156 base::ScopedTempDir profile_dir_;
157 std::unique_ptr<base::SequencedWorkerPoolOwner> worker_pool_owner_; 157 std::unique_ptr<base::SequencedWorkerPoolOwner> worker_pool_owner_;
158 158
159 DISALLOW_COPY_AND_ASSIGN(PrefServiceFactoryTest); 159 DISALLOW_COPY_AND_ASSIGN(PrefServiceFactoryTest);
160 }; 160 };
161 161
162 // Check that a single client can set and read back values. 162 // Check that a single client can set and read back values.
163 TEST_F(PrefServiceFactoryTest, Basic) { 163 TEST_F(PrefServiceFactoryTest, Basic) {
164 auto pref_service = Create(); 164 auto pref_service = Create();
165 165
166 // TODO(tibell): Once we have a default store check the value prior to 166 EXPECT_EQ(kInitialValue, pref_service->GetInteger(kKey));
167 // setting.
168 pref_service->SetInteger(kKey, kUpdatedValue); 167 pref_service->SetInteger(kKey, kUpdatedValue);
169 EXPECT_EQ(kUpdatedValue, pref_service->GetInteger(kKey)); 168 EXPECT_EQ(kUpdatedValue, pref_service->GetInteger(kKey));
170 } 169 }
171 170
172 // Check that updates in one client eventually propagates to the other. 171 // Check that updates in one client eventually propagates to the other.
173 TEST_F(PrefServiceFactoryTest, MultipleClients) { 172 TEST_F(PrefServiceFactoryTest, MultipleClients) {
174 auto pref_service = Create(); 173 auto pref_service = Create();
175 auto pref_service2 = Create(); 174 auto pref_service2 = Create();
176 175
177 // TODO(tibell): Once we have a default store check the value prior to 176 EXPECT_EQ(kInitialValue, pref_service->GetInteger(kKey));
178 // setting. 177 EXPECT_EQ(kInitialValue, pref_service2->GetInteger(kKey));
179 pref_service->SetInteger(kKey, kUpdatedValue); 178 pref_service->SetInteger(kKey, kUpdatedValue);
180 WaitForPrefChange(pref_service2.get(), kKey); 179 WaitForPrefChange(pref_service2.get(), kKey);
181 EXPECT_EQ(kUpdatedValue, pref_service2->GetInteger(kKey)); 180 EXPECT_EQ(kUpdatedValue, pref_service2->GetInteger(kKey));
182 } 181 }
183 182
184 } // namespace 183 } // namespace
185 } // namespace prefs 184 } // namespace prefs
OLDNEW
« no previous file with comments | « services/preferences/persistent_pref_store_impl_unittest.cc ('k') | services/preferences/pref_store_manager_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698