diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/bluetooth/resources/bluetooth-scanning-helpers.js | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/bluetooth/resources/bluetooth-scanning-helpers.js')
-rw-r--r-- | testing/web-platform/tests/bluetooth/resources/bluetooth-scanning-helpers.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/testing/web-platform/tests/bluetooth/resources/bluetooth-scanning-helpers.js b/testing/web-platform/tests/bluetooth/resources/bluetooth-scanning-helpers.js new file mode 100644 index 0000000000..f474c9c306 --- /dev/null +++ b/testing/web-platform/tests/bluetooth/resources/bluetooth-scanning-helpers.js @@ -0,0 +1,42 @@ +'use strict'; + +const company_id = '224'; +const data = new TextEncoder().encode('foo'); +const manufacturerDataMap = {[company_id]: data}; +const health_uuid = health_thermometer.uuid; +const serviceDataMap = {[health_uuid]: data}; +const scanRecord = { + name: 'Health Thermometer', + uuids: ['generic_access', health_uuid], + txPower: 20, + appearance: 100, + manufacturerData: manufacturerDataMap, + serviceData: serviceDataMap, +}; +const scanResult = { + deviceAddress: '09:09:09:09:09:09', + rssi: 100, + scanRecord: scanRecord, +}; + +function verifyBluetoothAdvertisingEvent(e) { + assert_equals(e.constructor.name, 'BluetoothAdvertisingEvent') + assert_equals(e.device.name, scanRecord.name) + assert_equals(e.name, scanRecord.name) + assert_array_equals(e.uuids, + ["00001800-0000-1000-8000-00805f9b34fb", + "00001809-0000-1000-8000-00805f9b34fb"]) + assert_equals(e.txPower, 20) + assert_equals(e.rssi, 100) + + assert_equals(e.manufacturerData.constructor.name, + 'BluetoothManufacturerDataMap') + assert_equals(data[0], e.manufacturerData.get(224).getUint8(0)) + assert_equals(data[1], e.manufacturerData.get(224).getUint8(1)) + assert_equals(data[2], e.manufacturerData.get(224).getUint8(2)) + + assert_equals(e.serviceData.constructor.name, 'BluetoothServiceDataMap') + assert_equals(data[0], e.serviceData.get(health_uuid).getUint8(0)) + assert_equals(data[1], e.serviceData.get(health_uuid).getUint8(1)) + assert_equals(data[2], e.serviceData.get(health_uuid).getUint8(2)) +} |