blob: 430adc1d6a0221b00f5371428c68c28a64626b85 [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>
let testName = "Ensures hit-test returns expected mock results";
let fakeDeviceInitParams = { supportsImmersive: false,
supportsEnvironmentIntegration: true };
let requestSessionOptions = [ {mode: 'legacy-inline-ar' } ];
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_equals(session.mode, 'legacy-inline-ar');
assert_not_equals(session.environmentBlendMode, 'opaque');
return session.requestReferenceSpace({ type: "stationary", subtype: "eye-level" }).then((referenceSpace) => {
let ray = new XRRay({x : 0.0, y : 0.0, z : 0.0}, {x : 1.0, y : 0.0, z: 0.0});
let hit = new device.mojom.XRHitResult();
hit.hitMatrix = expectedHitMatrix;
fakeDeviceController.setHitTestResults({ results: [hit] });
return session.requestHitTest(ray, referenceSpace).then(
(hitResults) => {
t.step(() => {
// 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>