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

Unified Diff: device/bluetooth/bluetooth_device_unittest.cc

Issue 2037173003: Notify the BluetoothAdapter::Observer when a bluetooth peripheral disconnects on Android and Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 years, 6 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_device.cc ('k') | device/bluetooth/bluez/bluetooth_adapter_bluez.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/bluetooth_device_unittest.cc
diff --git a/device/bluetooth/bluetooth_device_unittest.cc b/device/bluetooth/bluetooth_device_unittest.cc
index 0b075e250d02187bba5c4bd989889af0079a1a9c..6ac2f63c374bf7c53a2d67bc8d1cc31b4790d750 100644
--- a/device/bluetooth/bluetooth_device_unittest.cc
+++ b/device/bluetooth/bluetooth_device_unittest.cc
@@ -158,6 +158,30 @@ TEST_F(BluetoothTest, CreateGattConnection) {
#endif // defined(OS_ANDROID) || defined(OS_MACOSX)
#if defined(OS_ANDROID) || defined(OS_MACOSX)
+TEST_F(BluetoothTest, DisconnectionNotifiesDeviceChanged) {
+ if (!PlatformSupportsLowEnergy()) {
+ LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test.";
+ return;
+ }
+ InitWithFakeAdapter();
+ TestBluetoothAdapterObserver observer(adapter_);
+ StartLowEnergyDiscoverySession();
+ BluetoothDevice* device = SimulateLowEnergyDevice(3);
+ device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED),
+ GetConnectErrorCallback(Call::NOT_EXPECTED));
+ SimulateGattConnection(device);
+ EXPECT_EQ(1, observer.device_changed_count());
+ EXPECT_TRUE(device->IsConnected());
+ EXPECT_TRUE(device->IsGattConnected());
+
+ SimulateGattDisconnection(device);
+ EXPECT_EQ(2, observer.device_changed_count());
+ EXPECT_FALSE(device->IsConnected());
+ EXPECT_FALSE(device->IsGattConnected());
+}
+#endif // defined(OS_ANDROID) || defined(OS_MACOSX)
+
+#if defined(OS_ANDROID) || defined(OS_MACOSX)
// Creates BluetoothGattConnection instances and tests that the interface
// functions even when some Disconnect and the BluetoothDevice is destroyed.
TEST_F(BluetoothTest, BluetoothGattConnection) {
« no previous file with comments | « device/bluetooth/bluetooth_device.cc ('k') | device/bluetooth/bluez/bluetooth_adapter_bluez.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698