Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change will migrate the remaining tests that have been converted to the Web Bluetooth Test API at the moment. BUG=509038 Change-Id: I6b38a9dd413f99caccbc9861d492eec0a25b1b91 Reviewed-on: https://chromium-review.googlesource.com/891653 Commit-Queue: Ovidio Henriquez <odejesush@chromium.org> Reviewed-by: Reilly Grant <reillyg@chromium.org> Cr-Commit-Position: refs/heads/master@{#538680}
- Loading branch information
1 parent
5496784
commit 99ea9dc
Showing
10 changed files
with
231 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
bluetooth/characteristic/service-same-from-2-characteristics.https.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<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-helpers.js"></script> | ||
<script> | ||
'use strict'; | ||
const test_desc = 'Same parent service returned from multiple characteristics.'; | ||
|
||
bluetooth_test(() => getHealthThermometerService() | ||
.then(({service}) => Promise.all([ | ||
service.getCharacteristic('measurement_interval'), | ||
service.getCharacteristic('temperature_measurement') | ||
])) | ||
.then(characteristics => | ||
assert_equals(characteristics[0].service, characteristics[1].service)), | ||
test_desc); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!DOCTYPE html> | ||
<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-helpers.js"></script> | ||
<script> | ||
'use strict'; | ||
const test_desc = '[SameObject] test for BluetoothRemoteGATTCharacteristic ' + | ||
'service.'; | ||
|
||
bluetooth_test(() => getMeasurementIntervalCharacteristic() | ||
.then(({characteristic}) => | ||
assert_equals(characteristic.service, characteristic.service)), | ||
test_desc); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!DOCTYPE html> | ||
<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-helpers.js"></script> | ||
<script> | ||
'use strict'; | ||
const test_desc = 'A read request succeeds and returns the descriptor\'s value.'; | ||
const EXPECTED_VALUE = [0, 1, 2]; | ||
let descriptor, fake_descriptor; | ||
|
||
bluetooth_test(() => getUserDescriptionDescriptor() | ||
.then(_ => ({descriptor, fake_descriptor} = _)) | ||
.then(() => | ||
fake_descriptor.setNextReadResponse(GATT_SUCCESS, EXPECTED_VALUE)) | ||
.then(() => descriptor.readValue()) | ||
.then(value => assert_array_equals(Array.from(new Uint8Array( | ||
value.buffer)), EXPECTED_VALUE)), | ||
test_desc); | ||
</script> |
19 changes: 19 additions & 0 deletions
19
bluetooth/device/gattserverdisconnected-event/disconnected.https.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<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-helpers.js"></script> | ||
<script> | ||
'use strict'; | ||
const test_desc = 'A device disconnecting while connected should fire the ' + | ||
'gattserverdisconnected event.'; | ||
|
||
bluetooth_test(() => getHealthThermometerDevice() | ||
.then(({device, fake_peripheral}) => { | ||
fake_peripheral.simulateGATTDisconnection(); | ||
return eventPromise(device, 'gattserverdisconnected'); | ||
}) | ||
.then(e => assert_true(e.bubbles)), | ||
test_desc); | ||
</script> |
24 changes: 24 additions & 0 deletions
24
bluetooth/device/gattserverdisconnected-event/disconnected_gc.https.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!DOCTYPE html> | ||
<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-helpers.js"></script> | ||
<script> | ||
'use strict'; | ||
const test_desc = 'A device disconnecting after the BluetoothDevice object ' + | ||
'has been GC\'ed should not access freed memory.'; | ||
|
||
bluetooth_test(() => getHealthThermometerDevice() | ||
.then(({fake_peripheral}) => { | ||
// 1. Disconnect. | ||
fake_peripheral.simulateGATTDisconnection(); | ||
// 2. Run garbage collection. | ||
fake_peripheral = undefined; | ||
runGarbageCollection(); | ||
}) | ||
// 3. Wait 50ms after the GC runs for the disconnection event to come back. | ||
// There's nothing to assert other than that only valid memory is used. | ||
.then(() => new Promise(resolve => step_timeout(resolve, 50))), | ||
test_desc); | ||
</script> |
32 changes: 32 additions & 0 deletions
32
bluetooth/device/gattserverdisconnected-event/one-event-per-disconnection.https.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!DOCTYPE html> | ||
<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-helpers.js"></script> | ||
<script> | ||
'use strict'; | ||
const test_desc = 'If a site disconnects from a device while the platform is ' + | ||
'disconnecting that device, only one gattserverdisconnected event should ' + | ||
'fire.'; | ||
let device, fake_peripheral; | ||
let num_events = 0; | ||
|
||
bluetooth_test(() => getHealthThermometerDevice() | ||
.then(_ => ({device, fake_peripheral} = _)) | ||
// 1. Listen for disconnections. | ||
.then(() => | ||
device.addEventListener('gattserverdisconnected', () => num_events++)) | ||
// 2. Disconnect several times. | ||
.then(() => Promise.all([ | ||
eventPromise(device, 'gattserverdisconnected'), | ||
fake_peripheral.simulateGATTDisconnection(), | ||
device.gatt.disconnect(), | ||
device.gatt.disconnect(), | ||
])) | ||
// 3. Wait to catch disconnect events. | ||
.then(() => new Promise(resolve => step_timeout(resolve, 50))) | ||
// 4. Ensure there is exactly 1 disconnection recorded. | ||
.then(() => assert_equals(num_events, 1)), | ||
test_desc); | ||
</script> |
34 changes: 34 additions & 0 deletions
34
bluetooth/device/gattserverdisconnected-event/reconnect-during-disconnected-event.https.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<!DOCTYPE html> | ||
<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-helpers.js"></script> | ||
<script> | ||
'use strict'; | ||
let test_desc = 'A device that reconnects during the gattserverdisconnected ' + | ||
'event should still receive gattserverdisconnected events after ' + | ||
're-connection.'; | ||
let device, fake_peripheral; | ||
bluetooth_test(() => getHealthThermometerDevice() | ||
.then(_ => ({device, fake_peripheral} = _)) | ||
// 1. Disconnect. | ||
.then(() => new Promise(resolve => { | ||
fake_peripheral.simulateGATTDisconnection(); | ||
device.addEventListener( | ||
'gattserverdisconnected', function onDisconnected() { | ||
device.removeEventListener('gattserverdisconnected', onDisconnected); | ||
// 2. Reconnect. | ||
fake_peripheral.setNextGATTConnectionResponse({ | ||
code: HCI_SUCCESS, | ||
}) | ||
.then(() => device.gatt.connect()) | ||
.then(() => resolve()); | ||
}); | ||
})) | ||
// 3. Disconnect after reconnecting. | ||
.then(() => { | ||
fake_peripheral.simulateGATTDisconnection(); | ||
return eventPromise(device, 'gattserverdisconnected') | ||
}), test_desc); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!DOCTYPE html> | ||
<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-helpers.js"></script> | ||
<script> | ||
'use strict'; | ||
const test_desc_idl = 'BluetoothDevice IDL test.'; | ||
|
||
test(() => { | ||
assert_throws(new TypeError(), () => new BluetoothDevice(), | ||
'the constructor should not be callable with "new"'); | ||
assert_throws(new TypeError(), () => BluetoothDevice(), | ||
'the constructor should not be callable'); | ||
}, test_desc_idl); | ||
|
||
const test_desc_attr = 'BluetoothDevice attributes.'; | ||
let device; | ||
bluetooth_test(() => getHealthThermometerDevice() | ||
.then(({device}) => { | ||
assert_equals(device.constructor.name, 'BluetoothDevice'); | ||
var old_device_id = device.id; | ||
assert_throws(new TypeError(), () => device.id = 'overwritten', | ||
'the device id should not be writable'); | ||
assert_throws(new TypeError(), () => device.name = 'overwritten', | ||
'the device name should not be writable'); | ||
assert_equals(device.id, old_device_id); | ||
assert_equals(device.name, 'Health Thermometer'); | ||
}), test_desc_attr); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!DOCTYPE html> | ||
<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-helpers.js"></script> | ||
<script> | ||
'use strict'; | ||
const test_desc = 'Same parent device returned from multiple services.'; | ||
|
||
bluetooth_test(() => getTwoHealthThermometerServicesDevice({ | ||
filters: [{services: ['health_thermometer']}] | ||
}) | ||
.then(({device}) => device.gatt.getPrimaryServices('health_thermometer')) | ||
.then(([service1, service2]) => | ||
assert_equals(service1.device, service2.device)), | ||
test_desc); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!DOCTYPE html> | ||
<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-helpers.js"></script> | ||
<script> | ||
'use strict'; | ||
const test_desc = '[SameObject] test for BluetoothRemoteGATTService device.'; | ||
|
||
bluetooth_test(() => getHealthThermometerDevice({ | ||
filters: [{services: ['health_thermometer']}] | ||
}) | ||
.then(({device}) => device.gatt.getPrimaryService('health_thermometer')) | ||
.then(service => assert_equals(service.device, service.device)), | ||
test_desc); | ||
</script> |