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..f7a620b59c0b48c201ef6b5fe7ae731418794a83 100644 |
--- a/device/bluetooth/test/mock_bluetooth_device.h |
+++ b/device/bluetooth/test/mock_bluetooth_device.h |
@@ -116,6 +116,14 @@ class MockBluetoothDevice : public BluetoothDevice { |
void AddUUID(const BluetoothUUID& uuid) { uuids_.insert(uuid); } |
+ // Functions to save and run 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); |
+ // Runs all pending callbacks. |
+ void RunPendingCallbacks(); |
+ |
void SetConnected(bool connected) { connected_ = connected; } |
private: |
@@ -125,6 +133,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_; |
}; |