tests: Bluetooth: ascs: Set pacs_cap_foreach_custom_fake as default mock
This moves pacs_cap_foreach_custom_fake to mocks to be default mock. Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This commit is contained in:
parent
4b5be77531
commit
6fec930c09
@ -35,37 +35,14 @@
|
||||
|
||||
DEFINE_FFF_GLOBALS;
|
||||
|
||||
static struct bt_codec lc3_codec =
|
||||
BT_CODEC_LC3(BT_CODEC_LC3_FREQ_ANY, BT_CODEC_LC3_DURATION_10,
|
||||
BT_CODEC_LC3_CHAN_COUNT_SUPPORT(1), 40u, 120u, 1u,
|
||||
(BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL | BT_AUDIO_CONTEXT_TYPE_MEDIA));
|
||||
|
||||
static void pacs_cap_foreach_custom_fake(enum bt_audio_dir dir, bt_pacs_cap_foreach_func_t func,
|
||||
void *user_data)
|
||||
{
|
||||
static const struct bt_pacs_cap cap[] = {
|
||||
{
|
||||
&lc3_codec,
|
||||
},
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < ARRAY_SIZE(cap); i++) {
|
||||
if (func(&cap[i], user_data) == false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void mock_init_rule_before(const struct ztest_unit_test *test, void *fixture)
|
||||
{
|
||||
mock_bap_unicast_server_init();
|
||||
mock_bt_iso_init();
|
||||
mock_kernel_init();
|
||||
PACS_FFF_FAKES_LIST(RESET_FAKE);
|
||||
mock_bt_pacs_init();
|
||||
mock_bap_stream_init();
|
||||
mock_bt_gatt_init();
|
||||
|
||||
bt_pacs_cap_foreach_fake.custom_fake = pacs_cap_foreach_custom_fake;
|
||||
}
|
||||
|
||||
static void mock_destroy_rule_after(const struct ztest_unit_test *test, void *fixture)
|
||||
@ -73,6 +50,7 @@ static void mock_destroy_rule_after(const struct ztest_unit_test *test, void *fi
|
||||
mock_bap_unicast_server_cleanup();
|
||||
mock_bt_iso_cleanup();
|
||||
mock_kernel_cleanup();
|
||||
mock_bt_pacs_cleanup();
|
||||
mock_bap_stream_cleanup();
|
||||
mock_bt_gatt_cleanup();
|
||||
}
|
||||
|
||||
@ -10,9 +10,8 @@
|
||||
#include <zephyr/fff.h>
|
||||
#include <zephyr/bluetooth/audio/pacs.h>
|
||||
|
||||
/* List of fakes used by this unit tester */
|
||||
#define PACS_FFF_FAKES_LIST(FAKE) \
|
||||
FAKE(bt_pacs_cap_foreach) \
|
||||
void mock_bt_pacs_init(void);
|
||||
void mock_bt_pacs_cleanup(void);
|
||||
|
||||
DECLARE_FAKE_VOID_FUNC(bt_pacs_cap_foreach, enum bt_audio_dir, bt_pacs_cap_foreach_func_t, void *);
|
||||
|
||||
|
||||
@ -4,8 +4,45 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr/types.h>
|
||||
#include <zephyr/bluetooth/audio/pacs.h>
|
||||
|
||||
#include "pacs.h"
|
||||
|
||||
/* List of fakes used by this unit tester */
|
||||
#define PACS_FFF_FAKES_LIST(FAKE) \
|
||||
FAKE(bt_pacs_cap_foreach) \
|
||||
|
||||
static struct bt_codec lc3_codec =
|
||||
BT_CODEC_LC3(BT_CODEC_LC3_FREQ_ANY, BT_CODEC_LC3_DURATION_10,
|
||||
BT_CODEC_LC3_CHAN_COUNT_SUPPORT(1), 40u, 120u, 1u,
|
||||
(BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL | BT_AUDIO_CONTEXT_TYPE_MEDIA));
|
||||
|
||||
DEFINE_FAKE_VOID_FUNC(bt_pacs_cap_foreach, enum bt_audio_dir, bt_pacs_cap_foreach_func_t, void *);
|
||||
|
||||
static void pacs_cap_foreach_custom_fake(enum bt_audio_dir dir, bt_pacs_cap_foreach_func_t func,
|
||||
void *user_data)
|
||||
{
|
||||
static const struct bt_pacs_cap cap[] = {
|
||||
{
|
||||
&lc3_codec,
|
||||
},
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < ARRAY_SIZE(cap); i++) {
|
||||
if (func(&cap[i], user_data) == false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void mock_bt_pacs_init(void)
|
||||
{
|
||||
PACS_FFF_FAKES_LIST(RESET_FAKE);
|
||||
bt_pacs_cap_foreach_fake.custom_fake = pacs_cap_foreach_custom_fake;
|
||||
}
|
||||
|
||||
void mock_bt_pacs_cleanup(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user