| 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 last_connect_error_code_ = error_code; | 144 last_connect_error_code_ = error_code; |
| 145 | 145 |
| 146 if (expected == Call::EXPECTED) | 146 if (expected == Call::EXPECTED) |
| 147 ++actual_error_callback_calls_; | 147 ++actual_error_callback_calls_; |
| 148 else | 148 else |
| 149 unexpected_error_callback_ = true; | 149 unexpected_error_callback_ = true; |
| 150 } | 150 } |
| 151 | 151 |
| 152 void BluetoothTestBase::GattErrorCallback( | 152 void BluetoothTestBase::GattErrorCallback( |
| 153 Call expected, | 153 Call expected, |
| 154 BluetoothGattService::GattErrorCode error_code) { | 154 BluetoothRemoteGattService::GattErrorCode error_code) { |
| 155 ++error_callback_count_; | 155 ++error_callback_count_; |
| 156 last_gatt_error_code_ = error_code; | 156 last_gatt_error_code_ = error_code; |
| 157 | 157 |
| 158 if (expected == Call::EXPECTED) | 158 if (expected == Call::EXPECTED) |
| 159 ++actual_error_callback_calls_; | 159 ++actual_error_callback_calls_; |
| 160 else | 160 else |
| 161 unexpected_error_callback_ = true; | 161 unexpected_error_callback_ = true; |
| 162 } | 162 } |
| 163 | 163 |
| 164 base::Closure BluetoothTestBase::GetCallback(Call expected) { | 164 base::Closure BluetoothTestBase::GetCallback(Call expected) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 177 } | 177 } |
| 178 | 178 |
| 179 BluetoothDevice::GattConnectionCallback | 179 BluetoothDevice::GattConnectionCallback |
| 180 BluetoothTestBase::GetGattConnectionCallback(Call expected) { | 180 BluetoothTestBase::GetGattConnectionCallback(Call expected) { |
| 181 if (expected == Call::EXPECTED) | 181 if (expected == Call::EXPECTED) |
| 182 ++expected_success_callback_calls_; | 182 ++expected_success_callback_calls_; |
| 183 return base::Bind(&BluetoothTestBase::GattConnectionCallback, | 183 return base::Bind(&BluetoothTestBase::GattConnectionCallback, |
| 184 weak_factory_.GetWeakPtr(), expected); | 184 weak_factory_.GetWeakPtr(), expected); |
| 185 } | 185 } |
| 186 | 186 |
| 187 BluetoothGattCharacteristic::NotifySessionCallback | 187 BluetoothRemoteGattCharacteristic::NotifySessionCallback |
| 188 BluetoothTestBase::GetNotifyCallback(Call expected) { | 188 BluetoothTestBase::GetNotifyCallback(Call expected) { |
| 189 if (expected == Call::EXPECTED) | 189 if (expected == Call::EXPECTED) |
| 190 ++expected_success_callback_calls_; | 190 ++expected_success_callback_calls_; |
| 191 return base::Bind(&BluetoothTestBase::NotifyCallback, | 191 return base::Bind(&BluetoothTestBase::NotifyCallback, |
| 192 weak_factory_.GetWeakPtr(), expected); | 192 weak_factory_.GetWeakPtr(), expected); |
| 193 } | 193 } |
| 194 | 194 |
| 195 BluetoothGattCharacteristic::ValueCallback | 195 BluetoothRemoteGattCharacteristic::ValueCallback |
| 196 BluetoothTestBase::GetReadValueCallback(Call expected) { | 196 BluetoothTestBase::GetReadValueCallback(Call expected) { |
| 197 if (expected == Call::EXPECTED) | 197 if (expected == Call::EXPECTED) |
| 198 ++expected_success_callback_calls_; | 198 ++expected_success_callback_calls_; |
| 199 return base::Bind(&BluetoothTestBase::ReadValueCallback, | 199 return base::Bind(&BluetoothTestBase::ReadValueCallback, |
| 200 weak_factory_.GetWeakPtr(), expected); | 200 weak_factory_.GetWeakPtr(), expected); |
| 201 } | 201 } |
| 202 | 202 |
| 203 BluetoothAdapter::ErrorCallback BluetoothTestBase::GetErrorCallback( | 203 BluetoothAdapter::ErrorCallback BluetoothTestBase::GetErrorCallback( |
| 204 Call expected) { | 204 Call expected) { |
| 205 if (expected == Call::EXPECTED) | 205 if (expected == Call::EXPECTED) |
| 206 ++expected_error_callback_calls_; | 206 ++expected_error_callback_calls_; |
| 207 return base::Bind(&BluetoothTestBase::ErrorCallback, | 207 return base::Bind(&BluetoothTestBase::ErrorCallback, |
| 208 weak_factory_.GetWeakPtr(), expected); | 208 weak_factory_.GetWeakPtr(), expected); |
| 209 } | 209 } |
| 210 | 210 |
| 211 BluetoothDevice::ConnectErrorCallback | 211 BluetoothDevice::ConnectErrorCallback |
| 212 BluetoothTestBase::GetConnectErrorCallback(Call expected) { | 212 BluetoothTestBase::GetConnectErrorCallback(Call expected) { |
| 213 if (expected == Call::EXPECTED) | 213 if (expected == Call::EXPECTED) |
| 214 ++expected_error_callback_calls_; | 214 ++expected_error_callback_calls_; |
| 215 return base::Bind(&BluetoothTestBase::ConnectErrorCallback, | 215 return base::Bind(&BluetoothTestBase::ConnectErrorCallback, |
| 216 weak_factory_.GetWeakPtr(), expected); | 216 weak_factory_.GetWeakPtr(), expected); |
| 217 } | 217 } |
| 218 | 218 |
| 219 base::Callback<void(BluetoothGattService::GattErrorCode)> | 219 base::Callback<void(BluetoothRemoteGattService::GattErrorCode)> |
| 220 BluetoothTestBase::GetGattErrorCallback(Call expected) { | 220 BluetoothTestBase::GetGattErrorCallback(Call expected) { |
| 221 if (expected == Call::EXPECTED) | 221 if (expected == Call::EXPECTED) |
| 222 ++expected_error_callback_calls_; | 222 ++expected_error_callback_calls_; |
| 223 return base::Bind(&BluetoothTestBase::GattErrorCallback, | 223 return base::Bind(&BluetoothTestBase::GattErrorCallback, |
| 224 weak_factory_.GetWeakPtr(), expected); | 224 weak_factory_.GetWeakPtr(), expected); |
| 225 } | 225 } |
| 226 | 226 |
| 227 void BluetoothTestBase::ResetEventCounts() { | 227 void BluetoothTestBase::ResetEventCounts() { |
| 228 last_connect_error_code_ = BluetoothDevice::ERROR_UNKNOWN; | 228 last_connect_error_code_ = BluetoothDevice::ERROR_UNKNOWN; |
| 229 callback_count_ = 0; | 229 callback_count_ = 0; |
| 230 error_callback_count_ = 0; | 230 error_callback_count_ = 0; |
| 231 gatt_connection_attempts_ = 0; | 231 gatt_connection_attempts_ = 0; |
| 232 gatt_disconnection_attempts_ = 0; | 232 gatt_disconnection_attempts_ = 0; |
| 233 gatt_discovery_attempts_ = 0; | 233 gatt_discovery_attempts_ = 0; |
| 234 gatt_notify_characteristic_attempts_ = 0; | 234 gatt_notify_characteristic_attempts_ = 0; |
| 235 gatt_read_characteristic_attempts_ = 0; | 235 gatt_read_characteristic_attempts_ = 0; |
| 236 gatt_write_characteristic_attempts_ = 0; | 236 gatt_write_characteristic_attempts_ = 0; |
| 237 gatt_read_descriptor_attempts_ = 0; | 237 gatt_read_descriptor_attempts_ = 0; |
| 238 gatt_write_descriptor_attempts_ = 0; | 238 gatt_write_descriptor_attempts_ = 0; |
| 239 } | 239 } |
| 240 | 240 |
| 241 } // namespace device | 241 } // namespace device |
| OLD | NEW |