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 *)38   explicit MockLink(
39       os::Handler* handler,
40       l2cap::internal::ParameterProvider* parameter_provider,
41       std::unique_ptr<hci::acl_manager::ClassicAclConnection> acl_connection,
42       LinkManager* /* link_manager */)
43       : Link(handler, std::move(acl_connection), parameter_provider, nullptr, nullptr, nullptr){};
44   MOCK_METHOD(hci::AddressWithType, GetDevice, (), (const, override));
45   MOCK_METHOD(void, OnAclDisconnected, (hci::ErrorCode status), (override));
46   MOCK_METHOD(void, Disconnect, (), (override));
47   MOCK_METHOD(std::shared_ptr<l2cap::internal::DynamicChannelImpl>, AllocateDynamicChannel, (Psm psm, Cid cid),
48               (override));
49 
50   MOCK_METHOD(bool, IsFixedChannelAllocated, (Cid cid), (override));
51   MOCK_METHOD(void, RefreshRefCount, (), (override));
52 };
53 
54 }  // namespace testing
55 }  // namespace internal
56 }  // namespace classic
57 }  // namespace l2cap
58 }  // namespace bluetooth
59