Commit db70ccb2 authored by Alex Cooper's avatar Alex Cooper Committed by Commit Bot

Swap testFunction and xr_session_promise_test param orders

Purely mechanical changes to swap the order of params from the helpers
in xr-test-utils.js to match those from webxr_util.js so that porting
tests can be more straightforward.

Does not address the potentially more complicated work of only one
sessionMode or the test harness handling the baseLayer yet.

Bug: 981003
Change-Id: I5a57b814582b88297a98c64c1fa452fe22736ee0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1704697
Auto-Submit: Alexander Cooper <alcooper@chromium.org>
Reviewed-by: default avatarBill Orr <billorr@chromium.org>
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/master@{#678451}
parent 43da8579
...@@ -24,7 +24,7 @@ let expectedHitMatrix = [1, 0, 0, 1, ...@@ -24,7 +24,7 @@ let expectedHitMatrix = [1, 0, 0, 1,
0, 0, 1, 3, 0, 0, 1, 3,
0, 0, 0, 1]; 0, 0, 0, 1];
let testFunction = function(session, t, fakeDeviceController) { let testFunction = function(session, fakeDeviceController, t) {
assert_equals(session.mode, 'immersive-ar'); assert_equals(session.mode, 'immersive-ar');
assert_not_equals(session.environmentBlendMode, 'opaque'); assert_not_equals(session.environmentBlendMode, 'opaque');
return session.requestReferenceSpace('local').then((referenceSpace) => { return session.requestReferenceSpace('local').then((referenceSpace) => {
...@@ -53,6 +53,6 @@ let testFunction = function(session, t, fakeDeviceController) { ...@@ -53,6 +53,6 @@ let testFunction = function(session, t, fakeDeviceController) {
}; };
xr_session_promise_test( xr_session_promise_test(
testFunction, fakeDeviceInitParams, requestSessionModes, testName); testName, testFunction, fakeDeviceInitParams, requestSessionModes);
</script> </script>
...@@ -46,6 +46,6 @@ let testFunction = (session) => new Promise((resolve, reject) => { ...@@ -46,6 +46,6 @@ let testFunction = (session) => new Promise((resolve, reject) => {
}); });
xr_session_promise_test( xr_session_promise_test(
testFunction, fakeDeviceInitParams, requestSessionModes, testName); testName, testFunction, fakeDeviceInitParams, requestSessionModes);
</script> </script>
...@@ -16,7 +16,7 @@ let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE; ...@@ -16,7 +16,7 @@ let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE;
let requestSessionModes = ['immersive-vr']; let requestSessionModes = ['immersive-vr'];
let testFunction = function(session, t, fakeDeviceController) { let testFunction = function(session, fakeDeviceController, t) {
// Session must have a baseLayer or frame requests will be ignored. // Session must have a baseLayer or frame requests will be ignored.
session.updateRenderState({ session.updateRenderState({
...@@ -50,6 +50,6 @@ let testFunction = function(session, t, fakeDeviceController) { ...@@ -50,6 +50,6 @@ let testFunction = function(session, t, fakeDeviceController) {
}; };
xr_session_promise_test( xr_session_promise_test(
testFunction, fakeDeviceInitParams, requestSessionModes, testName); testName, testFunction, fakeDeviceInitParams, requestSessionModes);
</script> </script>
...@@ -25,7 +25,7 @@ function assertApproximatelyEqual(a, b, step, epsilon = FLOAT_EPSILON) { ...@@ -25,7 +25,7 @@ function assertApproximatelyEqual(a, b, step, epsilon = FLOAT_EPSILON) {
assert_less_than(Math.abs(a - b), epsilon, step); assert_less_than(Math.abs(a - b), epsilon, step);
} }
let testFunction = function(session, t, fakeDeviceController) { let testFunction = function(session, fakeDeviceController, t) {
// Session must have a baseLayer or frame requests will be ignored. // Session must have a baseLayer or frame requests will be ignored.
session.updateRenderState({ session.updateRenderState({
baseLayer: new XRWebGLLayer(session, gl, { compositionDisabled: true }) baseLayer: new XRWebGLLayer(session, gl, { compositionDisabled: true })
...@@ -89,6 +89,6 @@ let testFunction = function(session, t, fakeDeviceController) { ...@@ -89,6 +89,6 @@ let testFunction = function(session, t, fakeDeviceController) {
}; };
xr_session_promise_test( xr_session_promise_test(
testFunction, fakeDeviceInitParams, requestSessionModes, testName); testName, testFunction, fakeDeviceInitParams, requestSessionModes);
</script> </script>
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// performs tests. If func returns a promise, test will only pass if the promise // performs tests. If func returns a promise, test will only pass if the promise
// resolves. // resolves.
function xr_session_promise_test( function xr_session_promise_test(
func, deviceOptions, sessionModes, name, properties) { name, func, deviceOptions, sessionModes, properties) {
if (document.getElementById('webgl-canvas') || if (document.getElementById('webgl-canvas') ||
document.getElementById('webgl2-canvas')) { document.getElementById('webgl2-canvas')) {
webglCanvasSetup(); webglCanvasSetup();
...@@ -42,7 +42,7 @@ function xr_session_promise_test( ...@@ -42,7 +42,7 @@ function xr_session_promise_test(
.then((session) => { .then((session) => {
testSession = session; testSession = session;
testSession.mode = nextMode; testSession.mode = nextMode;
return func(session, t, fakeDeviceController); return func(session, fakeDeviceController, t);
}) })
.then(() => { .then(() => {
// End the session. Silence any errors generated if the // End the session. Silence any errors generated if the
......
...@@ -24,7 +24,7 @@ let requestSessionModes = [ ...@@ -24,7 +24,7 @@ let requestSessionModes = [
'immersive-vr', 'immersive-vr',
]; ];
let testFunction = function(session, t, fakeDeviceController) { let testFunction = function(session, fakeDeviceController, t) {
// Session must have a baseLayer or else frame requests will be ignored. // Session must have a baseLayer or else frame requests will be ignored.
session.updateRenderState({ session.updateRenderState({
baseLayer: new XRWebGLLayer(session, gl) baseLayer: new XRWebGLLayer(session, gl)
...@@ -94,6 +94,6 @@ let testFunction = function(session, t, fakeDeviceController) { ...@@ -94,6 +94,6 @@ let testFunction = function(session, t, fakeDeviceController) {
}; };
xr_session_promise_test( xr_session_promise_test(
testFunction, fakeDeviceInitParams, requestSessionModes, testName); testName, testFunction, fakeDeviceInitParams, requestSessionModes);
</script> </script>
...@@ -19,7 +19,7 @@ let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE; ...@@ -19,7 +19,7 @@ let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE;
let requestSessionModes = ['immersive-vr']; let requestSessionModes = ['immersive-vr'];
let testFunction = function(session, t, fakeDeviceController) { let testFunction = function(session, fakeDeviceController, t) {
// Session must have a baseLayer or frame requests will be ignored. // Session must have a baseLayer or frame requests will be ignored.
let webglLayer = new XRWebGLLayer(session, gl); let webglLayer = new XRWebGLLayer(session, gl);
session.updateRenderState({ baseLayer: webglLayer }); session.updateRenderState({ baseLayer: webglLayer });
...@@ -47,6 +47,6 @@ let testFunction = function(session, t, fakeDeviceController) { ...@@ -47,6 +47,6 @@ let testFunction = function(session, t, fakeDeviceController) {
}; };
xr_session_promise_test( xr_session_promise_test(
testFunction, fakeDeviceInitParams, requestSessionModes, testName); testName, testFunction, fakeDeviceInitParams, requestSessionModes);
</script> </script>
...@@ -16,7 +16,7 @@ let testName = "Immersive session ends if data provider disconnects."; ...@@ -16,7 +16,7 @@ let testName = "Immersive session ends if data provider disconnects.";
let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE; let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE;
let requestSessionModes = ['immersive-vr']; let requestSessionModes = ['immersive-vr'];
let testFunction = function(session, t, fakeDeviceController) { let testFunction = function(session, fakeDeviceController, t) {
return new Promise((resolve) => { return new Promise((resolve) => {
// Session must have a baseLayer or frame requests will be ignored. // Session must have a baseLayer or frame requests will be ignored.
session.updateRenderState({ baseLayer: new XRWebGLLayer(session, gl) }); session.updateRenderState({ baseLayer: new XRWebGLLayer(session, gl) });
...@@ -34,6 +34,6 @@ let testFunction = function(session, t, fakeDeviceController) { ...@@ -34,6 +34,6 @@ let testFunction = function(session, t, fakeDeviceController) {
} }
xr_session_promise_test( xr_session_promise_test(
testFunction, fakeDeviceInitParams, requestSessionModes, testName); testName, testFunction, fakeDeviceInitParams, requestSessionModes);
</script> </script>
...@@ -16,7 +16,7 @@ let testName = "Inline session ends if magic window data provider disconnects."; ...@@ -16,7 +16,7 @@ let testName = "Inline session ends if magic window data provider disconnects.";
let fakeDeviceInitParams = VALID_NON_IMMERSIVE_DEVICE; let fakeDeviceInitParams = VALID_NON_IMMERSIVE_DEVICE;
let requestSessionModes = ['inline']; let requestSessionModes = ['inline'];
let testFunction = function(session, t, fakeDeviceController) { let testFunction = function(session, fakeDeviceController, t) {
return new Promise((resolve) => { return new Promise((resolve) => {
// Session must have a baseLayer or frame requests will be ignored. // Session must have a baseLayer or frame requests will be ignored.
session.updateRenderState({ session.updateRenderState({
...@@ -36,6 +36,6 @@ let testFunction = function(session, t, fakeDeviceController) { ...@@ -36,6 +36,6 @@ let testFunction = function(session, t, fakeDeviceController) {
} }
xr_session_promise_test( xr_session_promise_test(
testFunction, fakeDeviceInitParams, requestSessionModes, testName); testName, testFunction, fakeDeviceInitParams, requestSessionModes);
</script> </script>
...@@ -19,23 +19,23 @@ let requestSessionModes = [ ...@@ -19,23 +19,23 @@ let requestSessionModes = [
'immersive-vr', 'immersive-vr',
]; ];
let testFunction = function(session, t) { let testFunction = function(session, fakeDeviceController, t) {
t.step(() => { t.step(() => {
assert_equals(session.environmentBlendMode, 'opaque'); assert_equals(session.environmentBlendMode, 'opaque');
}); });
}; };
xr_session_promise_test( xr_session_promise_test(
testFunction, fakeDeviceInitParams, requestSessionModes, testName); testName, testFunction, fakeDeviceInitParams, requestSessionModes);
// TODO(https://crbug.com/828321): Enable once session options for AR are in place. // TODO(https://crbug.com/828321): Enable once session options for AR are in place.
/*xr_session_promise_test( (session, t) => { /*xr_session_promise_test("environmentBlendMode is correct for an AR device",
(session, fakeDeviceController, t) => {
t.step(() => { t.step(() => {
assert_equals(session.environmentBlendMode, 'alpha-blend'); assert_equals(session.environmentBlendMode, 'alpha-blend');
}); });
}, fakeDevices["FakeARPhone"], [ }, fakeDevices["FakeARPhone"], [
{ ar: true, outputContext: getOutputContext() } { ar: true, outputContext: getOutputContext() }
], ]);*/
"environmentBlendMode is correct for an AR device");*/
</script> </script>
...@@ -39,7 +39,7 @@ MockRuntime.prototype.requestHitTest = function(Ray) { ...@@ -39,7 +39,7 @@ MockRuntime.prototype.requestHitTest = function(Ray) {
return new Promise((resolve,reject) => { }); return new Promise((resolve,reject) => { });
} }
let testFunction = function(session, t, controller) { let testFunction = function(session, fakeDeviceController, t) {
return session.requestReferenceSpace('local') return session.requestReferenceSpace('local')
.then((referenceSpace) => { .then((referenceSpace) => {
refSpace = referenceSpace; refSpace = referenceSpace;
...@@ -51,7 +51,7 @@ let testFunction = function(session, t, controller) { ...@@ -51,7 +51,7 @@ let testFunction = function(session, t, controller) {
.then(() => { .then(() => {
immediatelyResolveHitTest = false; immediatelyResolveHitTest = false;
let hitTestPromise = session.requestHitTest(ray, refSpace); let hitTestPromise = session.requestHitTest(ray, refSpace);
controller.closeEnvironmentIntegrationProvider(); fakeDeviceController.closeEnvironmentIntegrationProvider();
return hitTestPromise; return hitTestPromise;
}) })
.then(() => { .then(() => {
...@@ -63,6 +63,6 @@ let testFunction = function(session, t, controller) { ...@@ -63,6 +63,6 @@ let testFunction = function(session, t, controller) {
}; };
xr_session_promise_test( xr_session_promise_test(
testFunction, fakeDeviceInitParams, requestSessionModes, testName); testName, testFunction, fakeDeviceInitParams, requestSessionModes);
</script> </script>
...@@ -21,7 +21,7 @@ let requestSessionModes = [ ...@@ -21,7 +21,7 @@ let requestSessionModes = [
'immersive-vr', 'immersive-vr',
]; ];
let testFunction = function(session, t, fakeDeviceController) { let testFunction = function(session, fakeDeviceController, t) {
// Session must have a baseLayer or else frame requests will be ignored. // Session must have a baseLayer or else frame requests will be ignored.
session.updateRenderState({ session.updateRenderState({
baseLayer: new XRWebGLLayer(session, gl, { baseLayer: new XRWebGLLayer(session, gl, {
...@@ -98,6 +98,6 @@ let testFunction = function(session, t, fakeDeviceController) { ...@@ -98,6 +98,6 @@ let testFunction = function(session, t, fakeDeviceController) {
}; };
xr_session_promise_test( xr_session_promise_test(
testFunction, fakeDeviceInitParams, requestSessionModes, testName); testName, testFunction, fakeDeviceInitParams, requestSessionModes);
</script> </script>
...@@ -33,7 +33,7 @@ let fakeDeviceInitParams = { ...@@ -33,7 +33,7 @@ let fakeDeviceInitParams = {
let requestSessionModes = ['immersive-vr']; let requestSessionModes = ['immersive-vr'];
let testFunction = function(session, t, fakeDeviceController) { let testFunction = function(session, fakeDeviceController, t) {
// Session must have a baseLayer or frame requests will be ignored. // Session must have a baseLayer or frame requests will be ignored.
let webglLayer = new XRWebGLLayer(session, gl); let webglLayer = new XRWebGLLayer(session, gl);
session.updateRenderState({ baseLayer: webglLayer }); session.updateRenderState({ baseLayer: webglLayer });
...@@ -89,6 +89,6 @@ let testFunction = function(session, t, fakeDeviceController) { ...@@ -89,6 +89,6 @@ let testFunction = function(session, t, fakeDeviceController) {
}; };
xr_session_promise_test( xr_session_promise_test(
testFunction, fakeDeviceInitParams, requestSessionModes, testName); testName, testFunction, fakeDeviceInitParams, requestSessionModes);
</script> </script>
...@@ -34,7 +34,7 @@ let fakeDeviceInitParams = { ...@@ -34,7 +34,7 @@ let fakeDeviceInitParams = {
let requestSessionModes = ['immersive-vr']; let requestSessionModes = ['immersive-vr'];
let testFunction = function(session, t, fakeDeviceController) { let testFunction = function(session, fakeDeviceController, t) {
// Session must have a baseLayer or frame requests will be ignored. // Session must have a baseLayer or frame requests will be ignored.
session.updateRenderState({ baseLayer: new XRWebGLLayer(session, gl) }); session.updateRenderState({ baseLayer: new XRWebGLLayer(session, gl) });
...@@ -81,6 +81,6 @@ let testFunction = function(session, t, fakeDeviceController) { ...@@ -81,6 +81,6 @@ let testFunction = function(session, t, fakeDeviceController) {
}; };
xr_session_promise_test( xr_session_promise_test(
testFunction, fakeDeviceInitParams, requestSessionModes, testName); testName, testFunction, fakeDeviceInitParams, requestSessionModes);
</script> </script>
...@@ -15,7 +15,7 @@ let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE; ...@@ -15,7 +15,7 @@ let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE;
let requestSessionModes = ['immersive-vr']; let requestSessionModes = ['immersive-vr'];
let testFunction = function(session, t, fakeDeviceController) { let testFunction = function(session, fakeDeviceController, t) {
// Session must have a baseLayer or frame requests will be ignored. // Session must have a baseLayer or frame requests will be ignored.
let webglLayer = new XRWebGLLayer(session, gl); let webglLayer = new XRWebGLLayer(session, gl);
session.updateRenderState({ baseLayer: webglLayer }); session.updateRenderState({ baseLayer: webglLayer });
...@@ -79,6 +79,6 @@ let testFunction = function(session, t, fakeDeviceController) { ...@@ -79,6 +79,6 @@ let testFunction = function(session, t, fakeDeviceController) {
}; };
xr_session_promise_test( xr_session_promise_test(
testFunction, fakeDeviceInitParams, requestSessionModes, testName); testName, testFunction, fakeDeviceInitParams, requestSessionModes);
</script> </script>
...@@ -17,7 +17,7 @@ let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE; ...@@ -17,7 +17,7 @@ let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE;
let requestSessionModes = ['immersive-vr']; let requestSessionModes = ['immersive-vr'];
let testFunction = let testFunction =
(session, t, fakeDeviceController) => new Promise((resolve, reject) => { (session, fakeDeviceController, t) => new Promise((resolve, reject) => {
try { try {
let webglLayerGood = new XRWebGLLayer(session, gl); let webglLayerGood = new XRWebGLLayer(session, gl);
} catch (err) { } catch (err) {
...@@ -54,6 +54,6 @@ let testFunction = ...@@ -54,6 +54,6 @@ let testFunction =
}); });
xr_session_promise_test( xr_session_promise_test(
testFunction, fakeDeviceInitParams, requestSessionModes, testName); testName, testFunction, fakeDeviceInitParams, requestSessionModes);
</script> </script>
...@@ -19,7 +19,7 @@ let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE; ...@@ -19,7 +19,7 @@ let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE;
let requestSessionModes = ['immersive-vr']; let requestSessionModes = ['immersive-vr'];
let testFunction = let testFunction =
(session, t, fakeDeviceController) => new Promise((resolve, reject) => { (session, fakeDeviceController, t) => new Promise((resolve, reject) => {
// Session must have a baseLayer or else frame requests will be ignored. // Session must have a baseLayer or else frame requests will be ignored.
let webglLayer = new XRWebGLLayer(session, gl); let webglLayer = new XRWebGLLayer(session, gl);
session.updateRenderState({ baseLayer: webglLayer }); session.updateRenderState({ baseLayer: webglLayer });
...@@ -63,6 +63,6 @@ let testFunction = ...@@ -63,6 +63,6 @@ let testFunction =
}); });
xr_session_promise_test( xr_session_promise_test(
testFunction, fakeDeviceInitParams, requestSessionModes, testName); testName, testFunction, fakeDeviceInitParams, requestSessionModes);
</script> </script>
...@@ -38,7 +38,7 @@ function setupProgram(gl, vertexSrc, fragmentSrc) { ...@@ -38,7 +38,7 @@ function setupProgram(gl, vertexSrc, fragmentSrc) {
} }
let testFunction = let testFunction =
(session, t, fakeDeviceController) => new Promise((resolve, reject) => { (session, fakeDeviceController, t) => new Promise((resolve, reject) => {
// Setup simple WebGL geometry to draw with. // Setup simple WebGL geometry to draw with.
let program = setupProgram(gl, let program = setupProgram(gl,
"attribute vec4 vPosition; void main() { gl_Position = vPosition; }", "attribute vec4 vPosition; void main() { gl_Position = vPosition; }",
...@@ -95,6 +95,6 @@ let testFunction = ...@@ -95,6 +95,6 @@ let testFunction =
}); });
xr_session_promise_test( xr_session_promise_test(
testFunction, fakeDeviceInitParams, requestSessionModes, testName); testName, testFunction, fakeDeviceInitParams, requestSessionModes);
</script> </script>
...@@ -17,7 +17,7 @@ let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE; ...@@ -17,7 +17,7 @@ let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE;
let requestSessionModes = ['immersive-vr']; let requestSessionModes = ['immersive-vr'];
let testFunction = let testFunction =
(session, t, fakeDeviceController) => new Promise((resolve, reject) => { (session, fakeDeviceController, t) => new Promise((resolve, reject) => {
// Session must have a baseLayer or else frame requests will be ignored. // Session must have a baseLayer or else frame requests will be ignored.
let webglLayer = new XRWebGLLayer(session, gl); let webglLayer = new XRWebGLLayer(session, gl);
let defaultFramebufferWidth = webglLayer.framebufferWidth; let defaultFramebufferWidth = webglLayer.framebufferWidth;
...@@ -59,6 +59,6 @@ let testFunction = ...@@ -59,6 +59,6 @@ let testFunction =
}); });
xr_session_promise_test( xr_session_promise_test(
testFunction, fakeDeviceInitParams, requestSessionModes, testName); testName, testFunction, fakeDeviceInitParams, requestSessionModes);
</script> </script>
...@@ -19,7 +19,7 @@ let requestSessionModes = [ ...@@ -19,7 +19,7 @@ let requestSessionModes = [
]; ];
let testFunction = let testFunction =
(session, t, fakeDeviceController) => new Promise((resolve, reject) => { (session, fakeDeviceController, t) => new Promise((resolve, reject) => {
// Session must have a baseLayer or frame requests will be ignored. // Session must have a baseLayer or frame requests will be ignored.
let webglLayer = new XRWebGLLayer(session, gl, { let webglLayer = new XRWebGLLayer(session, gl, {
compositionDisabled: session.mode == 'inline' }); compositionDisabled: session.mode == 'inline' });
...@@ -119,6 +119,6 @@ let testFunction = ...@@ -119,6 +119,6 @@ let testFunction =
}); });
xr_session_promise_test( xr_session_promise_test(
testFunction, fakeDeviceInitParams, requestSessionModes, testName); testName, testFunction, fakeDeviceInitParams, requestSessionModes);
</script> </script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment