 Chromium Code Reviews
 Chromium Code Reviews| 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 std::unique_ptr<BluetoothGattNotifySession> notify_session) { | 134 std::unique_ptr<BluetoothGattNotifySession> notify_session) { | 
| 135 ++callback_count_; | 135 ++callback_count_; | 
| 136 notify_sessions_.push_back(notify_session.release()); | 136 notify_sessions_.push_back(notify_session.release()); | 
| 137 | 137 | 
| 138 if (expected == Call::EXPECTED) | 138 if (expected == Call::EXPECTED) | 
| 139 ++actual_success_callback_calls_; | 139 ++actual_success_callback_calls_; | 
| 140 else | 140 else | 
| 141 unexpected_success_callback_ = true; | 141 unexpected_success_callback_ = true; | 
| 142 } | 142 } | 
| 143 | 143 | 
| 144 void BluetoothTestBase::StopNotifyCallback( | |
| 145 Call expected, | |
| 146 BluetoothGattNotifySession* notify_session) { | |
| 147 ++callback_count_; | |
| 148 for (ScopedVector<BluetoothGattNotifySession>::iterator i = | |
| 
ortuno
2016/08/02 01:56:34
If you do this then you never get a chance to test
 
tommyt
2016/08/05 12:22:30
I have removed this and adjusted the unittests.
 | |
| 149 notify_sessions_.begin(); | |
| 150 i != notify_sessions_.end(); ++i) { | |
| 151 if (*i == notify_session) { | |
| 152 notify_sessions_.erase(i); | |
| 153 break; | |
| 154 } | |
| 155 } | |
| 156 | |
| 157 if (expected == Call::EXPECTED) | |
| 158 ++actual_success_callback_calls_; | |
| 159 else | |
| 160 unexpected_success_callback_ = true; | |
| 161 } | |
| 162 | |
| 144 void BluetoothTestBase::ReadValueCallback(Call expected, | 163 void BluetoothTestBase::ReadValueCallback(Call expected, | 
| 145 const std::vector<uint8_t>& value) { | 164 const std::vector<uint8_t>& value) { | 
| 146 ++callback_count_; | 165 ++callback_count_; | 
| 147 last_read_value_ = value; | 166 last_read_value_ = value; | 
| 148 | 167 | 
| 149 if (expected == Call::EXPECTED) | 168 if (expected == Call::EXPECTED) | 
| 150 ++actual_success_callback_calls_; | 169 ++actual_success_callback_calls_; | 
| 151 else | 170 else | 
| 152 unexpected_success_callback_ = true; | 171 unexpected_success_callback_ = true; | 
| 153 } | 172 } | 
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 250 } | 269 } | 
| 251 | 270 | 
| 252 BluetoothRemoteGattCharacteristic::NotifySessionCallback | 271 BluetoothRemoteGattCharacteristic::NotifySessionCallback | 
| 253 BluetoothTestBase::GetNotifyCallback(Call expected) { | 272 BluetoothTestBase::GetNotifyCallback(Call expected) { | 
| 254 if (expected == Call::EXPECTED) | 273 if (expected == Call::EXPECTED) | 
| 255 ++expected_success_callback_calls_; | 274 ++expected_success_callback_calls_; | 
| 256 return base::Bind(&BluetoothTestBase::NotifyCallback, | 275 return base::Bind(&BluetoothTestBase::NotifyCallback, | 
| 257 weak_factory_.GetWeakPtr(), expected); | 276 weak_factory_.GetWeakPtr(), expected); | 
| 258 } | 277 } | 
| 259 | 278 | 
| 279 base::Closure BluetoothTestBase::GetStopNotifyCallback( | |
| 280 Call expected, | |
| 281 BluetoothGattNotifySession* notify_session) { | |
| 282 if (expected == Call::EXPECTED) | |
| 283 ++expected_success_callback_calls_; | |
| 284 return base::Bind(&BluetoothTestBase::StopNotifyCallback, | |
| 285 weak_factory_.GetWeakPtr(), expected, notify_session); | |
| 286 } | |
| 287 | |
| 260 BluetoothRemoteGattCharacteristic::ValueCallback | 288 BluetoothRemoteGattCharacteristic::ValueCallback | 
| 261 BluetoothTestBase::GetReadValueCallback(Call expected) { | 289 BluetoothTestBase::GetReadValueCallback(Call expected) { | 
| 262 if (expected == Call::EXPECTED) | 290 if (expected == Call::EXPECTED) | 
| 263 ++expected_success_callback_calls_; | 291 ++expected_success_callback_calls_; | 
| 264 return base::Bind(&BluetoothTestBase::ReadValueCallback, | 292 return base::Bind(&BluetoothTestBase::ReadValueCallback, | 
| 265 weak_factory_.GetWeakPtr(), expected); | 293 weak_factory_.GetWeakPtr(), expected); | 
| 266 } | 294 } | 
| 267 | 295 | 
| 268 BluetoothAdapter::ErrorCallback BluetoothTestBase::GetErrorCallback( | 296 BluetoothAdapter::ErrorCallback BluetoothTestBase::GetErrorCallback( | 
| 269 Call expected) { | 297 Call expected) { | 
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 324 gatt_write_characteristic_attempts_ = 0; | 352 gatt_write_characteristic_attempts_ = 0; | 
| 325 gatt_read_descriptor_attempts_ = 0; | 353 gatt_read_descriptor_attempts_ = 0; | 
| 326 gatt_write_descriptor_attempts_ = 0; | 354 gatt_write_descriptor_attempts_ = 0; | 
| 327 } | 355 } | 
| 328 | 356 | 
| 329 void BluetoothTestBase::RemoveTimedOutDevices() { | 357 void BluetoothTestBase::RemoveTimedOutDevices() { | 
| 330 adapter_->RemoveTimedOutDevices(); | 358 adapter_->RemoveTimedOutDevices(); | 
| 331 } | 359 } | 
| 332 | 360 | 
| 333 } // namespace device | 361 } // namespace device | 
| OLD | NEW |