mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-27 20:25:44 +00:00
d8823a497f
Automatic update from web-platform-tests Update WebXR TestAPI and tests to match new spec (#17630) Now that WebXR is more mature, the test API is being revisited with input from other UAs. This change updates existing methods and tests to match the new API, which largely involves: * FakeXRDeviceInit now requires views * FakeXRDeviceInit *CAN* support an initial viewerOrigin * setXRPresentationFrameData is now setViews and set/clearViewerOrigin * XRTest is now navigator.xr.test [1] As part of this, webxr_test_constants were cleaned up and expanded to help minimize boilerplate code in the tests. Where possible tests that were previously calling setXRPresentationFrameData to ensure that the fake device was "tracking" were updated to instead use a constant that sets these values. Future work (after the API update is complete) will identify if there are any cases where an initial requestAnimationFrame could be removed. Most changes (especially to vr/ tests) should be fairly mechanical, but now that the eye offsets expected/set by the test are actually being plumbed through, both xr/xrReferenceSpace_originOffset tests had to have their expected matrices updated. Two tests had to be updated due to the discovery of 981003. Other changes to update to the Test API after this change should be mostly additive and should actually already exist in the internal tests. [1] XRTest currently still exists as a workaround until 944987 is merged Also due to the fact that accessing xr blocks VR, the WebVR tests had to be updated to set a special flag to tell the test API to not set the object on XR. It's unlikely that this behavior will be able to be removed after 944987, but to allow XRTest to be removed these tests have had it migrated to navigator.vr.test Bug:979312 Change-Id: I19ccffd921728ec3799252693d945b7b3f99d757 -- wpt-commits: 3f8ee365a7cacc091dc1dd1d0b5f21a89241c894 wpt-pr: 17630
102 lines
3.7 KiB
HTML
102 lines
3.7 KiB
HTML
<!DOCTYPE html>
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<script src="resources/webxr_test_constants.js"></script>
|
|
<script src="resources/webxr_test_asserts.js"></script>
|
|
<script src="resources/webxr_math_utils.js"></script>
|
|
<script>
|
|
|
|
let matrix_tests_name = "XRRay matrix works";
|
|
|
|
let matrix_tests = function() {
|
|
// Matrix tests for XRRay.
|
|
// Spec: https://immersive-web.github.io/webxr/#xrray-interface
|
|
|
|
const initialOrigin = {x : 0, y : 0, z : 0, w : 1};
|
|
const initialDirection = {x : 0, y : 0, z : -1, w : 0};
|
|
|
|
// Test 1. Simple translation and rotation.
|
|
{
|
|
let originDict = {x : 10.0, y : 10.0, z : 10.0, w : 1.0};
|
|
let directionDict = {x : 10.0, y : 0.0, z : 0.0, w : 0.0};
|
|
let directionNorm = {x : 1.0, y : 0.0, z : 0.0, w : 0.0};
|
|
let xrRay = new XRRay(
|
|
DOMPoint.fromPoint(originDict),
|
|
DOMPoint.fromPoint(directionDict));
|
|
|
|
let transformedOrigin = normalize_perspective(transform_point_by_matrix(xrRay.matrix, initialOrigin));
|
|
let transformedDirection = normalize_perspective(transform_point_by_matrix(xrRay.matrix, initialDirection));
|
|
|
|
assert_point_approx_equals(
|
|
originDict, transformedOrigin,
|
|
FLOAT_EPSILON, "origin-test1:");
|
|
assert_point_approx_equals(
|
|
directionNorm, transformedDirection,
|
|
FLOAT_EPSILON, "direction-test1:");
|
|
}
|
|
|
|
// Test 2. Co-linear direction - rotation by 180 deg.
|
|
{
|
|
let originDict = {x : 10.0, y : 10.0, z : 10.0, w : 1.0};
|
|
let directionDict = {x : 0.0, y : 0.0, z : 1.0, w : 0.0};
|
|
let directionNorm = {x : 0.0, y : 0.0, z : 1.0, w : 0.0};
|
|
let xrRay = new XRRay(
|
|
DOMPoint.fromPoint(originDict),
|
|
DOMPoint.fromPoint(directionDict));
|
|
|
|
let transformedOrigin = normalize_perspective(transform_point_by_matrix(xrRay.matrix, initialOrigin));
|
|
let transformedDirection = normalize_perspective(transform_point_by_matrix(xrRay.matrix, initialDirection));
|
|
|
|
assert_point_approx_equals(
|
|
originDict, transformedOrigin,
|
|
FLOAT_EPSILON, "origin-test2:");
|
|
assert_point_approx_equals(
|
|
directionNorm, transformedDirection,
|
|
FLOAT_EPSILON, "direction-test2:");
|
|
}
|
|
|
|
// Test 3. No translation.
|
|
{
|
|
let originDict = {x : 0.0, y : 0.0, z : 0.0, w : 1.0};
|
|
let directionDict = {x : 10.0, y : 0.0, z : 0.0, w : 0.0};
|
|
let directionNorm = {x : 1.0, y : 0.0, z : 0.0, w : 0.0};
|
|
let xrRay = new XRRay(
|
|
DOMPoint.fromPoint(originDict),
|
|
DOMPoint.fromPoint(directionDict));
|
|
|
|
let transformedOrigin = normalize_perspective(transform_point_by_matrix(xrRay.matrix, initialOrigin));
|
|
let transformedDirection = normalize_perspective(transform_point_by_matrix(xrRay.matrix, initialDirection));
|
|
|
|
assert_point_approx_equals(
|
|
originDict, transformedOrigin,
|
|
FLOAT_EPSILON, "origin-test3:");
|
|
assert_point_approx_equals(
|
|
directionNorm, transformedDirection,
|
|
FLOAT_EPSILON, "direction-test3:");
|
|
}
|
|
|
|
// Test 4. No rotation.
|
|
{
|
|
let originDict = {x : 10.0, y : 10.0, z : 10.0, w : 1.0};
|
|
let directionDict = {x : 0.0, y : 0.0, z : -1.0, w : 0.0};
|
|
let directionNorm = {x : 0.0, y : 0.0, z : -1.0, w : 0.0};
|
|
let xrRay = new XRRay(
|
|
DOMPoint.fromPoint(originDict),
|
|
DOMPoint.fromPoint(directionDict));
|
|
|
|
let transformedOrigin = normalize_perspective(transform_point_by_matrix(xrRay.matrix, initialOrigin));
|
|
let transformedDirection = normalize_perspective(transform_point_by_matrix(xrRay.matrix, initialDirection));
|
|
|
|
assert_point_approx_equals(
|
|
originDict, transformedOrigin,
|
|
FLOAT_EPSILON, "origin-test4:");
|
|
assert_point_approx_equals(
|
|
directionNorm, transformedDirection,
|
|
FLOAT_EPSILON, "direction-test4:");
|
|
}
|
|
};
|
|
|
|
test(matrix_tests, matrix_tests_name);
|
|
|
|
</script>
|