OLD | NEW |
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 Loading... |
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 } |
OLD | NEW |