<!DOCTYPE html>
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/bluetooth/resources/bluetooth-test.js"></script>
<script src="/bluetooth/resources/bluetooth-fake-devices.js"></script>
<script>
let matching_services = [heart_rate.uuid];
let matching_name = 'Heart Rate Device';
let matching_namePrefix = 'Heart';
let matching_manufacturerData = [{ companyIdentifier: 0x0001 }];
let non_matching_services = ['battery_service'];
let non_matching_name = 'Some Device';
let non_matching_namePrefix = 'Some';
let non_matching_manufacturerData = [{ companyIdentifier: 0x000f }];
let test_specs = [
{
filters: [{
services: matching_services,
}],
exclusionFilters: [{
services: non_matching_services,
name: non_matching_name,
namePrefix: non_matching_namePrefix,
manufacturerData: non_matching_manufacturerData
}]
},
{
filters: [{
services: matching_services,
}],
exclusionFilters: [{
services: matching_services,
name: non_matching_name,
namePrefix: non_matching_namePrefix,
manufacturerData: non_matching_manufacturerData
}]
},
{
filters: [{
services: matching_services,
}],
exclusionFilters: [{
services: non_matching_services,
name: matching_name,
namePrefix: non_matching_namePrefix,
manufacturerData: non_matching_manufacturerData
}]
},
{
filters: [{
services: matching_services,
}],
exclusionFilters: [{
services: matching_services,
name: matching_name,
namePrefix: non_matching_namePrefix,
manufacturerData: non_matching_manufacturerData
}]
},
{
filters: [{
services: matching_services,
}],
exclusionFilters: [{
services: non_matching_services,
name: non_matching_name,
namePrefix: matching_namePrefix,
manufacturerData: non_matching_manufacturerData
}]
},
{
filters: [{
services: matching_services,
}],
exclusionFilters: [{
services: matching_services,
name: non_matching_name,
namePrefix: matching_namePrefix,
manufacturerData: non_matching_manufacturerData
}]
},
{
filters: [{
services: matching_services,
}],
exclusionFilters: [{
services: non_matching_services,
name: matching_name,
namePrefix: matching_namePrefix,
manufacturerData: non_matching_manufacturerData
}]
},
{
filters: [{
services: matching_services,
}],
exclusionFilters: [{
services: non_matching_services,
name: non_matching_name,
namePrefix: non_matching_namePrefix,
manufacturerData: matching_manufacturerData
}]
},
{
filters: [{
services: matching_services,
}],
exclusionFilters: [{
services: matching_services,
name: non_matching_name,
namePrefix: non_matching_namePrefix,
manufacturerData: matching_manufacturerData
}]
},
{
filters: [{
services: matching_services,
}],
exclusionFilters: [{
services: non_matching_services,
name: matching_name,
namePrefix: non_matching_namePrefix,
manufacturerData: matching_manufacturerData
}]
},
{
filters: [{
services: matching_services,
}],
exclusionFilters: [{
services: non_matching_services,
name: non_matching_name,
namePrefix: matching_namePrefix,
manufacturerData: matching_manufacturerData
}]
},
{
filters: [{
services: matching_services,
}],
exclusionFilters: [{
services: matching_services,
name: matching_name,
namePrefix: non_matching_namePrefix,
manufacturerData: matching_manufacturerData
}]
},
{
filters: [{
services: matching_services,
}],
exclusionFilters: [{
services: matching_services,
name: non_matching_name,
namePrefix: matching_namePrefix,
manufacturerData: matching_manufacturerData
}]
},
{
filters: [{
services: matching_services,
}],
exclusionFilters: [{
services: non_matching_services,
name: matching_name,
namePrefix: matching_namePrefix,
manufacturerData: matching_manufacturerData
}]
},
{
filters: [{
services: matching_services,
}],
exclusionFilters: [{
services: non_matching_services,
}]
},
{
filters: [{
services: matching_services,
}],
exclusionFilters: [{
services: non_matching_services,
name: non_matching_name,
}]
},
{
filters: [{
services: matching_services,
}],
exclusionFilters: [{
manufacturerData: non_matching_manufacturerData,
}]
},
{
filters: [{
services: matching_services,
}],
exclusionFilters: [{
services: non_matching_services,
manufacturerData: non_matching_manufacturerData,
}]
},
{
filters: [{
services: matching_services,
}],
exclusionFilters: [{
name: non_matching_name,
manufacturerData: non_matching_manufacturerData,
}]
},
{
filters: [{
services: matching_services,
}],
exclusionFilters: [{
namePrefix: non_matching_namePrefix,
manufacturerData: non_matching_manufacturerData,
}]
},
{
filters: [{
services: matching_services,
}],
exclusionFilters: [{
services: non_matching_services,
namePrefix: non_matching_namePrefix
}]
},
{
filters: [{
services: matching_services,
}],
exclusionFilters: [{
name: non_matching_name,
}]
},
{
filters: [{
services: matching_services,
}],
exclusionFilters: [{
name: non_matching_name,
namePrefix: non_matching_namePrefix
}]
},
{
filters: [{
services: matching_services,
}],
exclusionFilters: [{
namePrefix: non_matching_namePrefix
}]
}
];
bluetooth_test(t => {
return setBluetoothFakeAdapter('GlucoseHeartRateAdapter').then(() => {
let test_promises = Promise.resolve();
test_specs.forEach(args => {
test_promises = test_promises.then(() => requestDeviceWithTrustedClick(args))
.then(device => {
assert_equals(device.name, matching_name)
})
});
return test_promises;
});
}, 'If at least one exclusion filter member doesn\'t match the promise must resolve with matching device.');
</script>