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

Unified Diff: device/bluetooth/bluetooth_device_unittest.cc

Issue 2641133003: Bluetooth: macOS: Adding counter for service discovery callbacks. (Closed)
Patch Set: Adding logs Created 3 years, 11 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 85c8c9a97aa44fc480e67d253307a5067299e1da..ce936e2981c6ab92e847d53d6a6a7ef348fe546a 100644
--- a/device/bluetooth/bluetooth_device_unittest.cc
+++ b/device/bluetooth/bluetooth_device_unittest.cc
@@ -399,6 +399,39 @@ TEST_F(BluetoothTest, GetUUIDs_Connection) {
}
#endif // defined(OS_ANDROID) || defined(OS_MACOSX)
+#if defined(OS_MACOSX)
+TEST_F(BluetoothTest, DoubleDidModifyServicesEvent) {
ortuno 2017/01/23 06:12:38 This is a good test for the case in which we get t
jlebel 2017/01/23 18:49:38 Done.
+ if (!PlatformSupportsLowEnergy()) {
+ LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test.";
+ return;
+ }
+
+ InitWithFakeAdapter();
+ TestBluetoothAdapterObserver observer(adapter_);
+
+ BluetoothDevice* device = SimulateLowEnergyDevice(1);
+ device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED),
+ GetConnectErrorCallback(Call::NOT_EXPECTED));
+ SimulateGattConnection(device);
+
+ SimulateGattServicesDiscovered(device, {} /* services */);
+ EXPECT_EQ(2, observer.device_changed_count());
+ EXPECT_TRUE(device->IsGattServicesDiscoveryComplete());
+
+ observer.Reset();
+ SimulateGattServicesChanged(device);
+ SimulateGattServicesChanged(device);
+ EXPECT_EQ(2, observer.device_changed_count());
+ EXPECT_FALSE(device->IsGattServicesDiscoveryComplete());
+
+ observer.Reset();
+ SimulateGattServicesDiscovered(device, {} /* services */);
+ SimulateGattServicesDiscovered(device, {} /* services */);
ortuno 2017/01/23 06:12:38 Is there any way we can test that DiscoveryCharact
jlebel 2017/01/23 18:49:38 I guess the simplest way to do that would be to ad
ortuno 2017/01/23 20:44:02 SGTM
+ EXPECT_EQ(1, observer.device_changed_count());
+ EXPECT_TRUE(device->IsGattServicesDiscoveryComplete());
+}
+#endif // defined(OS_MACOSX)
+
#if defined(OS_ANDROID) || defined(OS_MACOSX)
// Tests Advertisement Data is updated correctly when we start discovery
// during a connection.

Powered by Google App Engine
This is Rietveld 408576698