• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2022 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 
17 #include <functional>
18 
19 #include "stack/btm/btm_dev.h"
20 #include "types/raw_address.h"
21 
22 namespace test {
23 namespace mock {
24 namespace stack_btm_dev {
25 
26 // Function state capture and return values, if needed
27 struct btm_find_dev {
28   std::function<tBTM_SEC_DEV_REC*(const RawAddress& bd_addr)> body{
29       [](const RawAddress&) { return nullptr; }};
operatorbtm_find_dev30   tBTM_SEC_DEV_REC* operator()(const RawAddress& bd_addr) {
31     return body(bd_addr);
32   };
33 };
34 extern struct btm_find_dev btm_find_dev;
35 
36 struct BTM_Sec_AddressKnown {
37   std::function<bool(const RawAddress& address)> body{
38       [](const RawAddress& /* address */) { return false; }};
operatorBTM_Sec_AddressKnown39   bool operator()(const RawAddress& address) { return body(address); };
40 };
41 extern struct BTM_Sec_AddressKnown BTM_Sec_AddressKnown;
42 
43 // Name: maybe_resolve_address
44 // Params: RawAddress* bda, tBLE_ADDR_TYPE* bda_type
45 // Returns: bool
46 struct maybe_resolve_address {
47   std::function<bool(RawAddress* bda, tBLE_ADDR_TYPE* bda_type)> body{
48       [](RawAddress* /* bda */, tBLE_ADDR_TYPE* /* bda_type */) {
49         return false;
50       }};
operatormaybe_resolve_address51   bool operator()(RawAddress* bda, tBLE_ADDR_TYPE* bda_type) {
52     return body(bda, bda_type);
53   };
54 };
55 extern struct maybe_resolve_address maybe_resolve_address;
56 
57 }  // namespace stack_btm_dev
58 }  // namespace mock
59 }  // namespace test
60