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

Side by Side Diff: LayoutTests/bluetooth/requestDevice.html

Issue 1174843002: Add tests for RequestDeviceOptions and clean up. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@pinned
Patch Set: Comment how the ScanFilterCheckingAdapter test works Created 5 years, 6 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 unified diff | Download patch
« no previous file with comments | « LayoutTests/bluetooth/readValue.html ('k') | public/platform/modules/bluetooth/WebBluetooth.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script> 2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharness-helpers.js"></script> 3 <script src="../resources/testharness-helpers.js"></script>
4 <script src="../resources/testharnessreport.js"></script> 4 <script src="../resources/testharnessreport.js"></script>
5 <script src="bluetooth-helpers.js"></script> 5 <script src="bluetooth-helpers.js"></script>
6 <script> 6 <script>
7 test(function(t) { assert_exists(window, "testRunner"); t.done(); }, 7 test(function(t) { assert_exists(window, "testRunner"); t.done(); },
8 "window.testRunner is required for the following tests."); 8 "window.testRunner is required for the following tests.");
9 9
10 sequential_promise_test(function() { 10 sequential_promise_test(function() {
(...skipping 20 matching lines...) Expand all
31 }, 'Reject with NotFoundError.'); 31 }, 'Reject with NotFoundError.');
32 32
33 sequential_promise_test(function() { 33 sequential_promise_test(function() {
34 testRunner.setBluetoothMockDataSet('SingleEmptyDeviceAdapter'); 34 testRunner.setBluetoothMockDataSet('SingleEmptyDeviceAdapter');
35 return navigator.bluetooth.requestDevice({ 35 return navigator.bluetooth.requestDevice({
36 filters: [{services: [genericAccessServiceUuid]}] 36 filters: [{services: [genericAccessServiceUuid]}]
37 }).then(function(device) { 37 }).then(function(device) {
38 assert_equals(device.constructor.name, "BluetoothDevice"); 38 assert_equals(device.constructor.name, "BluetoothDevice");
39 }); 39 });
40 }, 'Mock will resolve.'); 40 }, 'Mock will resolve.');
41
42 sequential_promise_test(function() {
43 testRunner.setBluetoothMockDataSet('ScanFilterCheckingAdapter');
44 // The work of this test is done in the ScanFilterCheckingAdapter. It asserts
45 // that this requestDevice() call tells the platform to scan for only devices
46 // that include the Battery, Glucose, or Heart Rate services.
47 return navigator.bluetooth.requestDevice({
48 filters: [
49 {services: [batteryServiceUuid]},
50 {services: [glucoseServiceUuid, heartRateServiceUuid]}
51 ],
52 // The optionalServices shouldn't affect the platform's scan.
53 optionalServices: [genericAccessServiceUuid]
54 });
55 }, 'Filters restrict the platform\'s Bluetooth scan.');
56
57 sequential_promise_test(function() {
58 testRunner.setBluetoothMockDataSet('MultiDeviceAdapter');
59 return navigator.bluetooth.requestDevice({
60 filters: [{services: [glucoseServiceUuid]}]
ortuno 2015/06/18 22:04:42 If you pass something other than a string, say an
61 }).then(function(device) {
62 assert_equals(device.name, "Glucose Device");
63 });
64 }, 'Simple filter selects matching device.');
65
66 sequential_promise_test(function() {
67 testRunner.setBluetoothMockDataSet('MultiDeviceAdapter');
68 return navigator.bluetooth.requestDevice({
69 filters: [{services: [genericAccessServiceUuid, heartRateServiceUuid]}]
70 }).then(function(device) {
71 assert_equals(device.name, "Heart Rate Device");
72 });
73 }, 'Filter with 2 services returns a matching device.');
74
75 sequential_promise_test(function() {
76 testRunner.setBluetoothMockDataSet('MultiDeviceAdapter');
77 return navigator.bluetooth.requestDevice({
78 filters: [{services: [batteryServiceUuid]},
79 {services: [heartRateServiceUuid]}]
80 }).then(function(device) {
81 assert_equals(device.name, "Heart Rate Device");
82 });
83 }, 'An extra filter doesn\'t prevent matching.');
84
85 sequential_promise_test(function() {
86 testRunner.setBluetoothMockDataSet('MultiDeviceAdapter');
87 // Both devices support the Generic Access service, but things need to
88 // support both services to pass the filter, and neither has a Battery
89 // service.
90 return assert_promise_rejects(navigator.bluetooth.requestDevice({
91 filters: [{services: [genericAccessServiceUuid, batteryServiceUuid]}]
92 }), 'NotFoundError');
93 }, 'Too-strict filters do prevent matching.');
94
41 </script> 95 </script>
OLDNEW
« no previous file with comments | « LayoutTests/bluetooth/readValue.html ('k') | public/platform/modules/bluetooth/WebBluetooth.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698