1 /*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "mock_preferences.h"
17 #include "preferences_value.h"
18
19 namespace OHOS {
20 namespace NativePreferences {
MockPreferences()21 MockPreferences::MockPreferences()
22 {}
~MockPreferences()23 MockPreferences::~MockPreferences()
24 {}
Get(const std::string & key,const PreferencesValue & defValue)25 PreferencesValue MockPreferences::Get(const std::string &key, const PreferencesValue &defValue)
26 {
27 (void)key;
28 (void)defValue;
29 return nullptr;
30 }
Put(const std::string & key,const PreferencesValue & value)31 int MockPreferences::Put(const std::string &key, const PreferencesValue &value)
32 {
33 (void)key;
34 (void)value;
35 return 0;
36 }
GetInt(const std::string & key,const int & defValue)37 int MockPreferences::GetInt(const std::string &key, const int &defValue)
38 {
39 (void)key;
40 (void)defValue;
41 return 0;
42 }
43
GetString(const std::string & key,const std::string & defValue)44 std::string MockPreferences::GetString(const std::string &key, const std::string &defValue)
45 {
46 (void)key;
47 (void)defValue;
48 return "";
49 }
50
GetBool(const std::string & key,const bool & defValue)51 bool MockPreferences::GetBool(const std::string &key, const bool &defValue)
52 {
53 (void)key;
54 (void)defValue;
55 return true;
56 }
57
GetFloat(const std::string & key,const float & defValue)58 float MockPreferences::GetFloat(const std::string &key, const float &defValue)
59 {
60 (void)key;
61 (void)defValue;
62 return 0;
63 }
64
GetDouble(const std::string & key,const double & defValue)65 double MockPreferences::GetDouble(const std::string &key, const double &defValue)
66 {
67 (void)key;
68 (void)defValue;
69 return 0;
70 }
71
GetLong(const std::string & key,const int64_t & defValue)72 int64_t MockPreferences::GetLong(const std::string &key, const int64_t &defValue)
73 {
74 (void)key;
75 (void)defValue;
76 return 0;
77 }
78
HasKey(const std::string & key)79 bool MockPreferences::HasKey(const std::string &key)
80 {
81 (void)key;
82 return true;
83 }
84
PutInt(const std::string & key,int value)85 int MockPreferences::PutInt(const std::string &key, int value)
86 {
87 (void)key;
88 (void)value;
89 return 0;
90 }
91
PutString(const std::string & key,const std::string & value)92 int MockPreferences::PutString(const std::string &key, const std::string &value)
93 {
94 (void)key;
95 (void)value;
96 return 0;
97 }
98
PutBool(const std::string & key,bool value)99 int MockPreferences::PutBool(const std::string &key, bool value)
100 {
101 (void)key;
102 (void)value;
103 return 0;
104 }
105
PutLong(const std::string & key,int64_t value)106 int MockPreferences::PutLong(const std::string &key, int64_t value)
107 {
108 (void)key;
109 (void)value;
110 return 0;
111 }
112
PutFloat(const std::string & key,float value)113 int MockPreferences::PutFloat(const std::string &key, float value)
114 {
115 (void)key;
116 (void)value;
117 return 0;
118 }
119
PutDouble(const std::string & key,double value)120 int MockPreferences::PutDouble(const std::string &key, double value)
121 {
122 (void)key;
123 (void)value;
124 return 0;
125 }
126
GetAll()127 std::map<std::string, PreferencesValue> MockPreferences::GetAll()
128 {
129 std::map<std::string, PreferencesValue> map_;
130 return map_;
131 }
132
Delete(const std::string & key)133 int MockPreferences::Delete(const std::string &key)
134 {
135 (void)key;
136 return 0;
137 }
Clear()138 int MockPreferences::Clear()
139 {
140 return 0;
141 }
142
Flush()143 void MockPreferences::Flush()
144 {
145 }
146
FlushSync()147 int MockPreferences::FlushSync()
148 {
149 return 0;
150 }
151
RegisterObserver(std::shared_ptr<PreferencesObserver> preferencesObserver,RegisterMode mode)152 int MockPreferences::RegisterObserver(std::shared_ptr<PreferencesObserver> preferencesObserver, RegisterMode mode)
153 {
154 (void)preferencesObserver;
155 (void)mode;
156 return 0;
157 }
UnRegisterObserver(std::shared_ptr<PreferencesObserver> preferencesObserver,RegisterMode mode)158 int MockPreferences::UnRegisterObserver(std::shared_ptr<PreferencesObserver> preferencesObserver, RegisterMode mode)
159 {
160 (void)preferencesObserver;
161 (void)mode;
162 return 0;
163 }
164 } // End of namespace NativePreferences
165 } // End of namespace OHOS
166