1 // Copyright 2012 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/prefs/testing_pref_service.h"
9 #include "base/compiler_specific.h"
10 #include "base/functional/bind.h"
11 #include "components/prefs/default_pref_store.h"
12 #include "components/prefs/pref_notifier_impl.h"
13 #include "components/prefs/pref_registry_simple.h"
14 #include "components/prefs/pref_value_store.h"
15 #include "testing/gtest/include/gtest/gtest.h"
18 TestingPrefServiceBase<PrefService, PrefRegistry>::TestingPrefServiceBase(
19 TestingPrefStore* managed_prefs,
20 TestingPrefStore* supervised_user_prefs,
21 TestingPrefStore* extension_prefs,
22 TestingPrefStore* standalone_browser_prefs,
23 TestingPrefStore* user_prefs,
24 TestingPrefStore* recommended_prefs,
25 PrefRegistry* pref_registry,
26 PrefNotifierImpl* pref_notifier)
28 std::unique_ptr<PrefNotifierImpl>(pref_notifier),
29 std::make_unique<PrefValueStore>(managed_prefs,
30 supervised_user_prefs,
32 standalone_browser_prefs,
33 /*command_line_prefs=*/nullptr,
36 pref_registry->defaults().get(),
39 standalone_browser_prefs,
42 &TestingPrefServiceBase<PrefService,
43 PrefRegistry>::HandleReadError),
45 managed_prefs_(managed_prefs),
46 supervised_user_prefs_(supervised_user_prefs),
47 extension_prefs_(extension_prefs),
48 standalone_browser_prefs_(standalone_browser_prefs),
49 user_prefs_(user_prefs),
50 recommended_prefs_(recommended_prefs) {}
52 TestingPrefServiceSimple::TestingPrefServiceSimple()
53 : TestingPrefServiceBase<PrefService, PrefRegistry>(
54 /*managed_prefs=*/new TestingPrefStore(),
55 /*supervised_user_prefs=*/new TestingPrefStore(),
56 /*extension_prefs=*/new TestingPrefStore(),
57 /*standalone_browser_prefs=*/new TestingPrefStore(),
58 /*user_prefs=*/new TestingPrefStore(),
59 /*recommended_prefs=*/new TestingPrefStore(),
60 new PrefRegistrySimple(),
61 new PrefNotifierImpl()) {}
63 TestingPrefServiceSimple::~TestingPrefServiceSimple() {
66 PrefRegistrySimple* TestingPrefServiceSimple::registry() {
67 return static_cast<PrefRegistrySimple*>(DeprecatedGetPrefRegistry());