Index: device/bluetooth/bluetooth_device_unittest.cc |
diff --git a/device/bluetooth/bluetooth_device_unittest.cc b/device/bluetooth/bluetooth_device_unittest.cc |
index 4cea1b6fa6e48e13990e2564085aae1aad3bb134..d5ad42af174975f1115e92a8b6612a804f166fad 100644 |
--- a/device/bluetooth/bluetooth_device_unittest.cc |
+++ b/device/bluetooth/bluetooth_device_unittest.cc |
@@ -125,4 +125,36 @@ TEST_F(BluetoothTest, LowEnergyDeviceNoUUIDs) { |
// also require build configuration to generate string resources into a .pak |
// file. |
+#if defined(OS_ANDROID) |
+// Basic CreateGattConnection test. |
+TEST_F(BluetoothTest, CreateGattConnection) { |
+ InitWithFakeAdapter(); |
+ TestBluetoothAdapterObserver observer(adapter_); |
+ |
+ // Get a device. |
+ adapter_->StartDiscoverySession(GetDiscoverySessionCallback(), |
+ GetErrorCallback()); |
+ base::RunLoop().RunUntilIdle(); |
+ DiscoverLowEnergyDevice(3); |
+ base::RunLoop().RunUntilIdle(); |
+ BluetoothDevice* device = observer.last_device(); |
+ |
+ callback_count_ = error_callback_count_ = 0; |
+ device->CreateGattConnection(GetGattConnectionCallback(), |
Jeffrey Yasskin
2015/08/20 21:35:14
Can we also see some more complex interleavings of
scheib
2015/09/13 02:41:01
Done.
|
+ GetConnectErrorCallback()); |
+ CompleteGattConnection(device); |
+ EXPECT_EQ(1, callback_count_--); |
Jeffrey Yasskin
2015/08/20 21:35:14
I'd rather assign callback_count_ on a separate li
scheib
2015/09/13 02:41:01
I think this makes the test harder to read, but OK
|
+ EXPECT_EQ(0, error_callback_count_); |
+ ASSERT_EQ(1u, gatt_connections_.size()); |
+ EXPECT_TRUE(device->IsGattConnected()); |
+ |
+ // Connect again once already connected. |
+ device->CreateGattConnection(GetGattConnectionCallback(), |
+ GetConnectErrorCallback()); |
+ EXPECT_EQ(1, callback_count_--); |
+ EXPECT_EQ(0, error_callback_count_); |
+ ASSERT_EQ(2u, gatt_connections_.size()); |
+} |
+#endif // defined(OS_ANDROID) |
+ |
} // namespace device |