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 ++callback_count_; |
135 notify_sessions_.push_back(notify_session.release()); | 136 notify_sessions_.push_back(notify_session.release()); |
136 | 137 |
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 | |
149 notify_sessions_.push_back(notify_session.release()); | |
150 | |
151 ++callback_count_; | |
152 ++actual_success_callback_calls_; | |
153 } | |
154 | |
155 void BluetoothTestBase::StopNotifyCallback(Call expected) { | |
156 ++callback_count_; | |
157 | |
158 if (expected == Call::EXPECTED) | 138 if (expected == Call::EXPECTED) |
159 ++actual_success_callback_calls_; | 139 ++actual_success_callback_calls_; |
160 else | 140 else |
161 unexpected_success_callback_ = true; | 141 unexpected_success_callback_ = true; |
162 } | 142 } |
163 | 143 |
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 | |
172 void BluetoothTestBase::ReadValueCallback(Call expected, | 144 void BluetoothTestBase::ReadValueCallback(Call expected, |
173 const std::vector<uint8_t>& value) { | 145 const std::vector<uint8_t>& value) { |
174 ++callback_count_; | 146 ++callback_count_; |
175 last_read_value_ = value; | 147 last_read_value_ = value; |
176 | 148 |
177 if (expected == Call::EXPECTED) | 149 if (expected == Call::EXPECTED) |
178 ++actual_success_callback_calls_; | 150 ++actual_success_callback_calls_; |
179 else | 151 else |
180 unexpected_success_callback_ = true; | 152 unexpected_success_callback_ = true; |
181 } | 153 } |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 } | 250 } |
279 | 251 |
280 BluetoothRemoteGattCharacteristic::NotifySessionCallback | 252 BluetoothRemoteGattCharacteristic::NotifySessionCallback |
281 BluetoothTestBase::GetNotifyCallback(Call expected) { | 253 BluetoothTestBase::GetNotifyCallback(Call expected) { |
282 if (expected == Call::EXPECTED) | 254 if (expected == Call::EXPECTED) |
283 ++expected_success_callback_calls_; | 255 ++expected_success_callback_calls_; |
284 return base::Bind(&BluetoothTestBase::NotifyCallback, | 256 return base::Bind(&BluetoothTestBase::NotifyCallback, |
285 weak_factory_.GetWeakPtr(), expected); | 257 weak_factory_.GetWeakPtr(), expected); |
286 } | 258 } |
287 | 259 |
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 | |
309 BluetoothRemoteGattCharacteristic::ValueCallback | 260 BluetoothRemoteGattCharacteristic::ValueCallback |
310 BluetoothTestBase::GetReadValueCallback(Call expected) { | 261 BluetoothTestBase::GetReadValueCallback(Call expected) { |
311 if (expected == Call::EXPECTED) | 262 if (expected == Call::EXPECTED) |
312 ++expected_success_callback_calls_; | 263 ++expected_success_callback_calls_; |
313 return base::Bind(&BluetoothTestBase::ReadValueCallback, | 264 return base::Bind(&BluetoothTestBase::ReadValueCallback, |
314 weak_factory_.GetWeakPtr(), expected); | 265 weak_factory_.GetWeakPtr(), expected); |
315 } | 266 } |
316 | 267 |
317 BluetoothAdapter::ErrorCallback BluetoothTestBase::GetErrorCallback( | 268 BluetoothAdapter::ErrorCallback BluetoothTestBase::GetErrorCallback( |
318 Call expected) { | 269 Call expected) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 gatt_write_characteristic_attempts_ = 0; | 324 gatt_write_characteristic_attempts_ = 0; |
374 gatt_read_descriptor_attempts_ = 0; | 325 gatt_read_descriptor_attempts_ = 0; |
375 gatt_write_descriptor_attempts_ = 0; | 326 gatt_write_descriptor_attempts_ = 0; |
376 } | 327 } |
377 | 328 |
378 void BluetoothTestBase::RemoveTimedOutDevices() { | 329 void BluetoothTestBase::RemoveTimedOutDevices() { |
379 adapter_->RemoveTimedOutDevices(); | 330 adapter_->RemoveTimedOutDevices(); |
380 } | 331 } |
381 | 332 |
382 } // namespace device | 333 } // namespace device |
OLD | NEW |