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

Unified Diff: device/bluetooth/bluetooth_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, 9 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 | « no previous file | device/bluetooth/bluetooth_low_energy_win_fake.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3b980d1d470d90b16f77f72dea1647bbf71421ff..ae79a43a7116ead71156437953f6540841247c69 100644
--- a/device/bluetooth/bluetooth_gatt_characteristic_unittest.cc
+++ b/device/bluetooth/bluetooth_gatt_characteristic_unittest.cc
@@ -896,6 +896,44 @@ TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_Multiple) {
}
#endif // defined(OS_ANDROID) || defined(OS_WIN)
+#if defined(OS_WIN)
+// Tests StartNotifySession reentrant in start notify session error callback.
+TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_Reentrant) {
scheib 2016/03/19 04:58:07 Please test all 4 combinations of initial callba
gogerald1 2016/04/21 21:05:22 Done. "success, error" looks impossible in current
+ ASSERT_NO_FATAL_FAILURE(
+ FakeCharacteristicBoilerplate(/* properties: NOTIFY */ 0x10));
+ SimulateGattDescriptor(
+ characteristic1_,
+ /* Client Characteristic Configuration descriptor's standard UUID: */
+ "00002902-0000-1000-8000-00805F9B34FB");
scheib 2016/03/19 04:58:07 BluetoothGattDescriptor::ClientCharacteristicConfi
gogerald1 2016/04/21 21:05:22 Done.
+ ASSERT_EQ(1u, characteristic1_->GetDescriptors().size());
+
+ SimulateGattCharacteristicSetNotifyWillFailAsynchronouslyOnce(
+ characteristic1_);
+
+ characteristic1_->StartNotifySession(
+ GetNotifyCallback(Call::NOT_EXPECTED),
+ GetReentrantStartNotifySessionErrorCallback(Call::EXPECTED,
+ characteristic1_));
+ EXPECT_EQ(0, callback_count_);
+ SimulateGattNotifySessionStarted(characteristic1_);
+ EXPECT_EQ(0, gatt_notify_characteristic_attempts_);
+ EXPECT_EQ(0, callback_count_);
+ EXPECT_EQ(1, error_callback_count_);
+ ASSERT_EQ(0u, notify_sessions_.size());
+
+ // Simulate reentrant StartNotifySession request from
+ // BluetoothTestBase::ReentrantStartNotifySessionErrorCallback.
+ SimulateGattNotifySessionStarted(characteristic1_);
+ EXPECT_EQ(1, gatt_notify_characteristic_attempts_);
+ EXPECT_EQ(1, 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_ANDROID) || defined(OS_WIN)
// Tests Characteristic Value changes during a Notify Session.
TEST_F(BluetoothGattCharacteristicTest, GattCharacteristicValueChanged) {
« no previous file with comments | « no previous file | device/bluetooth/bluetooth_low_energy_win_fake.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698