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 "hci/address.h" 23 #include "hci/controller.h" 24 #include "hci/hci_packets.h" 25 #include "hci/le_rand_callback.h" 26 27 // Unit test interfaces 28 namespace bluetooth { 29 namespace hci { 30 namespace testing { 31 32 class MockController : public Controller { 33 public: 34 MOCK_METHOD(void, RegisterCompletedAclPacketsCallback, (CompletedAclPacketsCallback cb)); 35 MOCK_METHOD(void, UnregisterCompletedAclPacketsCallback, ()); 36 MOCK_METHOD(void, RegisterCompletedMonitorAclPacketsCallback, (CompletedAclPacketsCallback cb)); 37 MOCK_METHOD(void, UnregisterCompletedMonitorAclPacketsCallback, ()); 38 MOCK_METHOD(std::string, GetLocalName, (), (const)); 39 MOCK_METHOD(LocalVersionInformation, GetLocalVersionInformation, (), (const)); 40 MOCK_METHOD(bool, SupportsSimplePairing, (), (const)); 41 MOCK_METHOD(bool, SupportsSecureConnections, (), (const)); 42 MOCK_METHOD(bool, SupportsSimultaneousLeBrEdr, (), (const)); 43 MOCK_METHOD(bool, SupportsInterlacedInquiryScan, (), (const)); 44 MOCK_METHOD(bool, SupportsRssiWithInquiryResults, (), (const)); 45 MOCK_METHOD(bool, SupportsExtendedInquiryResponse, (), (const)); 46 MOCK_METHOD(bool, SupportsRoleSwitch, (), (const)); 47 MOCK_METHOD(bool, Supports3SlotPackets, (), (const)); 48 MOCK_METHOD(bool, Supports5SlotPackets, (), (const)); 49 MOCK_METHOD(bool, SupportsClassic2mPhy, (), (const)); 50 MOCK_METHOD(bool, SupportsClassic3mPhy, (), (const)); 51 MOCK_METHOD(bool, Supports3SlotEdrPackets, (), (const)); 52 MOCK_METHOD(bool, Supports5SlotEdrPackets, (), (const)); 53 MOCK_METHOD(bool, SupportsSco, (), (const)); 54 MOCK_METHOD(bool, SupportsHv2Packets, (), (const)); 55 MOCK_METHOD(bool, SupportsHv3Packets, (), (const)); 56 MOCK_METHOD(bool, SupportsEv3Packets, (), (const)); 57 MOCK_METHOD(bool, SupportsEv4Packets, (), (const)); 58 MOCK_METHOD(bool, SupportsEv5Packets, (), (const)); 59 MOCK_METHOD(bool, SupportsEsco2mPhy, (), (const)); 60 MOCK_METHOD(bool, SupportsEsco3mPhy, (), (const)); 61 MOCK_METHOD(bool, Supports3SlotEscoEdrPackets, (), (const)); 62 MOCK_METHOD(bool, SupportsHoldMode, (), (const)); 63 MOCK_METHOD(bool, SupportsSniffMode, (), (const)); 64 MOCK_METHOD(bool, SupportsParkMode, (), (const)); 65 MOCK_METHOD(bool, SupportsNonFlushablePb, (), (const)); 66 MOCK_METHOD(bool, SupportsSniffSubrating, (), (const)); 67 MOCK_METHOD(bool, SupportsEncryptionPause, (), (const)); 68 MOCK_METHOD(bool, SupportsBle, (), (const)); 69 70 MOCK_METHOD(bool, SupportsBleEncryption, (), (const)); 71 MOCK_METHOD(bool, SupportsBleConnectionParametersRequest, (), (const)); 72 MOCK_METHOD(bool, SupportsBleExtendedReject, (), (const)); 73 MOCK_METHOD(bool, SupportsBlePeripheralInitiatedFeaturesExchange, (), (const)); 74 MOCK_METHOD(bool, SupportsBlePing, (), (const)); 75 MOCK_METHOD(bool, SupportsBleDataPacketLengthExtension, (), (const)); 76 MOCK_METHOD(bool, SupportsBlePrivacy, (), (const)); 77 MOCK_METHOD(bool, SupportsBleExtendedScannerFilterPolicies, (), (const)); 78 MOCK_METHOD(bool, SupportsBle2mPhy, (), (const)); 79 MOCK_METHOD(bool, SupportsBleStableModulationIndexTx, (), (const)); 80 MOCK_METHOD(bool, SupportsBleStableModulationIndexRx, (), (const)); 81 MOCK_METHOD(bool, SupportsBleCodedPhy, (), (const)); 82 MOCK_METHOD(bool, SupportsBleExtendedAdvertising, (), (const)); 83 MOCK_METHOD(bool, SupportsBlePeriodicAdvertising, (), (const)); 84 MOCK_METHOD(bool, SupportsBleConnectionParameterRequest, (), (const)); 85 MOCK_METHOD(bool, SupportsBleChannelSelectionAlgorithm2, (), (const)); 86 MOCK_METHOD(bool, SupportsBlePowerClass1, (), (const)); 87 MOCK_METHOD(bool, SupportsBleMinimumUsedChannels, (), (const)); 88 MOCK_METHOD(bool, SupportsBleConnectionCteRequest, (), (const)); 89 MOCK_METHOD(bool, SupportsBleConnectionCteResponse, (), (const)); 90 MOCK_METHOD(bool, SupportsBleConnectionlessCteTransmitter, (), (const)); 91 MOCK_METHOD(bool, SupportsBleConnectionlessCteReceiver, (), (const)); 92 MOCK_METHOD(bool, SupportsBleAntennaSwitchingDuringCteTx, (), (const)); 93 MOCK_METHOD(bool, SupportsBleAntennaSwitchingDuringCteRx, (), (const)); 94 MOCK_METHOD(bool, SupportsBleReceivingConstantToneExtensions, (), (const)); 95 MOCK_METHOD(bool, SupportsBlePeriodicAdvertisingSyncTransferSender, (), (const)); 96 MOCK_METHOD(bool, SupportsBlePeriodicAdvertisingSyncTransferRecipient, (), (const)); 97 MOCK_METHOD(bool, SupportsBleSleepClockAccuracyUpdates, (), (const)); 98 MOCK_METHOD(bool, SupportsBleRemotePublicKeyValidation, (), (const)); 99 MOCK_METHOD(bool, SupportsBleConnectedIsochronousStreamCentral, (), (const)); 100 MOCK_METHOD(bool, SupportsBleConnectedIsochronousStreamPeripheral, (), (const)); 101 MOCK_METHOD(bool, SupportsBleIsochronousBroadcaster, (), (const)); 102 MOCK_METHOD(bool, SupportsBleSynchronizedReceiver, (), (const)); 103 MOCK_METHOD(bool, SupportsBlePowerChannelHostSupport, (), (const)); 104 MOCK_METHOD(bool, SupportsBleIsochronousChannelsHostSupport, (), (const)); 105 MOCK_METHOD(bool, SupportsBlePowerControlRequest, (), (const)); 106 MOCK_METHOD(bool, SupportsBlePowerChangeIndication, (), (const)); 107 MOCK_METHOD(bool, SupportsBlePathLossMonitoring, (), (const)); 108 MOCK_METHOD(bool, SupportsBlePeriodicAdvertisingAdi, (), (const)); 109 MOCK_METHOD(bool, SupportsBleConnectionSubrating, (), (const)); 110 MOCK_METHOD(bool, SupportsBleConnectionSubratingHost, (), (const)); 111 MOCK_METHOD(bool, SupportsBleChannelSounding, (), (const)); 112 MOCK_METHOD(uint16_t, GetAclPacketLength, (), (const)); 113 MOCK_METHOD(uint16_t, GetNumAclPacketBuffers, (), (const)); 114 MOCK_METHOD(uint8_t, GetScoPacketLength, (), (const)); 115 MOCK_METHOD(uint16_t, GetNumScoPacketBuffers, (), (const)); 116 MOCK_METHOD(Address, GetMacAddress, (), (const)); 117 MOCK_METHOD(void, SetEventMask, (uint64_t event_mask)); 118 MOCK_METHOD(void, Reset, ()); 119 MOCK_METHOD(void, LeRand, (LeRandCallback cb)); 120 MOCK_METHOD(void, SetEventFilterClearAll, ()); 121 MOCK_METHOD(void, SetEventFilterInquiryResultAllDevices, ()); 122 MOCK_METHOD( 123 void, 124 SetEventFilterInquiryResultClassOfDevice, 125 (ClassOfDevice class_of_device, ClassOfDevice class_of_device_mask)); 126 MOCK_METHOD(void, SetEventFilterInquiryResultAddress, (Address address)); 127 MOCK_METHOD(void, SetEventFilterConnectionSetupAllDevices, (AutoAcceptFlag auto_accept_flag)); 128 MOCK_METHOD( 129 void, 130 SetEventFilterConnectionSetupClassOfDevice, 131 (ClassOfDevice class_of_device, ClassOfDevice class_of_device_mask, AutoAcceptFlag auto_accept_flag)); 132 MOCK_METHOD(void, SetEventFilterConnectionSetupAddress, (Address address, AutoAcceptFlag auto_accept_flag)); 133 MOCK_METHOD(void, WriteLocalName, (std::string local_name)); 134 MOCK_METHOD( 135 void, 136 HostBufferSize, 137 (uint16_t host_acl_data_packet_length, 138 uint8_t host_synchronous_data_packet_length, 139 uint16_t host_total_num_acl_data_packets, 140 uint16_t host_total_num_synchronous_data_packets)); 141 // LE controller commands 142 MOCK_METHOD(void, LeSetEventMask, (uint64_t le_event_mask)); 143 MOCK_METHOD(LeBufferSize, GetLeBufferSize, (), (const)); 144 MOCK_METHOD(uint64_t, GetLeSupportedStates, (), (const)); 145 MOCK_METHOD(LeBufferSize, GetControllerIsoBufferSize, (), (const)); 146 MOCK_METHOD(uint64_t, GetControllerLeLocalSupportedFeatures, (), (const)); 147 MOCK_METHOD(uint8_t, GetLeFilterAcceptListSize, (), (const)); 148 MOCK_METHOD(uint8_t, GetLeResolvingListSize, (), (const)); 149 MOCK_METHOD(LeMaximumDataLength, GetLeMaximumDataLength, (), (const)); 150 MOCK_METHOD(uint16_t, GetLeMaximumAdvertisingDataLength, (), (const)); 151 MOCK_METHOD(uint16_t, GetLeSuggestedDefaultDataLength, (), (const)); 152 MOCK_METHOD(uint8_t, GetLeNumberOfSupportedAdverisingSets, (), (const)); 153 MOCK_METHOD(uint8_t, GetLePeriodicAdvertiserListSize, (), (const)); 154 MOCK_METHOD(std::vector<uint8_t>, GetLocalSupportedBrEdrCodecIds, (), (const)); 155 MOCK_METHOD(VendorCapabilities, GetVendorCapabilities, (), (const)); 156 MOCK_METHOD(bool, IsSupported, (OpCode op_code), (const)); 157 158 MOCK_METHOD(uint32_t, GetDabSupportedCodecs, (), (const)); 159 MOCK_METHOD( 160 (const std::array<DynamicAudioBufferCodecCapability, 32>&), 161 GetDabCodecCapabilities, 162 (), 163 (const)); 164 MOCK_METHOD(void, SetDabAudioBufferTime, (uint16_t buffer_time_ms)); 165 }; 166 167 } // namespace testing 168 } // namespace hci 169 } // namespace bluetooth 170