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

Unified Diff: device/bluetooth/bluetooth_remote_gatt_descriptor_unittest.cc

Issue 2702163002: bluetooth: Close and null out BluetoothGatt on the UI Thread (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
« no previous file with comments | « device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/bluetooth_remote_gatt_descriptor_unittest.cc
diff --git a/device/bluetooth/bluetooth_remote_gatt_descriptor_unittest.cc b/device/bluetooth/bluetooth_remote_gatt_descriptor_unittest.cc
index 87aad25bcd2e309086c7fb8de5edd9e53bb239ed..1152797d16b26ceba4c426f1739e6d60bb2efa8f 100644
--- a/device/bluetooth/bluetooth_remote_gatt_descriptor_unittest.cc
+++ b/device/bluetooth/bluetooth_remote_gatt_descriptor_unittest.cc
@@ -640,4 +640,53 @@ TEST_F(BluetoothRemoteGattDescriptorTest, WriteRemoteDescriptor_ReadPending) {
}
#endif // defined(OS_ANDROID)
+#if defined(OS_ANDROID)
+// Tests that read requests after a device disconnects but before the
+// disconnect task runs do not result in a crash.
+// macOS: Does not apply. All events arrive on the UI Thread.
+// TODO(crbug.com/694102): Enable this test on Windows.
+TEST_F(BluetoothRemoteGattDescriptorTest, ReadDuringDisconnect) {
+ if (!PlatformSupportsLowEnergy()) {
+ LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test.";
+ return;
+ }
+
+ ASSERT_NO_FATAL_FAILURE(FakeDescriptorBoilerplate());
+
+ SimulateGattDisconnection(device_);
+ // Don't run the disconnect task.
+ descriptor1_->ReadRemoteDescriptor(GetReadValueCallback(Call::NOT_EXPECTED),
+ // TODO(crbug.com/621901): Expect an error.
+ GetGattErrorCallback(Call::NOT_EXPECTED));
+
+ base::RunLoop().RunUntilIdle();
+ // TODO(crbug.com/621901): Test error callback was called.
+}
+#endif // defined(OS_ANDROID)
+
+#if defined(OS_ANDROID)
+// Tests that write requests after a device disconnects but before the
+// disconnect task runs do not result in a crash.
+// macOS: Does not apply. All events arrive on the UI Thread.
+// TODO(crbug.com/694102): Enable this test on Windows.
+TEST_F(BluetoothRemoteGattDescriptorTest, WriteDuringDisconnect) {
+ if (!PlatformSupportsLowEnergy()) {
+ LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test.";
+ return;
+ }
+
+ ASSERT_NO_FATAL_FAILURE(FakeDescriptorBoilerplate());
+
+ SimulateGattDisconnection(device_);
+ // Don't run the disconnect task.
+ descriptor1_->WriteRemoteDescriptor(
+ std::vector<uint8_t>(), GetCallback(Call::NOT_EXPECTED),
+ // TODO(crbug.com/621901): Expect an error.
+ GetGattErrorCallback(Call::NOT_EXPECTED));
+
+ base::RunLoop().RunUntilIdle();
+ // TODO(crbug.com/621901): Test that an error was returned.
+}
+#endif // defined(OS_ANDROID)
+
} // namespace device
« no previous file with comments | « device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698