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 
20 #include <gmock/gmock.h>
21 
22 // Unit test interfaces
23 namespace bluetooth {
24 namespace hci {
25 namespace testing {
26 
27 class MockAclConnection : public AclConnection {
28  public:
29   MOCK_METHOD(Address, GetAddress, (), (const, override));
30   MOCK_METHOD(AddressType, GetAddressType, (), (const, override));
31   MOCK_METHOD(void, RegisterDisconnectCallback,
32               (common::OnceCallback<void(ErrorCode)> on_disconnect, os::Handler* handler), (override));
33   MOCK_METHOD(bool, Disconnect, (DisconnectReason reason), (override));
34   MOCK_METHOD(void, Finish, (), (override));
35   MOCK_METHOD(void, RegisterCallbacks, (ConnectionManagementCallbacks * callbacks, os::Handler* handler), (override));
36   MOCK_METHOD(void, UnregisterCallbacks, (ConnectionManagementCallbacks * callbacks), (override));
37 
38   QueueUpEnd* GetAclQueueEnd() const override {
39     return acl_queue_.GetUpEnd();
40   }
41   mutable common::BidiQueue<PacketView<kLittleEndian>, BasePacketBuilder> acl_queue_{10};
42 };
43 
44 class MockAclManager : public AclManager {
45  public:
46   MOCK_METHOD(void, RegisterCallbacks, (ConnectionCallbacks * callbacks, os::Handler* handler), (override));
47   MOCK_METHOD(void, RegisterLeCallbacks, (LeConnectionCallbacks * callbacks, os::Handler* handler), (override));
48   MOCK_METHOD(void, CreateConnection, (Address address), (override));
49   MOCK_METHOD(void, CreateLeConnection, (AddressWithType address_with_type), (override));
50   MOCK_METHOD(void, CancelConnect, (Address address), (override));
51 };
52 
53 }  // namespace testing
54 }  // namespace hci
55 }  // namespace bluetooth
56