Chromium Code Reviews| Index: device/bluetooth/test/bluetooth_test.cc |
| diff --git a/device/bluetooth/test/bluetooth_test.cc b/device/bluetooth/test/bluetooth_test.cc |
| index ca050881a381658fe9899e3f316ef633ee292b56..395d332cc12ca0cbb86b83d974152c4b7630c41a 100644 |
| --- a/device/bluetooth/test/bluetooth_test.cc |
| +++ b/device/bluetooth/test/bluetooth_test.cc |
| @@ -161,6 +161,47 @@ void BluetoothTestBase::GattErrorCallback( |
| unexpected_error_callback_ = true; |
| } |
| +void BluetoothTestBase::ReentrantStartNotifySessionSuccessCallback( |
| + Call expected, |
| + BluetoothRemoteGattCharacteristic* characteristic, |
| + std::unique_ptr<BluetoothGattNotifySession> notify_session) { |
| + ++callback_count_; |
| + notify_sessions_.push_back(notify_session.release()); |
|
ortuno
2016/04/22 16:23:39
I think std::move(notify_session) would be better
gogerald1
2016/04/27 20:15:32
Done.
|
| + |
| + if (expected == Call::EXPECTED) |
| + ++actual_success_callback_calls_; |
| + else |
| + unexpected_success_callback_ = true; |
| + |
| + characteristic->StartNotifySession(GetNotifyCallback(Call::EXPECTED), |
| + GetGattErrorCallback(Call::NOT_EXPECTED)); |
| +} |
| + |
| +void BluetoothTestBase::ReentrantStartNotifySessionErrorCallback( |
| + Call expected, |
| + BluetoothRemoteGattCharacteristic* characteristic, |
| + bool error_in_reentrant, |
| + BluetoothGattService::GattErrorCode error_code) { |
| + ++error_callback_count_; |
| + last_gatt_error_code_ = error_code; |
| + |
| + if (expected == Call::EXPECTED) |
| + ++actual_error_callback_calls_; |
| + else |
| + unexpected_error_callback_ = true; |
| + |
| + if (error_in_reentrant) { |
| + SimulateGattCharacteristicSetNotifyWillFailAsynchronouslyOnce( |
| + characteristic); |
| + characteristic->StartNotifySession(GetNotifyCallback(Call::NOT_EXPECTED), |
| + GetGattErrorCallback(Call::EXPECTED)); |
| + } else { |
| + characteristic->StartNotifySession( |
| + GetNotifyCallback(Call::EXPECTED), |
| + GetGattErrorCallback(Call::NOT_EXPECTED)); |
| + } |
| +} |
| + |
| base::Closure BluetoothTestBase::GetCallback(Call expected) { |
| if (expected == Call::EXPECTED) |
| ++expected_success_callback_calls_; |
| @@ -224,6 +265,29 @@ BluetoothTestBase::GetGattErrorCallback(Call expected) { |
| weak_factory_.GetWeakPtr(), expected); |
| } |
| +BluetoothRemoteGattCharacteristic::NotifySessionCallback |
| +BluetoothTestBase::GetReentrantStartNotifySessionSuccessCallback( |
| + Call expected, |
| + BluetoothRemoteGattCharacteristic* characteristic) { |
| + if (expected == Call::EXPECTED) |
| + ++expected_success_callback_calls_; |
| + return base::Bind( |
| + &BluetoothTestBase::ReentrantStartNotifySessionSuccessCallback, |
| + weak_factory_.GetWeakPtr(), expected, characteristic); |
| +} |
| + |
| +base::Callback<void(BluetoothGattService::GattErrorCode)> |
| +BluetoothTestBase::GetReentrantStartNotifySessionErrorCallback( |
| + Call expected, |
| + BluetoothRemoteGattCharacteristic* characteristic, |
| + bool error_in_reentrant) { |
| + if (expected == Call::EXPECTED) |
| + ++expected_error_callback_calls_; |
| + return base::Bind( |
| + &BluetoothTestBase::ReentrantStartNotifySessionErrorCallback, |
| + weak_factory_.GetWeakPtr(), expected, characteristic, error_in_reentrant); |
| +} |
| + |
| void BluetoothTestBase::ResetEventCounts() { |
| last_connect_error_code_ = BluetoothDevice::ERROR_UNKNOWN; |
| callback_count_ = 0; |