summaryrefslogtreecommitdiffstats
path: root/dom/vr/test/mochitest/VRSimulationDriver.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/vr/test/mochitest/VRSimulationDriver.js
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/vr/test/mochitest/VRSimulationDriver.js')
-rw-r--r--dom/vr/test/mochitest/VRSimulationDriver.js95
1 files changed, 95 insertions, 0 deletions
diff --git a/dom/vr/test/mochitest/VRSimulationDriver.js b/dom/vr/test/mochitest/VRSimulationDriver.js
new file mode 100644
index 0000000000..5b197b88e4
--- /dev/null
+++ b/dom/vr/test/mochitest/VRSimulationDriver.js
@@ -0,0 +1,95 @@
+var VRServiceTest;
+var vrMockDisplay;
+
+var VRSimulationDriver = (function () {
+ "use strict";
+
+ var AttachWebVRDisplay = function () {
+ if (vrMockDisplay) {
+ // Avoid creating multiple displays
+ return Promise.resolve(vrMockDisplay);
+ }
+ var promise = VRServiceTest.attachVRDisplay("VRDisplayTest");
+ promise.then(function (display) {
+ assert_true(display != null, "AttachWebVRDisplay should success.");
+ vrMockDisplay = display;
+ });
+
+ return promise;
+ };
+
+ var SetVRDisplayPose = function (
+ position,
+ linearVelocity,
+ linearAcceleration,
+ orientation,
+ angularVelocity,
+ angularAcceleration
+ ) {
+ vrMockDisplay.setPose(
+ position,
+ linearVelocity,
+ linearAcceleration,
+ orientation,
+ angularVelocity,
+ angularAcceleration
+ );
+ };
+
+ var SetEyeResolution = function (width, height) {
+ vrMockDisplay.setEyeResolution(width, height);
+ };
+
+ var SetEyeParameter = function (
+ eye,
+ offsetX,
+ offsetY,
+ offsetZ,
+ upDegree,
+ rightDegree,
+ downDegree,
+ leftDegree
+ ) {
+ vrMockDisplay.setEyeParameter(
+ eye,
+ offsetX,
+ offsetY,
+ offsetZ,
+ upDegree,
+ rightDegree,
+ downDegree,
+ leftDegree
+ );
+ };
+
+ var SetMountState = function (isMounted) {
+ vrMockDisplay.setMountState(isMounted);
+ };
+
+ var UpdateVRDisplay = function () {
+ vrMockDisplay.update();
+ };
+
+ var AttachVRController = function () {
+ var promise = VRServiceTest.attachVRController("VRControllerTest");
+ promise.then(function (controller) {
+ assert_true(controller != null, "AttachVRController should success.");
+ });
+
+ return promise;
+ };
+
+ var API = {
+ AttachWebVRDisplay,
+ SetVRDisplayPose,
+ SetEyeResolution,
+ SetEyeParameter,
+ SetMountState,
+ UpdateVRDisplay,
+ AttachVRController,
+
+ none: false,
+ };
+
+ return API;
+})();