Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(409)

Side by Side Diff: device/bluetooth/test/mock_bluetooth_gatt_service.h

Issue 1898643002: Refactor device::BluetoothGattXXX classes to split into remote/local. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/scoped_vector.h" 13 #include "base/memory/scoped_vector.h"
14 #include "device/bluetooth/bluetooth_gatt_service.h" 14 #include "device/bluetooth/bluetooth_remote_gatt_service.h"
15 #include "device/bluetooth/bluetooth_uuid.h" 15 #include "device/bluetooth/bluetooth_uuid.h"
16 #include "device/bluetooth/test/mock_bluetooth_gatt_characteristic.h" 16 #include "device/bluetooth/test/mock_bluetooth_gatt_characteristic.h"
17 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
18 18
19 namespace device { 19 namespace device {
20 20
21 class BluetoothGattCharacteristic; 21 class BluetoothRemoteGattCharacteristic;
22 class MockBluetoothDevice; 22 class MockBluetoothDevice;
23 23
24 class MockBluetoothGattService : public BluetoothGattService { 24 class MockBluetoothGattService : public BluetoothRemoteGattService {
25 public: 25 public:
26 MockBluetoothGattService(MockBluetoothDevice* device, 26 MockBluetoothGattService(MockBluetoothDevice* device,
27 const std::string& identifier, 27 const std::string& identifier,
28 const BluetoothUUID& uuid, 28 const BluetoothUUID& uuid,
29 bool is_primary, 29 bool is_primary,
30 bool is_local); 30 bool is_local);
31 virtual ~MockBluetoothGattService(); 31 virtual ~MockBluetoothGattService();
32 32
33 MOCK_CONST_METHOD0(GetIdentifier, std::string()); 33 MOCK_CONST_METHOD0(GetIdentifier, std::string());
34 MOCK_CONST_METHOD0(GetUUID, BluetoothUUID()); 34 MOCK_CONST_METHOD0(GetUUID, BluetoothUUID());
35 MOCK_CONST_METHOD0(IsLocal, bool()); 35 MOCK_CONST_METHOD0(IsLocal, bool());
36 MOCK_CONST_METHOD0(IsPrimary, bool()); 36 MOCK_CONST_METHOD0(IsPrimary, bool());
37 MOCK_CONST_METHOD0(GetDevice, BluetoothDevice*()); 37 MOCK_CONST_METHOD0(GetDevice, BluetoothDevice*());
38 MOCK_CONST_METHOD0(GetCharacteristics, 38 MOCK_CONST_METHOD0(GetCharacteristics,
39 std::vector<BluetoothGattCharacteristic*>()); 39 std::vector<BluetoothRemoteGattCharacteristic*>());
40 MOCK_CONST_METHOD0(GetIncludedServices, std::vector<BluetoothGattService*>()); 40 MOCK_CONST_METHOD0(GetIncludedServices,
41 std::vector<BluetoothRemoteGattService*>());
41 MOCK_CONST_METHOD1(GetCharacteristic, 42 MOCK_CONST_METHOD1(GetCharacteristic,
42 BluetoothGattCharacteristic*(const std::string&)); 43 BluetoothRemoteGattCharacteristic*(const std::string&));
43 MOCK_METHOD1(AddCharacteristic, bool(BluetoothGattCharacteristic*)); 44 MOCK_METHOD1(AddCharacteristic, bool(BluetoothRemoteGattCharacteristic*));
44 MOCK_METHOD1(AddIncludedService, bool(BluetoothGattService*)); 45 MOCK_METHOD1(AddIncludedService, bool(BluetoothRemoteGattService*));
45 MOCK_METHOD2(Register, void(const base::Closure&, const ErrorCallback&)); 46 MOCK_METHOD2(Register, void(const base::Closure&, const ErrorCallback&));
46 MOCK_METHOD2(Unregister, void(const base::Closure&, const ErrorCallback&)); 47 MOCK_METHOD2(Unregister, void(const base::Closure&, const ErrorCallback&));
47 48
48 // BluetoothGattService manages the lifetime of its 49 // BluetoothRemoteGattService manages the lifetime of its
49 // BluetoothGATTCharacteristics. 50 // BluetoothGATTCharacteristics.
50 // This method takes ownership of the MockBluetoothGATTCharacteristics. This 51 // This method takes ownership of the MockBluetoothGATTCharacteristics. This
51 // is only for convenience as far as testing is concerned, and it's possible 52 // is only for convenience as far as testing is concerned, and it's possible
52 // to write test cases without using these functions. 53 // to write test cases without using these functions.
53 // Example: 54 // Example:
54 // ON_CALL(*mock_service, GetCharacteristics)) 55 // ON_CALL(*mock_service, GetCharacteristics))
55 // .WillByDefault(Invoke( 56 // .WillByDefault(Invoke(
56 // *mock_service, 57 // *mock_service,
57 // &MockBluetoothGattService::GetMockCharacteristics)); 58 // &MockBluetoothGattService::GetMockCharacteristics));
58 void AddMockCharacteristic( 59 void AddMockCharacteristic(
59 std::unique_ptr<MockBluetoothGattCharacteristic> mock_characteristic); 60 std::unique_ptr<MockBluetoothGattCharacteristic> mock_characteristic);
60 std::vector<BluetoothGattCharacteristic*> GetMockCharacteristics() const; 61 std::vector<BluetoothRemoteGattCharacteristic*> GetMockCharacteristics()
61 BluetoothGattCharacteristic* GetMockCharacteristic( 62 const;
63 BluetoothRemoteGattCharacteristic* GetMockCharacteristic(
62 const std::string& identifier) const; 64 const std::string& identifier) const;
63 65
64 private: 66 private:
65 ScopedVector<MockBluetoothGattCharacteristic> mock_characteristics_; 67 ScopedVector<MockBluetoothGattCharacteristic> mock_characteristics_;
66 68
67 DISALLOW_COPY_AND_ASSIGN(MockBluetoothGattService); 69 DISALLOW_COPY_AND_ASSIGN(MockBluetoothGattService);
68 }; 70 };
69 71
70 } // namespace device 72 } // namespace device
71 73
72 #endif // DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_GATT_SERVICE_H_ 74 #endif // DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_GATT_SERVICE_H_
OLDNEW
« no previous file with comments | « device/bluetooth/test/mock_bluetooth_gatt_descriptor.cc ('k') | device/bluetooth/test/mock_bluetooth_gatt_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698