Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify ProximitySensor tests #19214

Merged
merged 3 commits into from
Sep 27, 2019

Conversation

xiuqijix
Copy link
Contributor

  • Support mock sensor
  • Add verifyProSensorReading function

@@ -92,6 +93,11 @@ function verifyGeoSensorReading(pattern, {latitude, longitude, altitude,
accuracy, altitudeAccuracy, heading, speed], timestamp, isNull);
}

function verifyProSensorReading(pattern, {distance, max, near, timestamp},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Abbreviating "proximity" to "pro" is confusing. I'd rather call this verifyProximitySensorReading().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -92,6 +93,11 @@ function verifyGeoSensorReading(pattern, {latitude, longitude, altitude,
accuracy, altitudeAccuracy, heading, speed], timestamp, isNull);
}

function verifyProSensorReading(pattern, {distance, max, near, timestamp},
isNull) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need for this line break here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


const kReadings = {
readings: [
[1.12345, 2.12345, true]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is supposed to be a raw reading value, so a boolean does not make much sense here. For proper testing, you should provide a number that the sensor code will convert into a boolean.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ProximitySensor is not supported in mojo yet, so I think we could optimize this in future. If you agree on this, I will add a TODO note. :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean it's not handled in resources/chromium/generic_sensor_mocks.js? If that's the case, it should be pretty easy to add the required bits there in this PR to make it complete. If not, can you clarify what you're referring to, and how this has been tested so far?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -62,6 +62,7 @@ function sensor_test(func, name, properties) {

function verifySensorReading(pattern, values, timestamp, isNull) {
function round(val) {
if (typeof(val) === "boolean") return val;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this special handling here, but I understand that the proximity sensor is the first case where we are testing a non-numeric property as well. I'd rather do something that just returns val if the float conversion below fails.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

- Support mock sensor
- Add verifyProSensorReading function
@@ -150,7 +150,8 @@ var GenericSensorTest = (() => {
['RelativeOrientationSensor',
device.mojom.SensorType.RELATIVE_ORIENTATION_QUATERNION],
['RelativeOrientationEulerAngles',
device.mojom.SensorType.RELATIVE_ORIENTATION_EULER_ANGLES]
device.mojom.SensorType.RELATIVE_ORIENTATION_EULER_ANGLES],
['proximity', device.mojom.SensorType.PROXIMITY]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name does not match the one you are using in ProximitySensor.https.html ("ProximitySensor").

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -62,7 +62,8 @@ function sensor_test(func, name, properties) {

function verifySensorReading(pattern, values, timestamp, isNull) {
function round(val) {
return Number.parseFloat(val).toPrecision(6);
const res = Number.parseFloat(val).toPrecision(6);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment explaining why we do this (something like "If |val| cannot be converted to a float, we return the original value. This can happen when a value in |pattern| is not a number.")?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

[1.12345, 2.12345, 1]
],
expectedReadings: [
[1.12345, 2.12345, 1]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one should be true rather than 1. readings are raw readings passed by the mocked platform, expectedReadings are the sanitized values obtained from a sensor object.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Member

@rakuco rakuco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thank you!

@rakuco rakuco closed this Sep 26, 2019
@rakuco rakuco reopened this Sep 26, 2019
@rakuco
Copy link
Member

rakuco commented Sep 26, 2019

@jgraham @Hexcles any idea why infrastructure/tests are failing? I'm assuming it's unrelated, but the logs aren't very clear. Is it /infrastructure/testdriver/generate_test_report.html failing on Firefox or something with the Chrome run afterwards?

@foolip
Copy link
Member

foolip commented Sep 27, 2019

Taskcluster failing the infrastructure/ tests is likely because of #19362. There's a workaround in place so I'll close and reopen to retrigger all CI.

@foolip foolip closed this Sep 27, 2019
@foolip foolip reopened this Sep 27, 2019
@rakuco rakuco merged commit ccd18e2 into web-platform-tests:master Sep 27, 2019
@xiuqijix xiuqijix deleted the sensor_proximity branch October 8, 2019 02:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants