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

Unified Diff: device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc

Issue 2707823002: bluetooth: Save characteristic value when notification arrives (Closed)
Patch Set: fix test Created 3 years, 9 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_remote_gatt_characteristic_unittest.cc
diff --git a/device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc b/device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc
index a1bd087993b730985f41faaa9e705b8e8586b30b..d934cfdfd47a54a3e850892e1c67b014f10e07b1 100644
--- a/device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc
+++ b/device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc
@@ -2136,6 +2136,36 @@ TEST_F(BluetoothRemoteGattCharacteristicTest, GattCharacteristicValueChanged) {
}
#endif // defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN)
+#if defined(OS_ANDROID)
+// Tests that Characteristic value changes arriving consecutively result in
+// two notifications with correct values.
+// macOS: Does not apply. All events arrive on the UI Thread.
+// TODO(crbug.com/694102): Enable this test on Windows.
+TEST_F(BluetoothRemoteGattCharacteristicTest,
+ TwoGattCharacteristicValueChanges) {
+ if (!PlatformSupportsLowEnergy()) {
+ LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test.";
+ return;
+ }
+ ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
+ /* properties: NOTIFY */ 0x10, NotifyValueState::NOTIFY));
+
+ TestBluetoothAdapterObserver observer(adapter_);
+
+ std::vector<uint8_t> test_vector1({111});
+ std::vector<uint8_t> test_vector2({222});
+
+ SimulateGattCharacteristicChanged(characteristic1_, test_vector1);
+ SimulateGattCharacteristicChanged(characteristic1_, test_vector2);
+
+ base::RunLoop().RunUntilIdle();
+ EXPECT_EQ(2, observer.gatt_characteristic_value_changed_count());
+ EXPECT_EQ(test_vector2, characteristic1_->GetValue());
+ EXPECT_EQ(std::vector<std::vector<uint8_t>>({test_vector1, test_vector2}),
+ observer.previous_characteristic_value_changed_values());
+}
+#endif // defined(OS_ANDROID)
+
#if defined(OS_ANDROID) || defined(OS_WIN)
// Tests Characteristic Value changing after a Notify Session and objects being
// destroyed.

Powered by Google App Engine
This is Rietveld 408576698