1 /*
2  * Copyright (c) 2022 Nordic Semiconductor ASA
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include "mocks/hci_core.h"
8 #include "mocks/hci_core_expects.h"
9 
10 #include <zephyr/bluetooth/buf.h>
11 #include <zephyr/kernel.h>
12 
expect_single_call_bt_unpair(uint8_t id,const bt_addr_le_t * addr)13 void expect_single_call_bt_unpair(uint8_t id, const bt_addr_le_t *addr)
14 {
15 	const char *func_name = "bt_unpair";
16 
17 	zassert_equal(bt_unpair_fake.call_count, 1, "'%s()' was called more than once", func_name);
18 
19 	zassert_equal(bt_unpair_fake.arg0_val, id, "'%s()' was called with incorrect '%s' value",
20 		      func_name, "id");
21 
22 	if (addr) {
23 		zassert_mem_equal(bt_unpair_fake.arg1_val, addr, sizeof(bt_addr_le_t),
24 				  "'%s()' was called with incorrect '%s' value", func_name, "addr");
25 	} else {
26 		zassert_equal(bt_unpair_fake.arg1_val, addr,
27 			      "'%s()' was called with incorrect '%s' value", func_name, "addr");
28 	}
29 }
30 
expect_not_called_bt_unpair(void)31 void expect_not_called_bt_unpair(void)
32 {
33 	const char *func_name = "bt_unpair";
34 
35 	zassert_equal(bt_unpair_fake.call_count, 0, "'%s()' was called unexpectedly", func_name);
36 }
37 
expect_single_call_bt_hci_cmd_create(uint16_t opcode,uint8_t param_len)38 void expect_single_call_bt_hci_cmd_create(uint16_t opcode, uint8_t param_len)
39 {
40 	const char *func_name = "bt_hci_cmd_create";
41 
42 	zassert_equal(bt_hci_cmd_create_fake.call_count, 1, "'%s()' was called more than once",
43 		      func_name);
44 
45 	zassert_equal(bt_hci_cmd_create_fake.arg0_val, opcode,
46 		      "'%s()' was called with incorrect '%s' value", func_name, "opcode");
47 	zassert_equal(bt_hci_cmd_create_fake.arg1_val, param_len,
48 		      "'%s()' was called with incorrect '%s' value", func_name, "param_len");
49 }
50 
expect_not_called_bt_hci_cmd_create(void)51 void expect_not_called_bt_hci_cmd_create(void)
52 {
53 	const char *func_name = "bt_hci_cmd_create";
54 
55 	zassert_equal(bt_hci_cmd_create_fake.call_count, 0, "'%s()' was called unexpectedly",
56 		      func_name);
57 }
58 
expect_single_call_bt_hci_cmd_send_sync(uint16_t opcode)59 void expect_single_call_bt_hci_cmd_send_sync(uint16_t opcode)
60 {
61 	const char *func_name = "bt_hci_cmd_send_sync";
62 
63 	zassert_equal(bt_hci_cmd_send_sync_fake.call_count, 1, "'%s()' was called more than once",
64 		      func_name);
65 
66 	zassert_equal(bt_hci_cmd_send_sync_fake.arg0_val, opcode,
67 		      "'%s()' was called with incorrect '%s' value", func_name, "opcode");
68 }
69 
expect_not_called_bt_hci_cmd_send_sync(void)70 void expect_not_called_bt_hci_cmd_send_sync(void)
71 {
72 	const char *func_name = "bt_hci_cmd_send_sync";
73 
74 	zassert_equal(bt_hci_cmd_send_sync_fake.call_count, 0, "'%s()' was called unexpectedly",
75 		      func_name);
76 }
77