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 d25944ce87b182d6136d55754eb92a652dba17a6..36021796637b2aa1250cd7ddf15aaf389cedc80c 100644 |
| --- a/device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc |
| +++ b/device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc |
| @@ -991,6 +991,115 @@ TEST_F(BluetoothRemoteGattCharacteristicTest, StartNotifySession_AfterDeleted) { |
| } |
| #endif // defined(OS_ANDROID) |
| +#if defined(OS_WIN) |
| +// Tests StartNotifySession reentrant in start notify session success callback |
| +// and the reentrant start notify session success. |
| +TEST_F(BluetoothRemoteGattCharacteristicTest, |
| + StartNotifySession_Reentrant_Success_Success) { |
| + ASSERT_NO_FATAL_FAILURE( |
| + FakeCharacteristicBoilerplate(/* properties: NOTIFY */ 0x10)); |
| + SimulateGattDescriptor( |
| + characteristic1_, |
| + BluetoothGattDescriptor::ClientCharacteristicConfigurationUuid().value()); |
| + ASSERT_EQ(1u, characteristic1_->GetDescriptors().size()); |
| + |
| + characteristic1_->StartNotifySession( |
| + GetReentrantStartNotifySessionSuccessCallback(Call::EXPECTED, |
| + characteristic1_), |
| + GetReentrantStartNotifySessionErrorCallback(Call::NOT_EXPECTED, |
| + characteristic1_, false)); |
|
ortuno
2016/04/22 16:23:39
false /* error_in_reentrant */
gogerald1
2016/04/27 20:15:32
Done.
|
| + EXPECT_EQ(0, callback_count_); |
| + SimulateGattNotifySessionStarted(characteristic1_); |
| + EXPECT_EQ(1, gatt_notify_characteristic_attempts_); |
| + |
| + // Simulate reentrant StartNotifySession request from |
| + // BluetoothTestBase::ReentrantStartNotifySessionSuccessCallback. |
| + SimulateGattNotifySessionStarted(characteristic1_); |
| + EXPECT_EQ(1, gatt_notify_characteristic_attempts_); |
| + EXPECT_EQ(2, callback_count_); |
| + EXPECT_EQ(0, error_callback_count_); |
| + ASSERT_EQ(2u, notify_sessions_.size()); |
| + for (unsigned int i = 0; i < notify_sessions_.size(); i++) { |
| + ASSERT_TRUE(notify_sessions_[i]); |
| + EXPECT_EQ(characteristic1_->GetIdentifier(), |
| + notify_sessions_[i]->GetCharacteristicIdentifier()); |
| + EXPECT_TRUE(notify_sessions_[i]->IsActive()); |
| + } |
| +} |
| +#endif // defined(OS_WIN) |
| + |
| +#if defined(OS_WIN) |
| +// Tests StartNotifySession reentrant in start notify session error callback |
| +// and the reentrant start notify session success. |
| +TEST_F(BluetoothRemoteGattCharacteristicTest, |
| + StartNotifySession_Reentrant_Error_Success) { |
| + ASSERT_NO_FATAL_FAILURE( |
| + FakeCharacteristicBoilerplate(/* properties: NOTIFY */ 0x10)); |
| + SimulateGattDescriptor( |
| + characteristic1_, |
| + BluetoothGattDescriptor::ClientCharacteristicConfigurationUuid().value()); |
| + ASSERT_EQ(1u, characteristic1_->GetDescriptors().size()); |
| + |
| + SimulateGattCharacteristicSetNotifyWillFailAsynchronouslyOnce( |
| + characteristic1_); |
| + |
| + characteristic1_->StartNotifySession( |
| + GetReentrantStartNotifySessionSuccessCallback(Call::NOT_EXPECTED, |
| + characteristic1_), |
| + GetReentrantStartNotifySessionErrorCallback(Call::EXPECTED, |
| + characteristic1_, false)); |
|
ortuno
2016/04/22 16:23:39
false /* error_in_reentrant */
gogerald1
2016/04/27 20:15:31
Done.
|
| + EXPECT_EQ(0, callback_count_); |
| + SimulateGattNotifySessionStarted(characteristic1_); |
| + EXPECT_EQ(0, gatt_notify_characteristic_attempts_); |
|
ortuno
2016/04/22 16:23:39
Add: EXPECT_EQ(1, error_callback_count_);
gogerald1
2016/04/27 20:15:32
Done.
|
| + |
| + // Simulate reentrant StartNotifySession request from |
| + // BluetoothTestBase::ReentrantStartNotifySessionErrorCallback. |
| + SimulateGattNotifySessionStarted(characteristic1_); |
| + EXPECT_EQ(1, gatt_notify_characteristic_attempts_); |
| + EXPECT_EQ(1, callback_count_); |
| + EXPECT_EQ(1, error_callback_count_); |
| + ASSERT_EQ(1u, notify_sessions_.size()); |
| + ASSERT_TRUE(notify_sessions_[0]); |
| + EXPECT_EQ(characteristic1_->GetIdentifier(), |
| + notify_sessions_[0]->GetCharacteristicIdentifier()); |
| + EXPECT_TRUE(notify_sessions_[0]->IsActive()); |
| +} |
| +#endif // defined(OS_WIN) |
| + |
| +#if defined(OS_WIN) |
| +// Tests StartNotifySession reentrant in start notify session error callback |
| +// and the reentrant start notify session error. |
| +TEST_F(BluetoothRemoteGattCharacteristicTest, |
| + StartNotifySession_Reentrant_Error_Error) { |
| + ASSERT_NO_FATAL_FAILURE( |
| + FakeCharacteristicBoilerplate(/* properties: NOTIFY */ 0x10)); |
| + SimulateGattDescriptor( |
| + characteristic1_, |
| + BluetoothGattDescriptor::ClientCharacteristicConfigurationUuid().value()); |
| + ASSERT_EQ(1u, characteristic1_->GetDescriptors().size()); |
| + |
| + SimulateGattCharacteristicSetNotifyWillFailAsynchronouslyOnce( |
| + characteristic1_); |
| + |
| + characteristic1_->StartNotifySession( |
| + GetReentrantStartNotifySessionSuccessCallback(Call::NOT_EXPECTED, |
| + characteristic1_), |
| + GetReentrantStartNotifySessionErrorCallback(Call::EXPECTED, |
| + characteristic1_, true)); |
|
ortuno
2016/04/22 16:23:39
true /* error_in_reentrant */
gogerald1
2016/04/27 20:15:32
Done.
|
| + EXPECT_EQ(0, callback_count_); |
| + SimulateGattNotifySessionStarted(characteristic1_); |
| + EXPECT_EQ(0, gatt_notify_characteristic_attempts_); |
| + |
| + // Simulate reentrant StartNotifySession request from |
| + // BluetoothTestBase::ReentrantStartNotifySessionErrorCallback. |
| + SimulateGattNotifySessionStarted(characteristic1_); |
| + EXPECT_EQ(0, gatt_notify_characteristic_attempts_); |
| + EXPECT_EQ(0, callback_count_); |
| + EXPECT_EQ(2, error_callback_count_); |
| + ASSERT_EQ(0u, notify_sessions_.size()); |
| +} |
| +#endif // defined(OS_WIN) |
| + |
| #if defined(OS_ANDROID) || defined(OS_WIN) |
| // Tests Characteristic Value changes during a Notify Session. |
| TEST_F(BluetoothRemoteGattCharacteristicTest, GattCharacteristicValueChanged) { |