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

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

Issue 1348953004: Test that the chooser can initiate device re-discovery. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@test-chooser
Patch Set: Adjust to new getBluetoothManualChooserEvents() interface. Created 5 years, 3 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 | « no previous file | no next file » | 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="resources/bluetooth-helpers.js"></script> 5 <script src="resources/bluetooth-helpers.js"></script>
6 <script> 6 <script>
7 'use strict'; 7 'use strict';
8 8
9 test(function(t) { assert_true(window.testRunner instanceof Object); t.done(); } , 9 test(function(t) { assert_true(window.testRunner instanceof Object); t.done(); } ,
10 'window.testRunner is required for the following tests.'); 10 'window.testRunner is required for the following tests.');
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 184
185 promise_test(() => { 185 promise_test(() => {
186 testRunner.setBluetoothMockDataSet('GlucoseHeartRateAdapter'); 186 testRunner.setBluetoothMockDataSet('GlucoseHeartRateAdapter');
187 // Both devices support the Generic Access service, but things need to 187 // Both devices support the Generic Access service, but things need to
188 // support both services to pass the filter, and neither has a Battery 188 // support both services to pass the filter, and neither has a Battery
189 // service. 189 // service.
190 return assert_promise_rejects(requestDeviceWithKeyDown({ 190 return assert_promise_rejects(requestDeviceWithKeyDown({
191 filters: [{services: ['generic_access', 'battery_service']}] 191 filters: [{services: ['generic_access', 'battery_service']}]
192 }), 'NotFoundError'); 192 }), 'NotFoundError');
193 }, 'Too-strict filters do prevent matching.'); 193 }, 'Too-strict filters do prevent matching.');
194
195 promise_test(() => {
196 testRunner.setBluetoothMockDataSet('SecondDiscoveryFindsHeartRateAdapter');
197 testRunner.setBluetoothManualChooser();
198
199 // Open the chooser, looking for a Heart Rate device.
200 let requestDevicePromise = requestDeviceWithKeyDown({
201 filters: [{services: ['heart_rate']}]
202 });
203
204 // The adapter finds nothing, so we just see discovery start and stop.
205 getBluetoothManualChooserEvents(3).then(events => {
206 assert_array_equals(events,
207 ['chooser-opened(file:///)',
208 'discovering',
209 'discovery-idle',
210 ]);
211
212 // On the second discovery, the adapter finds the Heart Rate device.
213 testRunner.sendBluetoothManualChooserEvent('rescan', '');
214 return getBluetoothManualChooserEvents(3);
215 }).then(events => {
216 assert_equals(events.length, 3, events);
217 assert_equals(events[0], 'discovering', 'events[0]');
218 let idsByName = new AddDeviceEventSet();
219 idsByName.assert_add_device_event(events[1]);
220 assert_true(idsByName.has('Heart Rate Device'));
221 assert_equals(events[2], 'discovery-idle');
222
223 // Select it and let the test complete.
224 testRunner.sendBluetoothManualChooserEvent('selected',
225 idsByName.get('Heart Rate Device' ));
226 return requestDevicePromise;
227 }).then(device => assert_equals(device.name, 'Heart Rate Device'));
228 }, 'The chooser can restart the BT scan.');
194 </script> 229 </script>
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698