зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1564733 [wpt PR 17630] - Update WebXR TestAPI and tests to match new spec, a=testonly
Automatic update from web-platform-tests Update WebXR TestAPI and tests to match new spec (#17630) Now that WebXR is more mature, the test API is being revisited with input from other UAs. This change updates existing methods and tests to match the new API, which largely involves: * FakeXRDeviceInit now requires views * FakeXRDeviceInit *CAN* support an initial viewerOrigin * setXRPresentationFrameData is now setViews and set/clearViewerOrigin * XRTest is now navigator.xr.test [1] As part of this, webxr_test_constants were cleaned up and expanded to help minimize boilerplate code in the tests. Where possible tests that were previously calling setXRPresentationFrameData to ensure that the fake device was "tracking" were updated to instead use a constant that sets these values. Future work (after the API update is complete) will identify if there are any cases where an initial requestAnimationFrame could be removed. Most changes (especially to vr/ tests) should be fairly mechanical, but now that the eye offsets expected/set by the test are actually being plumbed through, both xr/xrReferenceSpace_originOffset tests had to have their expected matrices updated. Two tests had to be updated due to the discovery of 981003. Other changes to update to the Test API after this change should be mostly additive and should actually already exist in the internal tests. [1] XRTest currently still exists as a workaround until 944987 is merged Also due to the fact that accessing xr blocks VR, the WebVR tests had to be updated to set a special flag to tell the test API to not set the object on XR. It's unlikely that this behavior will be able to be removed after 944987, but to allow XRTest to be removed these tests have had it migrated to navigator.vr.test Bug:979312 Change-Id: I19ccffd921728ec3799252693d945b7b3f99d757 -- wpt-commits: 3f8ee365a7cacc091dc1dd1d0b5f21a89241c894 wpt-pr: 17630
This commit is contained in:
Родитель
31a18bfb33
Коммит
d8823a497f
|
@ -12,8 +12,9 @@ class ChromeXRTest {
|
|||
return Promise.resolve(this.mockVRService_.addRuntime(init_params));
|
||||
}
|
||||
|
||||
simulateDeviceDisconnection(device) {
|
||||
this.mockVRService_.removeRuntime(device);
|
||||
disconnectAllDevices() {
|
||||
this.mockVRService_.removeAllRuntimes(device);
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
simulateUserActivation(callback) {
|
||||
|
@ -60,11 +61,11 @@ class MockVRService {
|
|||
return runtime;
|
||||
}
|
||||
|
||||
removeRuntime(runtime) {
|
||||
// We have no way of distinguishing between devices, so just clear the
|
||||
// entire list for now.
|
||||
// TODO(http://crbug.com/873409) We also have no way right now to disconnect
|
||||
// devices.
|
||||
removeAllRuntimes() {
|
||||
if (this.client_) {
|
||||
this.client_.onDeviceChanged();
|
||||
}
|
||||
|
||||
this.runtimes_ = [];
|
||||
}
|
||||
|
||||
|
@ -151,6 +152,8 @@ class MockRuntime {
|
|||
|
||||
this.framesOfReference = {};
|
||||
|
||||
// Initialize DisplayInfo first to set the defaults, then override with
|
||||
// anything from the deviceInit
|
||||
if (fakeDeviceInit.supportsImmersive) {
|
||||
this.displayInfo_ = this.getImmersiveDisplayInfo();
|
||||
} else {
|
||||
|
@ -160,16 +163,16 @@ class MockRuntime {
|
|||
if (fakeDeviceInit.supportsEnvironmentIntegration) {
|
||||
this.displayInfo_.capabilities.canProvideEnvironmentIntegration = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Test methods.
|
||||
setXRPresentationFrameData(poseMatrix, views) {
|
||||
if (poseMatrix == null) {
|
||||
this.pose_ = null;
|
||||
} else {
|
||||
this.setPoseFromMatrix(poseMatrix);
|
||||
if (fakeDeviceInit.viewerOrigin != null) {
|
||||
this.setViewerOrigin(fakeDeviceInit.viewerOrigin);
|
||||
}
|
||||
|
||||
this.setViews(fakeDeviceInit.views);
|
||||
}
|
||||
|
||||
// Test API methods.
|
||||
setViews(views) {
|
||||
if (views) {
|
||||
let changed = false;
|
||||
for (let i = 0; i < views.length; i++) {
|
||||
|
@ -182,17 +185,18 @@ class MockRuntime {
|
|||
}
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
if (changed && this.sessionClient_.ptr.isBound()) {
|
||||
this.sessionClient_.onChanged(this.displayInfo_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
setPoseFromMatrix(poseMatrix) {
|
||||
setViewerOrigin(origin, emulatedPosition = false) {
|
||||
let p = origin.position;
|
||||
let q = origin.orientation;
|
||||
this.pose_ = {
|
||||
orientation: null,
|
||||
position: null,
|
||||
orientation: { x: q[0], y: q[1], z: q[2], w: q[3] },
|
||||
position: { x: p[0], y: p[1], z: p[2] },
|
||||
angularVelocity: null,
|
||||
linearVelocity: null,
|
||||
angularAcceleration: null,
|
||||
|
@ -200,37 +204,13 @@ class MockRuntime {
|
|||
inputState: null,
|
||||
poseIndex: 0
|
||||
};
|
||||
|
||||
let pose = this.poseFromMatrix(poseMatrix);
|
||||
for (let field in pose) {
|
||||
if (this.pose_.hasOwnProperty(field)) {
|
||||
this.pose_[field] = pose[field];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
poseFromMatrix(m) {
|
||||
let m00 = m[0];
|
||||
let m11 = m[5];
|
||||
let m22 = m[10];
|
||||
|
||||
// The max( 0, ... ) is just a safeguard against rounding error.
|
||||
let orientation = new gfx.mojom.Quaternion();
|
||||
orientation.w = Math.sqrt(Math.max(0, 1 + m00 + m11 + m22)) / 2;
|
||||
orientation.x = Math.sqrt(Math.max(0, 1 + m00 - m11 - m22)) / 2;
|
||||
orientation.y = Math.sqrt(Math.max(0, 1 - m00 + m11 - m22)) / 2;
|
||||
orientation.z = Math.sqrt(Math.max(0, 1 - m00 - m11 + m22)) / 2;
|
||||
|
||||
let position = new gfx.mojom.Point3F();
|
||||
position.x = m[12];
|
||||
position.y = m[13];
|
||||
position.z = m[14];
|
||||
|
||||
return {
|
||||
orientation, position
|
||||
}
|
||||
clearViewerOrigin() {
|
||||
this.pose_ = null;
|
||||
}
|
||||
|
||||
// Helper methods
|
||||
getNonImmersiveDisplayInfo() {
|
||||
let displayInfo = this.getImmersiveDisplayInfo();
|
||||
|
||||
|
@ -296,6 +276,8 @@ class MockRuntime {
|
|||
let upTan = (1 + m[9]) / m[5];
|
||||
let downTan = (1 - m[9]) / m[5];
|
||||
|
||||
let offset = fakeXRViewInit.viewOffset.position;
|
||||
|
||||
return {
|
||||
fieldOfView: {
|
||||
upDegrees: toDegrees(upTan),
|
||||
|
@ -303,9 +285,9 @@ class MockRuntime {
|
|||
leftDegrees: toDegrees(leftTan),
|
||||
rightDegrees: toDegrees(rightTan)
|
||||
},
|
||||
offset: { x: 0, y: 0, z: 0 },
|
||||
renderWidth: 20,
|
||||
renderHeight: 20
|
||||
offset: { x: offset[0], y: offset[1], z: offset[2] },
|
||||
renderWidth: fakeXRViewInit.resolution.width,
|
||||
renderHeight: fakeXRViewInit.resolution.height
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -405,6 +387,7 @@ class MockRuntime {
|
|||
};
|
||||
}
|
||||
|
||||
// Mojo helper classes
|
||||
class MockXRPresentationProvider {
|
||||
constructor() {
|
||||
this.binding_ = new mojo.Binding(device.mojom.XRPresentationProvider, this);
|
||||
|
@ -448,4 +431,21 @@ class MockXRPresentationProvider {
|
|||
}
|
||||
}
|
||||
|
||||
// This is a temporary workaround for the fact that spinning up webxr before
|
||||
// the mojo interceptors are created will cause the interceptors to not get
|
||||
// registered, so we have to create this before we query xr;
|
||||
let XRTest = new ChromeXRTest();
|
||||
|
||||
// This test API is also used to run Chrome's internal legacy VR tests; however,
|
||||
// those fail if navigator.xr has been used. Those tests will set a bool telling
|
||||
// us not to try to check navigator.xr
|
||||
if ((typeof legacy_vr_test === 'undefined') || !legacy_vr_test) {
|
||||
// Some tests may run in the http context where navigator.xr isn't exposed
|
||||
// This should just be to test that it isn't exposed, but don't try to set up
|
||||
// the test framework in this case.
|
||||
if (navigator.xr) {
|
||||
navigator.xr.test = XRTest;
|
||||
}
|
||||
} else {
|
||||
navigator.vr = { test: XRTest };
|
||||
}
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
// assert_equals can fail when comparing floats due to precision errors, so
|
||||
// use assert_approx_equals with this constant instead
|
||||
const FLOAT_EPSILON = 0.001;
|
||||
|
||||
// Identity matrix
|
||||
const IDENTITY_MATRIX = [1, 0, 0, 0,
|
||||
0, 1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, 0, 0, 1];
|
||||
|
||||
// A valid pose matrix for when we don't care about specific values
|
||||
const VALID_POSE_MATRIX = [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1];
|
||||
|
||||
const VALID_PROJECTION_MATRIX =
|
||||
[1, 0, 0, 0, 0, 1, 0, 0, 3, 2, -1, -1, 0, 0, -0.2, 0];
|
||||
|
||||
const VALID_VIEW_MATRIX = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 4, 3, 2, 1];
|
||||
|
||||
// A valid VRPose for when we want the HMD to report being at the origin
|
||||
const ORIGIN_POSE = IDENTITY_MATRIX;
|
||||
|
||||
// A valid input grip matrix for when we don't care about specific values
|
||||
const VALID_GRIP = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 4, 3, 2, 1];
|
||||
|
||||
// A valid input pointer offset for when we don't care about specific values
|
||||
const VALID_POINTER_OFFSET = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1];
|
||||
|
||||
const VALID_GRIP_WITH_POINTER_OFFSET =
|
||||
[1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 4, 3, 3, 1];
|
||||
|
||||
const VALID_STAGE_TRANSFORM =
|
||||
[1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1.0, 1.65, -1.0, 1];
|
|
@ -8,17 +8,26 @@ const IDENTITY_MATRIX = [1, 0, 0, 0,
|
|||
0, 0, 1, 0,
|
||||
0, 0, 0, 1];
|
||||
|
||||
// A valid pose matrix for when we don't care about specific values
|
||||
const VALID_POSE_MATRIX = [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1];
|
||||
const IDENTITY_TRANSFORM = {
|
||||
position: [0, 0, 0],
|
||||
orientation: [0, 0, 0, 1],
|
||||
};
|
||||
|
||||
// A valid pose matrix/transform for when we don't care about specific values
|
||||
// Note that these two should be identical, just different representations
|
||||
const VALID_POSE_MATRIX = [0, 1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
1, 0, 0, 0,
|
||||
1, 1, 1, 1];
|
||||
|
||||
const VALID_POSE_TRANSFORM = {
|
||||
position: [1, 1, 1],
|
||||
orientation: [0.5, 0.5, 0.5, 0.5]
|
||||
};
|
||||
|
||||
const VALID_PROJECTION_MATRIX =
|
||||
[1, 0, 0, 0, 0, 1, 0, 0, 3, 2, -1, -1, 0, 0, -0.2, 0];
|
||||
|
||||
const VALID_VIEW_MATRIX = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 4, 3, 2, 1];
|
||||
|
||||
// A valid VRPose for when we want the HMD to report being at the origin
|
||||
const ORIGIN_POSE = IDENTITY_MATRIX;
|
||||
|
||||
// A valid input grip matrix for when we don't care about specific values
|
||||
const VALID_GRIP = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 4, 3, 2, 1];
|
||||
|
||||
|
@ -39,3 +48,51 @@ const VALID_BOUNDS = [
|
|||
{ x: -3.5, y: 0, z: 0.0 },
|
||||
{ x: -3.0, y: 0, z: -2.0 }
|
||||
];
|
||||
|
||||
const VALID_RESOLUTION = {
|
||||
width: 20,
|
||||
height: 20
|
||||
};
|
||||
|
||||
const LEFT_OFFSET = {
|
||||
position: [-0.1, 0, 0],
|
||||
orientation: [0, 0, 0, 1]
|
||||
};
|
||||
|
||||
const RIGHT_OFFSET = {
|
||||
position: [0.1, 0, 0],
|
||||
orientation: [0, 0, 0, 1]
|
||||
};
|
||||
|
||||
const VALID_VIEWS = [{
|
||||
eye:"left",
|
||||
projectionMatrix: VALID_PROJECTION_MATRIX,
|
||||
viewOffset: LEFT_OFFSET,
|
||||
resolution: VALID_RESOLUTION
|
||||
}, {
|
||||
eye:"right",
|
||||
projectionMatrix: VALID_PROJECTION_MATRIX,
|
||||
viewOffset: RIGHT_OFFSET,
|
||||
resolution: VALID_RESOLUTION
|
||||
},
|
||||
];
|
||||
|
||||
const NON_IMMERSIVE_VIEWS = [{
|
||||
eye: "none",
|
||||
projectionMatrix: VALID_PROJECTION_MATRIX,
|
||||
viewOffset: IDENTITY_TRANSFORM,
|
||||
resolution: VALID_RESOLUTION,
|
||||
}
|
||||
];
|
||||
|
||||
const TRACKED_IMMERSIVE_DEVICE = {
|
||||
supportsImmersive: true,
|
||||
views: VALID_VIEWS,
|
||||
viewerOrigin: IDENTITY_TRANSFORM
|
||||
};
|
||||
|
||||
const VALID_NON_IMMERSIVE_DEVICE = {
|
||||
supportsImmersive: false,
|
||||
views: NON_IMMERSIVE_VIEWS,
|
||||
viewerOrigin: IDENTITY_TRANSFORM
|
||||
};
|
||||
|
|
|
@ -39,15 +39,15 @@ function xr_session_promise_test(
|
|||
|
||||
xr_promise_test(
|
||||
name,
|
||||
(t) =>
|
||||
XRTest.simulateDeviceConnection(fakeDeviceInit)
|
||||
(t) =>{
|
||||
return navigator.xr.test.simulateDeviceConnection(fakeDeviceInit)
|
||||
.then((controller) => {
|
||||
testDeviceController = controller;
|
||||
return gl.makeXRCompatible();
|
||||
})
|
||||
.then(() => new Promise((resolve, reject) => {
|
||||
// Perform the session request in a user gesture.
|
||||
XRTest.simulateUserActivation(() => {
|
||||
navigator.xr.test.simulateUserActivation(() => {
|
||||
navigator.xr.requestSession(sessionMode)
|
||||
.then((session) => {
|
||||
testSession = session;
|
||||
|
@ -75,8 +75,9 @@ function xr_session_promise_test(
|
|||
.then(() => {
|
||||
// Cleanup system state.
|
||||
testSession.end().catch(() => {});
|
||||
XRTest.simulateDeviceDisconnection();
|
||||
}),
|
||||
return navigator.xr.test.disconnectAllDevices();
|
||||
})
|
||||
},
|
||||
properties);
|
||||
}
|
||||
|
||||
|
@ -138,4 +139,4 @@ let loadChromiumResources = Promise.resolve().then(() => {
|
|||
});
|
||||
|
||||
return chain;
|
||||
});
|
||||
});
|
||||
|
|
|
@ -3,11 +3,12 @@
|
|||
<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>
|
||||
<canvas id="webgl-canvas"></canvas>
|
||||
<script>
|
||||
xr_promise_test("An XR-compatible webglCanvasContext can be created",
|
||||
(t) => {
|
||||
return XRTest.simulateDeviceConnection({ supportsImmersive:true })
|
||||
return navigator.xr.test.simulateDeviceConnection(TRACKED_IMMERSIVE_DEVICE)
|
||||
.then( (controller) => {
|
||||
webglCanvas = document.getElementById('webgl-canvas');
|
||||
gl = webglCanvas.getContext('webgl', {xrCompatible: true});
|
||||
|
|
|
@ -3,13 +3,14 @@
|
|||
<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>
|
||||
<canvas id="webgl-canvas"></canvas>
|
||||
<script>
|
||||
|
||||
xr_promise_test(
|
||||
"A lost webglCanvasContext should not be able to set xr compatibility",
|
||||
(t) => {
|
||||
return XRTest.simulateDeviceConnection({ supportsImmersive:true })
|
||||
return navigator.xr.test.simulateDeviceConnection(TRACKED_IMMERSIVE_DEVICE)
|
||||
.then( (controller) => {
|
||||
webglCanvas = document.getElementById('webgl-canvas');
|
||||
gl = webglCanvas.getContext('webgl', {xrCompatible: true});
|
||||
|
|
|
@ -3,12 +3,13 @@
|
|||
<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>
|
||||
<canvas></canvas>
|
||||
<script>
|
||||
xr_session_promise_test(
|
||||
"Tests requestSession resolves when supported",
|
||||
(session) => {
|
||||
assert_not_equals(session, null);
|
||||
}, { supportsImmersive:true }, 'immersive-vr');
|
||||
}, TRACKED_IMMERSIVE_DEVICE, 'immersive-vr');
|
||||
</script>
|
||||
</body>
|
||||
</body>
|
||||
|
|
|
@ -3,11 +3,12 @@
|
|||
<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>
|
||||
xr_promise_test(
|
||||
"Requesting immersive session outside of a user gesture rejects",
|
||||
(t) => {
|
||||
return XRTest.simulateDeviceConnection({ supportsImmersive:true })
|
||||
return navigator.xr.test.simulateDeviceConnection(TRACKED_IMMERSIVE_DEVICE)
|
||||
.then( (controller) => promise_rejects(
|
||||
t, 'SecurityError', navigator.xr.requestSession('immersive-vr')));
|
||||
});
|
||||
|
|
|
@ -3,13 +3,14 @@
|
|||
<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>
|
||||
xr_promise_test(
|
||||
"Requesting an immersive session when unsupported rejects",
|
||||
(t) => {
|
||||
return XRTest.simulateDeviceConnection({ supportsImmersive:false })
|
||||
return navigator.xr.test.simulateDeviceConnection(VALID_NON_IMMERSIVE_DEVICE)
|
||||
.then( (controller) => new Promise((resolve) => {
|
||||
XRTest.simulateUserActivation( () => {
|
||||
navigator.xr.test.simulateUserActivation( () => {
|
||||
resolve(promise_rejects(
|
||||
t,
|
||||
"NotSupportedError",
|
||||
|
|
|
@ -3,13 +3,14 @@
|
|||
<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>
|
||||
xr_promise_test(
|
||||
"Requesting a session with no mode rejects",
|
||||
(t) => {
|
||||
return XRTest.simulateDeviceConnection({ supportsImmersive:false })
|
||||
return navigator.xr.test.simulateDeviceConnection(VALID_NON_IMMERSIVE_DEVICE)
|
||||
.then( (controller) => new Promise((resolve) => {
|
||||
XRTest.simulateUserActivation( () => {
|
||||
navigator.xr.test.simulateUserActivation( () => {
|
||||
resolve(promise_rejects(
|
||||
t,
|
||||
new TypeError(),
|
||||
|
|
|
@ -3,11 +3,12 @@
|
|||
<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>
|
||||
xr_promise_test(
|
||||
"Requesting non-immersive session outside of a user gesture succeeds",
|
||||
(t) => {
|
||||
return XRTest.simulateDeviceConnection({ supportsImmersive:false })
|
||||
return navigator.xr.test.simulateDeviceConnection(VALID_NON_IMMERSIVE_DEVICE)
|
||||
.then( (controller) => navigator.xr.requestSession('inline'))
|
||||
.then( (session) => { assert_not_equals(session, null); });
|
||||
});
|
||||
|
|
|
@ -3,11 +3,12 @@
|
|||
<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>
|
||||
xr_promise_test(
|
||||
"supportsSession resolves when immersive options supported",
|
||||
() => {
|
||||
return XRTest.simulateDeviceConnection({ supportsImmersive:true })
|
||||
return navigator.xr.test.simulateDeviceConnection(TRACKED_IMMERSIVE_DEVICE)
|
||||
.then( (controller) => navigator.xr.supportsSession('immersive-vr'));
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -3,11 +3,12 @@
|
|||
<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>
|
||||
xr_promise_test(
|
||||
"supportsSession rejects when options not supported",
|
||||
(t) => {
|
||||
return XRTest.simulateDeviceConnection({ supportsImmersive:false })
|
||||
return navigator.xr.test.simulateDeviceConnection(VALID_NON_IMMERSIVE_DEVICE)
|
||||
.then( (controller) => {
|
||||
return promise_rejects(
|
||||
t,
|
||||
|
|
|
@ -3,11 +3,12 @@
|
|||
<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>
|
||||
xr_promise_test(
|
||||
"supportsSession resolves when inline options supported",
|
||||
(t) => {
|
||||
return XRTest.simulateDeviceConnection({ supportsImmersive:true })
|
||||
return navigator.xr.test.simulateDeviceConnection(TRACKED_IMMERSIVE_DEVICE)
|
||||
.then( (controller) => {
|
||||
// Inline sessions should be supported.
|
||||
return navigator.xr.supportsSession('inline');
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/test-constants.js"></script>
|
||||
<script src="resources/webxr_test_constants.js"></script>
|
||||
<script src="resources/webxr_util.js"></script>
|
||||
<script src="resources/xr-test-asserts.js"></script>
|
||||
<canvas></canvas>
|
||||
|
@ -11,20 +11,9 @@
|
|||
let immersiveTestName = "XRFrame.getPose works for immersive sessions";
|
||||
let nonImmersiveTestName = "XRFrame.getPose works for non-immersive sessions";
|
||||
|
||||
let fakeDeviceInitParams = { supportsImmersive:true };
|
||||
let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE;
|
||||
|
||||
let testFunction = function(session, fakeDeviceController, t) {
|
||||
// Need to have a valid pose or input events 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 Promise.all([
|
||||
session.requestReferenceSpace('local'),
|
||||
session.requestReferenceSpace('local')
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<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>
|
||||
<canvas></canvas>
|
||||
|
||||
<script>
|
||||
|
@ -11,7 +12,7 @@
|
|||
let nonImmersiveTestName = "XRFrame methods throw exceptions outside of the " +
|
||||
"requestAnimationFrame callback for non-immersive sessions";
|
||||
|
||||
let fakeDeviceInitParams = { supportsImmersive:true };
|
||||
let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE;
|
||||
|
||||
let testFunction = (testSession, testController, t) => new Promise((resolve) => {
|
||||
let staleFrame = null;
|
||||
|
@ -54,4 +55,4 @@
|
|||
fakeDeviceInitParams, 'inline');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</body>
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/webxr_test_constants.js"></script>
|
||||
<script src="resources/webxr_test_asserts.js"></script>
|
||||
|
||||
<script>
|
||||
|
||||
let constructor_test_name = "XRRay constructors work";
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
<script src="resources/webxr_test_constants.js"></script>
|
||||
<script src="resources/webxr_test_asserts.js"></script>
|
||||
<script src="resources/webxr_math_utils.js"></script>
|
||||
|
||||
<script>
|
||||
|
||||
let matrix_tests_name = "XRRay matrix works";
|
||||
|
|
|
@ -4,11 +4,10 @@
|
|||
<script src="resources/webxr_util.js"></script>
|
||||
<script src="resources/webxr_test_constants.js"></script>
|
||||
<canvas id="webgl-canvas"></canvas>
|
||||
|
||||
<script>
|
||||
|
||||
let testName = "XRRigidTransform constructor works";
|
||||
let fakeDeviceInitParams = { supportsImmersive: true };
|
||||
let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE;
|
||||
|
||||
let testFunction =
|
||||
(session, fakeDeviceController, t) => new Promise((resolve, reject) => {
|
||||
|
|
|
@ -4,11 +4,10 @@
|
|||
<script src="resources/webxr_util.js"></script>
|
||||
<script src="resources/webxr_test_constants.js"></script>
|
||||
<canvas id="webgl-canvas"></canvas>
|
||||
|
||||
<script>
|
||||
|
||||
let testName = "XRRigidTransform inverse works";
|
||||
let fakeDeviceInitParams = { supportsImmersive: true };
|
||||
let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE;
|
||||
|
||||
let testFunction =
|
||||
(session, fakeDeviceController, t) => new Promise((resolve, reject) => {
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
<script src="resources/webxr_test_constants.js"></script>
|
||||
<script src="resources/webxr_test_asserts.js"></script>
|
||||
<script src="resources/webxr_math_utils.js"></script>
|
||||
|
||||
<script>
|
||||
|
||||
let matrix_tests_name = "XRRigidTransform matrix works";
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<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>
|
||||
<canvas></canvas>
|
||||
|
||||
<script>
|
||||
|
@ -11,7 +12,7 @@
|
|||
let nonImmersiveTestName = "XRSession requestAnimationFrame callbacks can be "
|
||||
+ "unregistered with cancelAnimationFrame for non-immersive sessions";
|
||||
|
||||
let fakeDeviceInitParams = { supportsImmersive:true };
|
||||
let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE;
|
||||
|
||||
let testFunction = (session) => new Promise((resolve, reject) => {
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<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>
|
||||
<canvas></canvas>
|
||||
<script>
|
||||
let immersiveTestName = "XRSession cancelAnimationFrame does not have unexpected "
|
||||
|
@ -10,7 +11,7 @@
|
|||
let nonImmersiveTestName = "XRSession cancelAnimationFrame does not have unexpected "
|
||||
+ "behavior when given invalid handles on non-immersive testSession";
|
||||
|
||||
let fakeDeviceInitParams = { supportsImmersive:true };
|
||||
let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE;
|
||||
|
||||
let testFunction = (testSession) => new Promise((resolve) => {
|
||||
let counter = 0;
|
||||
|
|
|
@ -3,13 +3,14 @@
|
|||
<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>
|
||||
<canvas></canvas>
|
||||
|
||||
<script>
|
||||
const immersivetestName = "end event fires when immersive session ends";
|
||||
const nonimmersiveTestName = "end event fires when non-immersive session ends";
|
||||
let watcherDone = new Event("watcherdone");
|
||||
const fakeDeviceInitParams = { supportsImmersive:true };
|
||||
const fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE;
|
||||
|
||||
let testFunction = function(session, testDeviceController, t) {
|
||||
let eventWatcher = new EventWatcher(t, session, ["end", "watcherdone"]);
|
||||
|
@ -32,4 +33,4 @@
|
|||
xr_session_promise_test(nonimmersiveTestName, testFunction,
|
||||
fakeDeviceInitParams, 'inline');
|
||||
</script>
|
||||
</body>
|
||||
</body>
|
||||
|
|
|
@ -3,18 +3,19 @@
|
|||
<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>
|
||||
<canvas></canvas>
|
||||
|
||||
<script>
|
||||
xr_promise_test(
|
||||
"Test prevention of multiple simultaneous immersive sessions",
|
||||
(t) => {
|
||||
return XRTest.simulateDeviceConnection({ supportsImmersive:true })
|
||||
return navigator.xr.test.simulateDeviceConnection(TRACKED_IMMERSIVE_DEVICE)
|
||||
.then( (controller) => new Promise((resolve) => {
|
||||
XRTest.simulateUserActivation( () => {
|
||||
navigator.xr.test.simulateUserActivation( () => {
|
||||
resolve(navigator.xr.requestSession('immersive-vr')
|
||||
.then( (session) => new Promise((resolve) => {
|
||||
XRTest.simulateUserActivation( () => {
|
||||
navigator.xr.test.simulateUserActivation( () => {
|
||||
// Requesting a second immersive session when another immersive
|
||||
// session is active should fail. Immersive sessions
|
||||
// should take up the users entire view, and therefore it should
|
||||
|
@ -27,7 +28,7 @@
|
|||
// End the immersive session and try again. Now the immersive
|
||||
// session creation should succeed.
|
||||
return session.end().then( () => new Promise((resolve) => {
|
||||
XRTest.simulateUserActivation( () => {
|
||||
navigator.xr.test.simulateUserActivation( () => {
|
||||
resolve(navigator.xr.requestSession('immersive-vr'));
|
||||
});
|
||||
}));
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<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>
|
||||
<canvas></canvas>
|
||||
|
||||
<script>
|
||||
|
@ -11,7 +12,7 @@
|
|||
let nonImmersiveTestName = "XRSession requestAnimationFrame calls the " +
|
||||
"provided callback a non-immersive session";
|
||||
|
||||
let fakeDeviceInitParams = { supportsImmersive:true };
|
||||
let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE;
|
||||
|
||||
let testFunction = (testSession) => new Promise((resolve) => {
|
||||
function onFrame(time, xrFrame) {
|
||||
|
@ -29,4 +30,4 @@
|
|||
fakeDeviceInitParams, 'inline');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</body>
|
||||
|
|
|
@ -3,31 +3,13 @@
|
|||
<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>
|
||||
<canvas></canvas>
|
||||
|
||||
<script>
|
||||
const testName = "RequestAnimationFrame resolves with good data";
|
||||
|
||||
const identityMatrix = new Float32Array([
|
||||
1, 0, 0, 0,
|
||||
0, 1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, 0, 0, 1
|
||||
]);
|
||||
|
||||
const rightFakeXRViewInit = {
|
||||
eye:"right",
|
||||
projectionMatrix: identityMatrix,
|
||||
viewMatrix: identityMatrix
|
||||
};
|
||||
|
||||
const leftFakeXRViewInit = {
|
||||
eye:"left",
|
||||
projectionMatrix: identityMatrix,
|
||||
viewMatrix: identityMatrix
|
||||
};
|
||||
|
||||
const fakeDeviceInitOptions = { supportsImmersive:true };
|
||||
const fakeDeviceInitOptions = TRACKED_IMMERSIVE_DEVICE;
|
||||
|
||||
let testSession;
|
||||
|
||||
|
@ -52,8 +34,8 @@
|
|||
let viewerPose = xrFrame.getViewerPose(referenceSpace);
|
||||
|
||||
assert_not_equals(viewerPose, null);
|
||||
for(let i = 0; i < identityMatrix.length; i++) {
|
||||
assert_equals(viewerPose.transform.matrix[i], identityMatrix[i]);
|
||||
for(let i = 0; i < IDENTITY_MATRIX.length; i++) {
|
||||
assert_equals(viewerPose.transform.matrix[i], IDENTITY_MATRIX[i]);
|
||||
}
|
||||
|
||||
assert_not_equals(viewerPose.views, null);
|
||||
|
@ -65,11 +47,6 @@
|
|||
resolve();
|
||||
}
|
||||
|
||||
testDeviceController.setXRPresentationFrameData(
|
||||
identityMatrix,
|
||||
[rightFakeXRViewInit, leftFakeXRViewInit]
|
||||
);
|
||||
|
||||
testSession.requestAnimationFrame(onFrame);
|
||||
})
|
||||
);
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
<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="resources/xr-test-asserts.js"></script>
|
||||
<canvas></canvas>
|
||||
|
||||
<script>
|
||||
|
@ -12,12 +14,22 @@
|
|||
let nonImmersiveTestName =
|
||||
"XRFrame getViewerPose updates on the next frame for non-immersive sessions";
|
||||
|
||||
let fakeDeviceInitParams = { supportsImmersive: true };
|
||||
let fakeDeviceInitParams = {
|
||||
supportsImmersive: true,
|
||||
views: VALID_VIEWS
|
||||
};
|
||||
|
||||
// Valid matrices for when we don't care about specific values
|
||||
const validPoseMatrix = [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1];
|
||||
const validProjectionMatrix = [1, 0, 0, 0, 0, 1, 0, 0, 3, 2, -1, -1, 0, 0, -0.2, 0];
|
||||
const validViewMatrix = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 4, 3, 2, 1];
|
||||
// A valid pose matrix/transform for when we don't care about specific values
|
||||
// Note that these two should be identical, just different representations
|
||||
const expectedPoseMatrix = [0, 1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
1, 0, 0, 0,
|
||||
1, 1, 1, 1];
|
||||
|
||||
const poseTransform = {
|
||||
position: [1, 1, 1],
|
||||
orientation: [0.5, 0.5, 0.5, 0.5]
|
||||
};
|
||||
|
||||
let testFunction = function(session, fakeDeviceController, t) {
|
||||
return session.requestReferenceSpace('local')
|
||||
|
@ -30,16 +42,7 @@
|
|||
// Expecting to not get a pose since none has been supplied
|
||||
assert_equals(vrFrame.getViewerPose(referenceSpace), null);
|
||||
|
||||
fakeDeviceController.setXRPresentationFrameData(
|
||||
validPoseMatrix, [{
|
||||
eye:"left",
|
||||
projectionMatrix: validProjectionMatrix,
|
||||
viewMatrix: validViewMatrix
|
||||
}, {
|
||||
eye:"right",
|
||||
projectionMatrix: validProjectionMatrix,
|
||||
viewMatrix: validViewMatrix
|
||||
}]);
|
||||
fakeDeviceController.setViewerOrigin(poseTransform);
|
||||
|
||||
// Check that pose does not update pose within the same frame.
|
||||
assert_equals(vrFrame.getViewerPose(referenceSpace), null);
|
||||
|
@ -51,10 +54,7 @@
|
|||
|
||||
let poseMatrix = pose.transform.matrix;
|
||||
assert_not_equals(poseMatrix, null);
|
||||
|
||||
for(let i = 0; i < poseMatrix.length; i++) {
|
||||
assert_equals(poseMatrix[i], validPoseMatrix[i]);
|
||||
}
|
||||
assert_matrix_approx_equals(poseMatrix, expectedPoseMatrix, FLOAT_EPSILON);
|
||||
});
|
||||
|
||||
// Finished.
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<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>
|
||||
<canvas></canvas>
|
||||
<script>
|
||||
|
||||
|
@ -11,7 +12,7 @@
|
|||
let nonImmersiveTestName =
|
||||
"Non-immersive XRSession requestReferenceSpace returns expected objects";
|
||||
|
||||
let fakeDeviceInitParams = { supportsImmersive: true };
|
||||
let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE;
|
||||
|
||||
let testFunction = function(session, fakeDeviceController, t) {
|
||||
return promise_rejects(t, new TypeError(), session.requestReferenceSpace('foo'))
|
||||
|
@ -61,4 +62,4 @@
|
|||
nonImmersiveTestName, testFunction, fakeDeviceInitParams, 'inline');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</body>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<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>
|
||||
<canvas></canvas>
|
||||
|
||||
<script>
|
||||
|
@ -12,14 +13,7 @@
|
|||
let inlineTestName =
|
||||
"Identity reference space provides correct poses for inline sessions";
|
||||
|
||||
let fakeDeviceInitParams = { supportsImmersive: true };
|
||||
|
||||
const identityMatrix = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
||||
|
||||
// Valid matrices for when we don't care about specific values
|
||||
const validPoseMatrix = [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1];
|
||||
const validProjectionMatrix = [1, 0, 0, 0, 0, 1, 0, 0, 3, 2, -1, -1, 0, 0, -0.2, 0];
|
||||
const validViewMatrix = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 4, 3, 2, 1];
|
||||
let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE;
|
||||
|
||||
let testFunction = function(session, fakeDeviceController, t) {
|
||||
return session.requestReferenceSpace('viewer')
|
||||
|
@ -37,19 +31,10 @@
|
|||
assert_not_equals(poseMatrix, null);
|
||||
|
||||
for(let i = 0; i < poseMatrix.length; i++) {
|
||||
assert_equals(poseMatrix[i], identityMatrix[i]);
|
||||
assert_equals(poseMatrix[i], IDENTITY_MATRIX[i]);
|
||||
}
|
||||
|
||||
fakeDeviceController.setXRPresentationFrameData(
|
||||
validPoseMatrix, [{
|
||||
eye:"left",
|
||||
projectionMatrix: validProjectionMatrix,
|
||||
viewMatrix: validViewMatrix
|
||||
}, {
|
||||
eye:"right",
|
||||
projectionMatrix: validProjectionMatrix,
|
||||
viewMatrix: validViewMatrix
|
||||
}]);
|
||||
fakeDeviceController.setViewerOrigin(VALID_POSE_TRANSFORM);
|
||||
});
|
||||
} else {
|
||||
t.step( () => {
|
||||
|
@ -62,7 +47,7 @@
|
|||
assert_not_equals(poseMatrix, null);
|
||||
|
||||
for(let i = 0; i < poseMatrix.length; i++) {
|
||||
assert_equals(poseMatrix[i], identityMatrix[i]);
|
||||
assert_equals(poseMatrix[i], IDENTITY_MATRIX[i]);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/test-constants.js"></script>
|
||||
<script src="resources/webxr_test_constants.js"></script>
|
||||
<script src="resources/webxr_util.js"></script>
|
||||
<script src="resources/xr-test-asserts.js"></script>
|
||||
<canvas></canvas>
|
||||
|
@ -11,20 +11,9 @@
|
|||
let immersiveTestName = "XRView.eye is correct for immersive sessions";
|
||||
let nonImmersiveTestName = "XRView.eye is correct for non-immersive sessions";
|
||||
|
||||
let fakeDeviceInitParams = { supportsImmersive:true };
|
||||
let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE;
|
||||
|
||||
let testFunction = function(session, fakeDeviceController, t) {
|
||||
// Need to have a valid pose or input events 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('viewer')
|
||||
.then((space) => new Promise((resolve) => {
|
||||
function onFrame(time, xrFrame) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/test-constants.js"></script>
|
||||
<script src="resources/webxr_test_constants.js"></script>
|
||||
<script src="resources/webxr_util.js"></script>
|
||||
<script src="resources/xr-test-asserts.js"></script>
|
||||
<canvas></canvas>
|
||||
|
@ -11,20 +11,9 @@
|
|||
let immersiveTestName = "XRWebGLLayer reports a valid viewports for immersive sessions";
|
||||
let inlineTestName = "XRWebGLLayer reports a valid viewports for inline sessions";
|
||||
|
||||
let fakeDeviceInitParams = { supportsImmersive:true };
|
||||
let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE;
|
||||
|
||||
let testFunction = function(session, fakeDeviceController, t) {
|
||||
// Need to have a valid pose.
|
||||
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('viewer')
|
||||
.then((space) => new Promise((resolve) => {
|
||||
function onFrame(time, xrFrame) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче