| <!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="../xr/resources/xr-internal-device-mocking.js"></script> |
| <script src="../xr/resources/xr-test-utils.js"></script> |
| <script src="../xr/resources/test-constants.js"></script> |
| <canvas id="webgl-canvas"></canvas> |
| |
| <script> |
| |
| let testName = "Ensures hit-test returns expected mock results"; |
| |
| let fakeDeviceInitParams = { supportsImmersive: false, |
| supportsEnvironmentIntegration: true }; |
| |
| let requestSessionOptions = [ { |
| immersive: false, |
| environmentIntegration: true, |
| outputContext: getOutputContext() |
| } ]; |
| |
| let expectedHitMatrix = [1, 0, 0, 1, |
| 0, 1, 0, 2, |
| 0, 0, 1, 3, |
| 0, 0, 0, 1]; |
| |
| let testFunction = function(session, t, fakeDeviceController) { |
| assert_false(session.immersive); |
| return session.requestFrameOfReference("eye-level").then((frameOfReference) => { |
| let direction = new Float32Array([1.0, 0.0, 0.0]); |
| let origin = new Float32Array([0.0, 0.0, 0.0]); |
| |
| let hit = new device.mojom.XRHitResult(); |
| hit.hitMatrix = expectedHitMatrix; |
| |
| fakeDeviceController.setHitTestResults({ results: [hit] }); |
| |
| return session.requestHitTest(origin, direction, frameOfReference).then( |
| (hitResults) => { |
| // Test that hit results are what we expected. |
| assert_equals(hitResults.length, 1); |
| assert_equals(hitResults[0].hitMatrix.length, 16); |
| assert_matrices_approx_equal( |
| hitResults[0].hitMatrix, |
| expectedHitMatrix, |
| FLOAT_EPSILON, |
| "Hit test matrix does not equals input test matrix"); |
| }); |
| }); |
| }; |
| |
| xr_session_promise_test( |
| testFunction, fakeDeviceInitParams, requestSessionOptions, testName); |
| |
| </script> |