| <!doctype html> |
| <title>XRWebGLBinding::createCylinderLayer</title> |
| <link rel="help" href="https://immersive-web.github.io/layers/#dom-xrwebglbinding-createquadlayer"> |
| <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="./xr_layer_promise_test.js"></script> |
| |
| <canvas id="webgl-canvas"></canvas> |
| |
| <script> |
| |
| function testCreateCylinderLayer(xrSession, deviceController, t, { gl, xrBinding, xrSpace }) { |
| return new Promise((resolve, reject) => { |
| const valid_init = { |
| space: xrSpace, |
| viewPixelWidth: 1024, |
| viewPixelHeight: 1024 |
| }; |
| |
| t.step(() => { |
| // Cylinder radius must be greater than or equal to 0. |
| let invalid_radius = Object.assign({}, valid_init, { radius: -5 }); |
| assert_throws_js(TypeError, () => xrBinding.createCylinderLayer(invalid_radius), "radius is negative"); |
| }); |
| |
| t.step(() => { |
| // Cylinder aspectRatio must be greater than 0. |
| let invalid_aspect_ratio = Object.assign({}, valid_init, { aspectRatio: 0 }); |
| assert_throws_js(TypeError, () => xrBinding.createCylinderLayer(invalid_aspect_ratio), "aspectRatio is 0"); |
| }); |
| |
| t.step(() => { |
| // Cylinder central angle must be greater than or equal to 0. |
| let invalid_central_angle = Object.assign({}, valid_init, { centralAngle: -6 }); |
| assert_throws_js(TypeError, () => xrBinding.createCylinderLayer(invalid_central_angle), "centralAngle is negative"); |
| }); |
| |
| t.step(() => { |
| // Cylinder central angle should not be greater than 2pi. |
| let invalid_central_angle = Object.assign({}, valid_init, { centralAngle: 7.0 }); |
| assert_throws_js(TypeError, () => xrBinding.createCylinderLayer(invalid_central_angle), "centralAngle is greater than 2pi"); |
| }); |
| |
| // Test that a valid init works. |
| t.step(() => { |
| const layer = xrBinding.createCylinderLayer(valid_init); |
| assert_true(layer instanceof XRCylinderLayer, "Valid init parameters must create an XRCylinderLayer"); |
| resolve(); |
| }); |
| }); |
| } |
| |
| xr_layer_promise_test("Ensure XrWebGLBinding::createCylinderLayer throws the appropriate errors", |
| testCreateCylinderLayer, TRACKED_IMMERSIVE_DEVICE, 'immersive-vr', { requiredFeatures: ['layers'] }); |
| </script> |