OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "device/bluetooth/test/mock_bluetooth_gatt_service.h" | 5 #include "device/bluetooth/test/mock_bluetooth_gatt_service.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "device/bluetooth/test/mock_bluetooth_device.h" | 10 #include "device/bluetooth/test/mock_bluetooth_device.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 } | 38 } |
39 | 39 |
40 void MockBluetoothGattService::AddMockCharacteristic( | 40 void MockBluetoothGattService::AddMockCharacteristic( |
41 std::unique_ptr<MockBluetoothGattCharacteristic> mock_characteristic) { | 41 std::unique_ptr<MockBluetoothGattCharacteristic> mock_characteristic) { |
42 mock_characteristics_.push_back(std::move(mock_characteristic)); | 42 mock_characteristics_.push_back(std::move(mock_characteristic)); |
43 } | 43 } |
44 | 44 |
45 std::vector<BluetoothRemoteGattCharacteristic*> | 45 std::vector<BluetoothRemoteGattCharacteristic*> |
46 MockBluetoothGattService::GetMockCharacteristics() const { | 46 MockBluetoothGattService::GetMockCharacteristics() const { |
47 std::vector<BluetoothRemoteGattCharacteristic*> characteristics; | 47 std::vector<BluetoothRemoteGattCharacteristic*> characteristics; |
48 for (BluetoothRemoteGattCharacteristic* characteristic : | 48 for (auto& mock : mock_characteristics_) { |
49 mock_characteristics_) { | 49 characteristics.push_back(mock.get()); |
50 characteristics.push_back(characteristic); | |
51 } | 50 } |
52 return characteristics; | 51 return characteristics; |
53 } | 52 } |
54 | 53 |
55 BluetoothRemoteGattCharacteristic* | 54 BluetoothRemoteGattCharacteristic* |
56 MockBluetoothGattService::GetMockCharacteristic( | 55 MockBluetoothGattService::GetMockCharacteristic( |
57 const std::string& identifier) const { | 56 const std::string& identifier) const { |
58 for (BluetoothRemoteGattCharacteristic* characteristic : | 57 for (auto& mock : mock_characteristics_) { |
59 mock_characteristics_) { | 58 if (mock->GetIdentifier() == identifier) { |
60 if (characteristic->GetIdentifier() == identifier) { | 59 return mock.get(); |
61 return characteristic; | |
62 } | 60 } |
63 } | 61 } |
64 return nullptr; | 62 return nullptr; |
65 } | 63 } |
66 | 64 |
67 } // namespace device | 65 } // namespace device |
OLD | NEW |