mirror of
https://github.com/servo/servo
synced 2026-04-28 02:19:14 +02:00
80 lines
3.9 KiB
HTML
80 lines
3.9 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<title>GetPrimaryServices 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: 'heart_rate', options: {filters: [{services: ['battery_service']}]} });
|
|
//Test 2
|
|
testCases.push({ requestedService: 'not_a_service_name', options: {filters: [{services: ['battery_service']}]} });
|
|
//Test 3
|
|
testCases.push({ requestedService: 'battery_service', options: {filters: [{services: ['battery_service']}]} });
|
|
//Test 4
|
|
testCases.push({ requestedService: '1234567891000-1000-8000-00805f9b34fb', options: {filters: [{services: ['battery_service']}]} });
|
|
//Test 5
|
|
testCases.push({ requestedService: '11', options: {filters: [{services: ['battery_service']}]} });
|
|
//Test 6
|
|
testCases.push({ requestedService: '12345678-1234-1234-1234-123456789abc', options: {filters: [{services: ['battery_service']}]} });
|
|
//Test 7
|
|
testCases.push({ requestedService: '00000000-0000-0000-0000-000000000000', options: {filters: [{services: ['battery_service']}]} });
|
|
//Test 8
|
|
testCases.push({ requestedService: 0x0000, options: {filters: [{services: ['battery_service']}]} });
|
|
//Test 9
|
|
testCases.push({ requestedService: 0x00000000, options: {filters: [{services: ['battery_service']}]} });
|
|
//Test 10
|
|
testCases.push({ requestedService: 0x180f, options: {filters: [{services: ['battery_service']}]} });
|
|
//Test 11
|
|
testCases.push({ requestedService: 0x12345678, options: {filters: [{services: ['battery_service']}]} });
|
|
//Test 12
|
|
testCases.push({ requestedService: 0x0000180f, options: {filters: [{services: ['battery_service']}]} });
|
|
//Test 13
|
|
testCases.push({ requestedService: 0x00001812, options: {filters: [{services: ['battery_service']}]} });
|
|
//Test 14
|
|
testCases.push({ requestedService: 'f000ffc0-0451-4000-b000-000000000000', options: {filters: [{services: ['battery_service']}]} });
|
|
//Test 15
|
|
testCases.push({ requestedService: '00001530-1212-efde-1523-785feabcd123', options: {filters: [{services: ['battery_service']}]} });
|
|
//Test 16
|
|
testCases.push({ requestedService: 0xf000ffc0, options: {filters: [{services: ['battery_service']}], optionalServices: [0xf000ffc0]} });
|
|
//Test 17
|
|
testCases.push({ requestedService: 0x00001530, options: {filters: [{services: ['battery_service']}], optionalServices: [0x00001530]} });
|
|
//Test 18
|
|
testCases.push({ requestedService: '0000180f-0000-1000-8000-00805f9b34fb', options: {filters: [{services: ['battery_service']}]} });
|
|
//Test 19
|
|
testCases.push({ requestedService: 'cycling_power', options: {filters: [{services: ['battery_service']}], optionalServices: ['cycling_power']} });
|
|
//Test 20
|
|
testCases.push({ requestedService: '00001818-0000-1000-8000-00805f9b34fb', options: {filters: [{services: ['battery_service']}], optionalServices: ['cycling_power']} });
|
|
|
|
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.getPrimaryServices(testCases[testNumber].requestedService);
|
|
})
|
|
.then(services => {
|
|
for(i = 0; i < services.length; ++i) {
|
|
log('> #' + (i+1));
|
|
log('> UUID: ' + services[i].uuid);
|
|
log('> Is primary: ' + services[i].isPrimary);
|
|
}
|
|
})
|
|
.catch(err => {
|
|
log(err);
|
|
});
|
|
}
|
|
|
|
populate(testCases);
|
|
</script>
|
|
</body>
|
|
</html>
|