From 01665fe94af22facecc80563bebc03778c50576d Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 10 Jun 2019 16:19:37 -0700 Subject: [PATCH] Add basic XR tests --- tests/wpt/mozilla/meta/MANIFEST.json | 29 ++++++++- tests/wpt/mozilla/meta/webxr/__dir__.ini | 2 + .../mozilla/tests/webxr/create_session.html | 15 +++++ .../wpt/mozilla/tests/webxr/obtain_frame.html | 62 +++++++++++++++++++ .../tests/webxr/resources/webxr-util.js | 17 +++++ 5 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 tests/wpt/mozilla/meta/webxr/__dir__.ini create mode 100644 tests/wpt/mozilla/tests/webxr/create_session.html create mode 100644 tests/wpt/mozilla/tests/webxr/obtain_frame.html create mode 100644 tests/wpt/mozilla/tests/webxr/resources/webxr-util.js diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index a2623a0c338..b17f863e64d 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -11222,7 +11222,10 @@ {} ] ], - "mozilla/xmlhttprequest_url.html": [] + "mozilla/xmlhttprequest_url.html": [], + "webxr/resources/webxr-util.js": [ + [] + ] }, "testharness": { "bluetooth/advertisingEvent/watchAdvertisements-succeeds.html": [ @@ -13927,6 +13930,18 @@ "mozilla/xmlhttprequest_url.html", {} ] + ], + "webxr/create_session.html": [ + [ + "webxr/create_session.html", + {} + ] + ], + "webxr/obtain_frame.html": [ + [ + "webxr/obtain_frame.html", + {} + ] ] }, "visual": { @@ -21112,6 +21127,18 @@ "mozilla/xmlhttprequest_url.html": [ "e5d10f27c06e1febd3bb70f8f128194fc3f63861", "testharness" + ], + "webxr/create_session.html": [ + "306ab85d3b1b914d2dd7c11a3b03dccd990148ae", + "testharness" + ], + "webxr/obtain_frame.html": [ + "1089bb25c2f6b26db4e21b6bf07c28add3fee5ec", + "testharness" + ], + "webxr/resources/webxr-util.js": [ + "505173c82998a80b1e543f1a18aefaf1891f8269", + "support" ] }, "url_base": "/_mozilla/", diff --git a/tests/wpt/mozilla/meta/webxr/__dir__.ini b/tests/wpt/mozilla/meta/webxr/__dir__.ini new file mode 100644 index 00000000000..fe96a649902 --- /dev/null +++ b/tests/wpt/mozilla/meta/webxr/__dir__.ini @@ -0,0 +1,2 @@ +prefs: [dom.webxr.enabled:true, dom.webxr.test:true] + diff --git a/tests/wpt/mozilla/tests/webxr/create_session.html b/tests/wpt/mozilla/tests/webxr/create_session.html new file mode 100644 index 00000000000..306ab85d3b1 --- /dev/null +++ b/tests/wpt/mozilla/tests/webxr/create_session.html @@ -0,0 +1,15 @@ + + + + + + + + + diff --git a/tests/wpt/mozilla/tests/webxr/obtain_frame.html b/tests/wpt/mozilla/tests/webxr/obtain_frame.html new file mode 100644 index 00000000000..1089bb25c2f --- /dev/null +++ b/tests/wpt/mozilla/tests/webxr/obtain_frame.html @@ -0,0 +1,62 @@ + + + + + + + + + + + + diff --git a/tests/wpt/mozilla/tests/webxr/resources/webxr-util.js b/tests/wpt/mozilla/tests/webxr/resources/webxr-util.js new file mode 100644 index 00000000000..505173c8299 --- /dev/null +++ b/tests/wpt/mozilla/tests/webxr/resources/webxr-util.js @@ -0,0 +1,17 @@ +// 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]}; + +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) { + assert_approx_equals(m1[i], m2[i], epsilon, m1 + prefix + "Component number " + i + " should match"); + } +} + +const TEST_VIEWS = [ + {eye: "left", projectionMatrix: VALID_PROJECTION_MATRIX, viewOffset: LEFT_OFFSET}, + {eye: "right", projectionMatrix: VALID_PROJECTION_MATRIX, viewOffset: RIGHT_OFFSET} +];