simulate_descriptor.https.html (2316B)
1 <!DOCTYPE html> 2 <meta charset="utf-8" /> 3 <meta name="timeout" content="long"> 4 <title>TestDriver bidi.bluetooth.simulate_descriptor method</title> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script src="/resources/testdriver.js?feature=bidi"></script> 8 <script src="/resources/testdriver-vendor.js"></script> 9 <script src="resources/bidi-bluetooth-helper.js"></script> 10 11 <script> 12 promise_setup(async () => { 13 await test_driver.bidi.bluetooth.request_device_prompt_updated.subscribe(); 14 await test_driver.bidi.bluetooth.gatt_connection_attempted.subscribe(); 15 }); 16 17 bluetooth_test(async (t) => { 18 const handle_prompt_promise = selectFirstDeviceOnDevicePromptUpdated(); 19 const [device] = await Promise.all([requestDeviceWithTrustedClick({ 20 acceptAllDevices: true, 21 optionalServices: [HEART_RATE_SERVICE_UUID] 22 }), handle_prompt_promise]); 23 24 await createGattConnection(device); 25 await test_driver.bidi.bluetooth.simulate_service({ 26 address: DEVICE_ADDRESS, 27 uuid: HEART_RATE_SERVICE_UUID, 28 type: 'add', 29 }); 30 await test_driver.bidi.bluetooth.simulate_characteristic({ 31 address: DEVICE_ADDRESS, 32 serviceUuid: HEART_RATE_SERVICE_UUID, 33 characteristicUuid: DATE_TIME_CHARACTERISTIC_UUID, 34 characteristicProperties: { 35 'read': true 36 }, 37 type: 'add', 38 }); 39 await test_driver.bidi.bluetooth.simulate_descriptor({ 40 address: DEVICE_ADDRESS, 41 serviceUuid: HEART_RATE_SERVICE_UUID, 42 characteristicUuid: DATE_TIME_CHARACTERISTIC_UUID, 43 descriptorUuid: CHARACTERISTIC_USER_DESCRIPTION_DESCRIPTOR_UUID, 44 type: 'add', 45 }); 46 service = await device.gatt.getPrimaryService(HEART_RATE_SERVICE_UUID); 47 characteristic = await service.getCharacteristic(DATE_TIME_CHARACTERISTIC_UUID); 48 descriptors = await characteristic.getDescriptors(); 49 assert_equals( 50 JSON.stringify(descriptors.map(descriptor => descriptor.uuid)), 51 JSON.stringify([CHARACTERISTIC_USER_DESCRIPTION_DESCRIPTOR_UUID]) 52 ); 53 }, "simulate a GATT descriptor."); 54 </script>