Files
servo/tests/html/bluetooth/bluetooth_get_included_services_test_cases.html
2016-09-26 20:02:42 +02:00

74 lines
4.0 KiB
HTML

<!DOCTYPE html>
<html>
<title>GetIncludedServices 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.getIncludedServices(testCases[testNumber].requestedIncludedService);
})
.then(includedServices => {
for(i = 0; i < includedServices.length; ++i) {
log('> #' + (i+1));
log('> UUID: ' + includedServices[i].uuid);
log('> Is primary: ' + includedServices[i].isPrimary);
}
})
.catch(err => {
log(err);
});
}
populate(testCases);
</script>
</body>
</html>