1 /*
2  * Copyright (c) 2023 Codecoup
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef MOCKS_BAP_UNICAST_SERVER_EXPECTS_H_
8 #define MOCKS_BAP_UNICAST_SERVER_EXPECTS_H_
9 
10 #include <zephyr/bluetooth/audio/bap.h>
11 #include <zephyr/ztest_assert.h>
12 
13 #include "bap_unicast_server.h"
14 #include "expects_util.h"
15 
16 #define expect_bt_bap_unicast_server_cb_config_called_once(_conn, _ep, _dir, _codec)               \
17 do {                                                                                               \
18 	const char *func_name = "bt_bap_unicast_server_cb.config";                                 \
19 												   \
20 	zexpect_call_count(func_name, 1, mock_bap_unicast_server_cb_config_fake.call_count);       \
21 												   \
22 	IF_NOT_EMPTY(_conn, (                                                                      \
23 		     zassert_equal_ptr(_conn, mock_bap_unicast_server_cb_config_fake.arg0_val,     \
24 				       "'%s()' was called with incorrect '%s' value",              \
25 				       func_name, "conn");))                                       \
26 												   \
27 	IF_NOT_EMPTY(_ep, (                                                                        \
28 		     zassert_equal_ptr(_ep, mock_bap_unicast_server_cb_config_fake.arg1_val,       \
29 				       "'%s()' was called with incorrect '%s' value",              \
30 				       func_name, "ep");))                                         \
31 												   \
32 	IF_NOT_EMPTY(_dir, (                                                                       \
33 		     zassert_equal(_dir, mock_bap_unicast_server_cb_config_fake.arg2_val,          \
34 				       "'%s()' was called with incorrect '%s' value",              \
35 				       func_name, "_dir");))                                       \
36 												   \
37 	IF_NOT_EMPTY(_codec, (                                                                     \
38 		     /* TODO */                                                                    \
39 		     zassert_unreachable("Not implemented");))                                     \
40 } while (0)
41 
42 #define expect_bt_bap_unicast_server_cb_reconfig_called_once(_stream, _dir, _codec)                \
43 do {                                                                                               \
44 	const char *func_name = "bt_bap_unicast_server_cb.reconfig";                               \
45 												   \
46 	zexpect_call_count(func_name, 1, mock_bap_unicast_server_cb_reconfig_fake.call_count);     \
47 												   \
48 	IF_NOT_EMPTY(_stream, (                                                                    \
49 		     zassert_equal_ptr(_stream, mock_bap_unicast_server_cb_reconfig_fake.arg0_val, \
50 				       "'%s()' was called with incorrect '%s' value",              \
51 				       func_name, "stream");))                                     \
52 												   \
53 	IF_NOT_EMPTY(_dir, (                                                                       \
54 		     zassert_equal(_dir, mock_bap_unicast_server_cb_reconfig_fake.arg1_val,        \
55 				   "'%s()' was called with incorrect '%s' value",                  \
56 				   func_name, "_dir");))                                           \
57 												   \
58 	IF_NOT_EMPTY(_codec, (                                                                     \
59 		     /* TODO */                                                                    \
60 		     zassert_unreachable("Not implemented");))                                     \
61 } while (0)
62 
63 #define expect_bt_bap_unicast_server_cb_qos_called_once(_stream, _qos)                             \
64 do {                                                                                               \
65 	const char *func_name = "bt_bap_unicast_server_cb.qos";                                    \
66 												   \
67 	zexpect_call_count(func_name, 1, mock_bap_unicast_server_cb_qos_fake.call_count);          \
68 												   \
69 	IF_NOT_EMPTY(_stream, (                                                                    \
70 		     zassert_equal_ptr(_stream, mock_bap_unicast_server_cb_qos_fake.arg0_val,      \
71 				       "'%s()' was called with incorrect '%s' value",              \
72 				       func_name, "stream");))                                     \
73 												   \
74 	IF_NOT_EMPTY(_qos, (                                                                       \
75 		     /* TODO */                                                                    \
76 		     zassert_unreachable("Not implemented");))                                     \
77 } while (0)
78 
79 #define expect_bt_bap_unicast_server_cb_enable_called_once(_stream, _meta, _meta_len)            \
80 do {                                                                                               \
81 	const char *func_name = "bt_bap_unicast_server_cb.enable";                                 \
82 												   \
83 	zexpect_call_count(func_name, 1, mock_bap_unicast_server_cb_enable_fake.call_count);       \
84 												   \
85 	IF_NOT_EMPTY(_stream, (                                                                    \
86 		     zassert_equal_ptr(_stream, mock_bap_unicast_server_cb_enable_fake.arg0_val,   \
87 				       "'%s()' was called with incorrect '%s' value",              \
88 				       func_name, "stream");))                                     \
89 												   \
90 	IF_NOT_EMPTY(_meta, (                                                                      \
91 		     /* TODO */                                                                    \
92 		     zassert_unreachable("Not implemented");))                                     \
93 												   \
94 	IF_NOT_EMPTY(_meta_len, (                                                                \
95 		     /* TODO */                                                                    \
96 		     zassert_unreachable("Not implemented");))                                     \
97 } while (0)
98 
99 #define expect_bt_bap_unicast_server_cb_metadata_called_once(_stream, _meta, _meta_len)          \
100 do {                                                                                               \
101 	const char *func_name = "bt_bap_unicast_server_cb.enable";                                 \
102 												   \
103 	zexpect_call_count(func_name, 1, mock_bap_unicast_server_cb_metadata_fake.call_count);     \
104 												   \
105 	IF_NOT_EMPTY(_stream, (                                                                    \
106 		     zassert_equal_ptr(_stream, mock_bap_unicast_server_cb_metadata_fake.arg0_val, \
107 				       "'%s()' was called with incorrect '%s' value",              \
108 				       func_name, "stream");))                                     \
109 												   \
110 	IF_NOT_EMPTY(_meta, (                                                                      \
111 		     /* TODO */                                                                    \
112 		     zassert_unreachable("Not implemented");))                                     \
113 												   \
114 	IF_NOT_EMPTY(_meta_len, (                                                                \
115 		     /* TODO */                                                                    \
116 		     zassert_unreachable("Not implemented");))                                     \
117 } while (0)
118 
119 #define expect_bt_bap_unicast_server_cb_disable_called_once(_stream)                               \
120 do {                                                                                               \
121 	const char *func_name = "bt_bap_unicast_server_cb.disable";                                \
122 												   \
123 	zexpect_call_count(func_name, 1, mock_bap_unicast_server_cb_disable_fake.call_count);      \
124 												   \
125 	IF_NOT_EMPTY(_stream, (                                                                    \
126 		     zassert_equal_ptr(_stream, mock_bap_unicast_server_cb_disable_fake.arg0_val,  \
127 				       "'%s()' was called with incorrect '%s' value",              \
128 				       func_name, "stream");))                                     \
129 } while (0)
130 
131 #define expect_bt_bap_unicast_server_cb_release_called_once(_stream)                               \
132 do {                                                                                               \
133 	const char *func_name = "bt_bap_unicast_server_cb.release";                                \
134 												   \
135 	zexpect_call_count(func_name, 1, mock_bap_unicast_server_cb_release_fake.call_count);      \
136 												   \
137 	IF_NOT_EMPTY(_stream, (                                                                    \
138 		     zassert_equal_ptr(_stream, mock_bap_unicast_server_cb_release_fake.arg0_val,  \
139 				       "'%s()' was called with incorrect '%s' value",              \
140 				       func_name, "stream");))                                     \
141 } while (0)
142 
143 #define expect_bt_bap_unicast_server_cb_release_called_twice(_streams)                             \
144 do {                                                                                               \
145 	const char *func_name = "bt_bap_unicast_server_cb.release";                                \
146 												   \
147 	zexpect_call_count(func_name, 2, mock_bap_unicast_server_cb_release_fake.call_count);      \
148 												   \
149 	IF_NOT_EMPTY(_stream[0], (                                                                 \
150 		     zassert_equal_ptr(_streams[0],                                                \
151 				       mock_bap_unicast_server_cb_release_fake.arg0_history[0],    \
152 				       "'%s()' was called with incorrect '%s' value",              \
153 				       func_name, "stream[0]");))                                  \
154 	IF_NOT_EMPTY(_stream[1], (                                                                 \
155 		     zassert_equal_ptr(_streams[1],                                                \
156 				       mock_bap_unicast_server_cb_release_fake.arg0_history[1],    \
157 				       "'%s()' was called with incorrect '%s' value",              \
158 				       func_name, "stream[1]");))                                  \
159 } while (0)
160 
161 #define expect_bt_bap_unicast_server_cb_start_called_once(_stream)                                 \
162 do {                                                                                               \
163 	const char *func_name = "bt_bap_unicast_server_cb.start";                                  \
164 												   \
165 	zexpect_call_count(func_name, 1, mock_bap_unicast_server_cb_start_fake.call_count);        \
166 												   \
167 	IF_NOT_EMPTY(_stream, (                                                                    \
168 		     zassert_equal_ptr(_stream, mock_bap_unicast_server_cb_start_fake.arg0_val,    \
169 				       "'%s()' was called with incorrect '%s' value",              \
170 				       func_name, "stream");))                                     \
171 } while (0)
172 
173 #define expect_bt_bap_unicast_server_cb_stop_called_once(_stream)                                  \
174 do {                                                                                               \
175 	const char *func_name = "bt_bap_unicast_server_cb.stop";                                   \
176 												   \
177 	zexpect_call_count(func_name, 1, mock_bap_unicast_server_cb_stop_fake.call_count);         \
178 												   \
179 	IF_NOT_EMPTY(_stream, (                                                                    \
180 		     zassert_equal_ptr(_stream, mock_bap_unicast_server_cb_stop_fake.arg0_val,     \
181 				       "'%s()' was called with incorrect '%s' value",              \
182 				       func_name, "stream");))                                     \
183 } while (0)
184 
expect_bt_bap_unicast_server_cb_config_not_called(void)185 static inline void expect_bt_bap_unicast_server_cb_config_not_called(void)
186 {
187 	const char *func_name = "bt_bap_unicast_server_cb.config";
188 
189 	zexpect_call_count(func_name, 0, mock_bap_unicast_server_cb_config_fake.call_count);
190 }
191 
192 #endif /* MOCKS_BAP_UNICAST_SERVER_EXPECTS_H_ */
193