mirror of
https://github.com/servo/servo
synced 2026-04-28 02:19:14 +02:00
72 lines
4.0 KiB
HTML
72 lines
4.0 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<title>GetIncludedService Test Cases</title>
|
|
<body>
|
|
<div id="buttons"></div>
|
|
<pre id="log"></pre>
|
|
<script src="bluetooth_functions.js"></script>
|
|
<script>
|
|
var testCases = [];
|
|
//Test 1
|
|
testCases.push({ requestedService: 'battery_service', requestedIncludedService: 'not_a_service_name', options: {filters: [{services: ['battery_service']}]} });
|
|
//Test 2
|
|
testCases.push({ requestedService: 'battery_service', requestedIncludedService: '1234567891000-1000-8000-00805f9b34fb', options: {filters: [{services: ['battery_service']}]} });
|
|
//Test 3
|
|
testCases.push({ requestedService: 'battery_service', requestedIncludedService: '11', options: {filters: [{services: ['battery_service']}]} });
|
|
//Test 4
|
|
testCases.push({ requestedService: 'battery_service', requestedIncludedService: '12345678-1234-1234-1234-123456789abc', options: {filters: [{services: ['battery_service']}]} });
|
|
//Test 5
|
|
testCases.push({ requestedService: 'battery_service', requestedIncludedService: '00000000-0000-0000-0000-000000000000', options: {filters: [{services: ['battery_service']}]} });
|
|
//Test 6
|
|
testCases.push({ requestedService: 'battery_service', requestedIncludedService: 0x0000, options: {filters: [{services: ['battery_service']}]} });
|
|
//Test 7
|
|
testCases.push({ requestedService: 'battery_service', requestedIncludedService: 0x00000000, options: {filters: [{services: ['battery_service']}]} });
|
|
//Test 8
|
|
testCases.push({ requestedService: 'battery_service', requestedIncludedService: 0x12345678, options: {filters: [{services: ['battery_service']}]} });
|
|
//Test 9
|
|
testCases.push({ requestedService: 'battery_service', requestedIncludedService: 0x0000180f, options: {filters: [{services: ['battery_service']}]} });
|
|
//Test 10
|
|
testCases.push({ requestedService: 'battery_service', requestedIncludedService: '00001812-0000-1000-8000-00805f9b34fb', options: {filters: [{services: ['battery_service']}]} });
|
|
//Test 11
|
|
testCases.push({ requestedService: 'battery_service', requestedIncludedService: 'f000ffc0-0451-4000-b000-000000000000', options: {filters: [{services: ['battery_service']}]} });
|
|
//Test 12
|
|
testCases.push({ requestedService: 'battery_service', requestedIncludedService: '00001530-1212-efde-1523-785feabcd123', options: {filters: [{services: ['battery_service']}]} });
|
|
//Test 13
|
|
testCases.push({ requestedService: 'battery_service', requestedIncludedService: 0x00001812, options: {filters: [{services: ['battery_service']}]} });
|
|
//Test 14
|
|
testCases.push({ requestedService: 'battery_service', requestedIncludedService: 0xf000ffc0, options: {filters: [{services: ['battery_service']}]} });
|
|
//Test 15
|
|
testCases.push({ requestedService: 'battery_service', requestedIncludedService: 0x00001530, options: {filters: [{services: ['battery_service']}]} });
|
|
|
|
function onButtonClick(testNumber) {
|
|
clear();
|
|
|
|
log('Requesting Bluetooth Device...');
|
|
window.navigator.bluetooth.requestDevice(testCases[testNumber].options)
|
|
.then(device => {
|
|
log('Connecting to GATTserver on device...');
|
|
return device.gatt.connect();
|
|
})
|
|
.then(server => {
|
|
log('Getting Primary Service "' + testCases[testNumber].requestedService + '"...');
|
|
return server.getPrimaryService(testCases[testNumber].requestedService);
|
|
})
|
|
.then(service => {
|
|
log('Getting Included Service "' + testCases[testNumber].requestedIncludedService + '"...')
|
|
return service.getIncludedService(testCases[testNumber].requestedIncludedService);
|
|
})
|
|
.then(includedService => {
|
|
log('Primary Service found on device: ' + includedService.device.name);
|
|
log('> UUID: ' + includedService.uuid);
|
|
log('> Is primary: ' + includedService.isPrimary);
|
|
})
|
|
.catch(err => {
|
|
log(err);
|
|
});
|
|
}
|
|
|
|
populate(testCases);
|
|
</script>
|
|
</body>
|
|
</html>
|