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

Unified Diff: device/bluetooth/test/bluetooth_test.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, 8 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 | « device/bluetooth/test/bluetooth_test.h ('k') | device/bluetooth/test/bluetooth_test_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..ee1ec95e7c680b3d0130c9916b99fc5f62bc1beb 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(std::move(notify_session));
+
+ 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) {
+ SimulateGattNotifySessionStartError(
+ characteristic, BluetoothRemoteGattService::GATT_ERROR_UNKNOWN);
+ 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;
« no previous file with comments | « device/bluetooth/test/bluetooth_test.h ('k') | device/bluetooth/test/bluetooth_test_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698