• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #include <cstdint>
17 #include <functional>
18 #include <string>
19 
20 namespace test {
21 namespace mock {
22 namespace device_iot_config {
23 
24 // Shared state between mocked functions and tests
25 // Name: device_iot_config_get_int
26 // Params: const std::string& section, const std::string& key, int& value
27 // Return: bool
28 struct device_iot_config_get_int {
29   bool return_value{false};
30   std::function<bool(const std::string& section, const std::string& key, int& value)> body{
31           [this](const std::string& /* section */, const std::string& /* key */, int& /* value */) {
32             return return_value;
33           }};
operatordevice_iot_config_get_int34   bool operator()(const std::string& section, const std::string& key, int& value) {
35     return body(section, key, value);
36   }
37 };
38 extern struct device_iot_config_get_int device_iot_config_get_int;
39 
40 // Name: device_iot_config_set_int
41 // Params: const std::string& section, const std::string& key, int& value
42 // Return: bool
43 struct device_iot_config_set_int {
44   bool return_value{false};
45   std::function<bool(const std::string& section, const std::string& key, int value)> body{
46           [this](const std::string& /* section */, const std::string& /* key */, int /* value */) {
47             return return_value;
48           }};
operatordevice_iot_config_set_int49   bool operator()(const std::string& section, const std::string& key, int value) {
50     return body(section, key, value);
51   }
52 };
53 extern struct device_iot_config_set_int device_iot_config_set_int;
54 
55 // Name: device_iot_config_int_add_one
56 // Params: const std::string& section, const std::string& key
57 // Return: bool
58 struct device_iot_config_int_add_one {
59   bool return_value{false};
60   std::function<bool(const std::string& section, const std::string& key)> body{
61           [this](const std::string& /* section */, const std::string& /* key */) {
62             return return_value;
63           }};
operatordevice_iot_config_int_add_one64   bool operator()(const std::string& section, const std::string& key) { return body(section, key); }
65 };
66 extern struct device_iot_config_int_add_one device_iot_config_int_add_one;
67 
68 // Name: device_iot_config_get_hex
69 // Params: const std::string& section, const std::string& key, int& value
70 // Return: bool
71 struct device_iot_config_get_hex {
72   bool return_value{false};
73   std::function<bool(const std::string& section, const std::string& key, int& value)> body{
74           [this](const std::string& /* section */, const std::string& /* key */, int& /* value */) {
75             return return_value;
76           }};
operatordevice_iot_config_get_hex77   bool operator()(const std::string& section, const std::string& key, int& value) {
78     return body(section, key, value);
79   }
80 };
81 extern struct device_iot_config_get_hex device_iot_config_get_hex;
82 
83 // Name: device_iot_config_set_hex
84 // Params: const std::string& section, const std::string& key, int value, int
85 // byte_num
86 // Return: bool
87 struct device_iot_config_set_hex {
88   bool return_value{false};
89   std::function<bool(const std::string& section, const std::string& key, int value, int byte_num)>
90           body{[this](const std::string& /* section */, const std::string& /* key */,
91                       int /* value */, int /* byte_num */) { return return_value; }};
operatordevice_iot_config_set_hex92   bool operator()(const std::string& section, const std::string& key, int value, int byte_num) {
93     return body(section, key, value, byte_num);
94   }
95 };
96 extern struct device_iot_config_set_hex device_iot_config_set_hex;
97 
98 // Name: device_iot_config_set_hex_if_greater
99 // Params: const std::string& section, const std::string& key, int value, int
100 // byte_num
101 // Return: bool
102 struct device_iot_config_set_hex_if_greater {
103   bool return_value{false};
104   std::function<bool(const std::string& section, const std::string& key, int value, int byte_num)>
105           body{[this](const std::string& /* section */, const std::string& /* key */,
106                       int /* value */, int /* byte_num */) { return return_value; }};
operatordevice_iot_config_set_hex_if_greater107   bool operator()(const std::string& section, const std::string& key, int value, int byte_num) {
108     return body(section, key, value, byte_num);
109   }
110 };
111 extern struct device_iot_config_set_hex_if_greater device_iot_config_set_hex_if_greater;
112 
113 // Name: device_iot_config_get_str
114 // Params: const std::string& section, const std::string& key, char* value, int*
115 // size_bytes
116 // Return: bool
117 struct device_iot_config_get_str {
118   bool return_value{false};
119   std::function<bool(const std::string& section, const std::string& key, char* value,
120                      int* size_bytes)>
121           body{[this](const std::string& /* section */, const std::string& /* key */,
122                       char* /* value */, int* /* size_bytes */) { return return_value; }};
operatordevice_iot_config_get_str123   bool operator()(const std::string& section, const std::string& key, char* value,
124                   int* size_bytes) {
125     return body(section, key, value, size_bytes);
126   }
127 };
128 extern struct device_iot_config_get_str device_iot_config_get_str;
129 
130 // Name: device_iot_config_set_str
131 // Params: const std::string& section, const std::string& key, const
132 // std::string& value
133 // Return: bool
134 struct device_iot_config_set_str {
135   bool return_value{false};
136   std::function<bool(const std::string& section, const std::string& key, const std::string& value)>
137           body{[this](const std::string& /* section */, const std::string& /* key */,
138                       const std::string& /* value */) { return return_value; }};
operatordevice_iot_config_set_str139   bool operator()(const std::string& section, const std::string& key, const std::string& value) {
140     return body(section, key, value);
141   }
142 };
143 extern struct device_iot_config_set_str device_iot_config_set_str;
144 
145 // Name: device_iot_config_get_bin
146 // Params: const std::string& section, const std::string& key, uint8_t* value,
147 // size_t* length
148 // Return: bool
149 struct device_iot_config_get_bin {
150   bool return_value{false};
151   std::function<bool(const std::string& section, const std::string& key, uint8_t* value,
152                      size_t* length)>
153           body{[this](const std::string& /* section */, const std::string& /* key */,
154                       uint8_t* /* value */, size_t* /* length */) { return return_value; }};
operatordevice_iot_config_get_bin155   bool operator()(const std::string& section, const std::string& key, uint8_t* value,
156                   size_t* length) {
157     return body(section, key, value, length);
158   }
159 };
160 extern struct device_iot_config_get_bin device_iot_config_get_bin;
161 
162 // Name: device_iot_config_set_bin
163 // Params: const std::string& section, const std::string& key, const uint8_t*
164 // value, size_t length
165 // Return: bool
166 struct device_iot_config_set_bin {
167   bool return_value{false};
168   std::function<bool(const std::string& section, const std::string& key, const uint8_t* value,
169                      size_t length)>
170           body{[this](const std::string& /* section */, const std::string& /* key */,
171                       const uint8_t* /* value */, size_t /* length */) { return return_value; }};
operatordevice_iot_config_set_bin172   bool operator()(const std::string& section, const std::string& key, const uint8_t* value,
173                   size_t length) {
174     return body(section, key, value, length);
175   }
176 };
177 extern struct device_iot_config_set_bin device_iot_config_set_bin;
178 
179 // Name: device_iot_config_get_bin_length
180 // Params: const std::string& section, const std::string& key
181 // Return: size_t
182 struct device_iot_config_get_bin_length {
183   size_t return_value{0};
184   std::function<size_t(const std::string& section, const std::string& key)> body{
185           [this](const std::string& /* section */, const std::string& /* key */) {
186             return return_value;
187           }};
operatordevice_iot_config_get_bin_length188   size_t operator()(const std::string& section, const std::string& key) {
189     return body(section, key);
190   }
191 };
192 extern struct device_iot_config_get_bin_length device_iot_config_get_bin_length;
193 
194 // Name: device_iot_config_has_section
195 // Params: const std::string& section
196 // Return: bool
197 struct device_iot_config_has_section {
198   bool return_value{false};
199   std::function<bool(const std::string& section)> body{
200           [this](const std::string& /* section */) { return return_value; }};
operatordevice_iot_config_has_section201   bool operator()(const std::string& section) { return body(section); }
202 };
203 extern struct device_iot_config_has_section device_iot_config_has_section;
204 
205 // Name: device_iot_config_exist
206 // Params: const std::string& section, const std::string& key
207 // Return: bool
208 struct device_iot_config_exist {
209   bool return_value{false};
210   std::function<bool(const std::string& section, const std::string& key)> body{
211           [this](const std::string& /* section */, const std::string& /* key */) {
212             return return_value;
213           }};
operatordevice_iot_config_exist214   bool operator()(const std::string& section, const std::string& key) { return body(section, key); }
215 };
216 extern struct device_iot_config_exist device_iot_config_exist;
217 
218 // Name: device_iot_config_remove
219 // Params: const std::string& section, const std::string& key
220 // Return: bool
221 struct device_iot_config_remove {
222   bool return_value{false};
223   std::function<bool(const std::string& section, const std::string& key)> body{
224           [this](const std::string& /* section */, const std::string& /* key */) {
225             return return_value;
226           }};
operatordevice_iot_config_remove227   bool operator()(const std::string& section, const std::string& key) { return body(section, key); }
228 };
229 extern struct device_iot_config_remove device_iot_config_remove;
230 
231 // Name: device_iot_config_clear
232 // Params: void
233 // Return: bool
234 struct device_iot_config_clear {
235   bool return_value{false};
236   std::function<bool(void)> body{[this]() { return return_value; }};
operatordevice_iot_config_clear237   bool operator()(void) { return body(); }
238 };
239 extern struct device_iot_config_clear device_iot_config_clear;
240 
241 // Name: device_iot_config_flush
242 // Params: void
243 // Return: void
244 struct device_iot_config_flush {
245   std::function<void(void)> body{[]() {}};
operatordevice_iot_config_flush246   void operator()(void) { body(); }
247 };
248 extern struct device_iot_config_flush device_iot_config_flush;
249 
250 // Name: device_debug_iot_config_dump
251 // Params: int fd
252 // Return: void
253 struct device_debug_iot_config_dump {
254   std::function<void(int fd)> body{[](int /* fd */) {}};
operatordevice_debug_iot_config_dump255   void operator()(int fd) { body(fd); }
256 };
257 extern struct device_debug_iot_config_dump device_debug_iot_config_dump;
258 
259 }  // namespace device_iot_config
260 }  // namespace mock
261 }  // namespace test
262