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

Side by Side Diff: ios/public/test/test_keyed_service_provider.cc

Issue 1158223003: [iOS] Add FakeSyncService and factory for testing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ios/public/test/test_keyed_service_provider.h"
6
7 #include "base/memory/singleton.h"
8 #include "components/keyed_service/ios/browser_state_dependency_manager.h"
9 #include "components/keyed_service/ios/browser_state_keyed_service_factory.h"
10 #include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state. h"
11 #include "ios/public/test/fake_sync_service.h"
12
13 namespace {
14
15 class FakeSyncServiceFactory : public BrowserStateKeyedServiceFactory {
sdefresne 2015/06/08 16:24:17 nit: move this to fake_sync_service_factory.{h,cc}
16 public:
17 // Returns the singleton FakeSyncServiceFactory instance.
18 static FakeSyncServiceFactory* GetInstance() {
19 return Singleton<FakeSyncServiceFactory>::get();
20 }
21
22 // Returns the FakeSyncServiceFactory associated to |browser_state|.
23 static FakeSyncService* GetForBrowserState(web::BrowserState* browser_state) {
sdefresne 2015/06/08 16:24:17 nit: s/FakeSyncService*/sync_driver::SyncService*/
24 return static_cast<FakeSyncService*>(
25 FakeSyncServiceFactory::GetInstance()->GetServiceForBrowserState(
26 browser_state, true));
27 }
28
29 private:
30 friend struct DefaultSingletonTraits<FakeSyncServiceFactory>;
31
32 // BrowserStateKeyedServiceFactory implementation:
33 KeyedService* BuildServiceInstanceFor(
34 web::BrowserState* context) const override {
35 return new FakeSyncService;
36 }
37
38 FakeSyncServiceFactory()
39 : BrowserStateKeyedServiceFactory(
40 "FakeSyncService",
41 BrowserStateDependencyManager::GetInstance()) {}
42 ~FakeSyncServiceFactory() override {}
43
44 DISALLOW_COPY_AND_ASSIGN(FakeSyncServiceFactory);
45 };
46
47 } // namespace
48
49 namespace ios {
50
51 TestKeyedServiceProvider::TestKeyedServiceProvider() {
52 }
53
54 TestKeyedServiceProvider::~TestKeyedServiceProvider() {
55 }
56
57 KeyedServiceBaseFactory* TestKeyedServiceProvider::GetSyncServiceFactory() {
58 return FakeSyncServiceFactory::GetInstance();
59 }
60
61 sync_driver::SyncService*
62 TestKeyedServiceProvider::GetSyncServiceForBrowserState(
63 ChromeBrowserState* browser_state) {
64 return FakeSyncServiceFactory::GetForBrowserState(browser_state);
65 }
66
67 } // namespace ios
OLDNEW
« ios/public/test/fake_sync_service.h ('K') | « ios/public/test/test_keyed_service_provider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698