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

Unified Diff: device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc

Issue 2695573002: Adding BluetoothTestBase::CheckNotifySessionValue() method (Closed)
Patch Set: Cleanup 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..6cfe6304020b3e03879f003828437d6d02fc5a3c 100644
--- a/device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc
+++ b/device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc
@@ -1422,33 +1422,15 @@ 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)
+ ExpectedChangeNotifyValueAttempts(1);
+ ExpectedNotifyValue(NotifyValueState::NOTIFY);
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)
+ ExpectedChangeNotifyValueAttempts(2);
+ ExpectedNotifyValue(NotifyValueState::NONE);
// Check that the notify session is inactive.
EXPECT_FALSE(notify_sessions_[0]->IsActive());
@@ -1467,33 +1449,15 @@ 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)
+ ExpectedChangeNotifyValueAttempts(1);
+ ExpectedNotifyValue(NotifyValueState::NOTIFY);
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)
+ ExpectedChangeNotifyValueAttempts(2);
+ ExpectedNotifyValue(NotifyValueState::NONE);
// Check that the notify session is inactive.
EXPECT_FALSE(characteristic1_->IsNotifying());
@@ -1634,33 +1598,15 @@ 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)
+ ExpectedChangeNotifyValueAttempts(1);
+ ExpectedNotifyValue(NotifyValueState::INDICATE);
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)
+ ExpectedChangeNotifyValueAttempts(2);
+ ExpectedNotifyValue(NotifyValueState::NONE);
// Check that the notify session is inactive.
EXPECT_FALSE(notify_sessions_[0]->IsActive());
@@ -1680,33 +1626,15 @@ 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)
+ ExpectedChangeNotifyValueAttempts(1);
+ ExpectedNotifyValue(NotifyValueState::NOTIFY);
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)
+ ExpectedChangeNotifyValueAttempts(2);
+ ExpectedNotifyValue(NotifyValueState::NONE);
// Check that the notify session is inactive.
EXPECT_FALSE(notify_sessions_[0]->IsActive());
@@ -1976,48 +1904,23 @@ 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)
+ ExpectedChangeNotifyValueAttempts(1);
+ ExpectedNotifyValue(NotifyValueState::NOTIFY);
// 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)
+ ExpectedChangeNotifyValueAttempts(2);
+ ExpectedNotifyValue(NotifyValueState::NONE);
// 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)
+ ExpectedChangeNotifyValueAttempts(2);
+ ExpectedNotifyValue(NotifyValueState::NONE);
SimulateGattNotifySessionStopped(characteristic1_);
base::RunLoop().RunUntilIdle();
@@ -2026,19 +1929,8 @@ 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)
+ ExpectedChangeNotifyValueAttempts(3);
+ ExpectedNotifyValue(NotifyValueState::NOTIFY);
// 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