Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2630)

Unified Diff: device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc

Issue 1804093003: Add BluetoothGattCharacteristicTest::StartNotifySession_Reentrant unit test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/bluetooth/bluetooth_low_energy_win_fake.cc ('k') | device/bluetooth/test/bluetooth_test.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..831a84738cc01eaa729df626d7a0e497a650cb8e 100644
--- a/device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc
+++ b/device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc
@@ -991,6 +991,117 @@ 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 /* error_in_reentrant */));
+ 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());
+
+ SimulateGattNotifySessionStartError(
+ characteristic1_, BluetoothRemoteGattService::GATT_ERROR_UNKNOWN);
+
+ characteristic1_->StartNotifySession(
+ GetReentrantStartNotifySessionSuccessCallback(Call::NOT_EXPECTED,
+ characteristic1_),
+ GetReentrantStartNotifySessionErrorCallback(
+ Call::EXPECTED, characteristic1_, false /* error_in_reentrant */));
+ EXPECT_EQ(0, callback_count_);
+ SimulateGattNotifySessionStarted(characteristic1_);
+ EXPECT_EQ(0, gatt_notify_characteristic_attempts_);
+ EXPECT_EQ(1, error_callback_count_);
+
+ // 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());
+
+ SimulateGattNotifySessionStartError(
+ characteristic1_, BluetoothRemoteGattService::GATT_ERROR_UNKNOWN);
+
+ characteristic1_->StartNotifySession(
+ GetReentrantStartNotifySessionSuccessCallback(Call::NOT_EXPECTED,
+ characteristic1_),
+ GetReentrantStartNotifySessionErrorCallback(
+ Call::EXPECTED, characteristic1_, true /* error_in_reentrant */));
+ 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) {
« no previous file with comments | « device/bluetooth/bluetooth_low_energy_win_fake.cc ('k') | device/bluetooth/test/bluetooth_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698