| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "device/bluetooth/bluetooth_adapter.h" | 10 #include "device/bluetooth/bluetooth_adapter.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 ++callback_count_; | 57 ++callback_count_; |
| 58 discovery_sessions_.push_back(discovery_session.release()); | 58 discovery_sessions_.push_back(discovery_session.release()); |
| 59 } | 59 } |
| 60 | 60 |
| 61 void BluetoothTestBase::GattConnectionCallback( | 61 void BluetoothTestBase::GattConnectionCallback( |
| 62 scoped_ptr<BluetoothGattConnection> connection) { | 62 scoped_ptr<BluetoothGattConnection> connection) { |
| 63 ++callback_count_; | 63 ++callback_count_; |
| 64 gatt_connections_.push_back(connection.release()); | 64 gatt_connections_.push_back(connection.release()); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void BluetoothTestBase::NotifyCallback( |
| 68 scoped_ptr<BluetoothGattNotifySession> notify_session) { |
| 69 ++callback_count_; |
| 70 notify_sessions_.push_back(notify_session.release()); |
| 71 } |
| 72 |
| 67 void BluetoothTestBase::ReadValueCallback(const std::vector<uint8>& value) { | 73 void BluetoothTestBase::ReadValueCallback(const std::vector<uint8>& value) { |
| 68 ++callback_count_; | 74 ++callback_count_; |
| 69 last_read_value_ = value; | 75 last_read_value_ = value; |
| 70 } | 76 } |
| 71 | 77 |
| 72 void BluetoothTestBase::ErrorCallback() { | 78 void BluetoothTestBase::ErrorCallback() { |
| 73 ++error_callback_count_; | 79 ++error_callback_count_; |
| 74 } | 80 } |
| 75 | 81 |
| 76 void BluetoothTestBase::ConnectErrorCallback( | 82 void BluetoothTestBase::ConnectErrorCallback( |
| (...skipping 17 matching lines...) Expand all Loading... |
| 94 return base::Bind(&BluetoothTestBase::DiscoverySessionCallback, | 100 return base::Bind(&BluetoothTestBase::DiscoverySessionCallback, |
| 95 weak_factory_.GetWeakPtr()); | 101 weak_factory_.GetWeakPtr()); |
| 96 } | 102 } |
| 97 | 103 |
| 98 BluetoothDevice::GattConnectionCallback | 104 BluetoothDevice::GattConnectionCallback |
| 99 BluetoothTestBase::GetGattConnectionCallback() { | 105 BluetoothTestBase::GetGattConnectionCallback() { |
| 100 return base::Bind(&BluetoothTestBase::GattConnectionCallback, | 106 return base::Bind(&BluetoothTestBase::GattConnectionCallback, |
| 101 weak_factory_.GetWeakPtr()); | 107 weak_factory_.GetWeakPtr()); |
| 102 } | 108 } |
| 103 | 109 |
| 110 BluetoothGattCharacteristic::NotifySessionCallback |
| 111 BluetoothTestBase::GetNotifyCallback() { |
| 112 return base::Bind(&BluetoothTestBase::NotifyCallback, |
| 113 weak_factory_.GetWeakPtr()); |
| 114 } |
| 115 |
| 104 BluetoothGattCharacteristic::ValueCallback | 116 BluetoothGattCharacteristic::ValueCallback |
| 105 BluetoothTestBase::GetReadValueCallback() { | 117 BluetoothTestBase::GetReadValueCallback() { |
| 106 return base::Bind(&BluetoothTestBase::ReadValueCallback, | 118 return base::Bind(&BluetoothTestBase::ReadValueCallback, |
| 107 weak_factory_.GetWeakPtr()); | 119 weak_factory_.GetWeakPtr()); |
| 108 } | 120 } |
| 109 | 121 |
| 110 BluetoothAdapter::ErrorCallback BluetoothTestBase::GetErrorCallback() { | 122 BluetoothAdapter::ErrorCallback BluetoothTestBase::GetErrorCallback() { |
| 111 return base::Bind(&BluetoothTestBase::ErrorCallback, | 123 return base::Bind(&BluetoothTestBase::ErrorCallback, |
| 112 weak_factory_.GetWeakPtr()); | 124 weak_factory_.GetWeakPtr()); |
| 113 } | 125 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 124 weak_factory_.GetWeakPtr()); | 136 weak_factory_.GetWeakPtr()); |
| 125 } | 137 } |
| 126 | 138 |
| 127 void BluetoothTestBase::ResetEventCounts() { | 139 void BluetoothTestBase::ResetEventCounts() { |
| 128 last_connect_error_code_ = BluetoothDevice::ERROR_UNKNOWN; | 140 last_connect_error_code_ = BluetoothDevice::ERROR_UNKNOWN; |
| 129 callback_count_ = 0; | 141 callback_count_ = 0; |
| 130 error_callback_count_ = 0; | 142 error_callback_count_ = 0; |
| 131 gatt_connection_attempts_ = 0; | 143 gatt_connection_attempts_ = 0; |
| 132 gatt_disconnection_attempts_ = 0; | 144 gatt_disconnection_attempts_ = 0; |
| 133 gatt_discovery_attempts_ = 0; | 145 gatt_discovery_attempts_ = 0; |
| 146 gatt_notify_characteristic_attempts_ = 0; |
| 134 gatt_read_characteristic_attempts_ = 0; | 147 gatt_read_characteristic_attempts_ = 0; |
| 135 gatt_write_characteristic_attempts_ = 0; | 148 gatt_write_characteristic_attempts_ = 0; |
| 136 } | 149 } |
| 137 | 150 |
| 138 } // namespace device | 151 } // namespace device |
| OLD | NEW |