| <!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> |
| let testName = "inlineVerticalFieldOfView is set appropriately on inline sessions"; |
| |
| let fakeDeviceInitParams = { supportsImmersive:false }; |
| |
| let requestSessionModes = [ 'inline' ]; |
| |
| // These are the numbers that we expect chrome to clamp to. |
| let minFOV = 0.01; |
| let maxFOV = 3.13; |
| let defaultFOV = Math.PI/2; |
| |
| function assertApproximatelyEqual(a, b, step, epsilon = FLOAT_EPSILON) { |
| assert_less_than(Math.abs(a - b), epsilon, step); |
| } |
| |
| let testFunction = function(session, t, fakeDeviceController) { |
| // Session must have a baseLayer or frame requests will be ignored. |
| session.updateRenderState({ |
| baseLayer: new XRWebGLLayer(session, gl, { compositionDisabled: true }) |
| }); |
| |
| // Helper method because the renderState does not (per the spec) get updated |
| // until the next rAF after it was updated, so this method returns a promise |
| // which will resolve when the updated state should be applied. |
| function updateAndApplyInlineFOV(fov) { |
| session.updateRenderState({ |
| inlineVerticalFieldOfView: fov |
| }); |
| |
| return new Promise((resolve, reject) => { |
| session.requestAnimationFrame(() => { resolve(); }); |
| }); |
| } |
| |
| // Helper method to keep the line length reasonable with a long attribute name |
| // and ensure that the nullable value actually has a value. |
| function getFOV() { |
| let fov = session.renderState.inlineVerticalFieldOfView; |
| t.step(() => { |
| assert_not_equals(fov, null); |
| }); |
| |
| return fov; |
| } |
| |
| return new Promise((resolve, reject) => { |
| // Begin by validating that the default is set as expected/specced. |
| t.step(() => { |
| assertApproximatelyEqual(getFOV(), defaultFOV, "default"); |
| }); |
| |
| // Set something below min, and assert that it is set to the min. |
| updateAndApplyInlineFOV(-10).then(() => { |
| |
| t.step(() => { |
| assertApproximatelyEqual(getFOV(), minFOV, "min"); |
| }); |
| |
| // Set something above the max and assert that it is set to the max. |
| updateAndApplyInlineFOV(10).then(()=> { |
| t.step(()=> { |
| assertApproximatelyEqual(getFOV(), maxFOV, "max"); |
| }); |
| |
| // Set to something reasonable and assert that the value gets set. |
| let normalFOV = 1.5; |
| updateAndApplyInlineFOV(normalFOV).then(() => { |
| t.step(() => { |
| assertApproximatelyEqual(getFOV(), normalFOV, "normal"); |
| }); |
| |
| resolve(); |
| }); |
| }); |
| }); |
| }); |
| }; |
| |
| xr_session_promise_test( |
| testFunction, fakeDeviceInitParams, requestSessionModes, testName); |
| |
| </script> |