OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "device/bluetooth/test/bluetooth_test.h" | 5 #include "device/bluetooth/test/bluetooth_test.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 | 125 |
126 if (expected == Call::EXPECTED) | 126 if (expected == Call::EXPECTED) |
127 ++actual_success_callback_calls_; | 127 ++actual_success_callback_calls_; |
128 else | 128 else |
129 unexpected_success_callback_ = true; | 129 unexpected_success_callback_ = true; |
130 } | 130 } |
131 | 131 |
132 void BluetoothTestBase::NotifyCallback( | 132 void BluetoothTestBase::NotifyCallback( |
133 Call expected, | 133 Call expected, |
134 std::unique_ptr<BluetoothGattNotifySession> notify_session) { | 134 std::unique_ptr<BluetoothGattNotifySession> notify_session) { |
| 135 notify_sessions_.push_back(notify_session.release()); |
| 136 |
135 ++callback_count_; | 137 ++callback_count_; |
| 138 if (expected == Call::EXPECTED) |
| 139 ++actual_success_callback_calls_; |
| 140 else |
| 141 unexpected_success_callback_ = true; |
| 142 } |
| 143 |
| 144 void BluetoothTestBase::NotifyCheckForPrecedingCalls( |
| 145 int num_of_preceding_calls, |
| 146 std::unique_ptr<BluetoothGattNotifySession> notify_session) { |
| 147 EXPECT_EQ(num_of_preceding_calls, callback_count_); |
| 148 |
136 notify_sessions_.push_back(notify_session.release()); | 149 notify_sessions_.push_back(notify_session.release()); |
137 | 150 |
| 151 ++callback_count_; |
| 152 ++actual_success_callback_calls_; |
| 153 } |
| 154 |
| 155 void BluetoothTestBase::StopNotifyCallback(Call expected) { |
| 156 ++callback_count_; |
| 157 |
138 if (expected == Call::EXPECTED) | 158 if (expected == Call::EXPECTED) |
139 ++actual_success_callback_calls_; | 159 ++actual_success_callback_calls_; |
140 else | 160 else |
141 unexpected_success_callback_ = true; | 161 unexpected_success_callback_ = true; |
142 } | 162 } |
143 | 163 |
| 164 void BluetoothTestBase::StopNotifyCheckForPrecedingCalls( |
| 165 int num_of_preceding_calls) { |
| 166 EXPECT_EQ(num_of_preceding_calls, callback_count_); |
| 167 |
| 168 ++callback_count_; |
| 169 ++actual_success_callback_calls_; |
| 170 } |
| 171 |
144 void BluetoothTestBase::ReadValueCallback(Call expected, | 172 void BluetoothTestBase::ReadValueCallback(Call expected, |
145 const std::vector<uint8_t>& value) { | 173 const std::vector<uint8_t>& value) { |
146 ++callback_count_; | 174 ++callback_count_; |
147 last_read_value_ = value; | 175 last_read_value_ = value; |
148 | 176 |
149 if (expected == Call::EXPECTED) | 177 if (expected == Call::EXPECTED) |
150 ++actual_success_callback_calls_; | 178 ++actual_success_callback_calls_; |
151 else | 179 else |
152 unexpected_success_callback_ = true; | 180 unexpected_success_callback_ = true; |
153 } | 181 } |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 } | 278 } |
251 | 279 |
252 BluetoothRemoteGattCharacteristic::NotifySessionCallback | 280 BluetoothRemoteGattCharacteristic::NotifySessionCallback |
253 BluetoothTestBase::GetNotifyCallback(Call expected) { | 281 BluetoothTestBase::GetNotifyCallback(Call expected) { |
254 if (expected == Call::EXPECTED) | 282 if (expected == Call::EXPECTED) |
255 ++expected_success_callback_calls_; | 283 ++expected_success_callback_calls_; |
256 return base::Bind(&BluetoothTestBase::NotifyCallback, | 284 return base::Bind(&BluetoothTestBase::NotifyCallback, |
257 weak_factory_.GetWeakPtr(), expected); | 285 weak_factory_.GetWeakPtr(), expected); |
258 } | 286 } |
259 | 287 |
| 288 BluetoothRemoteGattCharacteristic::NotifySessionCallback |
| 289 BluetoothTestBase::GetNotifyCheckForPrecedingCalls(int num_of_preceding_calls) { |
| 290 ++expected_success_callback_calls_; |
| 291 return base::Bind(&BluetoothTestBase::NotifyCheckForPrecedingCalls, |
| 292 weak_factory_.GetWeakPtr(), num_of_preceding_calls); |
| 293 } |
| 294 |
| 295 base::Closure BluetoothTestBase::GetStopNotifyCallback(Call expected) { |
| 296 if (expected == Call::EXPECTED) |
| 297 ++expected_success_callback_calls_; |
| 298 return base::Bind(&BluetoothTestBase::StopNotifyCallback, |
| 299 weak_factory_.GetWeakPtr(), expected); |
| 300 } |
| 301 |
| 302 base::Closure BluetoothTestBase::GetStopNotifyCheckForPrecedingCalls( |
| 303 int num_of_preceding_calls) { |
| 304 ++expected_success_callback_calls_; |
| 305 return base::Bind(&BluetoothTestBase::StopNotifyCheckForPrecedingCalls, |
| 306 weak_factory_.GetWeakPtr(), num_of_preceding_calls); |
| 307 } |
| 308 |
260 BluetoothRemoteGattCharacteristic::ValueCallback | 309 BluetoothRemoteGattCharacteristic::ValueCallback |
261 BluetoothTestBase::GetReadValueCallback(Call expected) { | 310 BluetoothTestBase::GetReadValueCallback(Call expected) { |
262 if (expected == Call::EXPECTED) | 311 if (expected == Call::EXPECTED) |
263 ++expected_success_callback_calls_; | 312 ++expected_success_callback_calls_; |
264 return base::Bind(&BluetoothTestBase::ReadValueCallback, | 313 return base::Bind(&BluetoothTestBase::ReadValueCallback, |
265 weak_factory_.GetWeakPtr(), expected); | 314 weak_factory_.GetWeakPtr(), expected); |
266 } | 315 } |
267 | 316 |
268 BluetoothAdapter::ErrorCallback BluetoothTestBase::GetErrorCallback( | 317 BluetoothAdapter::ErrorCallback BluetoothTestBase::GetErrorCallback( |
269 Call expected) { | 318 Call expected) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 gatt_write_characteristic_attempts_ = 0; | 373 gatt_write_characteristic_attempts_ = 0; |
325 gatt_read_descriptor_attempts_ = 0; | 374 gatt_read_descriptor_attempts_ = 0; |
326 gatt_write_descriptor_attempts_ = 0; | 375 gatt_write_descriptor_attempts_ = 0; |
327 } | 376 } |
328 | 377 |
329 void BluetoothTestBase::RemoveTimedOutDevices() { | 378 void BluetoothTestBase::RemoveTimedOutDevices() { |
330 adapter_->RemoveTimedOutDevices(); | 379 adapter_->RemoveTimedOutDevices(); |
331 } | 380 } |
332 | 381 |
333 } // namespace device | 382 } // namespace device |
OLD | NEW |