| 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_mac.h" | 5 #include "device/bluetooth/test/bluetooth_test_mac.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 void BluetoothTestMac::SimulateGattConnectionError( | 218 void BluetoothTestMac::SimulateGattConnectionError( |
| 219 BluetoothDevice* device, | 219 BluetoothDevice* device, |
| 220 BluetoothDevice::ConnectErrorCode errorCode) { | 220 BluetoothDevice::ConnectErrorCode errorCode) { |
| 221 BluetoothLowEnergyDeviceMac* lowEnergyDeviceMac = | 221 BluetoothLowEnergyDeviceMac* lowEnergyDeviceMac = |
| 222 (BluetoothLowEnergyDeviceMac*)device; | 222 (BluetoothLowEnergyDeviceMac*)device; |
| 223 CBPeripheral* peripheral = lowEnergyDeviceMac->GetPeripheral(); | 223 CBPeripheral* peripheral = lowEnergyDeviceMac->GetPeripheral(); |
| 224 MockCBPeripheral* mockPeripheral = (MockCBPeripheral*)peripheral; | 224 MockCBPeripheral* mockPeripheral = (MockCBPeripheral*)peripheral; |
| 225 [mockPeripheral setStateForTesting:CBPeripheralStateDisconnected]; | 225 [mockPeripheral setStateForTesting:CBPeripheralStateDisconnected]; |
| 226 CBCentralManager* centralManager = | 226 CBCentralManager* centralManager = |
| 227 static_cast<CBCentralManager*>(mock_central_manager_); | 227 static_cast<CBCentralManager*>(mock_central_manager_); |
| 228 // TODO(http://crbug.com/585894): Need to convert the connect error code into | 228 NSError* error = |
| 229 // NSError | 229 BluetoothAdapterMac::GetNSErrorFromConnectErrorCode(errorCode); |
| 230 NSError* error = [NSError errorWithDomain:@"BluetoothDevice::ConnectErrorCode" | |
| 231 code:-1 | |
| 232 userInfo:nil]; | |
| 233 [centralManager.delegate centralManager:centralManager | 230 [centralManager.delegate centralManager:centralManager |
| 234 didFailToConnectPeripheral:peripheral | 231 didFailToConnectPeripheral:peripheral |
| 235 error:error]; | 232 error:error]; |
| 236 } | 233 } |
| 237 | 234 |
| 238 void BluetoothTestMac::OnFakeBluetoothDeviceConnectGattCalled() { | 235 void BluetoothTestMac::OnFakeBluetoothDeviceConnectGattCalled() { |
| 239 gatt_connection_attempts_++; | 236 gatt_connection_attempts_++; |
| 240 } | 237 } |
| 241 | 238 |
| 242 void BluetoothTestMac::OnFakeBluetoothGattDisconnect() { | 239 void BluetoothTestMac::OnFakeBluetoothGattDisconnect() { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 272 // crypto::SHA256HashString(input_str, raw, sizeof(raw)); | 269 // crypto::SHA256HashString(input_str, raw, sizeof(raw)); |
| 273 // if (base::HexEncode(raw, sizeof(raw)) == target) { | 270 // if (base::HexEncode(raw, sizeof(raw)) == target) { |
| 274 // return input_str; | 271 // return input_str; |
| 275 // } | 272 // } |
| 276 // ++input[0]; | 273 // ++input[0]; |
| 277 // } | 274 // } |
| 278 // return ""; | 275 // return ""; |
| 279 // } | 276 // } |
| 280 | 277 |
| 281 } // namespace device | 278 } // namespace device |
| OLD | NEW |