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

Unified Diff: device/bluetooth/bluetooth_gatt_characteristic_unittest.cc

Issue 1749403002: Implement BluetoothRemoteGattCharacteristicWin::StartNotifySession and related unit tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: adjust comments Created 4 years, 10 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
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 d320f956062082ef61589bba6d8c84f303679d7b..1263205aba78a3ed08644fabdcccd14d95291d90 100644
--- a/device/bluetooth/bluetooth_gatt_characteristic_unittest.cc
+++ b/device/bluetooth/bluetooth_gatt_characteristic_unittest.cc
@@ -98,9 +98,9 @@ class BluetoothGattCharacteristicTest : public BluetoothTest {
GetNotifyCallback(Call::EXPECTED),
GetGattErrorCallback(Call::NOT_EXPECTED));
- EXPECT_EQ(1, gatt_notify_characteristic_attempts_);
EXPECT_EQ(0, callback_count_);
SimulateGattNotifySessionStarted(characteristic1_);
+ EXPECT_EQ(1, gatt_notify_characteristic_attempts_);
EXPECT_EQ(1, callback_count_);
EXPECT_EQ(0, error_callback_count_);
ASSERT_EQ(1u, notify_sessions_.size());
@@ -743,7 +743,7 @@ TEST_F(BluetoothGattCharacteristicTest, WriteRemoteCharacteristic_ReadPending) {
}
#endif // defined(OS_ANDROID) || defined(OS_WIN)
-#if defined(OS_ANDROID)
+#if defined(OS_ANDROID) || defined(OS_WIN)
// StartNotifySession fails if characteristic doesn't have Notify or Indicate
// property.
TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_NoNotifyOrIndicate) {
@@ -756,12 +756,12 @@ TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_NoNotifyOrIndicate) {
// The expected error callback is asynchronous:
EXPECT_EQ(0, error_callback_count_);
- base::RunLoop().RunUntilIdle();
+ RunUntilIdle();
EXPECT_EQ(1, error_callback_count_);
}
-#endif // defined(OS_ANDROID)
+#endif // defined(OS_ANDROID) || defined(OS_WIN)
-#if defined(OS_ANDROID)
+#if defined(OS_ANDROID) || defined(OS_WIN)
// StartNotifySession fails if the characteristic is missing the Client
// Characteristic Configuration descriptor.
TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_NoConfigDescriptor) {
@@ -774,12 +774,12 @@ TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_NoConfigDescriptor) {
// The expected error callback is asynchronous:
EXPECT_EQ(0, error_callback_count_);
- base::RunLoop().RunUntilIdle();
+ RunUntilIdle();
EXPECT_EQ(1, error_callback_count_);
}
-#endif // defined(OS_ANDROID)
+#endif // defined(OS_ANDROID) || defined(OS_WIN)
-#if defined(OS_ANDROID)
+#if defined(OS_ANDROID) || defined(OS_WIN)
// StartNotifySession fails synchronously when failing to set a characteristic
// to enable notifications.
// Android: This is mBluetoothGatt.setCharacteristicNotification failing.
@@ -792,15 +792,15 @@ TEST_F(BluetoothGattCharacteristicTest,
// The expected error callback is asynchronous:
EXPECT_EQ(0, error_callback_count_);
- base::RunLoop().RunUntilIdle();
+ RunUntilIdle();
EXPECT_EQ(1, error_callback_count_);
EXPECT_EQ(0, gatt_notify_characteristic_attempts_);
ASSERT_EQ(0u, notify_sessions_.size());
}
-#endif // defined(OS_ANDROID)
+#endif // defined(OS_ANDROID) || defined(OS_WIN)
-#if defined(OS_ANDROID)
+#if defined(OS_ANDROID) || defined(OS_WIN)
// Tests StartNotifySession descriptor write synchronous failure.
TEST_F(BluetoothGattCharacteristicTest,
StartNotifySession_WriteDescriptorSynchronousError) {
@@ -811,33 +811,33 @@ TEST_F(BluetoothGattCharacteristicTest,
// The expected error callback is asynchronous:
EXPECT_EQ(0, error_callback_count_);
- base::RunLoop().RunUntilIdle();
+ RunUntilIdle();
EXPECT_EQ(1, error_callback_count_);
EXPECT_EQ(1, gatt_notify_characteristic_attempts_);
ASSERT_EQ(0u, notify_sessions_.size());
}
-#endif // defined(OS_ANDROID)
+#endif // defined(OS_ANDROID) || defined(OS_WIN)
-#if defined(OS_ANDROID)
+#if defined(OS_ANDROID) || defined(OS_WIN)
// Tests StartNotifySession success on a characteristic enabling Notify.
TEST_F(BluetoothGattCharacteristicTest, StartNotifySession) {
ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
/* properties: NOTIFY */ 0x10,
/* expected_config_descriptor_value: NOTIFY */ 1));
}
-#endif // defined(OS_ANDROID)
+#endif // defined(OS_ANDROID) || defined(OS_WIN)
-#if defined(OS_ANDROID)
+#if defined(OS_ANDROID) || defined(OS_WIN)
// Tests StartNotifySession success on a characteristic enabling Indicate.
TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_OnIndicate) {
ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
/* properties: INDICATE */ 0x20,
/* expected_config_descriptor_value: INDICATE */ 2));
}
-#endif // defined(OS_ANDROID)
+#endif // defined(OS_ANDROID) || defined(OS_WIN)
-#if defined(OS_ANDROID)
+#if defined(OS_ANDROID) || defined(OS_WIN)
// Tests StartNotifySession success on a characteristic enabling Notify &
// Indicate.
TEST_F(BluetoothGattCharacteristicTest,
@@ -846,9 +846,9 @@ TEST_F(BluetoothGattCharacteristicTest,
/* properties: NOTIFY and INDICATE bits set */ 0x30,
/* expected_config_descriptor_value: NOTIFY */ 1));
}
-#endif // defined(OS_ANDROID)
+#endif // defined(OS_ANDROID) || defined(OS_WIN)
-#if defined(OS_ANDROID)
+#if defined(OS_ANDROID) || defined(OS_WIN)
// Tests Characteristic Value changes during a Notify Session.
TEST_F(BluetoothGattCharacteristicTest, GattCharacteristicValueChanged) {
ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
@@ -869,7 +869,7 @@ TEST_F(BluetoothGattCharacteristicTest, GattCharacteristicValueChanged) {
EXPECT_EQ(2, observer.gatt_characteristic_value_changed_count());
EXPECT_EQ(test_vector2, characteristic1_->GetValue());
}
-#endif // defined(OS_ANDROID)
+#endif // defined(OS_ANDROID) || defined(OS_WIN)
#if defined(OS_ANDROID)
// Tests Characteristic Value changing after a Notify Session and objects being
@@ -890,7 +890,7 @@ TEST_F(BluetoothGattCharacteristicTest,
}
#endif // defined(OS_ANDROID)
-#if defined(OS_ANDROID)
+#if defined(OS_ANDROID) || defined(OS_WIN)
// Tests multiple StartNotifySession success.
TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_Multiple) {
ASSERT_NO_FATAL_FAILURE(
@@ -907,6 +907,9 @@ TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_Multiple) {
characteristic1_->StartNotifySession(
GetNotifyCallback(Call::EXPECTED),
GetGattErrorCallback(Call::NOT_EXPECTED));
+
+ EXPECT_EQ(0, callback_count_);
+ SimulateGattNotifySessionStarted(characteristic1_);
#if defined(OS_ANDROID)
// TODO(crbug.com/551634): Decide when implementing IsNotifying if Android
// should trust the notification request always worked, or if we should always
@@ -915,8 +918,6 @@ TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_Multiple) {
#else
EXPECT_EQ(1, gatt_notify_characteristic_attempts_);
#endif
- EXPECT_EQ(0, callback_count_);
- SimulateGattNotifySessionStarted(characteristic1_);
EXPECT_EQ(2, callback_count_);
EXPECT_EQ(0, error_callback_count_);
ASSERT_EQ(2u, notify_sessions_.size());
@@ -929,7 +930,7 @@ TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_Multiple) {
EXPECT_TRUE(notify_sessions_[0]->IsActive());
EXPECT_TRUE(notify_sessions_[1]->IsActive());
}
-#endif // defined(OS_ANDROID)
+#endif // defined(OS_ANDROID) || defined(OS_WIN)
ortuno 2016/03/07 18:48:44 These test only cover starting notifications. Sinc
gogerald1 2016/03/07 22:52:48 Done.
#if defined(OS_ANDROID) || defined(OS_WIN)
TEST_F(BluetoothGattCharacteristicTest, GetDescriptors_FindNone) {

Powered by Google App Engine
This is Rietveld 408576698