1 /*
2  * Copyright (c) 2023 Codecoup
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <zephyr/types.h>
8 #include <zephyr/bluetooth/audio/pacs.h>
9 
10 #include "pacs.h"
11 
12 /* List of fakes used by this unit tester */
13 #define PACS_FFF_FAKES_LIST(FAKE) \
14 	FAKE(bt_pacs_cap_foreach) \
15 	FAKE(bt_pacs_get_available_contexts_for_conn) \
16 
17 static const struct bt_audio_codec_cap lc3_codec = BT_AUDIO_CODEC_CAP_LC3(
18 	BT_AUDIO_CODEC_CAP_FREQ_ANY, BT_AUDIO_CODEC_CAP_DURATION_10,
19 	BT_AUDIO_CODEC_CAP_CHAN_COUNT_SUPPORT(1), 40u, 120u, 1u,
20 	(BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL | BT_AUDIO_CONTEXT_TYPE_MEDIA));
21 
22 DEFINE_FAKE_VOID_FUNC(bt_pacs_cap_foreach, enum bt_audio_dir, bt_pacs_cap_foreach_func_t, void *);
23 DEFINE_FAKE_VALUE_FUNC(enum bt_audio_context, bt_pacs_get_available_contexts_for_conn,
24 		       struct bt_conn *, enum bt_audio_dir);
25 
pacs_cap_foreach_custom_fake(enum bt_audio_dir dir,bt_pacs_cap_foreach_func_t func,void * user_data)26 static void pacs_cap_foreach_custom_fake(enum bt_audio_dir dir, bt_pacs_cap_foreach_func_t func,
27 					 void *user_data)
28 {
29 	static const struct bt_pacs_cap cap[] = {
30 		{
31 			&lc3_codec,
32 		},
33 	};
34 
35 	for (size_t i = 0; i < ARRAY_SIZE(cap); i++) {
36 		if (func(&cap[i], user_data) == false) {
37 			break;
38 		}
39 	}
40 }
41 
mock_bt_pacs_init(void)42 void mock_bt_pacs_init(void)
43 {
44 	PACS_FFF_FAKES_LIST(RESET_FAKE);
45 	bt_pacs_cap_foreach_fake.custom_fake = pacs_cap_foreach_custom_fake;
46 }
47 
mock_bt_pacs_cleanup(void)48 void mock_bt_pacs_cleanup(void)
49 {
50 
51 }
52