Roll src/third_party/WebKit 787a07c:716df21 (svn 201034:201036)
[chromium-blink-merge.git] / device / bluetooth / test / mock_bluetooth_gatt_service.cc
blob93cbfc573e8391dc1adb836080036311454e8f9c
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
3 // found in the LICENSE file.
5 #include "device/bluetooth/test/mock_bluetooth_gatt_service.h"
7 #include "device/bluetooth/test/mock_bluetooth_device.h"
9 using testing::Return;
10 using testing::_;
12 namespace device {
14 MockBluetoothGattService::MockBluetoothGattService(
15 MockBluetoothDevice* device,
16 const std::string& identifier,
17 const BluetoothUUID& uuid,
18 bool is_primary,
19 bool is_local) {
20 ON_CALL(*this, GetIdentifier()).WillByDefault(Return(identifier));
21 ON_CALL(*this, GetUUID()).WillByDefault(Return(uuid));
22 ON_CALL(*this, IsLocal()).WillByDefault(Return(is_local));
23 ON_CALL(*this, IsPrimary()).WillByDefault(Return(is_primary));
24 ON_CALL(*this, GetDevice()).WillByDefault(Return(device));
25 ON_CALL(*this, GetCharacteristics())
26 .WillByDefault(Return(std::vector<BluetoothGattCharacteristic*>()));
27 ON_CALL(*this, GetIncludedServices())
28 .WillByDefault(Return(std::vector<BluetoothGattService*>()));
29 ON_CALL(*this, GetCharacteristic(_))
30 .WillByDefault(Return(static_cast<BluetoothGattCharacteristic*>(NULL)));
33 MockBluetoothGattService::~MockBluetoothGattService() {
36 void MockBluetoothGattService::AddMockCharacteristic(
37 scoped_ptr<MockBluetoothGattCharacteristic> mock_characteristic) {
38 mock_characteristics_.push_back(mock_characteristic.Pass());
41 std::vector<BluetoothGattCharacteristic*>
42 MockBluetoothGattService::GetMockCharacteristics() const {
43 std::vector<BluetoothGattCharacteristic*> characteristics;
44 for (BluetoothGattCharacteristic* characteristic : mock_characteristics_) {
45 characteristics.push_back(characteristic);
47 return characteristics;
50 BluetoothGattCharacteristic* MockBluetoothGattService::GetMockCharacteristic(
51 const std::string& identifier) const {
52 for (BluetoothGattCharacteristic* characteristic : mock_characteristics_) {
53 if (characteristic->GetIdentifier() == identifier) {
54 return characteristic;
57 return nullptr;
60 } // namespace device