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,
30                                 uint8_t service_id, uint16_t sec_level,
31                                 uint16_t psm, uint32_t mx_proto_id,
32                                 uint32_t mx_chan_id) = 0;
33   virtual uint8_t acl_link_role(const RawAddress& remote_bd_addr,
34                                 tBT_TRANSPORT transport) = 0;
35   virtual bool IsEncrypted(const RawAddress& remote_bd_addr,
36                            tBT_TRANSPORT transport) = 0;
37   virtual bool IsLinkKeyKnown(const RawAddress& remote_bd_addr,
38                               tBT_TRANSPORT transport) = 0;
39   virtual uint8_t ReadSecKeySize(const RawAddress& remote_bd_addr) = 0;
40   virtual ~BtmApiInterface() = default;
41 };
42 
43 class MockBtmApiInterface : public BtmApiInterface {
44  public:
45   MOCK_METHOD7(SetSecurityLevel,
46                bool(bool is_originator, const char* p_name, uint8_t service_id,
47                     uint16_t sec_level, uint16_t psm, uint32_t mx_proto_id,
48                     uint32_t mx_chan_id));
49   MOCK_METHOD2(acl_link_role, uint8_t(const RawAddress& remote_bd_addr,
50                                       tBT_TRANSPORT transport));
51   MOCK_METHOD2(IsEncrypted,
52                bool(const RawAddress& remote_bd_addr, tBT_TRANSPORT transport));
53   MOCK_METHOD2(IsLinkKeyKnown,
54                bool(const RawAddress& remote_bd_addr, tBT_TRANSPORT transport));
55   MOCK_METHOD1(ReadSecKeySize, uint8_t(const RawAddress& remote_bd_addr));
56 };
57 
58 /**
59  * Set the {@link MockBtmApiInterface} for testing
60  *
61  * @param mock_btm_api_interface pointer to mock btm interface, could be null
62  */
63 void SetMockBtmApiInterface(MockBtmApiInterface* mock_btm_interface);
64 
65 }  // namespace manager
66 }  // namespace bluetooth
67