1 /*
2  * Copyright (c) 2023 Codecoup
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 #include <stdint.h>
7 
8 #include <zephyr/bluetooth/audio/bap.h>
9 #include <zephyr/bluetooth/iso.h>
10 #include <zephyr/fff.h>
11 #include <zephyr/net_buf.h>
12 
13 #include "bap_stream.h"
14 
15 /* List of fakes used by this unit tester */
16 #define FFF_FAKES_LIST(FAKE)                                                                       \
17 	FAKE(mock_bap_stream_configured_cb)                                                        \
18 	FAKE(mock_bap_stream_qos_set_cb)                                                           \
19 	FAKE(mock_bap_stream_enabled_cb)                                                           \
20 	FAKE(mock_bap_stream_metadata_updated_cb)                                                  \
21 	FAKE(mock_bap_stream_disabled_cb)                                                          \
22 	FAKE(mock_bap_stream_released_cb)                                                          \
23 	FAKE(mock_bap_stream_started_cb)                                                           \
24 	FAKE(mock_bap_stream_stopped_cb)                                                           \
25 	FAKE(mock_bap_stream_recv_cb)                                                              \
26 	FAKE(mock_bap_stream_sent_cb)                                                              \
27 	FAKE(mock_bap_stream_connected_cb)                                                         \
28 	FAKE(mock_bap_stream_disconnected_cb)
29 
30 struct bt_bap_stream_ops mock_bap_stream_ops;
31 
32 DEFINE_FAKE_VOID_FUNC(mock_bap_stream_configured_cb, struct bt_bap_stream *,
33 		      const struct bt_bap_qos_cfg_pref *);
34 DEFINE_FAKE_VOID_FUNC(mock_bap_stream_qos_set_cb, struct bt_bap_stream *);
35 DEFINE_FAKE_VOID_FUNC(mock_bap_stream_enabled_cb, struct bt_bap_stream *);
36 DEFINE_FAKE_VOID_FUNC(mock_bap_stream_metadata_updated_cb, struct bt_bap_stream *);
37 DEFINE_FAKE_VOID_FUNC(mock_bap_stream_disabled_cb, struct bt_bap_stream *);
38 DEFINE_FAKE_VOID_FUNC(mock_bap_stream_released_cb, struct bt_bap_stream *);
39 DEFINE_FAKE_VOID_FUNC(mock_bap_stream_started_cb, struct bt_bap_stream *);
40 DEFINE_FAKE_VOID_FUNC(mock_bap_stream_stopped_cb, struct bt_bap_stream *, uint8_t);
41 DEFINE_FAKE_VOID_FUNC(mock_bap_stream_recv_cb, struct bt_bap_stream *,
42 		      const struct bt_iso_recv_info *, struct net_buf *);
43 DEFINE_FAKE_VOID_FUNC(mock_bap_stream_sent_cb, struct bt_bap_stream *);
44 DEFINE_FAKE_VOID_FUNC(mock_bap_stream_connected_cb, struct bt_bap_stream *);
45 DEFINE_FAKE_VOID_FUNC(mock_bap_stream_disconnected_cb, struct bt_bap_stream *, uint8_t);
46 
mock_bap_stream_init(void)47 void mock_bap_stream_init(void)
48 {
49 	FFF_FAKES_LIST(RESET_FAKE);
50 
51 #if defined(CONFIG_BT_BAP_UNICAST)
52 	mock_bap_stream_ops.configured = mock_bap_stream_configured_cb;
53 	mock_bap_stream_ops.qos_set = mock_bap_stream_qos_set_cb;
54 	mock_bap_stream_ops.enabled = mock_bap_stream_enabled_cb;
55 	mock_bap_stream_ops.metadata_updated = mock_bap_stream_metadata_updated_cb;
56 	mock_bap_stream_ops.disabled = mock_bap_stream_disabled_cb;
57 	mock_bap_stream_ops.released = mock_bap_stream_released_cb;
58 #endif /* CONFIG_BT_BAP_UNICAST */
59 	mock_bap_stream_ops.started = mock_bap_stream_started_cb;
60 	mock_bap_stream_ops.stopped = mock_bap_stream_stopped_cb;
61 #if defined(CONFIG_BT_AUDIO_RX)
62 	mock_bap_stream_ops.recv = mock_bap_stream_recv_cb;
63 #endif /* CONFIG_BT_AUDIO_RX */
64 #if defined(CONFIG_BT_AUDIO_TX)
65 	mock_bap_stream_ops.sent = mock_bap_stream_sent_cb;
66 #endif /* CONFIG_BT_AUDIO_TX */
67 	mock_bap_stream_ops.connected = mock_bap_stream_connected_cb;
68 	mock_bap_stream_ops.disconnected = mock_bap_stream_disconnected_cb;
69 }
70 
mock_bap_stream_cleanup(void)71 void mock_bap_stream_cleanup(void)
72 {
73 
74 }
75