Chromium Code Reviews| Index: device/bluetooth/bluetooth_remote_gatt_descriptor_unittest.cc |
| diff --git a/device/bluetooth/bluetooth_remote_gatt_descriptor_unittest.cc b/device/bluetooth/bluetooth_remote_gatt_descriptor_unittest.cc |
| index 1152797d16b26ceba4c426f1739e6d60bb2efa8f..eb52ed4807fa4361d484e344d9560489323e86d8 100644 |
| --- a/device/bluetooth/bluetooth_remote_gatt_descriptor_unittest.cc |
| +++ b/device/bluetooth/bluetooth_remote_gatt_descriptor_unittest.cc |
| @@ -188,9 +188,13 @@ TEST_F(BluetoothRemoteGattDescriptorTest, GetUUID) { |
| } |
| #endif // defined(OS_ANDROID) || defined(OS_MACOSX) |
| -#if defined(OS_ANDROID) |
| +#if defined(OS_ANDROID) || defined(OS_MACOSX) |
| // Tests ReadRemoteDescriptor and GetValue with empty value buffer. |
| TEST_F(BluetoothRemoteGattDescriptorTest, ReadRemoteDescriptor_Empty) { |
| + if (!PlatformSupportsLowEnergy()) { |
| + LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
| + return; |
| + } |
| ASSERT_NO_FATAL_FAILURE(FakeDescriptorBoilerplate()); |
| descriptor1_->ReadRemoteDescriptor(GetReadValueCallback(Call::EXPECTED), |
| @@ -207,11 +211,15 @@ TEST_F(BluetoothRemoteGattDescriptorTest, ReadRemoteDescriptor_Empty) { |
| EXPECT_EQ(empty_vector, last_read_value_); |
| EXPECT_EQ(empty_vector, descriptor1_->GetValue()); |
| } |
| -#endif // defined(OS_ANDROID) |
| +#endif // defined(OS_ANDROID) || defined(OS_MACOSX) |
| -#if defined(OS_ANDROID) |
| +#if defined(OS_ANDROID) || defined(OS_MACOSX) |
| // Tests WriteRemoteDescriptor with empty value buffer. |
| TEST_F(BluetoothRemoteGattDescriptorTest, WriteRemoteDescriptor_Empty) { |
| + if (!PlatformSupportsLowEnergy()) { |
| + LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
| + return; |
| + } |
| ASSERT_NO_FATAL_FAILURE(FakeDescriptorBoilerplate()); |
| std::vector<uint8_t> empty_vector; |
| @@ -227,11 +235,17 @@ TEST_F(BluetoothRemoteGattDescriptorTest, WriteRemoteDescriptor_Empty) { |
| EXPECT_EQ(empty_vector, last_write_value_); |
| } |
| -#endif // defined(OS_ANDROID) |
| +#endif // defined(OS_ANDROID) || defined(OS_MACOSX) |
| #if defined(OS_ANDROID) |
| // Tests ReadRemoteDescriptor completing after Chrome objects are deleted. |
| +// macOS: Not applicable: This can never happen if CBPeripheral delegate is set |
| +// to nil. |
| TEST_F(BluetoothRemoteGattDescriptorTest, ReadRemoteDescriptor_AfterDeleted) { |
| + if (!PlatformSupportsLowEnergy()) { |
| + LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
| + return; |
| + } |
| ASSERT_NO_FATAL_FAILURE(FakeDescriptorBoilerplate()); |
| descriptor1_->ReadRemoteDescriptor(GetReadValueCallback(Call::NOT_EXPECTED), |
| @@ -250,7 +264,13 @@ TEST_F(BluetoothRemoteGattDescriptorTest, ReadRemoteDescriptor_AfterDeleted) { |
| #if defined(OS_ANDROID) |
| // Tests WriteRemoteDescriptor completing after Chrome objects are deleted. |
| +// macOS: Not applicable: This can never happen if CBPeripheral delegate is set |
| +// to nil. |
| TEST_F(BluetoothRemoteGattDescriptorTest, WriteRemoteDescriptor_AfterDeleted) { |
| + if (!PlatformSupportsLowEnergy()) { |
| + LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
| + return; |
| + } |
| ASSERT_NO_FATAL_FAILURE(FakeDescriptorBoilerplate()); |
| std::vector<uint8_t> empty_vector; |
| @@ -267,9 +287,13 @@ TEST_F(BluetoothRemoteGattDescriptorTest, WriteRemoteDescriptor_AfterDeleted) { |
| } |
| #endif // defined(OS_ANDROID) |
| -#if defined(OS_ANDROID) |
| +#if defined(OS_ANDROID) || defined(OS_MACOSX) |
| // Tests ReadRemoteDescriptor and GetValue with non-empty value buffer. |
| TEST_F(BluetoothRemoteGattDescriptorTest, ReadRemoteDescriptor) { |
| + if (!PlatformSupportsLowEnergy()) { |
| + LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
| + return; |
| + } |
| ASSERT_NO_FATAL_FAILURE(FakeDescriptorBoilerplate()); |
| descriptor1_->ReadRemoteDescriptor(GetReadValueCallback(Call::EXPECTED), |
| @@ -289,11 +313,15 @@ TEST_F(BluetoothRemoteGattDescriptorTest, ReadRemoteDescriptor) { |
| EXPECT_EQ(test_vector, last_read_value_); |
| EXPECT_EQ(test_vector, descriptor1_->GetValue()); |
| } |
| -#endif // defined(OS_ANDROID) |
| +#endif // defined(OS_ANDROID) || defined(OS_MACOSX) |
| -#if defined(OS_ANDROID) |
| +#if defined(OS_ANDROID) || defined(OS_MACOSX) |
| // Tests WriteRemoteDescriptor with non-empty value buffer. |
| TEST_F(BluetoothRemoteGattDescriptorTest, WriteRemoteDescriptor) { |
| + if (!PlatformSupportsLowEnergy()) { |
| + LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
| + return; |
| + } |
| ASSERT_NO_FATAL_FAILURE(FakeDescriptorBoilerplate()); |
| uint8_t values[] = {0, 1, 2, 3, 4, 0xf, 0xf0, 0xff}; |
| @@ -307,11 +335,15 @@ TEST_F(BluetoothRemoteGattDescriptorTest, WriteRemoteDescriptor) { |
| EXPECT_EQ(test_vector, last_write_value_); |
| } |
| -#endif // defined(OS_ANDROID) |
| +#endif // defined(OS_ANDROID) || defined(OS_MACOSX) |
| -#if defined(OS_ANDROID) |
| +#if defined(OS_ANDROID) || defined(OS_MACOSX) |
| // Tests ReadRemoteDescriptor and GetValue multiple times. |
| TEST_F(BluetoothRemoteGattDescriptorTest, ReadRemoteDescriptor_Twice) { |
| + if (!PlatformSupportsLowEnergy()) { |
| + LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
| + return; |
| + } |
| ASSERT_NO_FATAL_FAILURE(FakeDescriptorBoilerplate()); |
| descriptor1_->ReadRemoteDescriptor(GetReadValueCallback(Call::EXPECTED), |
| @@ -340,11 +372,15 @@ TEST_F(BluetoothRemoteGattDescriptorTest, ReadRemoteDescriptor_Twice) { |
| EXPECT_EQ(empty_vector, last_read_value_); |
| EXPECT_EQ(empty_vector, descriptor1_->GetValue()); |
| } |
| -#endif // defined(OS_ANDROID) |
| +#endif // defined(OS_ANDROID) || defined(OS_MACOSX) |
| -#if defined(OS_ANDROID) |
| +#if defined(OS_ANDROID) || defined(OS_MACOSX) |
| // Tests WriteRemoteDescriptor multiple times. |
| TEST_F(BluetoothRemoteGattDescriptorTest, WriteRemoteDescriptor_Twice) { |
| + if (!PlatformSupportsLowEnergy()) { |
| + LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
| + return; |
| + } |
| ASSERT_NO_FATAL_FAILURE(FakeDescriptorBoilerplate()); |
| uint8_t values[] = {0, 1, 2, 3, 4, 0xf, 0xf0, 0xff}; |
| @@ -371,12 +407,16 @@ TEST_F(BluetoothRemoteGattDescriptorTest, WriteRemoteDescriptor_Twice) { |
| EXPECT_EQ(0, error_callback_count_); |
| EXPECT_EQ(empty_vector, last_write_value_); |
| } |
| -#endif // defined(OS_ANDROID) |
| +#endif // defined(OS_ANDROID) || defined(OS_MACOSX) |
| -#if defined(OS_ANDROID) |
| +#if defined(OS_ANDROID) || defined(OS_MACOSX) |
| // Tests ReadRemoteDescriptor on two descriptors. |
| TEST_F(BluetoothRemoteGattDescriptorTest, |
| ReadRemoteDescriptor_MultipleDescriptors) { |
| + if (!PlatformSupportsLowEnergy()) { |
| + LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
| + return; |
| + } |
| ASSERT_NO_FATAL_FAILURE(FakeDescriptorBoilerplate()); |
| descriptor1_->ReadRemoteDescriptor(GetReadValueCallback(Call::EXPECTED), |
| @@ -404,12 +444,16 @@ TEST_F(BluetoothRemoteGattDescriptorTest, |
| EXPECT_EQ(test_vector1, descriptor1_->GetValue()); |
| EXPECT_EQ(test_vector2, descriptor2_->GetValue()); |
| } |
| -#endif // defined(OS_ANDROID) |
| +#endif // defined(OS_ANDROID) || defined(OS_MACOSX) |
| -#if defined(OS_ANDROID) |
| +#if defined(OS_ANDROID) || defined(OS_MACOSX) |
| // Tests WriteRemoteDescriptor on two descriptors. |
| TEST_F(BluetoothRemoteGattDescriptorTest, |
| WriteRemoteDescriptor_MultipleDescriptors) { |
| + if (!PlatformSupportsLowEnergy()) { |
| + LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
| + return; |
| + } |
| ASSERT_NO_FATAL_FAILURE(FakeDescriptorBoilerplate()); |
| std::vector<uint8_t> test_vector1; |
| @@ -435,11 +479,15 @@ TEST_F(BluetoothRemoteGattDescriptorTest, |
| EXPECT_EQ(2, callback_count_); |
| EXPECT_EQ(0, error_callback_count_); |
| } |
| -#endif // defined(OS_ANDROID) |
| +#endif // defined(OS_ANDROID) || defined(OS_MACOSX) |
| -#if defined(OS_ANDROID) |
| +#if defined(OS_ANDROID) || defined(OS_MACOSX) |
| // Tests ReadRemoteDescriptor asynchronous error. |
| TEST_F(BluetoothRemoteGattDescriptorTest, ReadError) { |
| + if (!PlatformSupportsLowEnergy()) { |
| + LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
| + return; |
| + } |
| ASSERT_NO_FATAL_FAILURE(FakeDescriptorBoilerplate()); |
| descriptor1_->ReadRemoteDescriptor(GetReadValueCallback(Call::NOT_EXPECTED), |
| @@ -452,11 +500,15 @@ TEST_F(BluetoothRemoteGattDescriptorTest, ReadError) { |
| EXPECT_EQ(BluetoothRemoteGattService::GATT_ERROR_INVALID_LENGTH, |
| last_gatt_error_code_); |
| } |
| -#endif // defined(OS_ANDROID) |
| +#endif // defined(OS_ANDROID) || defined(OS_MACOSX) |
| -#if defined(OS_ANDROID) |
| +#if defined(OS_ANDROID) || defined(OS_MACOSX) |
| // Tests WriteRemoteDescriptor asynchronous error. |
| TEST_F(BluetoothRemoteGattDescriptorTest, WriteError) { |
| + if (!PlatformSupportsLowEnergy()) { |
| + LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
| + return; |
| + } |
| ASSERT_NO_FATAL_FAILURE(FakeDescriptorBoilerplate()); |
| std::vector<uint8_t> empty_vector; |
| @@ -472,11 +524,17 @@ TEST_F(BluetoothRemoteGattDescriptorTest, WriteError) { |
| EXPECT_EQ(BluetoothRemoteGattService::GATT_ERROR_INVALID_LENGTH, |
| last_gatt_error_code_); |
| } |
| -#endif // defined(OS_ANDROID) |
| +#endif // defined(OS_ANDROID) || defined(OS_MACOSX) |
| #if defined(OS_ANDROID) |
| // Tests ReadRemoteDescriptor synchronous error. |
| +// Test not relevant for macOS since descriptor read cannot generate |
| +// synchronous error. |
| TEST_F(BluetoothRemoteGattDescriptorTest, ReadSynchronousError) { |
| + if (!PlatformSupportsLowEnergy()) { |
| + LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
| + return; |
| + } |
| ASSERT_NO_FATAL_FAILURE(FakeDescriptorBoilerplate()); |
| SimulateGattDescriptorReadWillFailSynchronouslyOnce(descriptor1_); |
| @@ -504,7 +562,13 @@ TEST_F(BluetoothRemoteGattDescriptorTest, ReadSynchronousError) { |
| #if defined(OS_ANDROID) |
| // Tests WriteRemoteDescriptor synchronous error. |
| +// Test not relevant for macOS since descriptor write cannot generate |
| +// synchronous error. |
| TEST_F(BluetoothRemoteGattDescriptorTest, WriteSynchronousError) { |
| + if (!PlatformSupportsLowEnergy()) { |
| + LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
| + return; |
| + } |
| ASSERT_NO_FATAL_FAILURE(FakeDescriptorBoilerplate()); |
| SimulateGattDescriptorWriteWillFailSynchronouslyOnce(descriptor1_); |
| @@ -531,9 +595,13 @@ TEST_F(BluetoothRemoteGattDescriptorTest, WriteSynchronousError) { |
| } |
| #endif // defined(OS_ANDROID) |
| -#if defined(OS_ANDROID) |
| +#if defined(OS_ANDROID) || defined(OS_MACOSX) |
| // Tests ReadRemoteDescriptor error with a pending read operation. |
| TEST_F(BluetoothRemoteGattDescriptorTest, ReadRemoteDescriptor_ReadPending) { |
| + if (!PlatformSupportsLowEnergy()) { |
| + LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
| + return; |
| + } |
| ASSERT_NO_FATAL_FAILURE(FakeDescriptorBoilerplate()); |
| descriptor1_->ReadRemoteDescriptor(GetReadValueCallback(Call::EXPECTED), |
| @@ -556,11 +624,15 @@ TEST_F(BluetoothRemoteGattDescriptorTest, ReadRemoteDescriptor_ReadPending) { |
| EXPECT_EQ(1, callback_count_); |
| EXPECT_EQ(0, error_callback_count_); |
| } |
| -#endif // defined(OS_ANDROID) |
| +#endif // defined(OS_ANDROID) || defined(OS_MACOSX) |
| -#if defined(OS_ANDROID) |
| +#if defined(OS_ANDROID) || defined(OS_MACOSX) |
| // Tests WriteRemoteDescriptor error with a pending write operation. |
| TEST_F(BluetoothRemoteGattDescriptorTest, WriteRemoteDescriptor_WritePending) { |
| + if (!PlatformSupportsLowEnergy()) { |
| + LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
| + return; |
| + } |
| ASSERT_NO_FATAL_FAILURE(FakeDescriptorBoilerplate()); |
| std::vector<uint8_t> empty_vector; |
| @@ -584,11 +656,15 @@ TEST_F(BluetoothRemoteGattDescriptorTest, WriteRemoteDescriptor_WritePending) { |
| EXPECT_EQ(1, callback_count_); |
| EXPECT_EQ(0, error_callback_count_); |
| } |
| -#endif // defined(OS_ANDROID) |
| +#endif // defined(OS_ANDROID) || defined(OS_MACOSX) |
| -#if defined(OS_ANDROID) |
| +#if defined(OS_ANDROID) || defined(OS_MACOSX) |
| // Tests ReadRemoteDescriptor error with a pending write operation. |
| TEST_F(BluetoothRemoteGattDescriptorTest, ReadRemoteDescriptor_WritePending) { |
| + if (!PlatformSupportsLowEnergy()) { |
| + LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
| + return; |
| + } |
| ASSERT_NO_FATAL_FAILURE(FakeDescriptorBoilerplate()); |
| std::vector<uint8_t> empty_vector; |
| @@ -611,11 +687,15 @@ TEST_F(BluetoothRemoteGattDescriptorTest, ReadRemoteDescriptor_WritePending) { |
| EXPECT_EQ(1, callback_count_); |
| EXPECT_EQ(0, error_callback_count_); |
| } |
| -#endif // defined(OS_ANDROID) |
| +#endif // defined(OS_ANDROID) || defined(OS_MACOSX) |
| -#if defined(OS_ANDROID) |
| +#if defined(OS_ANDROID) || defined(OS_MACOSX) |
| // Tests WriteRemoteDescriptor error with a pending Read operation. |
| TEST_F(BluetoothRemoteGattDescriptorTest, WriteRemoteDescriptor_ReadPending) { |
| + if (!PlatformSupportsLowEnergy()) { |
| + LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
| + return; |
| + } |
| ASSERT_NO_FATAL_FAILURE(FakeDescriptorBoilerplate()); |
| std::vector<uint8_t> empty_vector; |
| @@ -638,7 +718,7 @@ TEST_F(BluetoothRemoteGattDescriptorTest, WriteRemoteDescriptor_ReadPending) { |
| EXPECT_EQ(1, callback_count_); |
| EXPECT_EQ(0, error_callback_count_); |
| } |
| -#endif // defined(OS_ANDROID) |
| +#endif // defined(OS_ANDROID) || defined(OS_MACOSX) |
|
ortuno
2017/04/03 01:27:50
Could you add test to make sure we can handle the
jlebel
2017/04/04 22:13:12
I'm concerned about endianess. I'm not sure what i
|
| #if defined(OS_ANDROID) |
| // Tests that read requests after a device disconnects but before the |