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 #ifndef DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_GATT_SERVICE_H_ | 5 #ifndef DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_GATT_SERVICE_H_ |
6 #define DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_GATT_SERVICE_H_ | 6 #define DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_GATT_SERVICE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
| 11 #include "base/memory/scoped_vector.h" |
11 #include "device/bluetooth/bluetooth_gatt_service.h" | 12 #include "device/bluetooth/bluetooth_gatt_service.h" |
12 #include "device/bluetooth/bluetooth_uuid.h" | 13 #include "device/bluetooth/bluetooth_uuid.h" |
| 14 #include "device/bluetooth/test/mock_bluetooth_gatt_characteristic.h" |
13 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
14 | 16 |
15 namespace device { | 17 namespace device { |
16 | 18 |
17 class BluetoothGattCharacteristic; | 19 class BluetoothGattCharacteristic; |
18 class MockBluetoothDevice; | 20 class MockBluetoothDevice; |
19 | 21 |
20 class MockBluetoothGattService : public BluetoothGattService { | 22 class MockBluetoothGattService : public BluetoothGattService { |
21 public: | 23 public: |
22 MockBluetoothGattService(MockBluetoothDevice* device, | 24 MockBluetoothGattService(MockBluetoothDevice* device, |
(...skipping 11 matching lines...) Expand all Loading... |
34 MOCK_CONST_METHOD0(GetCharacteristics, | 36 MOCK_CONST_METHOD0(GetCharacteristics, |
35 std::vector<BluetoothGattCharacteristic*>()); | 37 std::vector<BluetoothGattCharacteristic*>()); |
36 MOCK_CONST_METHOD0(GetIncludedServices, std::vector<BluetoothGattService*>()); | 38 MOCK_CONST_METHOD0(GetIncludedServices, std::vector<BluetoothGattService*>()); |
37 MOCK_CONST_METHOD1(GetCharacteristic, | 39 MOCK_CONST_METHOD1(GetCharacteristic, |
38 BluetoothGattCharacteristic*(const std::string&)); | 40 BluetoothGattCharacteristic*(const std::string&)); |
39 MOCK_METHOD1(AddCharacteristic, bool(BluetoothGattCharacteristic*)); | 41 MOCK_METHOD1(AddCharacteristic, bool(BluetoothGattCharacteristic*)); |
40 MOCK_METHOD1(AddIncludedService, bool(BluetoothGattService*)); | 42 MOCK_METHOD1(AddIncludedService, bool(BluetoothGattService*)); |
41 MOCK_METHOD2(Register, void(const base::Closure&, const ErrorCallback&)); | 43 MOCK_METHOD2(Register, void(const base::Closure&, const ErrorCallback&)); |
42 MOCK_METHOD2(Unregister, void(const base::Closure&, const ErrorCallback&)); | 44 MOCK_METHOD2(Unregister, void(const base::Closure&, const ErrorCallback&)); |
43 | 45 |
| 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. |
| 51 // Example: |
| 52 // ON_CALL(*mock_service, GetCharacteristics)) |
| 53 // .WillByDefault(Invoke( |
| 54 // *mock_service, |
| 55 // &MockBluetoothGattService::GetMockCharacteristics)); |
| 56 void AddMockCharacteristic( |
| 57 scoped_ptr<MockBluetoothGattCharacteristic> mock_characteristic); |
| 58 std::vector<BluetoothGattCharacteristic*> GetMockCharacteristics() const; |
| 59 |
44 private: | 60 private: |
| 61 ScopedVector<MockBluetoothGattCharacteristic> mock_characteristics_; |
| 62 |
45 DISALLOW_COPY_AND_ASSIGN(MockBluetoothGattService); | 63 DISALLOW_COPY_AND_ASSIGN(MockBluetoothGattService); |
46 }; | 64 }; |
47 | 65 |
48 } // namespace device | 66 } // namespace device |
49 | 67 |
50 #endif // DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_GATT_SERVICE_H_ | 68 #endif // DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_GATT_SERVICE_H_ |
OLD | NEW |