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

Unified Diff: device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc

Issue 2695573002: Adding BluetoothTestBase::CheckNotifySessionValue() method (Closed)
Patch Set: Fixing tests Created 3 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
« no previous file with comments | « no previous file | device/bluetooth/test/bluetooth_test.h » ('j') | device/bluetooth/test/bluetooth_test.cc » ('J')
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 52fabd3edfc592e64380f751c093ddcfd6b3cd42..c429dd2b33b9eb4d785730f91dc1c7d63a6d0b87 100644
--- a/device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc
+++ b/device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc
@@ -1422,33 +1422,13 @@ TEST_F(BluetoothRemoteGattCharacteristicTest, StopNotifySession) {
ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
/* properties: NOTIFY */ 0x10,
/* expected_config_descriptor_value: NOTIFY */ 1));
-// macOS: Not applicable. CoreBluetooth exposes -[CBPeripheral
-// setNotifyValue:forCharacteristic:] which handles all interactions with
-// the CCC descriptor.
-#if !defined(OS_MACOSX)
- EXPECT_EQ(1, gatt_write_descriptor_attempts_);
-#else
- EXPECT_EQ(1, gatt_notify_characteristic_attempts_);
- EXPECT_TRUE(last_notify_value);
-#endif // !defined(OS_MACOSX)
+ CheckNotifySessionValue(1, 1);
notify_sessions_[0]->Stop(GetStopNotifyCallback(Call::EXPECTED));
SimulateGattNotifySessionStopped(characteristic1_);
base::RunLoop().RunUntilIdle();
-// macOS: Not applicable. CoreBluetooth exposes -[CBPeripheral
-// setNotifyValue:forCharacteristic:] which handles all interactions with
-// the CCC descriptor.
-#if !defined(OS_MACOSX)
- // Check that the right values were written to the descriptor.
- EXPECT_EQ(2, gatt_write_descriptor_attempts_);
- ASSERT_EQ(2u, last_write_value_.size());
- EXPECT_EQ(0, last_write_value_[0]);
- EXPECT_EQ(0, last_write_value_[1]);
-#else
- EXPECT_EQ(2, gatt_notify_characteristic_attempts_);
- EXPECT_FALSE(last_notify_value);
-#endif // !defined(OS_MACOSX)
+ CheckNotifySessionValue(0, 2);
// Check that the notify session is inactive.
EXPECT_FALSE(notify_sessions_[0]->IsActive());
@@ -1467,33 +1447,13 @@ TEST_F(BluetoothRemoteGattCharacteristicTest,
ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
/* properties: NOTIFY */ 0x10,
/* expected_config_descriptor_value: NOTIFY */ 1));
-// macOS: Not applicable. CoreBluetooth exposes -[CBPeripheral
-// setNotifyValue:forCharacteristic:] which handles all interactions with
-// the CCC descriptor.
-#if !defined(OS_MACOSX)
- EXPECT_EQ(1, gatt_write_descriptor_attempts_);
-#else
- EXPECT_EQ(1, gatt_notify_characteristic_attempts_);
- EXPECT_TRUE(last_notify_value);
-#endif // !defined(OS_MACOSX)
+ CheckNotifySessionValue(1, 1);
notify_sessions_.clear();
SimulateGattNotifySessionStopped(characteristic1_);
base::RunLoop().RunUntilIdle();
-// macOS: Not applicable. CoreBluetooth exposes -[CBPeripheral
-// setNotifyValue:forCharacteristic:] which handles all interactions with
-// the CCC descriptor.
-#if !defined(OS_MACOSX)
- // Check that the right values were written to the descriptor.
- EXPECT_EQ(2, gatt_write_descriptor_attempts_);
- ASSERT_EQ(2u, last_write_value_.size());
- EXPECT_EQ(0, last_write_value_[0]);
- EXPECT_EQ(0, last_write_value_[1]);
-#else
- EXPECT_EQ(2, gatt_notify_characteristic_attempts_);
- EXPECT_FALSE(last_notify_value);
-#endif // !defined(OS_MACOSX)
+ CheckNotifySessionValue(0, 2);
// Check that the notify session is inactive.
EXPECT_FALSE(characteristic1_->IsNotifying());
@@ -1634,33 +1594,13 @@ TEST_F(BluetoothRemoteGattCharacteristicTest, StopNotifySession_OnIndicate) {
ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
/* properties: INDICATE */ 0x20,
/* expected_config_descriptor_value: INDICATE */ 2));
-// macOS: Not applicable. CoreBluetooth exposes -[CBPeripheral
-// setNotifyValue:forCharacteristic:] which handles all interactions with
-// the CCC descriptor.
-#if !defined(OS_MACOSX)
- EXPECT_EQ(1, gatt_write_descriptor_attempts_);
-#else
- EXPECT_EQ(1, gatt_notify_characteristic_attempts_);
- EXPECT_TRUE(last_notify_value);
-#endif // !defined(OS_MACOSX)
+ CheckNotifySessionValue(2, 1);
notify_sessions_[0]->Stop(GetStopNotifyCallback(Call::EXPECTED));
SimulateGattNotifySessionStopped(characteristic1_);
base::RunLoop().RunUntilIdle();
-// macOS: Not applicable. CoreBluetooth exposes -[CBPeripheral
-// setNotifyValue:forCharacteristic:] which handles all interactions with
-// the CCC descriptor.
-#if !defined(OS_MACOSX)
- // Check that the right values were written to the descriptor.
- EXPECT_EQ(2, gatt_write_descriptor_attempts_);
- ASSERT_EQ(2u, last_write_value_.size());
- EXPECT_EQ(0, last_write_value_[0]);
- EXPECT_EQ(0, last_write_value_[1]);
-#else
- EXPECT_EQ(2, gatt_notify_characteristic_attempts_);
- EXPECT_FALSE(last_notify_value);
-#endif // !defined(OS_MACOSX)
+ CheckNotifySessionValue(0, 2);
// Check that the notify session is inactive.
EXPECT_FALSE(notify_sessions_[0]->IsActive());
@@ -1680,33 +1620,13 @@ TEST_F(BluetoothRemoteGattCharacteristicTest,
ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
/* properties: NOTIFY and INDICATE bits set */ 0x30,
/* expected_config_descriptor_value: INDICATE */ 1));
-// macOS: Not applicable. CoreBluetooth exposes -[CBPeripheral
-// setNotifyValue:forCharacteristic:] which handles all interactions with
-// the CCC descriptor.
-#if !defined(OS_MACOSX)
- EXPECT_EQ(1, gatt_write_descriptor_attempts_);
-#else
- EXPECT_EQ(1, gatt_notify_characteristic_attempts_);
- EXPECT_TRUE(last_notify_value);
-#endif // !defined(OS_MACOSX)
+ CheckNotifySessionValue(1, 1);
notify_sessions_[0]->Stop(GetStopNotifyCallback(Call::EXPECTED));
SimulateGattNotifySessionStopped(characteristic1_);
base::RunLoop().RunUntilIdle();
-// macOS: Not applicable. CoreBluetooth exposes -[CBPeripheral
-// setNotifyValue:forCharacteristic:] which handles all interactions with
-// the CCC descriptor.
-#if !defined(OS_MACOSX)
- // Check that the right values were written to the descriptor.
- EXPECT_EQ(2, gatt_write_descriptor_attempts_);
- ASSERT_EQ(2u, last_write_value_.size());
- EXPECT_EQ(0, last_write_value_[0]);
- EXPECT_EQ(0, last_write_value_[1]);
-#else
- EXPECT_EQ(2, gatt_notify_characteristic_attempts_);
- EXPECT_FALSE(last_notify_value);
-#endif // !defined(OS_MACOSX)
+ CheckNotifySessionValue(0, 2);
// Check that the notify session is inactive.
EXPECT_FALSE(notify_sessions_[0]->IsActive());
@@ -1976,48 +1896,20 @@ TEST_F(BluetoothRemoteGattCharacteristicTest, StopNotifySession_StopStopStart) {
ASSERT_EQ(1u, notify_sessions_.size());
ASSERT_TRUE(notify_sessions_[0]);
EXPECT_TRUE(notify_sessions_[0]->IsActive());
-// macOS: Not applicable. CoreBluetooth exposes -[CBPeripheral
-// setNotifyValue:forCharacteristic:] which handles all interactions with
-// the CCC descriptor.
-#if !defined(OS_MACOSX)
- EXPECT_EQ(1, gatt_write_descriptor_attempts_);
-#else
- EXPECT_EQ(1, gatt_notify_characteristic_attempts_);
- EXPECT_TRUE(last_notify_value);
-#endif // !defined(OS_MACOSX)
+ CheckNotifySessionValue(1, 1);
// Stop the notify session twice
notify_sessions_[0]->Stop(GetStopNotifyCheckForPrecedingCalls(1));
notify_sessions_[0]->Stop(GetStopNotifyCheckForPrecedingCalls(2));
-// macOS: Not applicable. CoreBluetooth exposes -[CBPeripheral
-// setNotifyValue:forCharacteristic:] which handles all interactions with
-// the CCC descriptor.
-#if !defined(OS_MACOSX)
- // Check that the right values were written to the descriptor.
- EXPECT_EQ(2, gatt_write_descriptor_attempts_);
- ASSERT_EQ(2u, last_write_value_.size());
- EXPECT_EQ(0, last_write_value_[0]);
- EXPECT_EQ(0, last_write_value_[1]);
-#else
- EXPECT_EQ(2, gatt_notify_characteristic_attempts_);
- EXPECT_FALSE(last_notify_value);
-#endif // !defined(OS_MACOSX)
+ CheckNotifySessionValue(0, 2);
// Start another notify session
characteristic1_->StartNotifySession(
GetNotifyCheckForPrecedingCalls(3),
GetGattErrorCallback(Call::NOT_EXPECTED));
-// macOS: Not applicable. CoreBluetooth exposes -[CBPeripheral
-// setNotifyValue:forCharacteristic:] which handles all interactions with
-// the CCC descriptor.
-#if !defined(OS_MACOSX)
- // Check that nothing was written by the StartNotifySession call above
- EXPECT_EQ(2, gatt_write_descriptor_attempts_);
-#else
- EXPECT_EQ(2, gatt_notify_characteristic_attempts_);
-#endif // !defined(OS_MACOSX)
+ CheckNotifySessionValue(0, 2);
SimulateGattNotifySessionStopped(characteristic1_);
base::RunLoop().RunUntilIdle();
@@ -2026,19 +1918,7 @@ TEST_F(BluetoothRemoteGattCharacteristicTest, StopNotifySession_StopStopStart) {
SimulateGattNotifySessionStarted(characteristic1_);
base::RunLoop().RunUntilIdle();
-// macOS: Not applicable. CoreBluetooth exposes -[CBPeripheral
-// setNotifyValue:forCharacteristic:] which handles all interactions with
-// the CCC descriptor.
-#if !defined(OS_MACOSX)
- // Check that the right values were written to the descriptor.
- EXPECT_EQ(3, gatt_write_descriptor_attempts_);
- ASSERT_EQ(2u, last_write_value_.size());
- EXPECT_EQ(1, last_write_value_[0]);
- EXPECT_EQ(0, last_write_value_[1]);
-#else
- EXPECT_EQ(3, gatt_notify_characteristic_attempts_);
- EXPECT_TRUE(last_notify_value);
-#endif // !defined(OS_MACOSX)
+ CheckNotifySessionValue(1, 3);
// Check the notify state
ASSERT_EQ(2u, notify_sessions_.size());
« no previous file with comments | « no previous file | device/bluetooth/test/bluetooth_test.h » ('j') | device/bluetooth/test/bluetooth_test.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698