Skip to content

Commit

Permalink
[sensor] Upstream sensor layout tests to wpt
Browse files Browse the repository at this point in the history
Rewrote /external/wpt/resources/chromium/generic_sensor_mocks.js to align with
/http/tests/resources/sensor-helpers.js, but excluded those functions specific
for device orientation.

Merged tests from /sensor/resources/generic-sensor-tests.js to
/external/wpt/generic-sensor/generic-sensor-tests.js

Moved common utils into /external/wpt/generic-sensor/resources/generic-sensor-helpers.js

Merged tests from /sensor/*.html to corresponding test folders under /external/wpt/,
e.g. sensor/orientation-sensor.html  -> external/wpt/orientation-sensor/OrientationSensor.https.html

Updated all sensor tests under external/wpt/ to adapt to sensor mojom mocks

Deleted folder web_tests/sensor/

Bug: 816462
Change-Id: I614ce82b7c90530b7a268d8f6a0f72cc96ea3d6f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1770158
Commit-Queue: Wanming Lin <[email protected]>
Reviewed-by: Reilly Grant <[email protected]>
Cr-Commit-Position: refs/heads/master@{#695905}
  • Loading branch information
Honry authored and chromium-wpt-export-bot committed Sep 18, 2019
1 parent a1e7e0b commit db7bad0
Show file tree
Hide file tree
Showing 26 changed files with 832 additions and 445 deletions.
2 changes: 1 addition & 1 deletion accelerometer/Accelerometer-iframe-access.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<link rel="help" href="https://www.w3.org/TR/accelerometer/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/generic-sensor/generic-sensor-tests.js"></script>
<script src="/generic-sensor/resources/generic-sensor-helpers.js"></script>
<script src="/generic-sensor/generic-sensor-iframe-tests.sub.js"></script>
<script src="/generic-sensor/generic-sensor-feature-policy-test.sub.js"></script>
<div id="log"></div>
Expand Down
36 changes: 32 additions & 4 deletions accelerometer/Accelerometer.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,40 @@
<link rel="help" href="https://www.w3.org/TR/accelerometer/">
<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>
<div id="log"></div>
<script>

runGenericSensorTests('Accelerometer');
runGenericSensorTests('GravitySensor');
runGenericSensorTests('LinearAccelerationSensor');
'use strict';

const kReadings = {
readings: [
[1.12345, 2.12345, 3.12345]
],
expectedReadings: [
[1.12345, 2.12345, 3.12345]
],
expectedRemappedReadings: [
[-2.12345, 1.12345, 3.12345]
]
};

runGenericSensorTests(
'Accelerometer',
kReadings,
verifyXyzSensorReading,
['accelerometer']);

runGenericSensorTests(
'GravitySensor',
kReadings,
verifyXyzSensorReading,
['accelerometer']);

runGenericSensorTests(
'LinearAccelerationSensor',
kReadings,
verifyXyzSensorReading,
['accelerometer']);

</script>
22 changes: 0 additions & 22 deletions accelerometer/Accelerometer_onerror-manual.https.html

This file was deleted.

2 changes: 1 addition & 1 deletion ambient-light/AmbientLightSensor-iframe-access.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link rel="help" href="https://w3c.github.io/ambient-light/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/generic-sensor/generic-sensor-tests.js"></script>
<script src="/generic-sensor/resources/generic-sensor-helpers.js"></script>
<script src="/generic-sensor/generic-sensor-iframe-tests.sub.js"></script>
<script src="/generic-sensor/generic-sensor-feature-policy-test.sub.js"></script>
<div id="log"></div>
Expand Down
19 changes: 17 additions & 2 deletions ambient-light/AmbientLightSensor.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,25 @@
<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>
<div id="log"></div>
<script>

runGenericSensorTests('AmbientLightSensor');
'use strict';

const kReadings = {
readings: [
[3.1415]
],
expectedReadings: [
[3.1415]
]
};

runGenericSensorTests(
'AmbientLightSensor',
kReadings,
verifyAlsSensorReading,
['ambient-light-sensor']);

</script>
20 changes: 0 additions & 20 deletions ambient-light/AmbientLightSensor_onerror-manual.https.html

This file was deleted.

24 changes: 22 additions & 2 deletions generic-sensor/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,31 @@
The `generic-sensor-tests.js` tests require an implementation of
The `resources/generic-sensor-helpers.js` tests require an implementation of
the `GenericSensorTest` interface, which should emulate platform
sensor backends. The `GenericSensorTest` interface is defined as:

```
class MockSensor {
// Sets fake data that is used to deliver sensor reading updates.
async setSensorReading(FrozenArray<double> readingData);
setStartShouldFail(boolean shouldFail); // Sets flag that forces sensor to fail.
getSamplingFrequency(); // Return the sampling frequency.
};
class MockSensorProvider {
// Sets flag that forces mock SensorProvider to fail when getSensor() is
// invoked.
setGetSensorShouldFail(DOMString sensorType, boolean shouldFail);
// Sets flag that forces mock SensorProvider to permissions denied when
// getSensor() is invoked.
setPermissionsDenied(DOMString sensorType, boolean permissionsDenied);
getCreatedSensor(DOMString sensorType); // Return `MockSensor` interface.
setMaximumSupportedFrequency(double frequency); // Sets the maximum frequency.
setMinimumSupportedFrequency(double frequency); // Sets the minimum frequency.
}
class GenericSensorTest {
async initialize(); // Sets up the testing enviroment.
initialize(); // Sets up the testing environment.
async reset(); // Frees the resources.
getSensorProvider(); // Returns `MockSensorProvider` interface.
};
```

Expand Down
Loading

0 comments on commit db7bad0

Please sign in to comment.