1 /*
2  * Copyright 2020 HIMSA II K/S - www.himsa.dk.
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 <gmock/gmock.h>
20 
21 #include "types/bt_transport.h"
22 #include "types/raw_address.h"
23 
24 namespace bluetooth {
25 namespace manager {
26 
27 class BtmApiInterface {
28 public:
29   virtual bool SetSecurityLevel(bool is_originator, const char* p_name, uint8_t service_id,
30                                 uint16_t sec_level, uint16_t psm, uint32_t mx_proto_id,
31                                 uint32_t mx_chan_id) = 0;
32   virtual uint8_t acl_link_role(const RawAddress& remote_bd_addr, tBT_TRANSPORT transport) = 0;
33   virtual bool IsEncrypted(const RawAddress& remote_bd_addr, tBT_TRANSPORT transport) = 0;
34   virtual bool IsLinkKeyKnown(const RawAddress& remote_bd_addr, tBT_TRANSPORT transport) = 0;
35   virtual uint8_t ReadSecKeySize(const RawAddress& remote_bd_addr) = 0;
36   virtual ~BtmApiInterface() = default;
37 };
38 
39 class MockBtmApiInterface : public BtmApiInterface {
40 public:
41   MOCK_METHOD7(SetSecurityLevel,
42                bool(bool is_originator, const char* p_name, uint8_t service_id, uint16_t sec_level,
43                     uint16_t psm, uint32_t mx_proto_id, uint32_t mx_chan_id));
44   MOCK_METHOD2(acl_link_role, uint8_t(const RawAddress& remote_bd_addr, tBT_TRANSPORT transport));
45   MOCK_METHOD2(IsEncrypted, bool(const RawAddress& remote_bd_addr, tBT_TRANSPORT transport));
46   MOCK_METHOD2(IsLinkKeyKnown, bool(const RawAddress& remote_bd_addr, tBT_TRANSPORT transport));
47   MOCK_METHOD1(ReadSecKeySize, uint8_t(const RawAddress& remote_bd_addr));
48 };
49 
50 /**
51  * Set the {@link MockBtmApiInterface} for testing
52  *
53  * @param mock_btm_api_interface pointer to mock btm interface, could be null
54  */
55 void SetMockBtmApiInterface(MockBtmApiInterface* mock_btm_interface);
56 
57 }  // namespace manager
58 }  // namespace bluetooth
59