Chromium Code Reviews| Index: device/bluetooth/bluetooth_device_unittest.cc |
| diff --git a/device/bluetooth/bluetooth_device_unittest.cc b/device/bluetooth/bluetooth_device_unittest.cc |
| index 01ed7837171d346f8820798fda8959b4a24244a9..07ef1c6b69cdfd2b4aa259f4f56555e5ca5cd226 100644 |
| --- a/device/bluetooth/bluetooth_device_unittest.cc |
| +++ b/device/bluetooth/bluetooth_device_unittest.cc |
| @@ -395,6 +395,43 @@ TEST_F(BluetoothTest, GetUUIDs_Connection) { |
| } |
| #endif // defined(OS_ANDROID) || defined(OS_MACOSX) |
| +#if defined(OS_MACOSX) |
| +// Tests that receiving 2 notifications in a row from macOS that services has |
|
ortuno
2017/01/23 20:44:02
Add why this doesn't apply to Android:
// Android
jlebel
2017/01/26 00:36:54
Done.
|
| +// changed is handled correctly. Each notification should generate a notfication |
| +// that the gatt device has changed, and each notification should ask to macOS |
| +// to scan for services. Only after the second service scan is received, the |
| +// device changed notification should be sent. |
|
ortuno
2017/01/23 20:44:02
I think this should be: the characteristic discove
jlebel
2017/01/26 00:36:54
Done.
|
| +TEST_F(BluetoothTest, DoubleDidModifyServicesEvent) { |
| + 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); |
| + EXPECT_EQ(1, observer.device_changed_count()); |
| + EXPECT_FALSE(device->IsGattServicesDiscoveryComplete()); |
| + |
| + observer.Reset(); |
| + SimulateGattServicesChanged(device); |
| + EXPECT_EQ(1, observer.device_changed_count()); |
| + EXPECT_FALSE(device->IsGattServicesDiscoveryComplete()); |
| + |
| + observer.Reset(); |
| + SimulateGattServicesDiscovered(device, {} /* services */); |
|
ortuno
2017/01/23 20:44:02
Could we add a service here and a different one be
jlebel
2017/01/26 00:36:54
Done.
|
| + EXPECT_EQ(0, observer.device_changed_count()); |
| + EXPECT_FALSE(device->IsGattServicesDiscoveryComplete()); |
| + SimulateGattServicesDiscovered(device, {} /* services */); |
| + 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. |