1 /*
2  * Copyright 2021 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 /*
18  * Generated mock file from original source file
19  *   Functions generated:11
20  */
21 
22 #include <map>
23 #include <string>
24 
25 extern std::map<std::string, int> mock_function_count_map;
26 
27 #include <base/logging.h>
28 #include <functional>
29 #include <mutex>
30 #include <thread>
31 #include "common/metric_id_allocator.h"
32 
33 #ifndef UNUSED_ATTR
34 #define UNUSED_ATTR
35 #endif
36 
37 namespace {
38 
39 const size_t paired_device_cache_capacity{10};
40 const std::string paired_device_cache_log_tag("Mock");
41 }  // namespace
42 
43 namespace bluetooth {
44 namespace common {
45 
46 const int MetricIdAllocator::kMinId = 0;
47 
MetricIdAllocator()48 MetricIdAllocator::MetricIdAllocator()
49     : paired_device_cache_(paired_device_cache_capacity,
50                            paired_device_cache_log_tag),
51       temporary_device_cache_(paired_device_cache_capacity,
52                               paired_device_cache_log_tag) {
53   next_id_ = 0;
54   initialized_ = true;
55 }
56 
57 class MockMetricIdAllocator : public MetricIdAllocator {
58  public:
MockMetricIdAllocator()59   MockMetricIdAllocator() {}
60 };
61 
62 MockMetricIdAllocator metric_id_allocator;
63 
GetInstance()64 MetricIdAllocator& MetricIdAllocator::GetInstance() {
65   mock_function_count_map[__func__]++;
66   return metric_id_allocator;
67 }
~MetricIdAllocator()68 MetricIdAllocator::~MetricIdAllocator() {}
Close()69 bool MetricIdAllocator::Close() {
70   mock_function_count_map[__func__]++;
71   return false;
72 }
Init(const std::unordered_map<RawAddress,int> & paired_device_map,Callback save_id_callback,Callback forget_device_callback)73 bool MetricIdAllocator::Init(
74     const std::unordered_map<RawAddress, int>& paired_device_map,
75     Callback save_id_callback, Callback forget_device_callback) {
76   mock_function_count_map[__func__]++;
77   return false;
78 }
IsEmpty() const79 bool MetricIdAllocator::IsEmpty() const {
80   mock_function_count_map[__func__]++;
81   return false;
82 }
IsValidId(const int id)83 bool MetricIdAllocator::IsValidId(const int id) {
84   mock_function_count_map[__func__]++;
85   return false;
86 }
SaveDevice(const RawAddress & mac_address)87 bool MetricIdAllocator::SaveDevice(const RawAddress& mac_address) {
88   mock_function_count_map[__func__]++;
89   return false;
90 }
AllocateId(const RawAddress & mac_address)91 int MetricIdAllocator::AllocateId(const RawAddress& mac_address) {
92   mock_function_count_map[__func__]++;
93   return 0;
94 }
ForgetDevice(const RawAddress & mac_address)95 void MetricIdAllocator::ForgetDevice(const RawAddress& mac_address) {
96   mock_function_count_map[__func__]++;
97 }
ForgetDevicePostprocess(const RawAddress & mac_address,const int id)98 void MetricIdAllocator::ForgetDevicePostprocess(const RawAddress& mac_address,
99                                                 const int id) {
100   mock_function_count_map[__func__]++;
101 }
102 
103 }  // namespace common
104 }  // namespace bluetooth
105