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