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

Unified Diff: device/bluetooth/test/mock_bluetooth_gatt_notify_session.cc

Issue 1382743002: bluetooth: Add characteristicvaluechanged event (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-notifications-1
Patch Set: Address jyasskin's comments Created 5 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_gatt_notify_session.cc
diff --git a/device/bluetooth/test/mock_bluetooth_gatt_notify_session.cc b/device/bluetooth/test/mock_bluetooth_gatt_notify_session.cc
index a4e9843621d11920d47cab102d95ccabbb5c48e5..e4123f67741db1a75d06e85469e36288f1613452 100644
--- a/device/bluetooth/test/mock_bluetooth_gatt_notify_session.cc
+++ b/device/bluetooth/test/mock_bluetooth_gatt_notify_session.cc
@@ -3,6 +3,8 @@
// found in the LICENSE file.
#include "device/bluetooth/test/mock_bluetooth_gatt_notify_session.h"
+#include "device/bluetooth/test/mock_bluetooth_adapter.h"
+#include "device/bluetooth/test/mock_bluetooth_gatt_characteristic.h"
using testing::Return;
@@ -18,4 +20,30 @@ MockBluetoothGattNotifySession::MockBluetoothGattNotifySession(
MockBluetoothGattNotifySession::~MockBluetoothGattNotifySession() {
}
+void MockBluetoothGattNotifySession::StartTestNotifications(
+ MockBluetoothAdapter* adapter,
+ MockBluetoothGattCharacteristic* characteristic,
+ const std::vector<uint8_t>& value) {
+ test_notifications_timer_.Start(
+ FROM_HERE, base::TimeDelta::FromMilliseconds(10),
+ base::Bind(&MockBluetoothGattNotifySession::DoNotify,
+ // base::Timer guarantees it won't call back after its
+ // destructor starts.
+ base::Unretained(this), base::Unretained(adapter),
+ characteristic, value));
+}
+
+void MockBluetoothGattNotifySession::StopTestNotifications() {
+ test_notifications_timer_.Stop();
+}
+
+void MockBluetoothGattNotifySession::DoNotify(
+ MockBluetoothAdapter* adapter,
+ MockBluetoothGattCharacteristic* characteristic,
+ const std::vector<uint8_t>& value) {
+ FOR_EACH_OBSERVER(
+ BluetoothAdapter::Observer, adapter->GetObservers(),
+ GattCharacteristicValueChanged(adapter, characteristic, value));
+}
+
} // namespace device

Powered by Google App Engine
This is Rietveld 408576698