| 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 #ifndef CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVIDER
_H_ | 5 #ifndef CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVIDER
_H_ |
| 6 #define CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVIDER
_H_ | 6 #define CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVIDER
_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> | 286 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> |
| 287 GetFailingConnectionsAdapter(); | 287 GetFailingConnectionsAdapter(); |
| 288 | 288 |
| 289 // |FailingGATTOperationsAdapter| | 289 // |FailingGATTOperationsAdapter| |
| 290 // Inherits from |EmptyAdapter| | 290 // Inherits from |EmptyAdapter| |
| 291 // FailingGATTOperationsAdapter holds a device with one | 291 // FailingGATTOperationsAdapter holds a device with one |
| 292 // service: ErrorsService. This service contains a characteristic for each | 292 // service: ErrorsService. This service contains a characteristic for each |
| 293 // type of GATT Error that can be thrown. Trying to write or read from these | 293 // type of GATT Error that can be thrown. Trying to write or read from these |
| 294 // characteristics results in the corresponding error being returned. | 294 // characteristics results in the corresponding error being returned. |
| 295 // GetProperties returns the following for all characteristics: | 295 // GetProperties returns the following for all characteristics: |
| 296 // (BluetoothGattCharacteristic::PROPERTY_READ | | 296 // (BluetoothRemoteGattCharacteristic::PROPERTY_READ | |
| 297 // BluetoothGattCharacteristic::PROPERTY_WRITE | | 297 // BluetoothRemoteGattCharacteristic::PROPERTY_WRITE | |
| 298 // BluetoothGattCharacteristic::PROPERTY_INDICATE) | 298 // BluetoothRemoteGattCharacteristic::PROPERTY_INDICATE) |
| 299 // Internal Structure: | 299 // Internal Structure: |
| 300 // - ErrorsDevice | 300 // - ErrorsDevice |
| 301 // - ErrorsService errorUUID(0xA0) | 301 // - ErrorsService errorUUID(0xA0) |
| 302 // - ErrorCharacteristic( | 302 // - ErrorCharacteristic( |
| 303 // BluetoothGattService::GATT_ERROR_UNKNOWN) | 303 // BluetoothRemoteGattService::GATT_ERROR_UNKNOWN) |
| 304 // errorUUID(0xA1) | 304 // errorUUID(0xA1) |
| 305 // - ErrorCharacteristic( | 305 // - ErrorCharacteristic( |
| 306 // BluetoothGattService::GATT_ERROR_FAILED) | 306 // BluetoothRemoteGattService::GATT_ERROR_FAILED) |
| 307 // errorUUID(0xA2) | 307 // errorUUID(0xA2) |
| 308 // - ErrorCharacteristic( | 308 // - ErrorCharacteristic( |
| 309 // BluetoothGattService::GATT_ERROR_IN_PROGRESS) | 309 // BluetoothRemoteGattService::GATT_ERROR_IN_PROGRESS) |
| 310 // errorUUID(0xA3) | 310 // errorUUID(0xA3) |
| 311 // - ErrorCharacteristic( | 311 // - ErrorCharacteristic( |
| 312 // BluetoothGattService::GATT_ERROR_INVALID_LENGTH) | 312 // BluetoothRemoteGattService::GATT_ERROR_INVALID_LENGTH) |
| 313 // errorUUID(0xA4) | 313 // errorUUID(0xA4) |
| 314 // - ErrorCharacteristic( | 314 // - ErrorCharacteristic( |
| 315 // BluetoothGattService::GATT_ERROR_NOT_PERMITTED) | 315 // BluetoothRemoteGattService::GATT_ERROR_NOT_PERMITTED) |
| 316 // errorUUID(0xA5) | 316 // errorUUID(0xA5) |
| 317 // - ErrorCharacteristic( | 317 // - ErrorCharacteristic( |
| 318 // BluetoothGattService::GATT_ERROR_NOT_AUTHORIZED) | 318 // BluetoothRemoteGattService::GATT_ERROR_NOT_AUTHORIZED) |
| 319 // errorUUID(0xA6) | 319 // errorUUID(0xA6) |
| 320 // - ErrorCharacteristic( | 320 // - ErrorCharacteristic( |
| 321 // BluetoothGattService::GATT_ERROR_NOT_PAIRED) | 321 // BluetoothRemoteGattService::GATT_ERROR_NOT_PAIRED) |
| 322 // errorUUID(0xA7) | 322 // errorUUID(0xA7) |
| 323 // - ErrorCharacteristic( | 323 // - ErrorCharacteristic( |
| 324 // BluetoothGattService::GATT_ERROR_NOT_SUPPORTED) | 324 // BluetoothRemoteGattService::GATT_ERROR_NOT_SUPPORTED) |
| 325 // errorUUID(0xA8) | 325 // errorUUID(0xA8) |
| 326 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> | 326 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> |
| 327 GetFailingGATTOperationsAdapter(); | 327 GetFailingGATTOperationsAdapter(); |
| 328 | 328 |
| 329 // Discovery Sessions | 329 // Discovery Sessions |
| 330 | 330 |
| 331 // |DiscoverySession| | 331 // |DiscoverySession| |
| 332 // Mock Functions: | 332 // Mock Functions: |
| 333 // - Stop: | 333 // - Stop: |
| 334 // Run success callback. | 334 // Run success callback. |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 GetBaseGATTService(device::MockBluetoothDevice* device, | 464 GetBaseGATTService(device::MockBluetoothDevice* device, |
| 465 const std::string& uuid); | 465 const std::string& uuid); |
| 466 | 466 |
| 467 // |DeviceInformationService| | 467 // |DeviceInformationService| |
| 468 // Internal Structure: | 468 // Internal Structure: |
| 469 // - Characteristics: | 469 // - Characteristics: |
| 470 // - Serial Number String: (0x2a25) (a blacklisted characteristic) | 470 // - Serial Number String: (0x2a25) (a blacklisted characteristic) |
| 471 // - Mock Functions: | 471 // - Mock Functions: |
| 472 // - Read: Fails test. | 472 // - Read: Fails test. |
| 473 // - GetProperties: Returns | 473 // - GetProperties: Returns |
| 474 // BluetoothGattCharacteristic::PROPERTY_READ | 474 // BluetoothRemoteGattCharacteristic::PROPERTY_READ |
| 475 static std::unique_ptr<testing::NiceMock<device::MockBluetoothGattService>> | 475 static std::unique_ptr<testing::NiceMock<device::MockBluetoothGattService>> |
| 476 GetDeviceInformationService(device::MockBluetoothDevice* device); | 476 GetDeviceInformationService(device::MockBluetoothDevice* device); |
| 477 | 477 |
| 478 // |BlacklistTestService| | 478 // |BlacklistTestService| |
| 479 // Internal Structure: | 479 // Internal Structure: |
| 480 // - Characteristics: | 480 // - Characteristics: |
| 481 // - Blacklist Exclude Reads Characteristic: | 481 // - Blacklist Exclude Reads Characteristic: |
| 482 // (bad1c9a2-9a5b-4015-8b60-1579bbbf2135) | 482 // (bad1c9a2-9a5b-4015-8b60-1579bbbf2135) |
| 483 // - Mock Functions: | 483 // - Mock Functions: |
| 484 // - Read: Fails test. | 484 // - Read: Fails test. |
| 485 // - Write: Calls success callback. | 485 // - Write: Calls success callback. |
| 486 // - GetProperties: Returns | 486 // - GetProperties: Returns |
| 487 // BluetoothGattCharacteristic::PROPERTY_READ | | 487 // BluetoothRemoteGattCharacteristic::PROPERTY_READ | |
| 488 // BluetoothGattCharacteristic::PROPERTY_WRITE | 488 // BluetoothRemoteGattCharacteristic::PROPERTY_WRITE |
| 489 static std::unique_ptr<testing::NiceMock<device::MockBluetoothGattService>> | 489 static std::unique_ptr<testing::NiceMock<device::MockBluetoothGattService>> |
| 490 GetBlacklistTestService(device::MockBluetoothDevice* device); | 490 GetBlacklistTestService(device::MockBluetoothDevice* device); |
| 491 | 491 |
| 492 // |GenericAccessService| | 492 // |GenericAccessService| |
| 493 // Internal Structure: | 493 // Internal Structure: |
| 494 // - Characteristics: | 494 // - Characteristics: |
| 495 // - Device Name: (0x2A00) | 495 // - Device Name: (0x2A00) |
| 496 // - Mock Functions: | 496 // - Mock Functions: |
| 497 // - Read: Calls success callback with device's name. | 497 // - Read: Calls success callback with device's name. |
| 498 // - Write: Calls success callback. | 498 // - Write: Calls success callback. |
| 499 // - GetProperties: Returns | 499 // - GetProperties: Returns |
| 500 // BluetoothGattCharacteristic::PROPERTY_READ | | 500 // BluetoothRemoteGattCharacteristic::PROPERTY_READ | |
| 501 // BluetoothGattCharacteristic::PROPERTY_WRITE | 501 // BluetoothRemoteGattCharacteristic::PROPERTY_WRITE |
| 502 // - Peripheral Privacy Flag: (0x2A02) (blacklisted for writes) | 502 // - Peripheral Privacy Flag: (0x2A02) (blacklisted for writes) |
| 503 // - Mock Functions: | 503 // - Mock Functions: |
| 504 // - Read: Calls success callback with boolean value 'false'. | 504 // - Read: Calls success callback with boolean value 'false'. |
| 505 // - Write: Fails test. | 505 // - Write: Fails test. |
| 506 // - GetProperties: Returns | 506 // - GetProperties: Returns |
| 507 // BluetoothGattCharacteristic::PROPERTY_READ | | 507 // BluetoothRemoteGattCharacteristic::PROPERTY_READ | |
| 508 // BluetoothGattCharacteristic::PROPERTY_WRITE | 508 // BluetoothRemoteGattCharacteristic::PROPERTY_WRITE |
| 509 static std::unique_ptr<testing::NiceMock<device::MockBluetoothGattService>> | 509 static std::unique_ptr<testing::NiceMock<device::MockBluetoothGattService>> |
| 510 GetGenericAccessService(device::MockBluetoothDevice* device); | 510 GetGenericAccessService(device::MockBluetoothDevice* device); |
| 511 | 511 |
| 512 // |HeartRateService| | 512 // |HeartRateService| |
| 513 // Internal Structure: | 513 // Internal Structure: |
| 514 // - Characteristics: | 514 // - Characteristics: |
| 515 // - Heart Rate Measurement (0x2a37) | 515 // - Heart Rate Measurement (0x2a37) |
| 516 // - Mock Functions: | 516 // - Mock Functions: |
| 517 // - StartNotifySession: Sets a timer to call | 517 // - StartNotifySession: Sets a timer to call |
| 518 // GattCharacteristicValueChanged every 10ms and calls | 518 // GattCharacteristicValueChanged every 10ms and calls |
| 519 // success callback with a | 519 // success callback with a |
| 520 // BaseGATTNotifySession(characteristic_instance_id) | 520 // BaseGATTNotifySession(characteristic_instance_id) |
| 521 // TODO: Instead of a timer we should be able to tell the fake | 521 // TODO: Instead of a timer we should be able to tell the fake |
| 522 // to call GattCharacteristicValueChanged from js. | 522 // to call GattCharacteristicValueChanged from js. |
| 523 // https://crbug.com/543884 | 523 // https://crbug.com/543884 |
| 524 // - GetProperties: Returns | 524 // - GetProperties: Returns |
| 525 // BluetoothGattCharacteristic::PROPERTY_NOTIFY | 525 // BluetoothRemoteGattCharacteristic::PROPERTY_NOTIFY |
| 526 // - Body Sensor Location (0x2a38) | 526 // - Body Sensor Location (0x2a38) |
| 527 // - Mock Functions: | 527 // - Mock Functions: |
| 528 // - Read: Calls GattCharacteristicValueChanged and success | 528 // - Read: Calls GattCharacteristicValueChanged and success |
| 529 // callback with [1] which corresponds to chest. | 529 // callback with [1] which corresponds to chest. |
| 530 // - GetProperties: Returns | 530 // - GetProperties: Returns |
| 531 // BluetoothGattCharacteristic::PROPERTY_READ | 531 // BluetoothRemoteGattCharacteristic::PROPERTY_READ |
| 532 // - Body Sensor Location (0x2a38) | 532 // - Body Sensor Location (0x2a38) |
| 533 // - Mock Functions: | 533 // - Mock Functions: |
| 534 // - Read: Calls GattCharacteristicValueChanged and success | 534 // - Read: Calls GattCharacteristicValueChanged and success |
| 535 // callback with [2] which corresponds to wrist. | 535 // callback with [2] which corresponds to wrist. |
| 536 // - GetProperties: Returns | 536 // - GetProperties: Returns |
| 537 // BluetoothGattCharacteristic::PROPERTY_READ | 537 // BluetoothRemoteGattCharacteristic::PROPERTY_READ |
| 538 static std::unique_ptr<testing::NiceMock<device::MockBluetoothGattService>> | 538 static std::unique_ptr<testing::NiceMock<device::MockBluetoothGattService>> |
| 539 GetHeartRateService(device::MockBluetoothAdapter* adapter, | 539 GetHeartRateService(device::MockBluetoothAdapter* adapter, |
| 540 device::MockBluetoothDevice* device); | 540 device::MockBluetoothDevice* device); |
| 541 | 541 |
| 542 // Characteristics | 542 // Characteristics |
| 543 | 543 |
| 544 // |BaseCharacteristic|(identifier, service, uuid) | 544 // |BaseCharacteristic|(identifier, service, uuid) |
| 545 // Descriptors added: | 545 // Descriptors added: |
| 546 // None. | 546 // None. |
| 547 // Mock Functions: | 547 // Mock Functions: |
| (...skipping 13 matching lines...) Expand all Loading... |
| 561 // - GetProperties: | 561 // - GetProperties: |
| 562 // Returns: NULL | 562 // Returns: NULL |
| 563 // - GetPermissions: | 563 // - GetPermissions: |
| 564 // Returns: NULL | 564 // Returns: NULL |
| 565 static std::unique_ptr< | 565 static std::unique_ptr< |
| 566 testing::NiceMock<device::MockBluetoothGattCharacteristic>> | 566 testing::NiceMock<device::MockBluetoothGattCharacteristic>> |
| 567 GetBaseGATTCharacteristic( | 567 GetBaseGATTCharacteristic( |
| 568 const std::string& identifier, | 568 const std::string& identifier, |
| 569 device::MockBluetoothGattService* service, | 569 device::MockBluetoothGattService* service, |
| 570 const std::string& uuid, | 570 const std::string& uuid, |
| 571 device::BluetoothGattCharacteristic::Properties properties); | 571 device::BluetoothRemoteGattCharacteristic::Properties properties); |
| 572 | 572 |
| 573 // |ErrorCharacteristic|(service, error_type) | 573 // |ErrorCharacteristic|(service, error_type) |
| 574 // Inherits from BaseCharacteristic(service, errorUUID(error_type + 0xA1)) | 574 // Inherits from BaseCharacteristic(service, errorUUID(error_type + 0xA1)) |
| 575 // Descriptors added: | 575 // Descriptors added: |
| 576 // None. | 576 // None. |
| 577 // Mock Functions: | 577 // Mock Functions: |
| 578 // - ReadRemoteCharacteristic: | 578 // - ReadRemoteCharacteristic: |
| 579 // Run error callback with error_type | 579 // Run error callback with error_type |
| 580 // - WriteRemoteCharacteristic: | 580 // - WriteRemoteCharacteristic: |
| 581 // Run error callback with error_type | 581 // Run error callback with error_type |
| 582 // - StartNotifySession: | 582 // - StartNotifySession: |
| 583 // Run error callback with error_type | 583 // Run error callback with error_type |
| 584 static std::unique_ptr< | 584 static std::unique_ptr< |
| 585 testing::NiceMock<device::MockBluetoothGattCharacteristic>> | 585 testing::NiceMock<device::MockBluetoothGattCharacteristic>> |
| 586 GetErrorCharacteristic( | 586 GetErrorCharacteristic( |
| 587 device::MockBluetoothGattService* service, | 587 device::MockBluetoothGattService* service, |
| 588 device::BluetoothGattService::GattErrorCode error_code); | 588 device::BluetoothRemoteGattService::GattErrorCode error_code); |
| 589 | 589 |
| 590 // Notify Sessions | 590 // Notify Sessions |
| 591 | 591 |
| 592 // |BaseGATTNotifySession|(characteristic_identifier) | 592 // |BaseGATTNotifySession|(characteristic_identifier) |
| 593 // Mock Functions: | 593 // Mock Functions: |
| 594 // - GetCharacteristicIdentifier: | 594 // - GetCharacteristicIdentifier: |
| 595 // Returns: characteristic_identifier | 595 // Returns: characteristic_identifier |
| 596 // - IsActive: | 596 // - IsActive: |
| 597 // Returns: true | 597 // Returns: true |
| 598 // - Stop: | 598 // - Stop: |
| (...skipping 22 matching lines...) Expand all Loading... |
| 621 | 621 |
| 622 // Function to turn an integer into an MAC address of the form | 622 // Function to turn an integer into an MAC address of the form |
| 623 // XX:XX:XX:XX:XX:XX. For example makeMACAddress(0xdeadbeef) | 623 // XX:XX:XX:XX:XX:XX. For example makeMACAddress(0xdeadbeef) |
| 624 // returns "00:00:DE:AD:BE:EF". | 624 // returns "00:00:DE:AD:BE:EF". |
| 625 static std::string makeMACAddress(uint64_t addr); | 625 static std::string makeMACAddress(uint64_t addr); |
| 626 }; | 626 }; |
| 627 | 627 |
| 628 } // namespace content | 628 } // namespace content |
| 629 | 629 |
| 630 #endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVI
DER_H_ | 630 #endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVI
DER_H_ |
| OLD | NEW |