Chromium Code Reviews| 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> | 6 <script> |
| 7 | 7 |
| 8 'use strict'; | 8 'use strict'; |
| 9 | 9 |
| 10 if (!window.testRunner) | 10 if (!window.testRunner) |
| 11 debug('This test cannot be run without the TestRunner'); | 11 debug('This test cannot be run without the TestRunner'); |
| 12 | 12 |
| 13 const kDefaultReadingValue = 3.1415; | 13 const kDefaultReadingValue = 3.1415; |
| 14 | 14 |
| 15 function update_sensor_reading(buffer) { | 15 function update_sensor_reading(buffer) { |
| 16 buffer[0] = window.performance.now(); | 16 buffer[0] = window.performance.now(); |
| 17 buffer[1] = kDefaultReadingValue; | 17 buffer[1] = kDefaultReadingValue; |
| 18 } | 18 } |
| 19 | 19 |
| 20 test(() => assert_throws( | |
| 21 new RangeError(), | |
| 22 () => new AmbientLightSensor({frequency: -60})), | |
|
timvolodine
2016/09/19 16:52:13
nit: also test for capping at 60?
Mikhail
2016/09/20 13:29:36
Done.
| |
| 23 'Test that negative frequency causes exception from constructor.'); | |
| 24 | |
| 20 sensor_test(sensor => { | 25 sensor_test(sensor => { |
| 21 let ambientLightSensor = new AmbientLightSensor({frequency: 60}); | 26 let ambientLightSensor = new AmbientLightSensor({frequency: 60}); |
|
timvolodine
2016/09/19 16:52:13
just curious here: does the frequency here mean 'm
Mikhail
2016/09/20 13:29:36
that is more 'desired polling frequency', frequenc
timvolodine
2016/09/20 17:46:37
it's not exactly clear what 'desired polling frequ
Mikhail
2016/09/21 10:00:42
That is indeed being discussed in WG atm, however
| |
| 22 ambientLightSensor.start(); | 27 ambientLightSensor.start(); |
| 23 let testPromise = sensor.mockSensorProvider.getCreatedSensor() | 28 let testPromise = sensor.mockSensorProvider.getCreatedSensor() |
| 24 .then((mockSensor) => { | 29 .then((mockSensor) => { |
| 25 return new Promise((resolve, reject) => { | 30 return new Promise((resolve, reject) => { |
| 26 ambientLightSensor.onstatechange = event => { | 31 ambientLightSensor.onstatechange = event => { |
| 27 if (ambientLightSensor.state === 'idle') { | 32 if (ambientLightSensor.state === 'idle') { |
| 28 resolve(mockSensor); | 33 resolve(mockSensor); |
| 29 } | 34 } |
| 30 | 35 |
| 31 if (ambientLightSensor.state === 'active') { | 36 if (ambientLightSensor.state === 'active') { |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 180 ambientLightSensor.onerror = reject; | 185 ambientLightSensor.onerror = reject; |
| 181 }); | 186 }); |
| 182 }) | 187 }) |
| 183 .then(mockSensor => { return mockSensor.removeConfigurationCalled(); }); | 188 .then(mockSensor => { return mockSensor.removeConfigurationCalled(); }); |
| 184 | 189 |
| 185 return testPromise; | 190 return testPromise; |
| 186 }, 'Test that sensor receives suspend / resume notifications when page' | 191 }, 'Test that sensor receives suspend / resume notifications when page' |
| 187 +' visibility changes.'); | 192 +' visibility changes.'); |
| 188 | 193 |
| 189 </script> | 194 </script> |
| OLD | NEW |