OLD | NEW |
---|---|
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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/scoped_vector.h" | |
10 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
11 #include "device/bluetooth/bluetooth_device.h" | 12 #include "device/bluetooth/bluetooth_device.h" |
12 #include "device/bluetooth/bluetooth_uuid.h" | 13 #include "device/bluetooth/bluetooth_uuid.h" |
14 #include "device/bluetooth/test/mock_bluetooth_gatt_service.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 |
19 class BluetoothGattService; | |
17 class MockBluetoothAdapter; | 20 class MockBluetoothAdapter; |
18 | 21 |
19 class MockBluetoothDevice : public BluetoothDevice { | 22 class MockBluetoothDevice : public BluetoothDevice { |
20 public: | 23 public: |
21 MockBluetoothDevice(MockBluetoothAdapter* adapter, | 24 MockBluetoothDevice(MockBluetoothAdapter* adapter, |
22 uint32 bluetooth_class, | 25 uint32 bluetooth_class, |
23 const std::string& name, | 26 const std::string& name, |
24 const std::string& address, | 27 const std::string& address, |
25 bool paired, | 28 bool paired, |
26 bool connected); | 29 bool connected); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 void(const GattConnectionCallback& callback, | 75 void(const GattConnectionCallback& callback, |
73 const ConnectErrorCallback& error_callback)); | 76 const ConnectErrorCallback& error_callback)); |
74 | 77 |
75 MOCK_METHOD2(StartConnectionMonitor, | 78 MOCK_METHOD2(StartConnectionMonitor, |
76 void(const base::Closure& callback, | 79 void(const base::Closure& callback, |
77 const BluetoothDevice::ErrorCallback& error_callback)); | 80 const BluetoothDevice::ErrorCallback& error_callback)); |
78 | 81 |
79 MOCK_CONST_METHOD0(GetGattServices, std::vector<BluetoothGattService*>()); | 82 MOCK_CONST_METHOD0(GetGattServices, std::vector<BluetoothGattService*>()); |
80 MOCK_CONST_METHOD1(GetGattService, BluetoothGattService*(const std::string&)); | 83 MOCK_CONST_METHOD1(GetGattService, BluetoothGattService*(const std::string&)); |
81 | 84 |
85 // BluetoothDevice manages the lifetime of its BluetoothGATTServices. | |
86 // This methods takes ownership of the BluetoothGATTServices. This is only for | |
87 // convenience as far as testing is concerned, and it's possible to write test | |
88 // cases without using these functions. | |
scheib
2015/05/28 23:09:16
Document how to use the method in tests with the c
ortuno
2015/05/29 17:53:55
Done.
| |
89 void AddMockService(scoped_ptr<MockBluetoothGattService> mock_device); | |
90 std::vector<BluetoothGattService*> GetMockServices(); | |
91 | |
82 private: | 92 private: |
83 uint32 bluetooth_class_; | 93 uint32 bluetooth_class_; |
84 std::string name_; | 94 std::string name_; |
85 std::string address_; | 95 std::string address_; |
86 BluetoothDevice::UUIDList uuids_; | 96 BluetoothDevice::UUIDList uuids_; |
97 | |
98 ScopedVector<MockBluetoothGattService> mock_services_; | |
87 }; | 99 }; |
88 | 100 |
89 } // namespace device | 101 } // namespace device |
90 | 102 |
91 #endif // DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_DEVICE_H_ | 103 #endif // DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_DEVICE_H_ |
OLD | NEW |