Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Unified Diff: third_party/WebKit/LayoutTests/bluetooth/readValue.html

Issue 1815483003: bluetooth: Create Mojo equivalent of SetBluetoothMockDataSet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-mojo
Patch Set: MMerge with ToT Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/bluetooth/readValue.html
diff --git a/third_party/WebKit/LayoutTests/bluetooth/readValue.html b/third_party/WebKit/LayoutTests/bluetooth/readValue.html
index d67a6b617799cb0e65c65c9ebaffbb4513799e98..73b7b1415e15564d461a487293d24077f2f50077 100644
--- a/third_party/WebKit/LayoutTests/bluetooth/readValue.html
+++ b/third_party/WebKit/LayoutTests/bluetooth/readValue.html
@@ -9,61 +9,67 @@ test(t => { assert_true(window.testRunner instanceof Object); t.done(); },
'window.testRunner is required for the following tests.');
promise_test(() => {
- testRunner.setBluetoothMockDataSet('HeartRateAdapter');
- return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}],
- optionalServices: ['generic_access']})
+ return setBluetoothFakeAdapter('HeartRateAdapter')
+ .then(() => requestDeviceWithKeyDown({
+ filters: [{services: ['heart_rate']}],
+ optionalServices: ['generic_access']}))
.then(device => device.gatt.connect())
.then(gattServer => gattServer.getPrimaryService('generic_access'))
.then(service => service.getCharacteristic('gap.device_name'))
.then(characteristic => {
- testRunner.setBluetoothMockDataSet('EmptyAdapter');
- return assert_promise_rejects_with_message(
- characteristic.readValue(), new DOMException(
- 'Bluetooth Device is no longer in range.',
- 'NetworkError'),
- 'Device went out of range');
+ return setBluetoothFakeAdapter('EmptyAdapter')
+ .then(() => assert_promise_rejects_with_message(
+ characteristic.readValue(),
+ new DOMException(
+ 'Bluetooth Device is no longer in range.',
+ 'NetworkError'),
+ 'Device went out of range'));
});
}, 'Device goes out of range. Reject with NetworkError.');
promise_test(() => {
- testRunner.setBluetoothMockDataSet('HeartRateAdapter');
- return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}],
- optionalServices: ['generic_access']})
+ return setBluetoothFakeAdapter('HeartRateAdapter')
+ .then(() => requestDeviceWithKeyDown({
+ filters: [{services: ['heart_rate']}],
+ optionalServices: ['generic_access']}))
.then(device => device.gatt.connect())
.then(gattServer => gattServer.getPrimaryService('generic_access'))
.then(service => service.getCharacteristic('gap.device_name'))
.then(characteristic => {
- testRunner.setBluetoothMockDataSet('MissingServiceHeartRateAdapter');
- return assert_promise_rejects_with_message(
- characteristic.readValue(), new DOMException(
- 'GATT Service no longer exists.',
- 'InvalidStateError'),
- 'Service got removed.');
+ return setBluetoothFakeAdapter('MissingServiceHeartRateAdapter')
+ .then(() => assert_promise_rejects_with_message(
+ characteristic.readValue(),
+ new DOMException(
+ 'GATT Service no longer exists.',
+ 'InvalidStateError'),
+ 'Service got removed.'));
});
}, 'Service gets removed. Reject with InvalidStateError.');
promise_test(() => {
- testRunner.setBluetoothMockDataSet('HeartRateAdapter');
- return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}],
- optionalServices: ['generic_access']})
+ return setBluetoothFakeAdapter('HeartRateAdapter')
+ .then(() => requestDeviceWithKeyDown({
+ filters: [{services: ['heart_rate']}],
+ optionalServices: ['generic_access']}))
.then(device => device.gatt.connect())
.then(gattService => gattService.getPrimaryService('generic_access'))
.then(service => service.getCharacteristic('gap.device_name'))
.then(characteristic => {
- testRunner.setBluetoothMockDataSet(
- 'MissingCharacteristicHeartRateAdapter');
- return assert_promise_rejects_with_message(
- characteristic.readValue(), new DOMException(
- 'GATT Characteristic no longer exists.',
- 'InvalidStateError'),
- 'Characteristic got removed.');
+ return setBluetoothFakeAdapter('MissingCharacteristicHeartRateAdapter')
+ .then(() => assert_promise_rejects_with_message(
+ characteristic.readValue(),
+ new DOMException(
+ 'GATT Characteristic no longer exists.',
+ 'InvalidStateError'),
+ 'Characteristic got removed.'));
});
}, 'Characteristic gets removed. Reject with InvalidStateError.');
gatt_errors_tests.forEach(testSpec => {
promise_test(() => {
- testRunner.setBluetoothMockDataSet('FailingGATTOperationsAdapter');
- return requestDeviceWithKeyDown({filters: [{services: [errorUUID(0xA0)]}]})
+ return setBluetoothFakeAdapter('FailingGATTOperationsAdapter')
+ .then(() => requestDeviceWithKeyDown({
+ filters: [{services: [errorUUID(0xA0)]}]}))
.then(device => device.gatt.connect())
.then(gattServer => gattServer.getPrimaryService(errorUUID(0xA0)))
.then(service => service.getCharacteristic(testSpec.uuid))
@@ -77,9 +83,10 @@ gatt_errors_tests.forEach(testSpec => {
});
promise_test(() => {
- testRunner.setBluetoothMockDataSet('HeartRateAdapter');
- return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}],
- optionalServices: ['generic_access']})
+ return setBluetoothFakeAdapter('HeartRateAdapter')
+ .then(() => requestDeviceWithKeyDown({
+ filters: [{services: ['heart_rate']}],
+ optionalServices: ['generic_access']}))
.then(device => device.gatt.connect())
.then(gattServer => gattServer.getPrimaryService('generic_access'))
.then(service => service.getCharacteristic('gap.device_name'))
@@ -92,9 +99,10 @@ promise_test(() => {
}, 'Request for characteristic. Should return right characteristic');
promise_test(() => {
- testRunner.setBluetoothMockDataSet('HeartRateAdapter');
- return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}],
- optionalServices: ['generic_access']})
+ return setBluetoothFakeAdapter('HeartRateAdapter')
+ .then(() => requestDeviceWithKeyDown({
+ filters: [{services: ['heart_rate']}],
+ optionalServices: ['generic_access']}))
.then(device => device.gatt.connect())
.then(gattServer => gattServer.getPrimaryService('generic_access'))
.then(service => service.getCharacteristic('gap.device_name'))

Powered by Google App Engine
This is Rietveld 408576698