| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 // ON_CALL(*mock_device, GetGattServices)) | 109 // ON_CALL(*mock_device, GetGattServices)) |
| 110 // .WillByDefault(Invoke(*mock_device, | 110 // .WillByDefault(Invoke(*mock_device, |
| 111 // &MockBluetoothDevice::GetMockServices)); | 111 // &MockBluetoothDevice::GetMockServices)); |
| 112 void AddMockService(std::unique_ptr<MockBluetoothGattService> mock_device); | 112 void AddMockService(std::unique_ptr<MockBluetoothGattService> mock_device); |
| 113 std::vector<BluetoothRemoteGattService*> GetMockServices() const; | 113 std::vector<BluetoothRemoteGattService*> GetMockServices() const; |
| 114 BluetoothRemoteGattService* GetMockService( | 114 BluetoothRemoteGattService* GetMockService( |
| 115 const std::string& identifier) const; | 115 const std::string& identifier) const; |
| 116 | 116 |
| 117 void AddUUID(const BluetoothUUID& uuid) { uuids_.insert(uuid); } | 117 void AddUUID(const BluetoothUUID& uuid) { uuids_.insert(uuid); } |
| 118 | 118 |
| 119 // Functions to save and run callbacks from this device. Useful when |
| 120 // trying to run callbacks in response to other actions e.g. run a read |
| 121 // value callback in response to a connection request. |
| 122 // Appends callback to the end of the callbacks queue. |
| 123 void PushPendingCallback(const base::Closure& callback); |
| 124 // Runs all pending callbacks. |
| 125 void RunPendingCallbacks(); |
| 126 |
| 119 void SetConnected(bool connected) { connected_ = connected; } | 127 void SetConnected(bool connected) { connected_ = connected; } |
| 120 | 128 |
| 121 private: | 129 private: |
| 122 uint32_t bluetooth_class_; | 130 uint32_t bluetooth_class_; |
| 123 base::Optional<std::string> name_; | 131 base::Optional<std::string> name_; |
| 124 std::string address_; | 132 std::string address_; |
| 125 BluetoothDevice::UUIDSet uuids_; | 133 BluetoothDevice::UUIDSet uuids_; |
| 126 bool connected_; | 134 bool connected_; |
| 127 | 135 |
| 136 // Used by tests to save callbacks that will be run in the future. |
| 137 std::queue<base::Closure> pending_callbacks_; |
| 138 |
| 128 ScopedVector<MockBluetoothGattService> mock_services_; | 139 ScopedVector<MockBluetoothGattService> mock_services_; |
| 129 }; | 140 }; |
| 130 | 141 |
| 131 } // namespace device | 142 } // namespace device |
| 132 | 143 |
| 133 #endif // DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_DEVICE_H_ | 144 #endif // DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_DEVICE_H_ |
| OLD | NEW |