Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: device/bluetooth/test/bluetooth_test_mac.mm

Issue 2595373003: Bluetooth: mac: Working on macOS descriptor implementation. (Closed)
Patch Set: Fixes Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 384
385 void BluetoothTestMac::SimulateGattCharacteristicWriteError( 385 void BluetoothTestMac::SimulateGattCharacteristicWriteError(
386 BluetoothRemoteGattCharacteristic* characteristic, 386 BluetoothRemoteGattCharacteristic* characteristic,
387 BluetoothRemoteGattService::GattErrorCode error_code) { 387 BluetoothRemoteGattService::GattErrorCode error_code) {
388 MockCBCharacteristic* characteristic_mock = 388 MockCBCharacteristic* characteristic_mock =
389 GetCBMockCharacteristic(characteristic); 389 GetCBMockCharacteristic(characteristic);
390 NSError* error = BluetoothDeviceMac::GetNSErrorFromGattErrorCode(error_code); 390 NSError* error = BluetoothDeviceMac::GetNSErrorFromGattErrorCode(error_code);
391 [characteristic_mock simulateWriteWithError:error]; 391 [characteristic_mock simulateWriteWithError:error];
392 } 392 }
393 393
394 void BluetoothTestMac::SimulateGattDescriptor(
395 BluetoothRemoteGattCharacteristic* characteristic,
396 const std::string& uuid) {
397 MockCBCharacteristic* characteristic_mock =
398 GetCBMockCharacteristic(characteristic);
399 CBUUID* cb_uuid = [CBUUID UUIDWithString:@(uuid.c_str())];
400 [characteristic_mock simulateDescriptorWithUUID:cb_uuid];
401 MockCBPeripheral* peripheral_mock = GetMockCBPeripheral(characteristic);
402 [peripheral_mock didModifyServices:@[]];
403 // After -[MockCBPeripheral didModifyServices:], BluetoothLowEnergyDeviceMac
404 // is expected to call -[CBPeripheral discoverServices:]
405 [peripheral_mock mockDidDiscoverEvents];
406 }
407
394 void BluetoothTestMac::SimulateGattNotifySessionStarted( 408 void BluetoothTestMac::SimulateGattNotifySessionStarted(
395 BluetoothRemoteGattCharacteristic* characteristic) { 409 BluetoothRemoteGattCharacteristic* characteristic) {
396 MockCBCharacteristic* characteristic_mock = 410 MockCBCharacteristic* characteristic_mock =
397 GetCBMockCharacteristic(characteristic); 411 GetCBMockCharacteristic(characteristic);
398 [characteristic_mock simulateGattNotifySessionStarted]; 412 [characteristic_mock simulateGattNotifySessionStarted];
399 } 413 }
400 414
401 void BluetoothTestMac::SimulateGattNotifySessionStartError( 415 void BluetoothTestMac::SimulateGattNotifySessionStartError(
402 BluetoothRemoteGattCharacteristic* characteristic, 416 BluetoothRemoteGattCharacteristic* characteristic,
403 BluetoothRemoteGattService::GattErrorCode error_code) { 417 BluetoothRemoteGattService::GattErrorCode error_code) {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 491
478 MockCBPeripheral* BluetoothTestMac::GetMockCBPeripheral( 492 MockCBPeripheral* BluetoothTestMac::GetMockCBPeripheral(
479 BluetoothRemoteGattService* service) const { 493 BluetoothRemoteGattService* service) const {
480 BluetoothDevice* device = service->GetDevice(); 494 BluetoothDevice* device = service->GetDevice();
481 BluetoothLowEnergyDeviceMac* device_mac = 495 BluetoothLowEnergyDeviceMac* device_mac =
482 static_cast<BluetoothLowEnergyDeviceMac*>(device); 496 static_cast<BluetoothLowEnergyDeviceMac*>(device);
483 CBPeripheral* cb_peripheral = device_mac->GetPeripheral(); 497 CBPeripheral* cb_peripheral = device_mac->GetPeripheral();
484 return ObjCCast<MockCBPeripheral>(cb_peripheral); 498 return ObjCCast<MockCBPeripheral>(cb_peripheral);
485 } 499 }
486 500
501 MockCBPeripheral* BluetoothTestMac::GetMockCBPeripheral(
502 BluetoothRemoteGattCharacteristic* characteristic) const {
503 return GetMockCBPeripheral(characteristic->GetService());
504 }
505
487 MockCBCharacteristic* BluetoothTest::GetCBMockCharacteristic( 506 MockCBCharacteristic* BluetoothTest::GetCBMockCharacteristic(
488 device::BluetoothRemoteGattCharacteristic* characteristic) const { 507 BluetoothRemoteGattCharacteristic* characteristic) const {
489 device::BluetoothRemoteGattCharacteristicMac* mac_gatt_characteristic = 508 device::BluetoothRemoteGattCharacteristicMac* mac_gatt_characteristic =
490 static_cast<device::BluetoothRemoteGattCharacteristicMac*>( 509 static_cast<device::BluetoothRemoteGattCharacteristicMac*>(
491 characteristic); 510 characteristic);
492 CBCharacteristic* cb_characteristic = 511 CBCharacteristic* cb_characteristic =
493 mac_gatt_characteristic->GetCBCharacteristic(); 512 mac_gatt_characteristic->GetCBCharacteristic();
494 return ObjCCast<MockCBCharacteristic>(cb_characteristic); 513 return ObjCCast<MockCBCharacteristic>(cb_characteristic);
495 } 514 }
496 515
497 // Utility function for generating new (CBUUID, address) pairs where CBUUID 516 // Utility function for generating new (CBUUID, address) pairs where CBUUID
498 // hashes to address. For use when adding a new device address to the testing 517 // hashes to address. For use when adding a new device address to the testing
(...skipping 24 matching lines...) Expand all
523 // crypto::SHA256HashString(input_str, raw, sizeof(raw)); 542 // crypto::SHA256HashString(input_str, raw, sizeof(raw));
524 // if (base::HexEncode(raw, sizeof(raw)) == target) { 543 // if (base::HexEncode(raw, sizeof(raw)) == target) {
525 // return input_str; 544 // return input_str;
526 // } 545 // }
527 // ++input[0]; 546 // ++input[0];
528 // } 547 // }
529 // return ""; 548 // return "";
530 // } 549 // }
531 550
532 } // namespace device 551 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/test/bluetooth_test_mac.h ('k') | device/bluetooth/test/mock_bluetooth_cbcharacteristic_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698