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

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

Issue 2791903003: Pref service: have Mash and Chrome connect to the right pref stores (Closed)
Patch Set: ProfilePrefStoreManagerTest: explicit list stores to connect to 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
« no previous file with comments | « chrome/browser/profiles/profile_impl.cc ('k') | services/preferences/pref_store_manager_impl.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) 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 29 matching lines...) Expand all
40 bool OnConnect(const service_manager::ServiceInfo& remote_info, 40 bool OnConnect(const service_manager::ServiceInfo& remote_info,
41 service_manager::InterfaceRegistry* registry) override { 41 service_manager::InterfaceRegistry* registry) override {
42 registry->AddInterface<service_manager::mojom::ServiceFactory>(this); 42 registry->AddInterface<service_manager::mojom::ServiceFactory>(this);
43 return true; 43 return true;
44 } 44 }
45 45
46 void CreateService(service_manager::mojom::ServiceRequest request, 46 void CreateService(service_manager::mojom::ServiceRequest request,
47 const std::string& name) override { 47 const std::string& name) override {
48 if (name == prefs::mojom::kServiceName) { 48 if (name == prefs::mojom::kServiceName) {
49 pref_service_context_.reset(new service_manager::ServiceContext( 49 pref_service_context_.reset(new service_manager::ServiceContext(
50 CreatePrefService({PrefValueStore::COMMAND_LINE_STORE, 50 CreatePrefService(
51 PrefValueStore::RECOMMENDED_STORE}, 51 {PrefValueStore::COMMAND_LINE_STORE,
52 worker_pool_), 52 PrefValueStore::RECOMMENDED_STORE, PrefValueStore::USER_STORE,
53 PrefValueStore::DEFAULT_STORE},
54 worker_pool_),
53 std::move(request))); 55 std::move(request)));
54 } 56 }
55 } 57 }
56 58
57 void Create(const service_manager::Identity& remote_identity, 59 void Create(const service_manager::Identity& remote_identity,
58 service_manager::mojom::ServiceFactoryRequest request) override { 60 service_manager::mojom::ServiceFactoryRequest request) override {
59 service_factory_bindings_.AddBinding(this, std::move(request)); 61 service_factory_bindings_.AddBinding(this, std::move(request));
60 } 62 }
61 63
62 private: 64 private:
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 void WillDestroyCurrentMessageLoop() override { worker_pool_owner_.reset(); } 121 void WillDestroyCurrentMessageLoop() override { worker_pool_owner_.reset(); }
120 122
121 // Create a fully initialized PrefService synchronously. 123 // Create a fully initialized PrefService synchronously.
122 std::unique_ptr<PrefService> Create() { 124 std::unique_ptr<PrefService> Create() {
123 std::unique_ptr<PrefService> pref_service; 125 std::unique_ptr<PrefService> pref_service;
124 base::RunLoop run_loop; 126 base::RunLoop run_loop;
125 auto pref_registry = make_scoped_refptr(new PrefRegistrySimple()); 127 auto pref_registry = make_scoped_refptr(new PrefRegistrySimple());
126 pref_registry->RegisterIntegerPref(kKey, kInitialValue); 128 pref_registry->RegisterIntegerPref(kKey, kInitialValue);
127 pref_registry->RegisterIntegerPref(kOtherKey, kInitialValue); 129 pref_registry->RegisterIntegerPref(kOtherKey, kInitialValue);
128 ConnectToPrefService(connector(), pref_registry, 130 ConnectToPrefService(connector(), pref_registry,
131 std::vector<PrefValueStore::PrefStoreType>(),
129 base::Bind(&PrefServiceFactoryTest::OnCreate, 132 base::Bind(&PrefServiceFactoryTest::OnCreate,
130 run_loop.QuitClosure(), &pref_service)); 133 run_loop.QuitClosure(), &pref_service));
131 run_loop.Run(); 134 run_loop.Run();
132 return pref_service; 135 return pref_service;
133 } 136 }
134 137
135 // Wait until first update of the pref |key| in |pref_service| synchronously. 138 // Wait until first update of the pref |key| in |pref_service| synchronously.
136 void WaitForPrefChange(PrefService* pref_service, const std::string& key) { 139 void WaitForPrefChange(PrefService* pref_service, const std::string& key) {
137 PrefChangeRegistrar registrar; 140 PrefChangeRegistrar registrar;
138 registrar.Init(pref_service); 141 registrar.Init(pref_service);
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 base::MakeUnique<base::Value>(2), 0); 256 base::MakeUnique<base::Value>(2), 0);
254 WaitForPrefChange(pref_service.get(), kKey); 257 WaitForPrefChange(pref_service.get(), kKey);
255 EXPECT_EQ(2, pref_service->GetInteger(kKey)); 258 EXPECT_EQ(2, pref_service->GetInteger(kKey));
256 259
257 pref_service->SetInteger(kKey, 3); 260 pref_service->SetInteger(kKey, 3);
258 EXPECT_EQ(2, pref_service->GetInteger(kKey)); 261 EXPECT_EQ(2, pref_service->GetInteger(kKey));
259 } 262 }
260 263
261 } // namespace 264 } // namespace
262 } // namespace prefs 265 } // namespace prefs
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_impl.cc ('k') | services/preferences/pref_store_manager_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698