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

Side by Side Diff: third_party/WebKit/LayoutTests/sensor/resources/generic-sensor-tests.js

Issue 2686503002: [Sensors] Return 'NotReadableError' exception if failed to find a sensor (Closed)
Patch Set: Created 3 years, 10 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 | third_party/WebKit/Source/modules/sensor/SensorProxy.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 'use strict'; 1 'use strict';
2 2
3 // Run a set of tests for a given |sensorType|. |updateReading| is 3 // Run a set of tests for a given |sensorType|. |updateReading| is
4 // a called by the test to provide the mock values for sensor. |verifyReading| 4 // a called by the test to provide the mock values for sensor. |verifyReading|
5 // is called so that the value read in JavaScript are the values expected (the o nes 5 // is called so that the value read in JavaScript are the values expected (the o nes
6 // sent by |updateReading|). 6 // sent by |updateReading|).
7 function runGenericSensorTests(sensorType, updateReading, verifyReading) { 7 function runGenericSensorTests(sensorType, updateReading, verifyReading) {
8 test(() => assert_throws( 8 test(() => assert_throws(
9 new RangeError(), 9 new RangeError(),
10 () => new sensorType({frequency: -60})), 10 () => new sensorType({frequency: -60})),
11 'Test that negative frequency causes exception from constructor.'); 11 'Test that negative frequency causes exception from constructor.');
12 12
13 sensor_test(sensor => { 13 sensor_test(sensor => {
14 sensor.mockSensorProvider.setGetSensorShouldFail(true); 14 sensor.mockSensorProvider.setGetSensorShouldFail(true);
15 let sensorObject = new sensorType; 15 let sensorObject = new sensorType;
16 sensorObject.start(); 16 sensorObject.start();
17 return new Promise((resolve, reject) => { 17 return new Promise((resolve, reject) => {
18 let wrapper = new CallbackWrapper(event => { 18 let wrapper = new CallbackWrapper(event => {
19 assert_equals(sensorObject.state, 'errored'); 19 assert_equals(sensorObject.state, 'errored');
20 assert_equals(event.error.name, 'NotFoundError'); 20 assert_equals(event.error.name, 'NotReadableError');
21 sensorObject.onerror = null; 21 sensorObject.onerror = null;
22 resolve(); 22 resolve();
23 }, reject); 23 }, reject);
24 24
25 sensorObject.onerror = wrapper.callback; 25 sensorObject.onerror = wrapper.callback;
26 }); 26 });
27 }, 'Test that "onerror" is send when sensor is not supported.'); 27 }, 'Test that "onerror" is send when sensor is not supported.');
28 28
29 sensor_test(sensor => { 29 sensor_test(sensor => {
30 let sensorObject = new sensorType({frequency: 560}); 30 let sensorObject = new sensorType({frequency: 560});
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 327
328 sensor_test(sensor => { 328 sensor_test(sensor => {
329 return checkFrequencyHintWorks(sensor); 329 return checkFrequencyHintWorks(sensor);
330 }, 'Test that frequency hint works (onchange reporting).'); 330 }, 'Test that frequency hint works (onchange reporting).');
331 331
332 sensor_test(sensor => { 332 sensor_test(sensor => {
333 sensor.mockSensorProvider.setContinuousReportingMode(); 333 sensor.mockSensorProvider.setContinuousReportingMode();
334 return checkFrequencyHintWorks(sensor); 334 return checkFrequencyHintWorks(sensor);
335 }, 'Test that frequency hint works (continuous reporting).'); 335 }, 'Test that frequency hint works (continuous reporting).');
336 } 336 }
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/sensor/SensorProxy.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698