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_characteristic.h" | 5 #include "device/bluetooth/test/mock_bluetooth_gatt_characteristic.h" |
6 | 6 #include "device/bluetooth/test/mock_bluetooth_gatt_descriptor.h" |
7 #include "device/bluetooth/test/mock_bluetooth_gatt_service.h" | 7 #include "device/bluetooth/test/mock_bluetooth_gatt_service.h" |
8 | 8 |
9 using testing::Return; | 9 using testing::Return; |
10 using testing::ReturnRefOfCopy; | 10 using testing::ReturnRefOfCopy; |
11 using testing::_; | 11 using testing::_; |
12 | 12 |
13 namespace device { | 13 namespace device { |
14 | 14 |
15 MockBluetoothGattCharacteristic::MockBluetoothGattCharacteristic( | 15 MockBluetoothGattCharacteristic::MockBluetoothGattCharacteristic( |
16 MockBluetoothGattService* service, | 16 MockBluetoothGattService* service, |
(...skipping 11 matching lines...) Expand all Loading... |
28 ON_CALL(*this, GetProperties()).WillByDefault(Return(properties)); | 28 ON_CALL(*this, GetProperties()).WillByDefault(Return(properties)); |
29 ON_CALL(*this, GetPermissions()).WillByDefault(Return(permissions)); | 29 ON_CALL(*this, GetPermissions()).WillByDefault(Return(permissions)); |
30 ON_CALL(*this, IsNotifying()).WillByDefault(Return(false)); | 30 ON_CALL(*this, IsNotifying()).WillByDefault(Return(false)); |
31 ON_CALL(*this, GetDescriptors()) | 31 ON_CALL(*this, GetDescriptors()) |
32 .WillByDefault(Return(std::vector<BluetoothRemoteGattDescriptor*>())); | 32 .WillByDefault(Return(std::vector<BluetoothRemoteGattDescriptor*>())); |
33 } | 33 } |
34 | 34 |
35 MockBluetoothGattCharacteristic::~MockBluetoothGattCharacteristic() { | 35 MockBluetoothGattCharacteristic::~MockBluetoothGattCharacteristic() { |
36 } | 36 } |
37 | 37 |
| 38 void MockBluetoothGattCharacteristic::AddMockDescriptor( |
| 39 std::unique_ptr<MockBluetoothGattDescriptor> mock_descriptor) { |
| 40 mock_descriptors_.push_back(std::move(mock_descriptor)); |
| 41 } |
| 42 |
| 43 std::vector<BluetoothRemoteGattDescriptor*> |
| 44 MockBluetoothGattCharacteristic::GetMockDescriptors() const { |
| 45 std::vector<BluetoothRemoteGattDescriptor*> descriptors; |
| 46 for (auto& descriptor : mock_descriptors_) { |
| 47 descriptors.push_back(descriptor.get()); |
| 48 } |
| 49 return descriptors; |
| 50 } |
| 51 |
| 52 BluetoothRemoteGattDescriptor* |
| 53 MockBluetoothGattCharacteristic::GetMockDescriptor( |
| 54 const std::string& identifier) const { |
| 55 for (auto& descriptor : mock_descriptors_) { |
| 56 if (descriptor->GetIdentifier() == identifier) { |
| 57 return descriptor.get(); |
| 58 } |
| 59 } |
| 60 return nullptr; |
| 61 } |
| 62 |
38 } // namespace device | 63 } // namespace device |
OLD | NEW |