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 <cstdint> 19 20 #include "common/contextual_callback.h" 21 #include "hci/address.h" 22 #include "hci/controller.h" 23 #include "hci/hci_packets.h" 24 #include "module.h" 25 #include "os/handler.h" 26 27 #include <gmock/gmock.h> 28 29 // Unit test interfaces 30 namespace bluetooth { 31 namespace hci { 32 namespace testing { 33 34 class MockController : public Controller { 35 public: 36 MOCK_METHOD(void, RegisterCompletedAclPacketsCallback, (CompletedAclPacketsCallback cb)); 37 MOCK_METHOD(void, UnregisterCompletedAclPacketsCallback, ()); 38 MOCK_METHOD(void, RegisterCompletedMonitorAclPacketsCallback, (CompletedAclPacketsCallback cb)); 39 MOCK_METHOD(void, UnregisterCompletedMonitorAclPacketsCallback, ()); 40 MOCK_METHOD(std::string, GetLocalName, (), (const)); 41 MOCK_METHOD(LocalVersionInformation, GetLocalVersionInformation, (), (const)); 42 MOCK_METHOD(bool, SupportsSimplePairing, (), (const)); 43 MOCK_METHOD(bool, SupportsSecureConnections, (), (const)); 44 MOCK_METHOD(bool, SupportsSimultaneousLeBrEdr, (), (const)); 45 MOCK_METHOD(bool, SupportsInterlacedInquiryScan, (), (const)); 46 MOCK_METHOD(bool, SupportsRssiWithInquiryResults, (), (const)); 47 MOCK_METHOD(bool, SupportsExtendedInquiryResponse, (), (const)); 48 MOCK_METHOD(bool, SupportsRoleSwitch, (), (const)); 49 MOCK_METHOD(bool, Supports3SlotPackets, (), (const)); 50 MOCK_METHOD(bool, Supports5SlotPackets, (), (const)); 51 MOCK_METHOD(bool, SupportsClassic2mPhy, (), (const)); 52 MOCK_METHOD(bool, SupportsClassic3mPhy, (), (const)); 53 MOCK_METHOD(bool, Supports3SlotEdrPackets, (), (const)); 54 MOCK_METHOD(bool, Supports5SlotEdrPackets, (), (const)); 55 MOCK_METHOD(bool, SupportsSco, (), (const)); 56 MOCK_METHOD(bool, SupportsHv2Packets, (), (const)); 57 MOCK_METHOD(bool, SupportsHv3Packets, (), (const)); 58 MOCK_METHOD(bool, SupportsEv3Packets, (), (const)); 59 MOCK_METHOD(bool, SupportsEv4Packets, (), (const)); 60 MOCK_METHOD(bool, SupportsEv5Packets, (), (const)); 61 MOCK_METHOD(bool, SupportsEsco2mPhy, (), (const)); 62 MOCK_METHOD(bool, SupportsEsco3mPhy, (), (const)); 63 MOCK_METHOD(bool, Supports3SlotEscoEdrPackets, (), (const)); 64 MOCK_METHOD(bool, SupportsHoldMode, (), (const)); 65 MOCK_METHOD(bool, SupportsSniffMode, (), (const)); 66 MOCK_METHOD(bool, SupportsParkMode, (), (const)); 67 MOCK_METHOD(bool, SupportsNonFlushablePb, (), (const)); 68 MOCK_METHOD(bool, SupportsSniffSubrating, (), (const)); 69 MOCK_METHOD(bool, SupportsEncryptionPause, (), (const)); 70 MOCK_METHOD(bool, SupportsBle, (), (const)); 71 MOCK_METHOD(bool, SupportsBlePrivacy, (), (const)); 72 MOCK_METHOD(bool, SupportsBlePacketExtension, (), (const)); 73 MOCK_METHOD(bool, SupportsBleConnectionParametersRequest, (), (const)); 74 MOCK_METHOD(bool, SupportsBle2mPhy, (), (const)); 75 MOCK_METHOD(bool, SupportsBleCodedPhy, (), (const)); 76 MOCK_METHOD(bool, SupportsBleExtendedAdvertising, (), (const)); 77 MOCK_METHOD(bool, SupportsBlePeriodicAdvertising, (), (const)); 78 MOCK_METHOD(bool, SupportsBlePeripheralInitiatedFeatureExchange, (), (const)); 79 MOCK_METHOD(bool, SupportsBleConnectionParameterRequest, (), (const)); 80 MOCK_METHOD(bool, SupportsBlePeriodicAdvertisingSyncTransferSender, (), (const)); 81 MOCK_METHOD(bool, SupportsBlePeriodicAdvertisingSyncTransferRecipient, (), (const)); 82 MOCK_METHOD(bool, SupportsBleConnectedIsochronousStreamCentral, (), (const)); 83 MOCK_METHOD(bool, SupportsBleConnectedIsochronousStreamPeripheral, (), (const)); 84 MOCK_METHOD(bool, SupportsBleIsochronousBroadcaster, (), (const)); 85 MOCK_METHOD(bool, SupportsBleSynchronizedReceiver, (), (const)); 86 MOCK_METHOD(uint16_t, GetAclPacketLength, (), (const)); 87 MOCK_METHOD(uint16_t, GetNumAclPacketBuffers, (), (const)); 88 MOCK_METHOD(uint8_t, GetScoPacketLength, (), (const)); 89 MOCK_METHOD(uint16_t, GetNumScoPacketBuffers, (), (const)); 90 MOCK_METHOD(Address, GetMacAddress, (), (const)); 91 MOCK_METHOD(void, SetEventMask, (uint64_t event_mask)); 92 MOCK_METHOD(void, Reset, ()); 93 MOCK_METHOD(void, SetEventFilterClearAll, ()); 94 MOCK_METHOD(void, SetEventFilterInquiryResultAllDevices, ()); 95 MOCK_METHOD( 96 void, 97 SetEventFilterInquiryResultClassOfDevice, 98 (ClassOfDevice class_of_device, ClassOfDevice class_of_device_mask)); 99 MOCK_METHOD(void, SetEventFilterInquiryResultAddress, (Address address)); 100 MOCK_METHOD(void, SetEventFilterConnectionSetupAllDevices, (AutoAcceptFlag auto_accept_flag)); 101 MOCK_METHOD( 102 void, 103 SetEventFilterConnectionSetupClassOfDevice, 104 (ClassOfDevice class_of_device, ClassOfDevice class_of_device_mask, AutoAcceptFlag auto_accept_flag)); 105 MOCK_METHOD(void, SetEventFilterConnectionSetupAddress, (Address address, AutoAcceptFlag auto_accept_flag)); 106 MOCK_METHOD(void, WriteLocalName, (std::string local_name)); 107 MOCK_METHOD( 108 void, 109 HostBufferSize, 110 (uint16_t host_acl_data_packet_length, 111 uint8_t host_synchronous_data_packet_length, 112 uint16_t host_total_num_acl_data_packets, 113 uint16_t host_total_num_synchronous_data_packets)); 114 // LE controller commands 115 MOCK_METHOD(void, LeSetEventMask, (uint64_t le_event_mask)); 116 MOCK_METHOD(LeBufferSize, GetLeBufferSize, (), (const)); 117 MOCK_METHOD(uint64_t, GetLeSupportedStates, (), (const)); 118 MOCK_METHOD(LeBufferSize, GetControllerIsoBufferSize, (), (const)); 119 MOCK_METHOD(uint64_t, GetControllerLeLocalSupportedFeatures, (), (const)); 120 MOCK_METHOD(uint8_t, GetLeConnectListSize, (), (const)); 121 MOCK_METHOD(uint8_t, GetLeResolvingListSize, (), (const)); 122 MOCK_METHOD(LeMaximumDataLength, GetLeMaximumDataLength, (), (const)); 123 MOCK_METHOD(uint16_t, GetLeMaximumAdvertisingDataLength, (), (const)); 124 MOCK_METHOD(uint16_t, GetLeSuggestedDefaultDataLength, (), (const)); 125 MOCK_METHOD(uint8_t, GetLeNumberOfSupportedAdverisingSets, (), (const)); 126 MOCK_METHOD(uint8_t, GetLePeriodicAdvertiserListSize, (), (const)); 127 MOCK_METHOD(VendorCapabilities, GetVendorCapabilities, (), (const)); 128 MOCK_METHOD(bool, IsSupported, (OpCode op_code), (const)); 129 }; 130 131 } // namespace testing 132 } // namespace hci 133 } // namespace bluetooth 134