| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <script src="../resources/testharness.js"></script> | 2 <script src="../resources/testharness.js"></script> |
| 3 <script src="../resources/testharnessreport.js"></script> | 3 <script src="../resources/testharnessreport.js"></script> |
| 4 <script src="../resources/mojo-helpers.js"></script> | 4 <script src="../resources/mojo-helpers.js"></script> |
| 5 <script src="resources/sensor-helpers.js"></script> | 5 <script src="resources/sensor-helpers.js"></script> |
| 6 <script src="resources/generic-sensor-tests.js"></script> | 6 <script src="resources/generic-sensor-tests.js"></script> |
| 7 <script> | 7 <script> |
| 8 | 8 |
| 9 'use strict'; | 9 'use strict'; |
| 10 | 10 |
| 11 if (!window.testRunner) | 11 if (!window.testRunner) |
| 12 debug('This test cannot be run without the TestRunner'); | 12 debug('This test cannot be run without the TestRunner'); |
| 13 | 13 |
| 14 const kDefaultReadingValue = 3.1415; | 14 const kDefaultReadingValue = 3.1415; |
| 15 | 15 |
| 16 function update_sensor_reading(buffer, expects_modified_reading, readsCount) { | 16 function update_sensor_reading(buffer) { |
| 17 buffer[1] = window.performance.now(); | 17 buffer[1] = window.performance.now(); |
| 18 buffer[2] = kDefaultReadingValue; | 18 buffer[2] = kDefaultReadingValue; |
| 19 if (expects_modified_reading) | |
| 20 buffer[2] += readsCount; | |
| 21 } | 19 } |
| 22 | 20 |
| 23 function verify_sensor_reading(reading) { | 21 function verify_sensor_reading(reading) { |
| 24 return reading.illuminance == kDefaultReadingValue; | 22 return reading.illuminance == kDefaultReadingValue; |
| 25 } | 23 } |
| 26 | 24 |
| 27 function verify_sensor_reading(sensor, should_be_null) { | 25 function verify_sensor_reading(sensor, should_be_null) { |
| 28 if (should_be_null) { | 26 if (should_be_null) { |
| 29 return sensor.illuminance == null && | 27 return sensor.illuminance == null && |
| 30 sensor.timestamp == null; | 28 sensor.timestamp == null; |
| 31 } | 29 } |
| 32 return sensor.illuminance == kDefaultReadingValue && | 30 return sensor.illuminance == kDefaultReadingValue && |
| 33 sensor.timestamp != null; | 31 sensor.timestamp != null; |
| 34 } | 32 } |
| 35 | 33 |
| 36 runGenericSensorTests(AmbientLightSensor, update_sensor_reading, verify_sensor_r
eading); | 34 runGenericSensorTests(AmbientLightSensor, update_sensor_reading, verify_sensor_r
eading); |
| 37 </script> | 35 </script> |
| OLD | NEW |