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 #ifndef DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_GATT_SERVICE_H_
6 #define DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_GATT_SERVICE_H_
11 #include "base/memory/scoped_vector.h"
12 #include "device/bluetooth/bluetooth_gatt_service.h"
13 #include "device/bluetooth/bluetooth_uuid.h"
14 #include "device/bluetooth/test/mock_bluetooth_gatt_characteristic.h"
15 #include "testing/gmock/include/gmock/gmock.h"
19 class BluetoothGattCharacteristic
;
20 class MockBluetoothDevice
;
22 class MockBluetoothGattService
: public BluetoothGattService
{
24 MockBluetoothGattService(MockBluetoothDevice
* device
,
25 const std::string
& identifier
,
26 const BluetoothUUID
& uuid
,
29 virtual ~MockBluetoothGattService();
31 MOCK_CONST_METHOD0(GetIdentifier
, std::string());
32 MOCK_CONST_METHOD0(GetUUID
, BluetoothUUID());
33 MOCK_CONST_METHOD0(IsLocal
, bool());
34 MOCK_CONST_METHOD0(IsPrimary
, bool());
35 MOCK_CONST_METHOD0(GetDevice
, BluetoothDevice
*());
36 MOCK_CONST_METHOD0(GetCharacteristics
,
37 std::vector
<BluetoothGattCharacteristic
*>());
38 MOCK_CONST_METHOD0(GetIncludedServices
, std::vector
<BluetoothGattService
*>());
39 MOCK_CONST_METHOD1(GetCharacteristic
,
40 BluetoothGattCharacteristic
*(const std::string
&));
41 MOCK_METHOD1(AddCharacteristic
, bool(BluetoothGattCharacteristic
*));
42 MOCK_METHOD1(AddIncludedService
, bool(BluetoothGattService
*));
43 MOCK_METHOD2(Register
, void(const base::Closure
&, const ErrorCallback
&));
44 MOCK_METHOD2(Unregister
, void(const base::Closure
&, const ErrorCallback
&));
46 // BluetoothGattService manages the lifetime of its
47 // BluetoothGATTCharacteristics.
48 // This method takes ownership of the MockBluetoothGATTCharacteristics. This
49 // is only for convenience as far as testing is concerned, and it's possible
50 // to write test cases without using these functions.
52 // ON_CALL(*mock_service, GetCharacteristics))
53 // .WillByDefault(Invoke(
55 // &MockBluetoothGattService::GetMockCharacteristics));
56 void AddMockCharacteristic(
57 scoped_ptr
<MockBluetoothGattCharacteristic
> mock_characteristic
);
58 std::vector
<BluetoothGattCharacteristic
*> GetMockCharacteristics() const;
59 BluetoothGattCharacteristic
* GetMockCharacteristic(
60 const std::string
& identifier
) const;
63 ScopedVector
<MockBluetoothGattCharacteristic
> mock_characteristics_
;
65 DISALLOW_COPY_AND_ASSIGN(MockBluetoothGattService
);
70 #endif // DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_GATT_SERVICE_H_