get-different-service-after-reconnection.js (1785B)
1 'use strict'; 2 const test_desc = 3 'Calls to FUNCTION_NAME after a disconnection should return ' + 4 'a different object.'; 5 let device, services_first_connection, services_second_connection; 6 7 bluetooth_bidi_test( 8 () => getHealthThermometerDevice({ 9 filters: [{services: ['health_thermometer']}], 10 optionalServices: ['generic_access'] 11 }) 12 .then(_ => ({device} = _)) 13 .then(() => device.gatt.CALLS([ 14 getPrimaryService('health_thermometer') | getPrimaryServices() | 15 getPrimaryServices('health_thermometer')[UUID] 16 ])) 17 .then(services => services_first_connection = services) 18 .then(() => device.gatt.disconnect()) 19 .then(() => device.gatt.connect()) 20 .then(() => device.gatt.PREVIOUS_CALL) 21 .then(services => services_second_connection = services) 22 .then(() => { 23 // Convert to arrays if necessary. 24 services_first_connection = 25 [].concat(services_first_connection); 26 services_second_connection = 27 [].concat(services_second_connection); 28 29 assert_equals( 30 services_first_connection.length, 31 services_second_connection.length); 32 33 let first_connection_set = new Set(services_first_connection); 34 let second_connection_set = new Set(services_second_connection); 35 36 // The two sets should be disjoint. 37 let common_services = services_first_connection.filter( 38 val => second_connection_set.has(val)); 39 assert_equals(common_services.length, 0); 40 }), 41 test_desc);