Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/bluetooth/requestDevice-matches-a-filter.html |
| diff --git a/third_party/WebKit/LayoutTests/bluetooth/requestDevice-matches-a-filter.html b/third_party/WebKit/LayoutTests/bluetooth/requestDevice-matches-a-filter.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2d2eba608391d646be9ab9bf92f8fad98270abe2 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/bluetooth/requestDevice-matches-a-filter.html |
| @@ -0,0 +1,148 @@ |
| +<!DOCTYPE html> |
|
scheib
2015/10/22 04:58:42
I'm confused by file name again. The first 2 block
ortuno
2015/10/22 16:21:31
Similarly here. The name comes from the "Matches a
|
| +<script src="../resources/testharness.js"></script> |
| +<script src="../resources/testharness-helpers.js"></script> |
| +<script src="../resources/testharnessreport.js"></script> |
| +<script src="resources/bluetooth-helpers.js"></script> |
| +<script> |
| +'use strict'; |
| + |
| +test(function(t) { assert_true(window.testRunner instanceof Object); t.done(); }, |
| + 'window.testRunner is required for the following tests.'); |
| + |
| +let matching_services = [heart_rate.uuid]; |
| +let matching_name = 'Heart Rate Device'; |
| +let matching_namePrefix = 'Heart'; |
| + |
| +let non_matching_services = ['battery_service']; |
| +let non_matching_name = 'Some Device'; |
| +let non_matching_namePrefix = 'Some'; |
| + |
| +[{ |
| + filters: [{ |
| + services: non_matching_services, |
| + name: non_matching_name, |
| + namePrefix: non_matching_namePrefix |
| + }] |
| +}, { |
| + filters: [{ |
| + services: matching_services, |
| + name: non_matching_name, |
| + namePrefix: non_matching_namePrefix |
| + }] |
| +}, { |
| + filters: [{ |
| + services: non_matching_services, |
| + name: matching_name, |
| + namePrefix: non_matching_namePrefix |
| + }] |
| +}, { |
| + filters: [{ |
| + services: matching_services, |
| + name: matching_name, |
| + namePrefix: non_matching_namePrefix |
| + }] |
| +}, { |
| + filters: [{ |
| + services: non_matching_services, |
| + name: non_matching_name, |
| + namePrefix: matching_namePrefix |
| + }] |
| +}, { |
| + filters: [{ |
| + services: matching_services, |
| + name: non_matching_name, |
| + namePrefix: matching_namePrefix |
| + }] |
| +}, { |
| + filters: [{ |
| + services: non_matching_services, |
| + name: matching_name, |
| + namePrefix: matching_namePrefix |
| + }] |
| +}].forEach(args => { |
| + promise_test(() => { |
| + testRunner.setBluetoothMockDataSet('GlucoseHeartRateAdapter'); |
| + return assert_promise_rejects(requestDeviceWithKeyDown(args), |
| + 'NotFoundError'); |
| + }, 'If at least one filter doesn\'t match the promise must reject.'); |
| +}); |
| + |
| +[{ |
| + filters: [{ |
| + services: non_matching_services, |
| + }] |
| +}, { |
| + filters: [{ |
| + services: non_matching_services, |
| + name: non_matching_name, |
| + }] |
| +}, { |
| + filters: [{ |
| + services: non_matching_services, |
| + namePrefix: non_matching_namePrefix |
| + }] |
| +}, { |
| + filters: [{ |
| + name: non_matching_name, |
| + }] |
| +}, { |
| + filters: [{ |
| + name: non_matching_name, |
| + namePrefix: non_matching_namePrefix |
| + }] |
| +}, { |
| + filters: [{ |
| + namePrefix: non_matching_namePrefix |
| + }] |
| +}].forEach(args => { |
| + promise_test(() => { |
| + testRunner.setBluetoothMockDataSet('GlucoseHeartRateAdapter'); |
| + return assert_promise_rejects(requestDeviceWithKeyDown(args), |
| + 'NotFoundError'); |
| + }, 'If a present filter doesn\'t match the device doesn\'t match the filter.'); |
|
scheib
2015/10/22 04:58:42
If any part of the filter doesn't match ...
ortuno
2015/10/22 16:21:31
Done.
|
| +}); |
| + |
| +[{ |
| + filters: [{ |
| + services: matching_services, |
| + }] |
| +}, { |
| + filters: [{ |
| + services: matching_services, |
| + name: matching_name, |
| + }] |
| +}, { |
| + filters: [{ |
| + services: matching_services, |
| + namePrefix: matching_namePrefix |
| + }] |
| +}, { |
| + filters: [{ |
| + name: matching_name, |
| + }] |
| +}, { |
| + filters: [{ |
| + name: matching_name, |
| + namePrefix: matching_namePrefix |
| + }] |
| +}, { |
| + filters: [{ |
| + namePrefix: matching_namePrefix |
| + }] |
| +}, { |
| + filters: [{ |
| + services: matching_services, |
| + name: matching_name, |
| + namePrefix: matching_namePrefix |
| + }] |
| +}].forEach(args => { |
| + promise_test(() => { |
| + testRunner.setBluetoothMockDataSet('GlucoseHeartRateAdapter'); |
| + return requestDeviceWithKeyDown(args).then(device => { |
| + assert_in_array(matching_services[0], device.uuids); |
| + assert_equals(device.name, matching_name); |
| + assert_true(device.name.startsWith(matching_namePrefix)); |
| + }); |
| + }, 'Matches a filter if all present members match.') |
| +}); |
| +</script> |