-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Modify ProximitySensor tests #19214
Conversation
xiuqijix
commented
Sep 23, 2019
- 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}, |
There was a problem hiding this comment.
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()
.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
proximity/ProximitySensor.https.html
Outdated
|
||
const kReadings = { | ||
readings: [ | ||
[1.12345, 2.12345, true] |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. :)
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
56d8099
to
b0433f0
Compare
- 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] |
There was a problem hiding this comment.
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").
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.")?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
proximity/ProximitySensor.https.html
Outdated
[1.12345, 2.12345, 1] | ||
], | ||
expectedReadings: [ | ||
[1.12345, 2.12345, 1] |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, thank you!
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. |