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_mock.h"
19 #include "hci/address.h"
20 #include "l2cap/classic/internal/link.h"
21 #include "l2cap/internal/scheduler_mock.h"
22 
23 #include <gmock/gmock.h>
24 
25 // Unit test interfaces
26 namespace bluetooth {
27 namespace l2cap {
28 namespace classic {
29 namespace internal {
30 namespace testing {
31 
32 using hci::testing::MockClassicAclConnection;
33 
34 class MockLink : public Link {
35  public:
MockLink(os::Handler * handler,l2cap::internal::ParameterProvider * parameter_provider)36   explicit MockLink(os::Handler* handler, l2cap::internal::ParameterProvider* parameter_provider)
37       : Link(handler, std::make_unique<MockClassicAclConnection>(), parameter_provider, nullptr, nullptr, nullptr){};
MockLink(os::Handler * handler,l2cap::internal::ParameterProvider * parameter_provider,std::unique_ptr<hci::acl_manager::ClassicAclConnection> acl_connection,LinkManager * link_manager)38   explicit MockLink(os::Handler* handler, l2cap::internal::ParameterProvider* parameter_provider,
39                     std::unique_ptr<hci::acl_manager::ClassicAclConnection> acl_connection, LinkManager* link_manager)
40       : Link(handler, std::move(acl_connection), parameter_provider, nullptr, nullptr, nullptr){};
41   MOCK_METHOD(hci::AddressWithType, GetDevice, (), (const, override));
42   MOCK_METHOD(void, OnAclDisconnected, (hci::ErrorCode status), (override));
43   MOCK_METHOD(void, Disconnect, (), (override));
44   MOCK_METHOD(std::shared_ptr<l2cap::internal::DynamicChannelImpl>, AllocateDynamicChannel, (Psm psm, Cid cid),
45               (override));
46 
47   MOCK_METHOD(bool, IsFixedChannelAllocated, (Cid cid), (override));
48   MOCK_METHOD(void, RefreshRefCount, (), (override));
49 };
50 
51 }  // namespace testing
52 }  // namespace internal
53 }  // namespace classic
54 }  // namespace l2cap
55 }  // namespace bluetooth
56