1 /****************************************************************************** 2 * 3 * Copyright 2018 The Android Open Source Project 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 ******************************************************************************/ 18 #pragma once 19 20 #include <gmock/gmock.h> 21 22 #include "l2c_api.h" 23 24 namespace bluetooth { 25 namespace l2cap { 26 27 class L2capInterface { 28 public: 29 virtual uint16_t Register(uint16_t psm, tL2CAP_APPL_INFO* p_cb_info) = 0; 30 virtual uint16_t ConnectRequest(uint16_t psm, const RawAddress& bd_addr) = 0; 31 virtual bool ConnectResponse(const RawAddress& bd_addr, uint8_t id, 32 uint16_t lcid, uint16_t result, 33 uint16_t status) = 0; 34 virtual bool DisconnectRequest(uint16_t cid) = 0; 35 virtual bool DisconnectResponse(uint16_t cid) = 0; 36 virtual bool ConfigRequest(uint16_t cid, tL2CAP_CFG_INFO* p_cfg) = 0; 37 virtual bool ConfigResponse(uint16_t cid, tL2CAP_CFG_INFO* p_cfg) = 0; 38 virtual uint8_t DataWrite(uint16_t cid, BT_HDR* p_data) = 0; 39 virtual ~L2capInterface() = default; 40 }; 41 42 class MockL2capInterface : public L2capInterface { 43 public: 44 MOCK_METHOD2(Register, uint16_t(uint16_t psm, tL2CAP_APPL_INFO* p_cb_info)); 45 MOCK_METHOD2(ConnectRequest, 46 uint16_t(uint16_t psm, const RawAddress& bd_addr)); 47 MOCK_METHOD5(ConnectResponse, 48 bool(const RawAddress& bd_addr, uint8_t id, uint16_t lcid, 49 uint16_t result, uint16_t status)); 50 MOCK_METHOD1(DisconnectRequest, bool(uint16_t cid)); 51 MOCK_METHOD1(DisconnectResponse, bool(uint16_t cid)); 52 MOCK_METHOD2(ConfigRequest, bool(uint16_t cid, tL2CAP_CFG_INFO* p_cfg)); 53 MOCK_METHOD2(ConfigResponse, bool(uint16_t cid, tL2CAP_CFG_INFO* p_cfg)); 54 MOCK_METHOD2(DataWrite, uint8_t(uint16_t cid, BT_HDR* p_data)); 55 }; 56 57 /** 58 * Set the {@link MockL2capInterface} for testing 59 * 60 * @param mock_l2cap_interface pointer to mock l2cap interface, could be null 61 */ 62 void SetMockInterface(MockL2capInterface* mock_l2cap_interface); 63 64 } // namespace l2cap 65 } // namespace bluetooth 66