Commit af1c15b1 authored by Ovidio Henriquez's avatar Ovidio Henriquez Committed by Commit Bot

bluetooth: Use DeviceUUID in FakeBluetooth

This change refactors the Web Bluetooth test API to use the
DeviceUUIDs helper class defined in BluetoothDevice. Additionally,
this change finishes the implementation of SimulateGATTServicesChanged,
and as a result, tests are updated to set the next discovery response
before calling this interface.

BUG=719826

Change-Id: I0f986eb7afe6fbf7ebaa80ac4b633d46a027b80d
Reviewed-on: https://chromium-review.googlesource.com/939984
Commit-Queue: Ovidio Henriquez <odejesush@chromium.org>
Reviewed-by: default avatarGiovanni Ortuño Urquidi <ortuno@chromium.org>
Cr-Commit-Position: refs/heads/master@{#541577}
parent e2d74157
...@@ -580,7 +580,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothDevice { ...@@ -580,7 +580,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothDevice {
// Helper class to easily update the sets of UUIDs and keep them in sync with // Helper class to easily update the sets of UUIDs and keep them in sync with
// the set of all the device's UUIDs. // the set of all the device's UUIDs.
class DeviceUUIDs { class DEVICE_BLUETOOTH_EXPORT DeviceUUIDs {
public: public:
DeviceUUIDs(); DeviceUUIDs();
~DeviceUUIDs(); ~DeviceUUIDs();
......
...@@ -162,6 +162,7 @@ void FakeCentral::SimulateGATTServicesChanged( ...@@ -162,6 +162,7 @@ void FakeCentral::SimulateGATTServicesChanged(
std::move(callback).Run(false); std::move(callback).Run(false);
return; return;
} }
fake_peripheral->SimulateGATTServicesChanged();
std::move(callback).Run(true); std::move(callback).Run(true);
} }
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "device/bluetooth/bluetooth_uuid.h" #include "device/bluetooth/bluetooth_uuid.h"
#include "device/bluetooth/test/fake_remote_gatt_service.h" #include "device/bluetooth/test/fake_remote_gatt_service.h"
...@@ -35,7 +36,20 @@ void FakePeripheral::SetSystemConnected(bool connected) { ...@@ -35,7 +36,20 @@ void FakePeripheral::SetSystemConnected(bool connected) {
} }
void FakePeripheral::SetServiceUUIDs(UUIDSet service_uuids) { void FakePeripheral::SetServiceUUIDs(UUIDSet service_uuids) {
service_uuids_ = std::move(service_uuids); device::BluetoothDevice::GattServiceMap services_map;
bool inserted;
// Create a temporary map of services, because ReplaceServiceUUIDs expects a
// GattServiceMap even though it only uses the UUIDs.
int count = 0;
for (auto uuid : service_uuids) {
std::string id = base::IntToString(count++);
std::tie(std::ignore, inserted) =
services_map.emplace(id, std::make_unique<FakeRemoteGattService>(
id, uuid, true /* is_primary */, this));
DCHECK(inserted);
}
device_uuids_.ReplaceServiceUUIDs(services_map);
} }
void FakePeripheral::SetNextGATTConnectionResponse(uint16_t code) { void FakePeripheral::SetNextGATTConnectionResponse(uint16_t code) {
...@@ -66,6 +80,7 @@ void FakePeripheral::SimulateGATTDisconnection() { ...@@ -66,6 +80,7 @@ void FakePeripheral::SimulateGATTDisconnection() {
// for more details. // for more details.
system_connected_ = false; system_connected_ = false;
gatt_connected_ = false; gatt_connected_ = false;
device_uuids_.ClearServiceUUIDs();
SetGattServicesDiscoveryComplete(false); SetGattServicesDiscoveryComplete(false);
DidDisconnectGatt(); DidDisconnectGatt();
} }
...@@ -98,6 +113,12 @@ bool FakePeripheral::RemoveFakeService(const std::string& identifier) { ...@@ -98,6 +113,12 @@ bool FakePeripheral::RemoveFakeService(const std::string& identifier) {
return true; return true;
} }
void FakePeripheral::SimulateGATTServicesChanged() {
device_uuids_.ClearServiceUUIDs();
SetGattServicesDiscoveryComplete(false);
GetAdapter()->NotifyDeviceChanged(this);
}
uint32_t FakePeripheral::GetBluetoothClass() const { uint32_t FakePeripheral::GetBluetoothClass() const {
NOTREACHED(); NOTREACHED();
return 0; return 0;
...@@ -180,10 +201,6 @@ bool FakePeripheral::IsConnecting() const { ...@@ -180,10 +201,6 @@ bool FakePeripheral::IsConnecting() const {
return false; return false;
} }
device::BluetoothDevice::UUIDSet FakePeripheral::GetUUIDs() const {
return service_uuids_;
}
bool FakePeripheral::ExpectingPinCode() const { bool FakePeripheral::ExpectingPinCode() const {
NOTREACHED(); NOTREACHED();
return false; return false;
...@@ -328,6 +345,7 @@ void FakePeripheral::DispatchDiscoveryResponse() { ...@@ -328,6 +345,7 @@ void FakePeripheral::DispatchDiscoveryResponse() {
pending_gatt_discovery_ = false; pending_gatt_discovery_ = false;
if (code == mojom::kHCISuccess) { if (code == mojom::kHCISuccess) {
device_uuids_.ReplaceServiceUUIDs(gatt_services_);
SetGattServicesDiscoveryComplete(true); SetGattServicesDiscoveryComplete(true);
GetAdapter()->NotifyGattServicesDiscovered(this); GetAdapter()->NotifyGattServicesDiscovered(this);
} else { } else {
......
...@@ -62,6 +62,9 @@ class FakePeripheral : public device::BluetoothDevice { ...@@ -62,6 +62,9 @@ class FakePeripheral : public device::BluetoothDevice {
// Remove a fake service with |identifier| from this peripheral. // Remove a fake service with |identifier| from this peripheral.
bool RemoveFakeService(const std::string& identifier); bool RemoveFakeService(const std::string& identifier);
// Simulates a GATT services changed from the peripheral.
void SimulateGATTServicesChanged();
// BluetoothDevice overrides: // BluetoothDevice overrides:
uint32_t GetBluetoothClass() const override; uint32_t GetBluetoothClass() const override;
#if defined(OS_CHROMEOS) || defined(OS_LINUX) #if defined(OS_CHROMEOS) || defined(OS_LINUX)
...@@ -81,7 +84,6 @@ class FakePeripheral : public device::BluetoothDevice { ...@@ -81,7 +84,6 @@ class FakePeripheral : public device::BluetoothDevice {
bool IsGattConnected() const override; bool IsGattConnected() const override;
bool IsConnectable() const override; bool IsConnectable() const override;
bool IsConnecting() const override; bool IsConnecting() const override;
UUIDSet GetUUIDs() const override;
bool ExpectingPinCode() const override; bool ExpectingPinCode() const override;
bool ExpectingPasskey() const override; bool ExpectingPasskey() const override;
bool ExpectingConfirmation() const override; bool ExpectingConfirmation() const override;
......
...@@ -17,6 +17,7 @@ bluetooth_test(() => getMeasurementIntervalCharacteristic() ...@@ -17,6 +17,7 @@ bluetooth_test(() => getMeasurementIntervalCharacteristic()
.then(() => characteristic.getDescriptor(user_description.name)) .then(() => characteristic.getDescriptor(user_description.name))
.then(() => null, (e) => assert_unreached('Caught error unexpectedly.', e)) .then(() => null, (e) => assert_unreached('Caught error unexpectedly.', e))
.then(() => fake_characteristic.remove()) .then(() => fake_characteristic.remove())
.then(() => fake_peripheral.setNextGATTDiscoveryResponse({HCI_SUCCESS}))
.then(() => fake_peripheral.simulateGATTServicesChanged()) .then(() => fake_peripheral.simulateGATTServicesChanged())
.then(() => assert_promise_rejects_with_message( .then(() => assert_promise_rejects_with_message(
characteristic.getDescriptor(user_description.name), expected)), characteristic.getDescriptor(user_description.name), expected)),
......
...@@ -17,6 +17,7 @@ let characteristic, fake_peripheral, fake_service; ...@@ -17,6 +17,7 @@ let characteristic, fake_peripheral, fake_service;
bluetooth_test(() => getMeasurementIntervalCharacteristic() bluetooth_test(() => getMeasurementIntervalCharacteristic()
.then(_ => ({characteristic, fake_peripheral, fake_service} = _)) .then(_ => ({characteristic, fake_peripheral, fake_service} = _))
.then(() => fake_service.remove()) .then(() => fake_service.remove())
.then(() => fake_peripheral.setNextGATTDiscoveryResponse({HCI_SUCCESS}))
.then(() => fake_peripheral.simulateGATTServicesChanged()) .then(() => fake_peripheral.simulateGATTServicesChanged())
.then(() => assert_promise_rejects_with_message( .then(() => assert_promise_rejects_with_message(
characteristic.getDescriptor(user_description.name), characteristic.getDescriptor(user_description.name),
......
...@@ -17,6 +17,7 @@ bluetooth_test(() => getMeasurementIntervalCharacteristic() ...@@ -17,6 +17,7 @@ bluetooth_test(() => getMeasurementIntervalCharacteristic()
.then(() => characteristic.getDescriptor(user_description.name)) .then(() => characteristic.getDescriptor(user_description.name))
.then(() => null, (e) => assert_unreached('Caught error unexpectedly.', e)) .then(() => null, (e) => assert_unreached('Caught error unexpectedly.', e))
.then(() => fake_characteristic.remove()) .then(() => fake_characteristic.remove())
.then(() => fake_peripheral.setNextGATTDiscoveryResponse({HCI_SUCCESS}))
.then(() => fake_peripheral.simulateGATTServicesChanged()) .then(() => fake_peripheral.simulateGATTServicesChanged())
.then(() => assert_promise_rejects_with_message( .then(() => assert_promise_rejects_with_message(
characteristic.getDescriptors(user_description.name), expected)), characteristic.getDescriptors(user_description.name), expected)),
......
...@@ -17,6 +17,7 @@ bluetooth_test(() => getMeasurementIntervalCharacteristic() ...@@ -17,6 +17,7 @@ bluetooth_test(() => getMeasurementIntervalCharacteristic()
.then(() => characteristic.getDescriptor(user_description.name)) .then(() => characteristic.getDescriptor(user_description.name))
.then(() => null, (e) => assert_unreached('Caught error unexpectedly.', e)) .then(() => null, (e) => assert_unreached('Caught error unexpectedly.', e))
.then(() => fake_characteristic.remove()) .then(() => fake_characteristic.remove())
.then(() => fake_peripheral.setNextGATTDiscoveryResponse({HCI_SUCCESS}))
.then(() => fake_peripheral.simulateGATTServicesChanged()) .then(() => fake_peripheral.simulateGATTServicesChanged())
.then(() => assert_promise_rejects_with_message( .then(() => assert_promise_rejects_with_message(
characteristic.getDescriptors(), expected)), characteristic.getDescriptors(), expected)),
......
...@@ -17,6 +17,7 @@ let characteristic, fake_peripheral, fake_service; ...@@ -17,6 +17,7 @@ let characteristic, fake_peripheral, fake_service;
bluetooth_test(() => getMeasurementIntervalCharacteristic() bluetooth_test(() => getMeasurementIntervalCharacteristic()
.then(_ => ({characteristic, fake_peripheral, fake_service} = _)) .then(_ => ({characteristic, fake_peripheral, fake_service} = _))
.then(() => fake_service.remove()) .then(() => fake_service.remove())
.then(() => fake_peripheral.setNextGATTDiscoveryResponse({HCI_SUCCESS}))
.then(() => fake_peripheral.simulateGATTServicesChanged()) .then(() => fake_peripheral.simulateGATTServicesChanged())
.then(() => assert_promise_rejects_with_message( .then(() => assert_promise_rejects_with_message(
characteristic.getDescriptors(user_description.uuid), characteristic.getDescriptors(user_description.uuid),
......
...@@ -17,6 +17,7 @@ let characteristic, fake_peripheral, fake_service; ...@@ -17,6 +17,7 @@ let characteristic, fake_peripheral, fake_service;
bluetooth_test(() => getMeasurementIntervalCharacteristic() bluetooth_test(() => getMeasurementIntervalCharacteristic()
.then(_ => ({characteristic, fake_peripheral, fake_service} = _)) .then(_ => ({characteristic, fake_peripheral, fake_service} = _))
.then(() => fake_service.remove()) .then(() => fake_service.remove())
.then(() => fake_peripheral.setNextGATTDiscoveryResponse({HCI_SUCCESS}))
.then(() => fake_peripheral.simulateGATTServicesChanged()) .then(() => fake_peripheral.simulateGATTServicesChanged())
.then(() => assert_promise_rejects_with_message( .then(() => assert_promise_rejects_with_message(
characteristic.getDescriptors(user_description.name), characteristic.getDescriptors(user_description.name),
......
...@@ -14,6 +14,7 @@ let characteristic, fake_peripheral, fake_service; ...@@ -14,6 +14,7 @@ let characteristic, fake_peripheral, fake_service;
bluetooth_test(() => getMeasurementIntervalCharacteristic() bluetooth_test(() => getMeasurementIntervalCharacteristic()
.then(_ => ({characteristic, fake_peripheral, fake_service} = _)) .then(_ => ({characteristic, fake_peripheral, fake_service} = _))
.then(() => fake_service.remove()) .then(() => fake_service.remove())
.then(() => fake_peripheral.setNextGATTDiscoveryResponse({HCI_SUCCESS}))
.then(() => fake_peripheral.simulateGATTServicesChanged()) .then(() => fake_peripheral.simulateGATTServicesChanged())
.then(() => assert_promise_rejects_with_message( .then(() => assert_promise_rejects_with_message(
characteristic.startNotifications(), characteristic.startNotifications(),
......
...@@ -17,6 +17,7 @@ bluetooth_test(() => getMeasurementIntervalCharacteristic() ...@@ -17,6 +17,7 @@ bluetooth_test(() => getMeasurementIntervalCharacteristic()
.then(() => characteristic.getDescriptor(user_description.name)) .then(() => characteristic.getDescriptor(user_description.name))
.then(() => null, (e) => assert_unreached('Caught error unexpectedly.', e)) .then(() => null, (e) => assert_unreached('Caught error unexpectedly.', e))
.then(() => fake_characteristic.remove()) .then(() => fake_characteristic.remove())
.then(() => fake_peripheral.setNextGATTDiscoveryResponse({HCI_SUCCESS}))
.then(() => fake_peripheral.simulateGATTServicesChanged()) .then(() => fake_peripheral.simulateGATTServicesChanged())
.then(() => assert_promise_rejects_with_message( .then(() => assert_promise_rejects_with_message(
characteristic.readValue(), expected)), characteristic.readValue(), expected)),
......
...@@ -14,6 +14,7 @@ let characteristic, fake_peripheral, fake_service; ...@@ -14,6 +14,7 @@ let characteristic, fake_peripheral, fake_service;
bluetooth_test(() => getMeasurementIntervalCharacteristic() bluetooth_test(() => getMeasurementIntervalCharacteristic()
.then(_ => ({characteristic, fake_peripheral, fake_service} = _)) .then(_ => ({characteristic, fake_peripheral, fake_service} = _))
.then(() => fake_service.remove()) .then(() => fake_service.remove())
.then(() => fake_peripheral.setNextGATTDiscoveryResponse({HCI_SUCCESS}))
.then(() => fake_peripheral.simulateGATTServicesChanged()) .then(() => fake_peripheral.simulateGATTServicesChanged())
.then(() => assert_promise_rejects_with_message( .then(() => assert_promise_rejects_with_message(
characteristic.readValue(), characteristic.readValue(),
......
...@@ -17,6 +17,7 @@ bluetooth_test(() => getMeasurementIntervalCharacteristic() ...@@ -17,6 +17,7 @@ bluetooth_test(() => getMeasurementIntervalCharacteristic()
.then(() => characteristic.getDescriptor(user_description.name)) .then(() => characteristic.getDescriptor(user_description.name))
.then(() => null, (e) => assert_unreached('Caught error unexpectedly.', e)) .then(() => null, (e) => assert_unreached('Caught error unexpectedly.', e))
.then(() => fake_characteristic.remove()) .then(() => fake_characteristic.remove())
.then(() => fake_peripheral.setNextGATTDiscoveryResponse({HCI_SUCCESS}))
.then(() => fake_peripheral.simulateGATTServicesChanged()) .then(() => fake_peripheral.simulateGATTServicesChanged())
.then(() => assert_promise_rejects_with_message( .then(() => assert_promise_rejects_with_message(
characteristic.startNotifications(), expected)), characteristic.startNotifications(), expected)),
......
...@@ -17,6 +17,7 @@ bluetooth_test(() => getMeasurementIntervalCharacteristic() ...@@ -17,6 +17,7 @@ bluetooth_test(() => getMeasurementIntervalCharacteristic()
.then(() => characteristic.getDescriptor(user_description.name)) .then(() => characteristic.getDescriptor(user_description.name))
.then(() => null, (e) => assert_unreached('Caught error unexpectedly.', e)) .then(() => null, (e) => assert_unreached('Caught error unexpectedly.', e))
.then(() => fake_characteristic.remove()) .then(() => fake_characteristic.remove())
.then(() => fake_peripheral.setNextGATTDiscoveryResponse({HCI_SUCCESS}))
.then(() => fake_peripheral.simulateGATTServicesChanged()) .then(() => fake_peripheral.simulateGATTServicesChanged())
.then(() => assert_promise_rejects_with_message( .then(() => assert_promise_rejects_with_message(
characteristic.writeValue(new Uint8Array(1)), expected)), characteristic.writeValue(new Uint8Array(1)), expected)),
......
...@@ -14,6 +14,7 @@ let characteristic, fake_peripheral, fake_service; ...@@ -14,6 +14,7 @@ let characteristic, fake_peripheral, fake_service;
bluetooth_test(() => getMeasurementIntervalCharacteristic() bluetooth_test(() => getMeasurementIntervalCharacteristic()
.then(_ => ({characteristic, fake_peripheral, fake_service} = _)) .then(_ => ({characteristic, fake_peripheral, fake_service} = _))
.then(() => fake_service.remove()) .then(() => fake_service.remove())
.then(() => fake_peripheral.setNextGATTDiscoveryResponse({HCI_SUCCESS}))
.then(() => fake_peripheral.simulateGATTServicesChanged()) .then(() => fake_peripheral.simulateGATTServicesChanged())
.then(() => assert_promise_rejects_with_message( .then(() => assert_promise_rejects_with_message(
characteristic.writeValue(new ArrayBuffer(1 /* length */)), characteristic.writeValue(new ArrayBuffer(1 /* length */)),
......
...@@ -15,6 +15,7 @@ let descriptor, fake_peripheral, fake_service; ...@@ -15,6 +15,7 @@ let descriptor, fake_peripheral, fake_service;
bluetooth_test(() => getUserDescriptionDescriptor() bluetooth_test(() => getUserDescriptionDescriptor()
.then(_ => ({descriptor, fake_peripheral, fake_service} = _)) .then(_ => ({descriptor, fake_peripheral, fake_service} = _))
.then(() => fake_service.remove()) .then(() => fake_service.remove())
.then(() => fake_peripheral.setNextGATTDiscoveryResponse({HCI_SUCCESS}))
.then(() => fake_peripheral.simulateGATTServicesChanged()) .then(() => fake_peripheral.simulateGATTServicesChanged())
.then(() => assert_promise_rejects_with_message( .then(() => assert_promise_rejects_with_message(
descriptor.readValue(), descriptor.readValue(),
......
...@@ -15,6 +15,7 @@ let descriptor, fake_peripheral, fake_service; ...@@ -15,6 +15,7 @@ let descriptor, fake_peripheral, fake_service;
bluetooth_test(() => getUserDescriptionDescriptor() bluetooth_test(() => getUserDescriptionDescriptor()
.then(_ => ({descriptor, fake_peripheral, fake_service} = _)) .then(_ => ({descriptor, fake_peripheral, fake_service} = _))
.then(() => fake_service.remove()) .then(() => fake_service.remove())
.then(() => fake_peripheral.setNextGATTDiscoveryResponse({HCI_SUCCESS}))
.then(() => fake_peripheral.simulateGATTServicesChanged()) .then(() => fake_peripheral.simulateGATTServicesChanged())
.then(() => assert_promise_rejects_with_message( .then(() => assert_promise_rejects_with_message(
descriptor.writeValue(new ArrayBuffer(1 /* length */)), descriptor.writeValue(new ArrayBuffer(1 /* length */)),
......
...@@ -9,6 +9,7 @@ bluetooth_test(() => getMeasurementIntervalCharacteristic() ...@@ -9,6 +9,7 @@ bluetooth_test(() => getMeasurementIntervalCharacteristic()
.then(() => characteristic.getDescriptor(user_description.name)) .then(() => characteristic.getDescriptor(user_description.name))
.then(() => null, (e) => assert_unreached('Caught error unexpectedly.', e)) .then(() => null, (e) => assert_unreached('Caught error unexpectedly.', e))
.then(() => fake_characteristic.remove()) .then(() => fake_characteristic.remove())
.then(() => fake_peripheral.setNextGATTDiscoveryResponse({HCI_SUCCESS}))
.then(() => fake_peripheral.simulateGATTServicesChanged()) .then(() => fake_peripheral.simulateGATTServicesChanged())
.then(() => assert_promise_rejects_with_message( .then(() => assert_promise_rejects_with_message(
characteristic.CALLS([ characteristic.CALLS([
......
...@@ -9,6 +9,7 @@ let characteristic, fake_peripheral, fake_service; ...@@ -9,6 +9,7 @@ let characteristic, fake_peripheral, fake_service;
bluetooth_test(() => getMeasurementIntervalCharacteristic() bluetooth_test(() => getMeasurementIntervalCharacteristic()
.then(_ => ({characteristic, fake_peripheral, fake_service} = _)) .then(_ => ({characteristic, fake_peripheral, fake_service} = _))
.then(() => fake_service.remove()) .then(() => fake_service.remove())
.then(() => fake_peripheral.setNextGATTDiscoveryResponse({HCI_SUCCESS}))
.then(() => fake_peripheral.simulateGATTServicesChanged()) .then(() => fake_peripheral.simulateGATTServicesChanged())
.then(() => assert_promise_rejects_with_message( .then(() => assert_promise_rejects_with_message(
characteristic.CALLS([ characteristic.CALLS([
......
...@@ -7,6 +7,7 @@ let descriptor, fake_peripheral, fake_service; ...@@ -7,6 +7,7 @@ let descriptor, fake_peripheral, fake_service;
bluetooth_test(() => getUserDescriptionDescriptor() bluetooth_test(() => getUserDescriptionDescriptor()
.then(_ => ({descriptor, fake_peripheral, fake_service} = _)) .then(_ => ({descriptor, fake_peripheral, fake_service} = _))
.then(() => fake_service.remove()) .then(() => fake_service.remove())
.then(() => fake_peripheral.setNextGATTDiscoveryResponse({HCI_SUCCESS}))
.then(() => fake_peripheral.simulateGATTServicesChanged()) .then(() => fake_peripheral.simulateGATTServicesChanged())
.then(() => assert_promise_rejects_with_message( .then(() => assert_promise_rejects_with_message(
descriptor.CALLS([ descriptor.CALLS([
......
...@@ -8,6 +8,7 @@ let service, fake_service, fake_peripheral; ...@@ -8,6 +8,7 @@ let service, fake_service, fake_peripheral;
bluetooth_test(() => getHealthThermometerService() bluetooth_test(() => getHealthThermometerService()
.then(_ => ({service, fake_service, fake_peripheral} = _)) .then(_ => ({service, fake_service, fake_peripheral} = _))
.then(() => fake_service.remove()) .then(() => fake_service.remove())
.then(() => fake_peripheral.setNextGATTDiscoveryResponse({HCI_SUCCESS}))
.then(() => fake_peripheral.simulateGATTServicesChanged()) .then(() => fake_peripheral.simulateGATTServicesChanged())
.then(() => assert_promise_rejects_with_message( .then(() => assert_promise_rejects_with_message(
service.CALLS([ service.CALLS([
......
...@@ -16,6 +16,7 @@ let service, fake_service, fake_peripheral; ...@@ -16,6 +16,7 @@ let service, fake_service, fake_peripheral;
bluetooth_test(() => getHealthThermometerService() bluetooth_test(() => getHealthThermometerService()
.then(_ => ({service, fake_service, fake_peripheral} = _)) .then(_ => ({service, fake_service, fake_peripheral} = _))
.then(() => fake_service.remove()) .then(() => fake_service.remove())
.then(() => fake_peripheral.setNextGATTDiscoveryResponse({HCI_SUCCESS}))
.then(() => fake_peripheral.simulateGATTServicesChanged()) .then(() => fake_peripheral.simulateGATTServicesChanged())
.then(() => assert_promise_rejects_with_message( .then(() => assert_promise_rejects_with_message(
service.getCharacteristic('measurement_interval'), service.getCharacteristic('measurement_interval'),
......
...@@ -16,6 +16,7 @@ let service, fake_service, fake_peripheral; ...@@ -16,6 +16,7 @@ let service, fake_service, fake_peripheral;
bluetooth_test(() => getHealthThermometerService() bluetooth_test(() => getHealthThermometerService()
.then(_ => ({service, fake_service, fake_peripheral} = _)) .then(_ => ({service, fake_service, fake_peripheral} = _))
.then(() => fake_service.remove()) .then(() => fake_service.remove())
.then(() => fake_peripheral.setNextGATTDiscoveryResponse({HCI_SUCCESS}))
.then(() => fake_peripheral.simulateGATTServicesChanged()) .then(() => fake_peripheral.simulateGATTServicesChanged())
.then(() => assert_promise_rejects_with_message( .then(() => assert_promise_rejects_with_message(
service.getCharacteristics('measurement_interval'), service.getCharacteristics('measurement_interval'),
......
...@@ -16,6 +16,7 @@ let service, fake_service, fake_peripheral; ...@@ -16,6 +16,7 @@ let service, fake_service, fake_peripheral;
bluetooth_test(() => getHealthThermometerService() bluetooth_test(() => getHealthThermometerService()
.then(_ => ({service, fake_service, fake_peripheral} = _)) .then(_ => ({service, fake_service, fake_peripheral} = _))
.then(() => fake_service.remove()) .then(() => fake_service.remove())
.then(() => fake_peripheral.setNextGATTDiscoveryResponse({HCI_SUCCESS}))
.then(() => fake_peripheral.simulateGATTServicesChanged()) .then(() => fake_peripheral.simulateGATTServicesChanged())
.then(() => assert_promise_rejects_with_message( .then(() => assert_promise_rejects_with_message(
service.getCharacteristics(), service.getCharacteristics(),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment