OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/cryptauth/mock_eid_generator.h" | 5 #include "components/cryptauth/mock_eid_generator.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 | 8 |
9 namespace cryptauth { | 9 namespace cryptauth { |
10 | 10 |
11 MockEidGenerator::MockEidGenerator() : background_scan_filter_(nullptr), | 11 MockEidGenerator::MockEidGenerator() : background_scan_filter_(nullptr), |
12 advertisement_(nullptr), | 12 advertisement_(nullptr), |
13 possible_advertisements_(nullptr), | 13 possible_advertisements_(nullptr), |
14 identified_device_(nullptr) {} | 14 identified_device_(nullptr), |
| 15 num_identify_calls_(0) {} |
15 | 16 |
16 MockEidGenerator::~MockEidGenerator() {} | 17 MockEidGenerator::~MockEidGenerator() {} |
17 | 18 |
18 std::unique_ptr<EidGenerator::EidData> | 19 std::unique_ptr<EidGenerator::EidData> |
19 MockEidGenerator::GenerateBackgroundScanFilter( | 20 MockEidGenerator::GenerateBackgroundScanFilter( |
20 const std::vector<BeaconSeed>& scanning_device_beacon_seeds) const { | 21 const std::vector<BeaconSeed>& scanning_device_beacon_seeds) const { |
21 if (!background_scan_filter_) { | 22 if (!background_scan_filter_) { |
22 return nullptr; | 23 return nullptr; |
23 } | 24 } |
24 | 25 |
(...skipping 30 matching lines...) Expand all Loading... |
55 return std::vector<std::string>(); | 56 return std::vector<std::string>(); |
56 } | 57 } |
57 | 58 |
58 return *possible_advertisements_; | 59 return *possible_advertisements_; |
59 } | 60 } |
60 | 61 |
61 RemoteDevice const* MockEidGenerator::IdentifyRemoteDeviceByAdvertisement( | 62 RemoteDevice const* MockEidGenerator::IdentifyRemoteDeviceByAdvertisement( |
62 const std::string& advertisement_service_data, | 63 const std::string& advertisement_service_data, |
63 const std::vector<RemoteDevice>& device_list, | 64 const std::vector<RemoteDevice>& device_list, |
64 const std::vector<BeaconSeed>& scanning_device_beacon_seeds) const { | 65 const std::vector<BeaconSeed>& scanning_device_beacon_seeds) const { |
| 66 // Increment num_identify_calls_. Since this overrides a const method, some |
| 67 // hacking is needed to modify the num_identify_calls_ instance variable. |
| 68 int* num_identify_calls_ptr = const_cast<int*>(&num_identify_calls_); |
| 69 *num_identify_calls_ptr = *num_identify_calls_ptr + 1; |
| 70 |
65 return identified_device_; | 71 return identified_device_; |
66 } | 72 } |
67 | 73 |
68 } // namespace cryptauth | 74 } // namespace cryptauth |
OLD | NEW |