summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/ambient-light/AmbientLightSensor.https.html
blob: a8c65e4d3faf710bdc0064c5c968e1f486fe56ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!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>