1 /* 2 * Copyright 2019 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 "hci/acl_manager.h" 19 #include "hci/acl_manager/classic_acl_connection.h" 20 #include "hci/acl_manager/connection_callbacks.h" 21 #include "hci/acl_manager/connection_management_callbacks.h" 22 #include "hci/acl_manager/le_acl_connection.h" 23 #include "hci/acl_manager/le_connection_callbacks.h" 24 #include "hci/acl_manager/le_connection_management_callbacks.h" 25 26 #include <gmock/gmock.h> 27 28 // Unit test interfaces 29 namespace bluetooth { 30 namespace hci { 31 namespace testing { 32 33 using acl_manager::LeAclConnection; 34 using acl_manager::LeConnectionCallbacks; 35 using acl_manager::LeConnectionManagementCallbacks; 36 37 using acl_manager::ClassicAclConnection; 38 using acl_manager::ConnectionCallbacks; 39 using acl_manager::ConnectionManagementCallbacks; 40 41 class MockClassicAclConnection : public ClassicAclConnection { 42 public: 43 MOCK_METHOD(Address, GetAddress, (), (const, override)); 44 MOCK_METHOD(bool, Disconnect, (DisconnectReason reason), (override)); 45 MOCK_METHOD(void, RegisterCallbacks, (ConnectionManagementCallbacks * callbacks, os::Handler* handler), (override)); 46 GetAclQueueEnd()47 QueueUpEnd* GetAclQueueEnd() const override { 48 return acl_queue_.GetUpEnd(); 49 } 50 mutable common::BidiQueue<PacketView<kLittleEndian>, BasePacketBuilder> acl_queue_{10}; 51 }; 52 53 class MockLeAclConnection : public LeAclConnection { 54 public: 55 MOCK_METHOD(AddressWithType, GetLocalAddress, (), (const, override)); 56 MOCK_METHOD(AddressWithType, GetRemoteAddress, (), (const, override)); 57 MOCK_METHOD(void, Disconnect, (DisconnectReason reason), (override)); 58 MOCK_METHOD(void, RegisterCallbacks, (LeConnectionManagementCallbacks * callbacks, os::Handler* handler), (override)); 59 GetAclQueueEnd()60 QueueUpEnd* GetAclQueueEnd() const override { 61 return acl_queue_.GetUpEnd(); 62 } 63 mutable common::BidiQueue<PacketView<kLittleEndian>, BasePacketBuilder> acl_queue_{10}; 64 }; 65 66 class MockAclManager : public AclManager { 67 public: 68 MOCK_METHOD(void, RegisterCallbacks, (ConnectionCallbacks * callbacks, os::Handler* handler), (override)); 69 MOCK_METHOD(void, RegisterLeCallbacks, (LeConnectionCallbacks * callbacks, os::Handler* handler), (override)); 70 MOCK_METHOD(void, CreateConnection, (Address address), (override)); 71 MOCK_METHOD(void, CreateLeConnection, (AddressWithType address_with_type), (override)); 72 MOCK_METHOD(void, CancelConnect, (Address address), (override)); 73 MOCK_METHOD( 74 void, 75 SetPrivacyPolicyForInitiatorAddress, 76 (LeAddressManager::AddressPolicy address_policy, 77 AddressWithType fixed_address, 78 crypto_toolbox::Octet16 rotation_irk, 79 std::chrono::milliseconds minimum_rotation_time, 80 std::chrono::milliseconds maximum_rotation_time), 81 (override)); 82 }; 83 84 } // namespace testing 85 } // namespace hci 86 } // namespace bluetooth 87