Chromium Code Reviews| Index: device/bluetooth/bluetooth_gatt_characteristic_unittest.cc |
| diff --git a/device/bluetooth/bluetooth_gatt_characteristic_unittest.cc b/device/bluetooth/bluetooth_gatt_characteristic_unittest.cc |
| index ba3e25ba371760cdbb8e6d448752569f9a8d7549..2e4f1f4d7f445534bdedee5e6a07fcaf5949ba76 100644 |
| --- a/device/bluetooth/bluetooth_gatt_characteristic_unittest.cc |
| +++ b/device/bluetooth/bluetooth_gatt_characteristic_unittest.cc |
| @@ -72,8 +72,8 @@ class BluetoothGattCharacteristicTest : public BluetoothTest { |
| if (error != StartNotifySetupError::CONFIG_DESCRIPTOR_MISSING) { |
| SimulateGattDescriptor( |
| characteristic1_, |
| - /* Client Characteristic Configuration descriptor's standard UUID: */ |
| - "00002902-0000-1000-8000-00805F9B34FB"); |
| + BluetoothGattDescriptor::ClientCharacteristicConfigurationUuid() |
| + .canonical_value()); |
| ASSERT_EQ(1u, characteristic1_->GetDescriptors().size()); |
| } |
| @@ -897,8 +897,8 @@ TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_Multiple) { |
| FakeCharacteristicBoilerplate(/* properties: NOTIFY */ 0x10)); |
| SimulateGattDescriptor( |
| characteristic1_, |
| - /* Client Characteristic Configuration descriptor's standard UUID: */ |
| - "00002902-0000-1000-8000-00805F9B34FB"); |
| + BluetoothGattDescriptor::ClientCharacteristicConfigurationUuid() |
| + .canonical_value()); |
| ASSERT_EQ(1u, characteristic1_->GetDescriptors().size()); |
| characteristic1_->StartNotifySession( |
| @@ -924,6 +924,32 @@ TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_Multiple) { |
| } |
| #endif // defined(OS_ANDROID) |
| +#if defined(OS_ANDROID) |
| +// Tests multiple StartNotifySession success. |
| +TEST_F(BluetoothGattCharacteristicTest, StartNotifySessionError_Multiple) { |
|
ortuno
2016/03/04 18:55:21
We should add a test for when the gatt objects get
scheib
2016/03/11 04:44:59
Done in https://codereview.chromium.org/1779083002
|
| + ASSERT_NO_FATAL_FAILURE( |
| + FakeCharacteristicBoilerplate(/* properties: NOTIFY */ 0x10)); |
| + SimulateGattDescriptor( |
| + characteristic1_, |
| + BluetoothGattDescriptor::ClientCharacteristicConfigurationUuid() |
| + .canonical_value()); |
| + ASSERT_EQ(1u, characteristic1_->GetDescriptors().size()); |
| + |
| + characteristic1_->StartNotifySession(GetNotifyCallback(Call::NOT_EXPECTED), |
| + GetGattErrorCallback(Call::EXPECTED)); |
| + characteristic1_->StartNotifySession(GetNotifyCallback(Call::NOT_EXPECTED), |
| + GetGattErrorCallback(Call::EXPECTED)); |
| + EXPECT_EQ(1, gatt_notify_characteristic_attempts_); |
| + EXPECT_EQ(0, callback_count_); |
| + SimulateGattNotifySessionStartError(characteristic1_, |
| + BluetoothGattService::GATT_ERROR_FAILED); |
| + EXPECT_EQ(0, callback_count_); |
| + EXPECT_EQ(2, error_callback_count_); |
| + ASSERT_EQ(0u, notify_sessions_.size()); |
| + EXPECT_EQ(BluetoothGattService::GATT_ERROR_FAILED, last_gatt_error_code_); |
| +} |
| +#endif // defined(OS_ANDROID) |
| + |
| #if defined(OS_ANDROID) || defined(OS_WIN) |
| TEST_F(BluetoothGattCharacteristicTest, GetDescriptors_FindNone) { |
| ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate()); |
| @@ -977,4 +1003,30 @@ TEST_F(BluetoothGattCharacteristicTest, GetDescriptors_and_GetDescriptor) { |
| } |
| #endif // defined(OS_ANDROID) || defined(OS_WIN) |
| +#if defined(OS_ANDROID) || defined(OS_WIN) |
| +TEST_F(BluetoothGattCharacteristicTest, GetDescriptorsForUUID) { |
| + ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate()); |
| + |
| + // Add several Descriptors: |
| + BluetoothUUID uuid1("11111111-0000-1000-8000-00805f9b34fb"); |
| + BluetoothUUID uuid2("22222222-0000-1000-8000-00805f9b34fb"); |
| + BluetoothUUID uuid3("33333333-0000-1000-8000-00805f9b34fb"); |
| + BluetoothUUID uuid4("44444444-0000-1000-8000-00805f9b34fb"); |
| + SimulateGattDescriptor(characteristic1_, uuid1.canonical_value()); |
| + SimulateGattDescriptor(characteristic1_, uuid2.canonical_value()); |
| + SimulateGattDescriptor(characteristic2_, uuid3.canonical_value()); |
| + SimulateGattDescriptor(characteristic2_, uuid4.canonical_value()); |
| + |
| + EXPECT_EQ(uuid1, characteristic1_->GetDescriptorForUUID(uuid1)->GetUUID()); |
| + EXPECT_EQ(uuid2, characteristic1_->GetDescriptorForUUID(uuid2)->GetUUID()); |
| + EXPECT_EQ(uuid3, characteristic2_->GetDescriptorForUUID(uuid3)->GetUUID()); |
| + EXPECT_EQ(uuid4, characteristic2_->GetDescriptorForUUID(uuid4)->GetUUID()); |
| + |
| + EXPECT_EQ(nullptr, characteristic2_->GetDescriptorForUUID(uuid1)); |
| + EXPECT_EQ(nullptr, characteristic2_->GetDescriptorForUUID(uuid2)); |
| + EXPECT_EQ(nullptr, characteristic1_->GetDescriptorForUUID(uuid3)); |
| + EXPECT_EQ(nullptr, characteristic1_->GetDescriptorForUUID(uuid4)); |
| +} |
| +#endif // defined(OS_ANDROID) || defined(OS_WIN) |
| + |
| } // namespace device |