Update test API, hook it up to webxr mocking

This commit is contained in:
Manish Goregaokar 2019-07-10 11:33:11 -07:00
parent b818af794a
commit 0d5d1a3dc4
11 changed files with 158 additions and 79 deletions

View file

@ -19687,11 +19687,11 @@
"testharness"
],
"webxr/obtain_frame.html": [
"e2b4424d5779baedf6bdb50f1b3151336f31a4cb",
"063008c7ebc0df9997b8286296b4f7fe4663b331",
"testharness"
],
"webxr/resources/webxr-util.js": [
"554c1c183d3710e54dc60704dad0aac542ffd67c",
"f0c166e097271fd6a2709428fab2ccffea1eb08a",
"support"
]
},

View file

@ -54,9 +54,9 @@
pose = frame.getViewerPose(offset);
for (view of pose.views) {
if (view.eye == "left") {
assert_matrix_approx_equals(view.transform.matrix, [-1/3,-2/3,2/3,0,-2/3,2/3,1/3,0,-2/3,-1/3,-2/3,0,3.4,-1.9,-0.9,1], 0.001, "left offset transform");
assert_matrix_approx_equals(view.transform.matrix, [-1/3,-2/3,2/3,0,-2/3,2/3,1/3,0,-2/3,-1/3,-2/3,0,3.5 + 1/30,-1.9 + 2/30,-0.9 - 2/30,1], 0.001, "left offset transform");
} else if (view.eye == "right") {
assert_matrix_approx_equals(view.transform.matrix, [-1/3,-2/3,2/3,0,-2/3,2/3,1/3,0,-2/3,-1/3,-2/3,0,3.6,-1.9,-0.9,1], 0.001, "right offset transform");
assert_matrix_approx_equals(view.transform.matrix, [-1/3,-2/3,2/3,0,-2/3,2/3,1/3,0,-2/3,-1/3,-2/3,0,3.5 - 1/30,-1.9 - 2/30,-0.9 + 2/30,1], 0.001, "right offset transform");
} else {
throw "got unknown view";
}

View file

@ -1,10 +1,9 @@
// pieced together from various things in wpt/webxr/resources
const VALID_PROJECTION_MATRIX = [1, 0, 0, 0, 0, 1, 0, 0, 3, 2, -1, -1, 0, 0, -0.2, 0];
const LEFT_OFFSET = {position: [-0.1, 0, 0], orientation: [0,0,0,0]};
const RIGHT_OFFSET = {position: [0.1, 0, 0], orientation: [0,0,0,0]};
const LEFT_VIEWPORT = {x: 0, y: 0, width: 320, height: 480};
const RIGHT_VIEWPORT = {x: 320, y: 0, width: 320, height: 480};
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 RESOLUTION = {width: 320, height: 480};
let assert_matrix_approx_equals = function(m1, m2, epsilon, prefix = "") {
assert_equals(m1.length, m2.length, prefix + "Matrix lengths should match");
for(var i = 0; i < m1.length; ++i) {
@ -13,6 +12,6 @@ let assert_matrix_approx_equals = function(m1, m2, epsilon, prefix = "") {
}
const TEST_VIEWS = [
{eye: "left", projectionMatrix: VALID_PROJECTION_MATRIX, viewOffset: LEFT_OFFSET, viewport: LEFT_VIEWPORT},
{eye: "right", projectionMatrix: VALID_PROJECTION_MATRIX, viewOffset: RIGHT_OFFSET, viewport: RIGHT_VIEWPORT}
{eye: "left", projectionMatrix: VALID_PROJECTION_MATRIX, viewOffset: LEFT_OFFSET, resolution: RESOLUTION},
{eye: "right", projectionMatrix: VALID_PROJECTION_MATRIX, viewOffset: RIGHT_OFFSET, resolution: RESOLUTION}
];