blob: d161133ab56c83e4d544f888876dc969057cdb8e [file] [log] [blame]
<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="file:///gen/layout_test_data/mojo/public/js/mojo_bindings.js"></script>
<script src="file:///gen/device/vr/public/mojom/vr_service.mojom.js"></script>
<script src="../external/wpt/resources/chromium/webxr-test.js"></script>
<script src="../external/wpt/webxr/resources/webxr_test_constants.js"></script>
<script src="../xr/resources/xr-internal-device-mocking.js"></script>
<script src="../xr/resources/xr-test-utils.js"></script>
<canvas id="webgl-canvas"></canvas>
<script>
// This test is Chromium-specific because it uses the default human eye height
// of 1.6 meters defined in xr_stationary_reference_space.cc
let testName = "XRFrame.getPose works between eye-level and floor-level spaces";
let fakeDeviceInitParams = { supportsImmersive:true };
let requestSessionOptions = [{ mode: 'immersive-vr' }];
let testFunction = function(session, t, fakeDeviceController) {
// Session must have a baseLayer or frame requests will be ignored.
let webglLayer = new XRWebGLLayer(session, gl);
session.updateRenderState({ baseLayer: webglLayer });
// Need to have a valid pose or input events don't process.
fakeDeviceController.setXRPresentationFrameData(VALID_POSE_MATRIX, [{
eye:"left",
projectionMatrix: VALID_PROJECTION_MATRIX,
viewMatrix: VALID_VIEW_MATRIX
}, {
eye:"right",
projectionMatrix: VALID_PROJECTION_MATRIX,
viewMatrix: VALID_VIEW_MATRIX
}]);
return Promise.all([
session.requestReferenceSpace({ type: "stationary", subtype: "eye-level" }),
session.requestReferenceSpace({ type: "stationary", subtype: "floor-level" })
]).then((spaces) => new Promise((resolve) => {
function onFrame(time, xrFrame) {
// eye-level space starts out with originOffset = identity matrix
let eye_level = spaces[0];
// Make sure going between eye-level and floor-level spaces takes the
// estimated eye height into account.
let floor_level = spaces[1];
let eye_level_from_floor_level = xrFrame.getPose(eye_level, floor_level);
assert_equals(eye_level_from_floor_level.transform.position.y, 1.6);
// Finished test.
resolve();
}
session.requestAnimationFrame(onFrame);
}));
};
xr_session_promise_test(
testFunction, fakeDeviceInitParams, requestSessionOptions, testName);
</script>