1 /*
2  * Copyright 2020 HIMSA II K/S - www.himsa.com.
3  * Represented by EHIMA - www.ehima.com
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 #pragma once
18 
19 #include <base/functional/callback.h>
20 #include <gmock/gmock.h>
21 
22 #include <vector>
23 
24 #include "btm_iso_api_types.h"
25 
26 namespace hcic {
27 class HcicInterface {
28  public:
29   // iso_manager::cig_create_params is a workaround for the 10 params function
30   // limitation that gmock sets
31   virtual void SetCigParams(
32       uint8_t cig_id,
33       struct bluetooth::hci::iso_manager::cig_create_params cig_params,
34       base::OnceCallback<void(uint8_t*, uint16_t)> cb) = 0;
35 
36   virtual void RemoveCig(uint8_t cig_id,
37                          base::OnceCallback<void(uint8_t*, uint16_t)> cb) = 0;
38 
39   virtual void CreateCis(uint8_t num_cis,
40                          const EXT_CIS_CREATE_CFG* cis_create_cfg,
41                          base::OnceCallback<void(uint8_t*, uint16_t)> cb) = 0;
42 
43   virtual void Disconnect(uint16_t handle, uint8_t reason) = 0;
44 
45   virtual void SetupIsoDataPath(
46       uint16_t iso_handle, uint8_t data_path_dir, uint8_t data_path_id,
47       uint8_t codec_id_format, uint16_t codec_id_company,
48       uint16_t codec_id_vendor, uint32_t controller_delay,
49       std::vector<uint8_t> codec_conf,
50       base::OnceCallback<void(uint8_t*, uint16_t)> cb) = 0;
51 
52   virtual void RemoveIsoDataPath(
53       uint16_t iso_handle, uint8_t data_path_dir,
54       base::OnceCallback<void(uint8_t*, uint16_t)> cb) = 0;
55 
56   virtual void ReadIsoLinkQuality(
57       uint16_t iso_handle, base::OnceCallback<void(uint8_t*, uint16_t)> cb) = 0;
58 
59   // iso_manager::big_create_params is a workaround for the 10 params function
60   // limitation that gmock sets
61   virtual void CreateBig(
62       uint8_t big_handle,
63       struct bluetooth::hci::iso_manager::big_create_params big_params) = 0;
64 
65   virtual void TerminateBig(uint8_t big_handle, uint8_t reason) = 0;
66 
67   virtual ~HcicInterface() = default;
68 };
69 
70 class MockHcicInterface : public HcicInterface {
71  public:
72   MOCK_METHOD((void), SetCigParams,
73               (uint8_t cig_id,
74                struct bluetooth::hci::iso_manager::cig_create_params cig_params,
75                base::OnceCallback<void(uint8_t*, uint16_t)> cb),
76               (override));
77 
78   MOCK_METHOD((void), RemoveCig,
79               (uint8_t cig_id, base::OnceCallback<void(uint8_t*, uint16_t)> cb),
80               (override));
81 
82   MOCK_METHOD((void), CreateCis,
83               (uint8_t num_cis, const EXT_CIS_CREATE_CFG* cis_create_cfg,
84                base::OnceCallback<void(uint8_t*, uint16_t)> cb),
85               (override));
86 
87   MOCK_METHOD((void), Disconnect, (uint16_t handle, uint8_t reason),
88               (override));
89 
90   MOCK_METHOD((void), SetupIsoDataPath,
91               (uint16_t iso_handle, uint8_t data_path_dir, uint8_t data_path_id,
92                uint8_t codec_id_format, uint16_t codec_id_company,
93                uint16_t codec_id_vendor, uint32_t controller_delay,
94                std::vector<uint8_t> codec_conf,
95                base::OnceCallback<void(uint8_t*, uint16_t)> cb),
96               (override));
97 
98   MOCK_METHOD((void), RemoveIsoDataPath,
99               (uint16_t iso_handle, uint8_t data_path_dir,
100                base::OnceCallback<void(uint8_t*, uint16_t)> cb),
101               (override));
102 
103   MOCK_METHOD((void), ReadIsoLinkQuality,
104               (uint16_t iso_handle,
105                base::OnceCallback<void(uint8_t*, uint16_t)> cb),
106               (override));
107 
108   MOCK_METHOD(
109       (void), CreateBig,
110       (uint8_t big_handle,
111        struct bluetooth::hci::iso_manager::big_create_params big_params),
112       (override));
113 
114   MOCK_METHOD((void), TerminateBig, (uint8_t big_handle, uint8_t reason),
115               (override));
116 };
117 
118 void SetMockHcicInterface(MockHcicInterface* mock_hcic_interface);
119 
120 }  // namespace hcic
121