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

Side by Side Diff: device/bluetooth/test/mock_bluetooth_device.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: minor cleanup 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_DEVICE_H_ 5 #ifndef DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_DEVICE_H_
6 #define DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_DEVICE_H_ 6 #define DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_DEVICE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <string> 11 #include <string>
12 12
13 #include "base/memory/scoped_vector.h" 13 #include "base/memory/scoped_vector.h"
14 #include "base/strings/string16.h" 14 #include "base/strings/string16.h"
15 #include "device/bluetooth/bluetooth_device.h" 15 #include "device/bluetooth/bluetooth_device.h"
16 #include "device/bluetooth/bluetooth_uuid.h" 16 #include "device/bluetooth/bluetooth_uuid.h"
17 #include "device/bluetooth/test/mock_bluetooth_gatt_service.h" 17 #include "device/bluetooth/test/mock_bluetooth_gatt_service.h"
18 #include "testing/gmock/include/gmock/gmock.h" 18 #include "testing/gmock/include/gmock/gmock.h"
19 19
20 namespace device { 20 namespace device {
21 21
22 class BluetoothGattService; 22 class BluetoothRemoteGattService;
23 class MockBluetoothAdapter; 23 class MockBluetoothAdapter;
24 24
25 class MockBluetoothDevice : public BluetoothDevice { 25 class MockBluetoothDevice : public BluetoothDevice {
26 public: 26 public:
27 MockBluetoothDevice(MockBluetoothAdapter* adapter, 27 MockBluetoothDevice(MockBluetoothAdapter* adapter,
28 uint32_t bluetooth_class, 28 uint32_t bluetooth_class,
29 const std::string& name, 29 const std::string& name,
30 const std::string& address, 30 const std::string& address,
31 bool paired, 31 bool paired,
32 bool connected); 32 bool connected);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 const ConnectToServiceCallback& callback, 81 const ConnectToServiceCallback& callback,
82 const ConnectToServiceErrorCallback& error_callback)); 82 const ConnectToServiceErrorCallback& error_callback));
83 MOCK_METHOD3(ConnectToServiceInsecurely, 83 MOCK_METHOD3(ConnectToServiceInsecurely,
84 void(const BluetoothUUID& uuid, 84 void(const BluetoothUUID& uuid,
85 const ConnectToServiceCallback& callback, 85 const ConnectToServiceCallback& callback,
86 const ConnectToServiceErrorCallback& error_callback)); 86 const ConnectToServiceErrorCallback& error_callback));
87 MOCK_METHOD2(CreateGattConnection, 87 MOCK_METHOD2(CreateGattConnection,
88 void(const GattConnectionCallback& callback, 88 void(const GattConnectionCallback& callback,
89 const ConnectErrorCallback& error_callback)); 89 const ConnectErrorCallback& error_callback));
90 90
91 MOCK_CONST_METHOD0(GetGattServices, std::vector<BluetoothGattService*>()); 91 MOCK_CONST_METHOD0(GetGattServices,
92 MOCK_CONST_METHOD1(GetGattService, BluetoothGattService*(const std::string&)); 92 std::vector<BluetoothRemoteGattService*>());
93 MOCK_CONST_METHOD1(GetGattService,
94 BluetoothRemoteGattService*(const std::string&));
93 MOCK_METHOD0(CreateGattConnectionImpl, void()); 95 MOCK_METHOD0(CreateGattConnectionImpl, void());
94 MOCK_METHOD0(DisconnectGatt, void()); 96 MOCK_METHOD0(DisconnectGatt, void());
95 97
96 // BluetoothDevice manages the lifetime of its BluetoothGATTServices. 98 // BluetoothDevice manages the lifetime of its BluetoothGATTServices.
97 // This method takes ownership of the MockBluetoothGATTServices. This is only 99 // This method takes ownership of the MockBluetoothGATTServices. This is only
98 // for convenience as far as testing is concerned, and it's possible to write 100 // for convenience as far as testing is concerned, and it's possible to write
99 // test cases without using these functions. 101 // test cases without using these functions.
100 // Example: 102 // Example:
101 // ON_CALL(*mock_device, GetGattServices)) 103 // ON_CALL(*mock_device, GetGattServices))
102 // .WillByDefault(Invoke(*mock_device, 104 // .WillByDefault(Invoke(*mock_device,
103 // &MockBluetoothDevice::GetMockServices)); 105 // &MockBluetoothDevice::GetMockServices));
104 void AddMockService(std::unique_ptr<MockBluetoothGattService> mock_device); 106 void AddMockService(std::unique_ptr<MockBluetoothGattService> mock_device);
105 std::vector<BluetoothGattService*> GetMockServices() const; 107 std::vector<BluetoothRemoteGattService*> GetMockServices() const;
106 BluetoothGattService* GetMockService(const std::string& identifier) const; 108 BluetoothRemoteGattService* GetMockService(
109 const std::string& identifier) const;
107 110
108 private: 111 private:
109 uint32_t bluetooth_class_; 112 uint32_t bluetooth_class_;
110 std::string name_; 113 std::string name_;
111 std::string address_; 114 std::string address_;
112 BluetoothDevice::UUIDList uuids_; 115 BluetoothDevice::UUIDList uuids_;
113 116
114 ScopedVector<MockBluetoothGattService> mock_services_; 117 ScopedVector<MockBluetoothGattService> mock_services_;
115 }; 118 };
116 119
117 } // namespace device 120 } // namespace device
118 121
119 #endif // DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_DEVICE_H_ 122 #endif // DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_DEVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698