blob: a050e5490d5cd83fc9a269a81c32f5d30da72c39 [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-test-utils.js"></script>
<canvas id="webgl-canvas"></canvas>
<script>
let testName = "XRFrame contains the expected views";
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 event's 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 session.requestReferenceSpace({ type: "stationary", subtype: "eye-level" }).then((referenceSpace) => new Promise((resolve) => {
function onFrame(time, xrFrame) {
let pose = xrFrame.getViewerPose(referenceSpace);
assert_not_equals(pose, null);
assert_not_equals(pose.views, null);
assert_equals(pose.views.length, 2);
// Ensure that two views are provided.
let leftView = pose.views[0];
let rightView = pose.views[1];
// Ensure that the views are the right type.
assert_true(leftView instanceof XRView);
assert_true(rightView instanceof XRView);
// Ensure that they have the expected eye enums.
assert_equals(leftView.eye, "left");
assert_equals(rightView.eye, "right");
// Ensure they have the expected projection matrices.
assert_not_equals(leftView.projectionMatrix, null);
assert_not_equals(rightView.projectionMatrix, null);
assert_matrices_approx_equal(leftView.projectionMatrix, VALID_PROJECTION_MATRIX);
assert_matrices_approx_equal(rightView.projectionMatrix, VALID_PROJECTION_MATRIX);
// Finished test.
resolve();
}
session.requestAnimationFrame(onFrame);
}));
};
xr_session_promise_test(
testFunction, fakeDeviceInitParams, requestSessionOptions, testName);
</script>