| 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/mac/foundation_util.h" | 9 #include "base/mac/foundation_util.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 | 414 |
| 415 void BluetoothTestMac::SimulateGattNotifySessionStartError( | 415 void BluetoothTestMac::SimulateGattNotifySessionStartError( |
| 416 BluetoothRemoteGattCharacteristic* characteristic, | 416 BluetoothRemoteGattCharacteristic* characteristic, |
| 417 BluetoothRemoteGattService::GattErrorCode error_code) { | 417 BluetoothRemoteGattService::GattErrorCode error_code) { |
| 418 MockCBCharacteristic* characteristic_mock = | 418 MockCBCharacteristic* characteristic_mock = |
| 419 GetCBMockCharacteristic(characteristic); | 419 GetCBMockCharacteristic(characteristic); |
| 420 NSError* error = BluetoothDeviceMac::GetNSErrorFromGattErrorCode(error_code); | 420 NSError* error = BluetoothDeviceMac::GetNSErrorFromGattErrorCode(error_code); |
| 421 [characteristic_mock simulateGattNotifySessionFailedWithError:error]; | 421 [characteristic_mock simulateGattNotifySessionFailedWithError:error]; |
| 422 } | 422 } |
| 423 | 423 |
| 424 void BluetoothTestMac::SimulateGattNotifySessionStopped( |
| 425 BluetoothRemoteGattCharacteristic* characteristic) { |
| 426 MockCBCharacteristic* characteristic_mock = |
| 427 GetCBMockCharacteristic(characteristic); |
| 428 [characteristic_mock simulateGattNotifySessionStopped]; |
| 429 } |
| 430 |
| 431 void BluetoothTestMac::SimulateGattNotifySessionStopError( |
| 432 BluetoothRemoteGattCharacteristic* characteristic, |
| 433 BluetoothRemoteGattService::GattErrorCode error_code) { |
| 434 MockCBCharacteristic* characteristic_mock = |
| 435 GetCBMockCharacteristic(characteristic); |
| 436 NSError* error = BluetoothDeviceMac::GetNSErrorFromGattErrorCode(error_code); |
| 437 [characteristic_mock simulateGattNotifySessionStoppedWithError:error]; |
| 438 } |
| 439 |
| 424 void BluetoothTestMac::SimulateGattCharacteristicChanged( | 440 void BluetoothTestMac::SimulateGattCharacteristicChanged( |
| 425 BluetoothRemoteGattCharacteristic* characteristic, | 441 BluetoothRemoteGattCharacteristic* characteristic, |
| 426 const std::vector<uint8_t>& value) { | 442 const std::vector<uint8_t>& value) { |
| 427 MockCBCharacteristic* characteristic_mock = | 443 MockCBCharacteristic* characteristic_mock = |
| 428 GetCBMockCharacteristic(characteristic); | 444 GetCBMockCharacteristic(characteristic); |
| 429 scoped_nsobject<NSData> data( | 445 scoped_nsobject<NSData> data( |
| 430 [[NSData alloc] initWithBytes:value.data() length:value.size()]); | 446 [[NSData alloc] initWithBytes:value.data() length:value.size()]); |
| 431 [characteristic_mock simulateGattCharacteristicChangedWithValue:data]; | 447 [characteristic_mock simulateGattCharacteristicChangedWithValue:data]; |
| 432 } | 448 } |
| 433 | 449 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 464 void BluetoothTest::OnFakeBluetoothCharacteristicReadValue() { | 480 void BluetoothTest::OnFakeBluetoothCharacteristicReadValue() { |
| 465 gatt_read_characteristic_attempts_++; | 481 gatt_read_characteristic_attempts_++; |
| 466 } | 482 } |
| 467 | 483 |
| 468 void BluetoothTest::OnFakeBluetoothCharacteristicWriteValue( | 484 void BluetoothTest::OnFakeBluetoothCharacteristicWriteValue( |
| 469 std::vector<uint8_t> value) { | 485 std::vector<uint8_t> value) { |
| 470 last_write_value_ = value; | 486 last_write_value_ = value; |
| 471 gatt_write_characteristic_attempts_++; | 487 gatt_write_characteristic_attempts_++; |
| 472 } | 488 } |
| 473 | 489 |
| 474 void BluetoothTest::OnFakeBluetoothGattSetCharacteristicNotification() { | 490 void BluetoothTest::OnFakeBluetoothGattSetCharacteristicNotification( |
| 491 bool notify_value) { |
| 492 last_notify_value = notify_value; |
| 475 gatt_notify_characteristic_attempts_++; | 493 gatt_notify_characteristic_attempts_++; |
| 476 } | 494 } |
| 477 | 495 |
| 478 BluetoothDevice::UUIDSet | 496 BluetoothDevice::UUIDSet |
| 479 BluetoothTestMac::RetrieveConnectedPeripheralServiceUUIDs() { | 497 BluetoothTestMac::RetrieveConnectedPeripheralServiceUUIDs() { |
| 480 BluetoothDevice::UUIDSet service_uuids; | 498 BluetoothDevice::UUIDSet service_uuids; |
| 481 for (CBUUID* uuid in | 499 for (CBUUID* uuid in |
| 482 [mock_central_manager_->get() retrieveConnectedPeripheralServiceUUIDs]) { | 500 [mock_central_manager_->get() retrieveConnectedPeripheralServiceUUIDs]) { |
| 483 service_uuids.insert(BluetoothAdapterMac::BluetoothUUIDWithCBUUID(uuid)); | 501 service_uuids.insert(BluetoothAdapterMac::BluetoothUUIDWithCBUUID(uuid)); |
| 484 } | 502 } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 // crypto::SHA256HashString(input_str, raw, sizeof(raw)); | 560 // crypto::SHA256HashString(input_str, raw, sizeof(raw)); |
| 543 // if (base::HexEncode(raw, sizeof(raw)) == target) { | 561 // if (base::HexEncode(raw, sizeof(raw)) == target) { |
| 544 // return input_str; | 562 // return input_str; |
| 545 // } | 563 // } |
| 546 // ++input[0]; | 564 // ++input[0]; |
| 547 // } | 565 // } |
| 548 // return ""; | 566 // return ""; |
| 549 // } | 567 // } |
| 550 | 568 |
| 551 } // namespace device | 569 } // namespace device |
| OLD | NEW |