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

Unified Diff: device/bluetooth/bluetooth_local_gatt_characteristic_unittest.cc

Issue 1973703002: Implement //device/bt changes for notifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@notifications_dbus
Patch Set: Created 4 years, 7 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/bluetooth_local_gatt_characteristic_unittest.cc
diff --git a/device/bluetooth/bluetooth_local_gatt_characteristic_unittest.cc b/device/bluetooth/bluetooth_local_gatt_characteristic_unittest.cc
index dc9f9e8d99b6ccff0ae4765ac475c4c111a47c04..54a727583bef2ce732756610275b2734839579f2 100644
--- a/device/bluetooth/bluetooth_local_gatt_characteristic_unittest.cc
+++ b/device/bluetooth/bluetooth_local_gatt_characteristic_unittest.cc
@@ -27,14 +27,21 @@ class BluetoothLocalGattCharacteristicTest : public BluetoothGattServerTest {
device::BluetoothLocalGattCharacteristic::PROPERTY_RELIABLE_WRITE,
device::BluetoothLocalGattCharacteristic::Permissions(),
service_.get());
+ notify_characteristic_ = BluetoothLocalGattCharacteristic::Create(
+ BluetoothUUID(kTestUUIDGenericAttribute),
+ device::BluetoothLocalGattCharacteristic::PROPERTY_NOTIFY,
+ device::BluetoothLocalGattCharacteristic::Permissions(),
+ service_.get());
EXPECT_LT(0u, read_characteristic_->GetIdentifier().size());
EXPECT_LT(0u, write_characteristic_->GetIdentifier().size());
+ EXPECT_LT(0u, notify_characteristic_->GetIdentifier().size());
CompleteGattSetup();
}
protected:
base::WeakPtr<BluetoothLocalGattCharacteristic> read_characteristic_;
base::WeakPtr<BluetoothLocalGattCharacteristic> write_characteristic_;
+ base::WeakPtr<BluetoothLocalGattCharacteristic> notify_characteristic_;
};
#if defined(OS_CHROMEOS) || defined(OS_LINUX)
@@ -108,4 +115,38 @@ TEST_F(BluetoothLocalGattCharacteristicTest,
}
#endif // defined(OS_CHROMEOS) || defined(OS_LINUX)
+#if defined(OS_CHROMEOS) || defined(OS_LINUX)
+TEST_F(BluetoothLocalGattCharacteristicTest, StartAndStopNotifications) {
scheib 2016/05/12 16:53:19 Test Stop as well?
rkc 2016/05/12 20:12:49 Done.
+ EXPECT_FALSE(SimulateLocalGattCharacteristicNotificationsRequest(
+ service_.get(), read_characteristic_.get(), true));
+ EXPECT_FALSE(delegate_->NotificationStatusForCharacteristic(
+ read_characteristic_.get()));
+
+ EXPECT_FALSE(SimulateLocalGattCharacteristicNotificationsRequest(
+ service_.get(), write_characteristic_.get(), true));
+ EXPECT_FALSE(delegate_->NotificationStatusForCharacteristic(
+ write_characteristic_.get()));
+
+ EXPECT_TRUE(SimulateLocalGattCharacteristicNotificationsRequest(
+ service_.get(), notify_characteristic_.get(), true));
+ EXPECT_TRUE(delegate_->NotificationStatusForCharacteristic(
+ notify_characteristic_.get()));
+}
+#endif // defined(OS_CHROMEOS) || defined(OS_LINUX)
+
+#if defined(OS_CHROMEOS) || defined(OS_LINUX)
+TEST_F(BluetoothLocalGattCharacteristicTest, SendNotifications) {
+ const uint64_t kNewValue = 0x7331ul;
+
+ EXPECT_FALSE(SimulateLocalGattCharacteristicSendValueUpdate(
+ service_.get(), read_characteristic_.get(), GetValue(kNewValue)));
+
+ EXPECT_FALSE(SimulateLocalGattCharacteristicSendValueUpdate(
+ service_.get(), write_characteristic_.get(), GetValue(kNewValue)));
+
+ EXPECT_TRUE(SimulateLocalGattCharacteristicSendValueUpdate(
+ service_.get(), notify_characteristic_.get(), GetValue(kNewValue)));
+}
+#endif // defined(OS_CHROMEOS) || defined(OS_LINUX)
+
} // namespace device

Powered by Google App Engine
This is Rietveld 408576698