Chromium Code Reviews| Index: device/bluetooth/test/mock_bluetooth_device.h |
| diff --git a/device/bluetooth/test/mock_bluetooth_device.h b/device/bluetooth/test/mock_bluetooth_device.h |
| index b0fc9659edc2ef19a5518400d735d9ebf673bdf2..ddb521aab1c6bcf3a78f107575e752f40b4e9e89 100644 |
| --- a/device/bluetooth/test/mock_bluetooth_device.h |
| +++ b/device/bluetooth/test/mock_bluetooth_device.h |
| @@ -116,6 +116,16 @@ class MockBluetoothDevice : public BluetoothDevice { |
| void AddUUID(const BluetoothUUID& uuid) { uuids_.insert(uuid); } |
| + // Functions to save and retrieve callbacks from this device. Useful when |
| + // trying to run callbacks in response to other actions e.g. run a read |
| + // value callback in response to a connection request. |
| + // Appends callback to the end of the callbacks queue. |
| + void PushPendingCallback(const base::Closure& callback); |
| + // Returns true if there are any callbacks in the queue; false otherwise. |
| + bool HasPendingCallback(); |
| + // Pops and returns the first callback in the queue. |
| + base::Closure PopPendingCallback(); |
|
Jeffrey Yasskin
2016/10/22 01:02:06
Consider making this RunAllCallbacks() instead. If
ortuno
2016/10/24 01:52:33
Done. I also removed the HasPendingCallback functi
|
| + |
| void SetConnected(bool connected) { connected_ = connected; } |
| private: |
| @@ -125,6 +135,9 @@ class MockBluetoothDevice : public BluetoothDevice { |
| BluetoothDevice::UUIDSet uuids_; |
| bool connected_; |
| + // Used by tests to save callbacks that will be run in the future. |
| + std::queue<base::Closure> pending_callbacks_; |
| + |
| ScopedVector<MockBluetoothGattService> mock_services_; |
| }; |