mirror of
https://github.com/servo/servo.git
synced 2025-10-17 08:49:21 +01:00
63 lines
2.4 KiB
HTML
63 lines
2.4 KiB
HTML
<!DOCTYPE html>
|
|
<meta charset="utf-8">
|
|
<title>AmbientLightSensor Test</title>
|
|
<meta name="timeout" content="long">
|
|
<link rel="author" title="Intel" href="http://www.intel.com">
|
|
<link rel="help" href="https://www.w3.org/TR/ambient-light/">
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<script src="/generic-sensor/resources/generic-sensor-helpers.js"></script>
|
|
<script src="/generic-sensor/generic-sensor-tests.js"></script>
|
|
<script>
|
|
|
|
'use strict';
|
|
|
|
const kReadings = {
|
|
readings: [
|
|
// Readings are selected so that illuminance significance check causes
|
|
// the following to happen:
|
|
// 1. First two values test situation when two values would be rounded
|
|
// to same value. As the second value would be rounded to same value
|
|
// as first it won't trigger reading event.
|
|
// 2. New value is set to 24. And test checks it is correctly rounded to
|
|
// 0.
|
|
// 3. New reading is attempted to set to 35.
|
|
// 4. Value is read from sensor and compared new reading. But as new
|
|
// reading was not significantly different compared to initial, for
|
|
// privacy reasons, service returns the initial value.
|
|
// 5. New value is set to 49. And test checks it is correctly rounded to
|
|
// 50. New value is allowed as it is significantly different compared
|
|
// to old value (24).
|
|
// 6. New reading is attempted to set to 35.
|
|
// 7. Value is read from sensor and compared new reading. But as new
|
|
// reading was not significantly different compared to initial, for
|
|
// privacy reasons, service returns the initial value.
|
|
// 8. New value is set to 23. And test checks it is correctly rounded to
|
|
// 0. New value is allowed as it is significantly different compared
|
|
// to old value (49).
|
|
//
|
|
// Note: Readings and expectedReadings wraps around correctly as next
|
|
// value would be 150 (output from 127).
|
|
[127],
|
|
[165],
|
|
[24],
|
|
[35],
|
|
[49],
|
|
[35],
|
|
[23]
|
|
],
|
|
expectedReadings: [
|
|
[150], // output from 127
|
|
[0], // output from 24
|
|
[50], // output from 49
|
|
[0] // output from 23
|
|
]
|
|
};
|
|
|
|
runGenericSensorTests(
|
|
'AmbientLightSensor',
|
|
kReadings,
|
|
verifyAlsSensorReading,
|
|
['ambient-light-sensor']);
|
|
|
|
</script>
|