Chromium Code Reviews| Index: device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc |
| diff --git a/device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc b/device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc |
| index a0ee705f9173ccb1c95a6afb6f176a3ef30cfc37..fcc4d7990f34a4f8506e864ecc2dab59c4b93c95 100644 |
| --- a/device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc |
| +++ b/device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc |
| @@ -1155,10 +1155,7 @@ TEST_F(BluetoothRemoteGattCharacteristicTest, StartNotifySession_Multiple) { |
| characteristic1_, |
| BluetoothRemoteGattDescriptor::ClientCharacteristicConfigurationUuid() |
| .canonical_value()); |
| -#if !defined(OS_MACOSX) |
| - // TODO(crbug.com/624017): Need implementation for descriptors. |
| ASSERT_EQ(1u, characteristic1_->GetDescriptors().size()); |
| -#endif // !defined(OS_MACOSX) |
| characteristic1_->StartNotifySession( |
| GetNotifyCallback(Call::EXPECTED), |
| @@ -1513,13 +1510,15 @@ TEST_F(BluetoothRemoteGattCharacteristicTest, |
| } |
| #endif // defined(OS_ANDROID) |
| -#if defined(OS_ANDROID) |
| +#if defined(OS_ANDROID) || defined(OS_MACOSX) |
| // Tests that cancelling StopNotifySession works. |
| -// TODO(crbug.com/633191): Enable on macOS when SubscribeToNotifications is |
| -// implemented. |
| // TODO(crbug.com/636270): Enable on Windows when SubscribeToNotifications is |
| // implemented. |
| TEST_F(BluetoothRemoteGattCharacteristicTest, StopNotifySession_Cancelled) { |
| + if (!PlatformSupportsLowEnergy()) { |
| + LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
| + return; |
| + } |
| ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( |
| /* properties: NOTIFY */ 0x10, |
| /* expected_config_descriptor_value: NOTIFY */ 1)); |
| @@ -1537,11 +1536,15 @@ TEST_F(BluetoothRemoteGattCharacteristicTest, StopNotifySession_Cancelled) { |
| // Cancel Stop by deleting the device before Stop finishes. |
| DeleteDevice(device_); // TODO(576906) delete only the characteristic. |
| } |
| -#endif // defined(OS_ANDROID) |
| +#endif // defined(OS_ANDROID) || defined(OS_MACOSX) |
| -#if defined(OS_ANDROID) |
| +#if defined(OS_ANDROID) || defined(OS_MACOSX) |
| // Tests that deleted sessions are stopped. |
| TEST_F(BluetoothRemoteGattCharacteristicTest, StopNotifySession_AfterDeleted) { |
| + if (!PlatformSupportsLowEnergy()) { |
| + LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
| + return; |
| + } |
| ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( |
| /* properties: NOTIFY */ 0x10, |
| /* expected_config_descriptor_value: NOTIFY */ 1)); |
| @@ -1571,7 +1574,7 @@ TEST_F(BluetoothRemoteGattCharacteristicTest, StopNotifySession_AfterDeleted) { |
| notify_sessions_[0]->GetCharacteristicIdentifier()); |
| EXPECT_FALSE(notify_sessions_[0]->IsActive()); |
| } |
| -#endif // defined(OS_ANDROID) |
| +#endif // defined(OS_ANDROID) || defined(OS_MACOSX) |
| #if defined(OS_ANDROID) |
|
ortuno
2017/02/09 00:34:48
Can you mention why this is not enabled on macOS?
jlebel
2017/02/09 01:20:18
Done.
|
| // Tests StopNotifySession success on a characteristic that enabled Indicate. |
| @@ -1623,9 +1626,13 @@ TEST_F(BluetoothRemoteGattCharacteristicTest, |
| } |
| #endif // defined(OS_ANDROID) |
| -#if defined(OS_ANDROID) |
| +#if defined(OS_ANDROID) || defined(OS_MACOSX) |
| // Tests StopNotifySession error |
| TEST_F(BluetoothRemoteGattCharacteristicTest, StopNotifySession_Error) { |
| + if (!PlatformSupportsLowEnergy()) { |
| + LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
| + return; |
| + } |
| ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( |
| /* properties: NOTIFY */ 0x10, |
| /* expected_config_descriptor_value: NOTIFY */ 1)); |
| @@ -1646,22 +1653,23 @@ TEST_F(BluetoothRemoteGattCharacteristicTest, StopNotifySession_Error) { |
| EXPECT_FALSE(notify_sessions_[0]->IsActive()); |
| EXPECT_FALSE(characteristic1_->IsNotifying()); |
| } |
| -#endif // defined(OS_ANDROID) |
| +#endif // defined(OS_ANDROID) || defined(OS_MACOSX) |
| -#if defined(OS_ANDROID) |
| +#if defined(OS_ANDROID) || defined(OS_MACOSX) |
| // Tests multiple StopNotifySession calls for a single session. |
| TEST_F(BluetoothRemoteGattCharacteristicTest, StopNotifySession_Multiple1) { |
| + if (!PlatformSupportsLowEnergy()) { |
| + LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
| + return; |
| + } |
| ASSERT_NO_FATAL_FAILURE( |
| FakeCharacteristicBoilerplate(/* properties: NOTIFY */ 0x10)); |
| -#if !defined(OS_MACOSX) |
| - // TODO(624017) enable for macosx |
| SimulateGattDescriptor( |
| characteristic1_, |
| BluetoothRemoteGattDescriptor::ClientCharacteristicConfigurationUuid() |
| .canonical_value()); |
| ASSERT_EQ(1u, characteristic1_->GetDescriptors().size()); |
| -#endif |
| // Start notify session |
| characteristic1_->StartNotifySession( |
| @@ -1690,22 +1698,24 @@ TEST_F(BluetoothRemoteGattCharacteristicTest, StopNotifySession_Multiple1) { |
| EXPECT_FALSE(notify_sessions_[0]->IsActive()); |
| EXPECT_FALSE(characteristic1_->IsNotifying()); |
| } |
| -#endif // defined(OS_ANDROID) |
| +#endif // defined(OS_ANDROID) || defined(OS_MACOSX) |
| -#if defined(OS_ANDROID) |
| +#if defined(OS_ANDROID) || defined(OS_MACOSX) |
| // Tests multiple StartNotifySession calls and multiple StopNotifySession calls. |
| TEST_F(BluetoothRemoteGattCharacteristicTest, StopNotifySession_Multiple2) { |
| + if (!PlatformSupportsLowEnergy()) { |
| + LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
| + return; |
| + } |
| ASSERT_NO_FATAL_FAILURE( |
| FakeCharacteristicBoilerplate(/* properties: NOTIFY */ 0x10)); |
| -#if !defined(OS_MACOSX) |
| // TODO(624017) enable for macosx |
|
ortuno
2017/02/09 00:34:48
nit: remove the TODO.
jlebel
2017/02/09 01:20:18
Done.
|
| SimulateGattDescriptor( |
| characteristic1_, |
| BluetoothRemoteGattDescriptor::ClientCharacteristicConfigurationUuid() |
| .canonical_value()); |
| ASSERT_EQ(1u, characteristic1_->GetDescriptors().size()); |
| -#endif |
| // Start notify sessions |
| characteristic1_->StartNotifySession( |
| @@ -1745,12 +1755,16 @@ TEST_F(BluetoothRemoteGattCharacteristicTest, StopNotifySession_Multiple2) { |
| EXPECT_FALSE(notify_sessions_[1]->IsActive()); |
| EXPECT_FALSE(characteristic1_->IsNotifying()); |
| } |
| -#endif // defined(OS_ANDROID) |
| +#endif // defined(OS_ANDROID) || defined(OS_MACOSX) |
| -#if defined(OS_ANDROID) |
| +#if defined(OS_ANDROID) || defined(OS_MACOSX) |
| // Tests starting a new notify session before the previous stop request |
| // resolves. |
| TEST_F(BluetoothRemoteGattCharacteristicTest, StopNotifySession_StopStart) { |
| + if (!PlatformSupportsLowEnergy()) { |
| + LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
| + return; |
| + } |
| ASSERT_NO_FATAL_FAILURE( |
| FakeCharacteristicBoilerplate(/* properties: NOTIFY */ 0x10)); |
| SimulateGattDescriptor( |
| @@ -1791,11 +1805,15 @@ TEST_F(BluetoothRemoteGattCharacteristicTest, StopNotifySession_StopStart) { |
| EXPECT_TRUE(notify_sessions_[1]->IsActive()); |
| EXPECT_TRUE(characteristic1_->IsNotifying()); |
| } |
| -#endif // defined(OS_ANDROID) |
| +#endif // defined(OS_ANDROID) || defined(OS_MACOSX) |
| -#if defined(OS_ANDROID) |
| +#if defined(OS_ANDROID) || defined(OS_MACOSX) |
| TEST_F(BluetoothRemoteGattCharacteristicTest, |
| StopNotifySession_StartStopStart) { |
| + if (!PlatformSupportsLowEnergy()) { |
| + LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
| + return; |
| + } |
| ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( |
| /* properties: NOTIFY */ 0x10, |
| /* expected_config_descriptor_value: NOTIFY */ 1)); |
| @@ -1843,7 +1861,7 @@ TEST_F(BluetoothRemoteGattCharacteristicTest, |
| EXPECT_TRUE(characteristic1_->IsNotifying()); |
| } |
| -#endif |
| +#endif // defined(OS_ANDROID) || defined(OS_MACOSX) |
| #if defined(OS_ANDROID) |
|
ortuno
2017/02/09 00:34:48
You are missing this one.
jlebel
2017/02/09 01:20:18
Write is still missing
ortuno
2017/02/09 03:07:03
Same here. Surround the part that checks for the d
jlebel
2017/02/09 21:17:38
Done.
|
| // Tests starting a new notify session before the previous stop requests |
| @@ -1910,9 +1928,13 @@ TEST_F(BluetoothRemoteGattCharacteristicTest, StopNotifySession_StopStopStart) { |
| } |
| #endif // defined(OS_ANDROID) |
| -#if defined(OS_ANDROID) |
| +#if defined(OS_ANDROID) || defined(OS_MACOSX) |
| TEST_F(BluetoothRemoteGattCharacteristicTest, |
| StopNotifySession_Reentrant_Success_Stop) { |
| + if (!PlatformSupportsLowEnergy()) { |
| + LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
| + return; |
| + } |
| ASSERT_NO_FATAL_FAILURE( |
| FakeCharacteristicBoilerplate(/* properties: NOTIFY */ 0x10)); |
| SimulateGattDescriptor( |
| @@ -1948,11 +1970,15 @@ TEST_F(BluetoothRemoteGattCharacteristicTest, |
| EXPECT_FALSE(notify_sessions_[0]->IsActive()); |
| EXPECT_FALSE(characteristic1_->IsNotifying()); |
| } |
| -#endif |
| +#endif // defined(OS_ANDROID) || defined(OS_MACOSX) |
| -#if defined(OS_ANDROID) |
| +#if defined(OS_ANDROID) || defined(OS_MACOSX) |
| TEST_F(BluetoothRemoteGattCharacteristicTest, |
| StopNotifySession_Reentrant_Stop_StartSuccess) { |
| + if (!PlatformSupportsLowEnergy()) { |
| + LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
| + return; |
| + } |
| ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( |
| /* properties: NOTIFY */ 0x10, |
| /* expected_config_descriptor_value: NOTIFY */ 1)); |
| @@ -1990,11 +2016,15 @@ TEST_F(BluetoothRemoteGattCharacteristicTest, |
| EXPECT_TRUE(notify_sessions_[1]->IsActive()); |
| EXPECT_TRUE(characteristic1_->IsNotifying()); |
| } |
| -#endif |
| +#endif // defined(OS_ANDROID) || defined(OS_MACOSX) |
| -#if defined(OS_ANDROID) |
| +#if defined(OS_ANDROID) || defined(OS_MACOSX) |
| TEST_F(BluetoothRemoteGattCharacteristicTest, |
| StopNotifySession_Reentrant_Stop_StartError) { |
| + if (!PlatformSupportsLowEnergy()) { |
| + LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
| + return; |
| + } |
| ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( |
| /* properties: NOTIFY */ 0x10, |
| /* expected_config_descriptor_value: NOTIFY */ 1)); |
| @@ -2030,7 +2060,7 @@ TEST_F(BluetoothRemoteGattCharacteristicTest, |
| EXPECT_FALSE(notify_sessions_[0]->IsActive()); |
| EXPECT_FALSE(characteristic1_->IsNotifying()); |
| } |
| -#endif |
| +#endif // defined(OS_ANDROID) || defined(OS_MACOSX) |
| #if defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN) |
| // Tests Characteristic Value changes during a Notify Session. |