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

Unified Diff: device/bluetooth/bluetooth_device_unittest.cc

Issue 1256313002: bluetooth: android: Implement & test CreateGattConnection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated patchset dependency Created 5 years, 4 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_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

Powered by Google App Engine
This is Rietveld 408576698