-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update FakeXRDeviceInterface to match webxr-test-api
This updates the FakeXRDeviceInterface to support newly added methods in the webxr-test-api: * simulateVisibilityChange * setBoundsGeometry * setLocalToFloorLevelTransform * clearLocalToFloorLevelTransform and supports the setting of boundsCoordinates and localToFloorLevelTransform in FakeXRDeviceInit. The Bounds and LocalToFloorLevelTransform functions already existed on internal tests, and as such a few of the tests that were ready were ported to external wpts. Note that simulateInputSourceConnection and disconnect will be implemented by future work. Bug:979316 Change-Id: Idfb8bb631bfc1f1cb13b571a90b1a41b4a6fe518
- Loading branch information
1 parent
e0a9e5e
commit 5e49100
Showing
5 changed files
with
301 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<!DOCTYPE html> | ||
<script src=/resources/testharness.js></script> | ||
<script src=/resources/testharnessreport.js></script> | ||
<script src="resources/webxr_util.js"></script> | ||
<script src="resources/webxr_test_constants.js"></script> | ||
<canvas id="webgl-canvas"></canvas> | ||
|
||
<script> | ||
let immersiveTestName = "XRSession resetpose from a device properly fires off " + | ||
"the right events for immersive sessions"; | ||
let nonImmersiveTestName = "XRSession resetpose from a device properly fires off " + | ||
"the right events for non-immersive sessions"; | ||
|
||
let watcherDone = new Event("watcherdone"); | ||
|
||
let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE; | ||
|
||
let testFunction = function(session, fakeDeviceController, t) { | ||
let resetPromise = session.requestReferenceSpace('local') | ||
.then((refSpace) => { | ||
let eventWatcher = new EventWatcher( | ||
t, refSpace, ["reset", "watcherdone"]); | ||
refSpace.addEventListener("reset", (event) => { | ||
assert_equals(event.referenceSpace, refSpace); | ||
refSpace.dispatchEvent(watcherDone); | ||
}, false); | ||
return eventWatcher.wait_for(["reset", "watcherdone"]); | ||
}); | ||
|
||
fakeDeviceController.simulateResetPose(); | ||
|
||
// The triggered resetPose event should arrive after the next Animation Frame | ||
session.requestAnimationFrame(() => {}); | ||
|
||
return resetPromise; | ||
}; | ||
|
||
xr_session_promise_test( | ||
immersiveTestName, testFunction, fakeDeviceInitParams, 'immersive-vr'); | ||
xr_session_promise_test( | ||
nonImmersiveTestName, testFunction, fakeDeviceInitParams, 'inline'); | ||
|
||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<!DOCTYPE html> | ||
<script src=/resources/testharness.js></script> | ||
<script src=/resources/testharnessreport.js></script> | ||
<script src="resources/webxr_util.js"></script> | ||
<script src="resources/webxr_test_constants.js"></script> | ||
<script src="resources/xr-test-asserts.js"></script> | ||
<canvas></canvas> | ||
|
||
<script> | ||
let testName = | ||
"'XRBoundedReferenceSpace updates properly when the changes are applied"; | ||
|
||
let fakeDeviceInitParams = { | ||
supportsImmersive: true, | ||
views: VALID_VIEWS, | ||
viewerOrigin: IDENTITY_TRANSFORM, | ||
localToFloorLevelTransform: VALID_LOCAL_TO_FLOOR_TRANSFORM | ||
}; | ||
|
||
let testFunction = function(session, fakeDeviceController, t) { | ||
|
||
return new Promise((resolve, reject) => { | ||
session.requestReferenceSpace('bounded-floor') | ||
.then((referenceSpace) => { | ||
t.step(() => { | ||
assert_unreached("Should not be able to get a bounded space until bounds set"); | ||
}); | ||
}).catch((err) => { | ||
t.step(() => { | ||
assert_equals(err.name, "NotSupportedError"); | ||
}); | ||
|
||
function onFrame(time, xrFrame) { | ||
// After setting the bounds explicitly, we should be able to get a | ||
// reference space | ||
session.requestReferenceSpace('bounded-floor') | ||
.then((referenceSpace) => { | ||
t.step(() => { | ||
assert_equals(referenceSpace.boundsGeometry.length, VALID_BOUNDS.length); | ||
for (i = 0; i < VALID_BOUNDS.length; ++i) { | ||
let valid_point = VALID_BOUNDS[i]; | ||
let bounds_point = referenceSpace.boundsGeometry[i]; | ||
assert_equals(valid_point.x, bounds_point.x); | ||
assert_equals(bounds_point.y, 0.0); | ||
assert_equals(valid_point.z, bounds_point.z); | ||
assert_equals(bounds_point.w, 1.0); | ||
} | ||
}); | ||
|
||
resolve(); | ||
}); | ||
} | ||
|
||
// Now set the bounds explicitly and check again on the next frame. | ||
fakeDeviceController.setBoundsGeometry(VALID_BOUNDS); | ||
session.requestAnimationFrame(onFrame); | ||
}); | ||
}); | ||
}; | ||
|
||
xr_session_promise_test(testName, testFunction, fakeDeviceInitParams, 'immersive-vr'); | ||
|
||
</script> |
70 changes: 70 additions & 0 deletions
70
webxr/xrStationaryReferenceSpace_floorlevel_updates.https.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<!DOCTYPE html> | ||
<script src=/resources/testharness.js></script> | ||
<script src=/resources/testharnessreport.js></script> | ||
<script src="resources/webxr_util.js"></script> | ||
<script src="resources/webxr_test_constants.js"></script> | ||
<script src="resources/xr-test-asserts.js"></script> | ||
<canvas></canvas> | ||
|
||
<script> | ||
let immersiveTestName = "'floor-level' XRStationaryReferenceSpace updates properly when " + | ||
"the transform changes for immersive sessions"; | ||
let nonImmersiveTestName = "'floor-level' XRStationaryReferenceSpace updates properly when " + | ||
"the transform changes for non-immersive sessions"; | ||
|
||
let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE; | ||
|
||
let testFunction = function(session, fakeDeviceController, t) { | ||
// Don't need to request a frame/allow the stage updates to propagate before | ||
// requesting local-floor because if the stage transform is set it just won't | ||
// be emulated on the first frame, and we wait a frame before checking. | ||
return session.requestReferenceSpace('local-floor') | ||
.then((referenceSpace) => new Promise((resolve, reject) => { | ||
function onFirstFrame(time, xrFrame) { | ||
// On the first frame where the pose has been initialized, the stage | ||
// should be using an emulated frame of reference because it has no | ||
// stageParameters yet. So the pose should be ~1.5 meters off the floor. | ||
t.step( () => { | ||
let pose = xrFrame.getViewerPose(referenceSpace); | ||
|
||
let poseMatrix = pose.transform.matrix; | ||
assert_approx_equals(poseMatrix[12], 0.0, FLOAT_EPSILON); | ||
assert_greater_than(poseMatrix[13], 1.0); | ||
assert_approx_equals(poseMatrix[14], 0.0, FLOAT_EPSILON); | ||
|
||
fakeDeviceController.setLocalToFloorLevelTransform(VALID_LOCAL_TO_FLOOR_TRANSFORM); | ||
|
||
// Need to request one animation frame for the new stage transform to | ||
// propagate before we check that it's what we expect. | ||
session.requestAnimationFrame(() => { | ||
session.requestAnimationFrame(onFrame); | ||
}); | ||
}); | ||
} | ||
|
||
function onFrame(time, xrFrame) { | ||
t.step( () => { | ||
// Check that stage transform was updated. | ||
let pose = xrFrame.getViewerPose(referenceSpace); | ||
assert_not_equals(pose, null); | ||
|
||
let poseMatrix = pose.transform.matrix; | ||
assert_matrix_approx_equals(poseMatrix, VALID_LOCAL_TO_FLOOR_MATRIX, FLOAT_EPSILON); | ||
}); | ||
|
||
// Finished. | ||
resolve(); | ||
} | ||
|
||
// Need to wait one frame for the removal to propagate before we check that | ||
// everything is at the expected emulated position. | ||
session.requestAnimationFrame(() => { | ||
session.requestAnimationFrame(onFirstFrame); | ||
}); | ||
})); | ||
}; | ||
|
||
xr_session_promise_test(immersiveTestName, testFunction, fakeDeviceInitParams, 'immersive-vr'); | ||
xr_session_promise_test(nonImmersiveTestName, testFunction, fakeDeviceInitParams, 'inline'); | ||
|
||
</script> |