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

Unified Diff: device/bluetooth/test/mock_bluetooth_device.h

Issue 2438963002: bluetooth: Add tests for when frame reconnects during readValue (Closed)
Patch Set: Address jyasskin's comments Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
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_;
};

Powered by Google App Engine
This is Rietveld 408576698