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) |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 ambientLightSensor.onstatechange = wrapper.callback; | 97 ambientLightSensor.onstatechange = wrapper.callback; |
98 ambientLightSensor.onerror = reject; | 98 ambientLightSensor.onerror = reject; |
99 }); | 99 }); |
100 }) | 100 }) |
101 .then(mockSensor => { return mockSensor.removeConfigurationCalled(); }); | 101 .then(mockSensor => { return mockSensor.removeConfigurationCalled(); }); |
102 | 102 |
103 return testPromise; | 103 return testPromise; |
104 }, 'Test that frequency is capped to 60.0 Hz.'); | 104 }, 'Test that frequency is capped to 60.0 Hz.'); |
105 | 105 |
106 sensor_test(sensor => { | 106 sensor_test(sensor => { |
| 107 let maxSupportedFrequency = 15; |
| 108 sensor.mockSensorProvider.setMaximumSupportedFrequency(maxSupportedFrequency); |
| 109 let ambientLightSensor = new AmbientLightSensor({frequency: 50}); |
| 110 ambientLightSensor.start(); |
| 111 |
| 112 let testPromise = sensor.mockSensorProvider.getCreatedSensor() |
| 113 .then(mockSensor => { return mockSensor.addConfigurationCalled(); }) |
| 114 .then(mockSensor => { |
| 115 return new Promise((resolve, reject) => { |
| 116 ambientLightSensor.onstatechange = event => { |
| 117 if (ambientLightSensor.state === 'idle') { |
| 118 resolve(mockSensor); |
| 119 } |
| 120 |
| 121 if (ambientLightSensor.state === 'active') { |
| 122 let configuration = mockSensor.active_sensor_configurations_[0]; |
| 123 assert_equals(configuration.frequency, maxSupportedFrequency); |
| 124 ambientLightSensor.stop(); |
| 125 } |
| 126 }; |
| 127 }); |
| 128 }) |
| 129 .then(mockSensor => { return mockSensor.removeConfigurationCalled(); }); |
| 130 |
| 131 return testPromise; |
| 132 }, 'Test that frequency is capped to the maximum supported from frequency.'); |
| 133 |
| 134 sensor_test(sensor => { |
107 let ambientLightSensor = new AmbientLightSensor({frequency: 60}); | 135 let ambientLightSensor = new AmbientLightSensor({frequency: 60}); |
108 ambientLightSensor.start(); | 136 ambientLightSensor.start(); |
109 let testPromise = sensor.mockSensorProvider.getCreatedSensor() | 137 let testPromise = sensor.mockSensorProvider.getCreatedSensor() |
110 .then((mockSensor) => { | 138 .then((mockSensor) => { |
111 return new Promise((resolve, reject) => { | 139 return new Promise((resolve, reject) => { |
112 ambientLightSensor.onstatechange = event => { | 140 ambientLightSensor.onstatechange = event => { |
113 if (ambientLightSensor.state == 'idle') { | 141 if (ambientLightSensor.state == 'idle') { |
114 resolve(mockSensor); | 142 resolve(mockSensor); |
115 } | 143 } |
116 | 144 |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 sensor1.onerror = reject; | 351 sensor1.onerror = reject; |
324 sensor2.onerror = reject; | 352 sensor2.onerror = reject; |
325 }); | 353 }); |
326 }) | 354 }) |
327 .then(mockSensor => { return mockSensor.removeConfigurationCalled(); }); | 355 .then(mockSensor => { return mockSensor.removeConfigurationCalled(); }); |
328 | 356 |
329 return testPromise; | 357 return testPromise; |
330 }, 'Test that sensor reading is correct.'); | 358 }, 'Test that sensor reading is correct.'); |
331 | 359 |
332 </script> | 360 </script> |
OLD | NEW |