1 /* 2 * Copyright 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #pragma once 17 18 #include <gmock/gmock.h> 19 20 #include <cstdint> 21 22 #include "common/contextual_callback.h" 23 #include "hci/address.h" 24 #include "hci/hci_interface.h" 25 #include "hci/hci_packets.h" 26 #include "hci/inquiry_interface.h" 27 28 // Unit test interfaces 29 namespace bluetooth { 30 namespace hci { 31 namespace testing { 32 33 class MockHciLayer : public HciInterface { 34 public: 35 MOCK_METHOD(void, EnqueueCommand, 36 (std::unique_ptr<CommandBuilder>, 37 common::ContextualOnceCallback<void(CommandCompleteView)>), 38 (override)); 39 MOCK_METHOD(void, EnqueueCommand, 40 (std::unique_ptr<CommandBuilder>, 41 common::ContextualOnceCallback<void(CommandStatusView)>), 42 (override)); 43 MOCK_METHOD(void, EnqueueCommand, 44 (std::unique_ptr<CommandBuilder>, 45 common::ContextualOnceCallback<void(CommandStatusOrCompleteView)>), 46 (override)); 47 MOCK_METHOD((common::BidiQueueEnd<AclBuilder, AclView>*), GetAclQueueEnd, (), (override)); 48 MOCK_METHOD((common::BidiQueueEnd<ScoBuilder, ScoView>*), GetScoQueueEnd, (), (override)); 49 MOCK_METHOD((common::BidiQueueEnd<IsoBuilder, IsoView>*), GetIsoQueueEnd, (), (override)); 50 MOCK_METHOD((void), RegisterEventHandler, 51 (EventCode, common::ContextualCallback<void(EventView)>), (override)); 52 MOCK_METHOD((void), UnregisterEventHandler, (EventCode), (override)); 53 MOCK_METHOD((void), RegisterLeEventHandler, 54 (SubeventCode, common::ContextualCallback<void(LeMetaEventView)>), (override)); 55 MOCK_METHOD((void), UnregisterLeEventHandler, (SubeventCode), (override)); 56 MOCK_METHOD((void), RegisterVendorSpecificEventHandler, 57 (VseSubeventCode, common::ContextualCallback<void(VendorSpecificEventView)>), 58 (override)); 59 MOCK_METHOD((void), UnregisterVendorSpecificEventHandler, (VseSubeventCode), (override)); 60 MOCK_METHOD((void), RegisterDefaultVendorSpecificEventHandler, 61 (common::ContextualCallback<void(VendorSpecificEventView)>), (override)); 62 MOCK_METHOD((void), UnregisterDefaultVendorSpecificEventHandler, (), (override)); 63 MOCK_METHOD((SecurityInterface*), GetSecurityInterface, 64 (common::ContextualCallback<void(EventView)> event_handler), (override)); 65 66 MOCK_METHOD((void), RegisterForDisconnects, 67 (common::ContextualCallback<void(uint16_t, hci::ErrorCode)> on_disconnect)); 68 69 MOCK_METHOD((LeSecurityInterface*), GetLeSecurityInterface, 70 (common::ContextualCallback<void(LeMetaEventView)> event_handler), (override)); 71 72 MOCK_METHOD( 73 (AclConnectionInterface*), GetAclConnectionInterface, 74 (common::ContextualCallback<void(EventView)> event_handler, 75 common::ContextualCallback<void(uint16_t, hci::ErrorCode)> on_disconnect, 76 common::ContextualCallback<void(Address, ClassOfDevice)> on_connection_request, 77 common::ContextualCallback<void(hci::ErrorCode, uint16_t, uint8_t, uint16_t, uint16_t)> 78 on_read_remote_version_complete), 79 (override)); 80 MOCK_METHOD((void), PutAclConnectionInterface, (), (override)); 81 82 MOCK_METHOD( 83 (LeAclConnectionInterface*), GetLeAclConnectionInterface, 84 (common::ContextualCallback<void(LeMetaEventView)> event_handler, 85 common::ContextualCallback<void(uint16_t, hci::ErrorCode)> on_disconnect, 86 common::ContextualCallback<void(hci::ErrorCode, uint16_t, uint8_t, uint16_t, uint16_t)> 87 on_read_remote_version_complete), 88 (override)); 89 MOCK_METHOD((void), PutLeAclConnectionInterface, (), (override)); 90 91 MOCK_METHOD((LeAdvertisingInterface*), GetLeAdvertisingInterface, 92 (common::ContextualCallback<void(LeMetaEventView)> event_handler), (override)); 93 94 MOCK_METHOD((LeScanningInterface*), GetLeScanningInterface, 95 (common::ContextualCallback<void(LeMetaEventView)> event_handler), (override)); 96 97 MOCK_METHOD((LeIsoInterface*), GetLeIsoInterface, 98 (common::ContextualCallback<void(LeMetaEventView)> event_handler), (override)); 99 100 MOCK_METHOD((DistanceMeasurementInterface*), GetDistanceMeasurementInterface, 101 (common::ContextualCallback<void(LeMetaEventView)> event_handler), (override)); 102 103 MOCK_METHOD((std::unique_ptr<InquiryInterface>), GetInquiryInterface, 104 (common::ContextualCallback<void(EventView)> event_handler), (override)); 105 106 MOCK_METHOD(void, RegisterForScoConnectionRequests, 107 (common::ContextualCallback<void(Address, ClassOfDevice, ConnectionRequestLinkType)> 108 on_sco_connection_request)); 109 }; 110 111 } // namespace testing 112 } // namespace hci 113 } // namespace bluetooth 114