Bug 1306493 - Part 2: Make vrMockDisplay to be the global var in VRSimulationDriver; r?kip draft
authorDaosheng Mu <daoshengmu@gmail.com>
Mon, 13 Mar 2017 13:09:19 +0800
changeset 499698 dfa538bcd91e27612d9bd138ad68b9088e3573a6
parent 499697 60712c4838d9bfd5f3bfb8e3cf18f8734591664c
child 499699 52fb9e94d4f9d791df141dbd011d28e7c9b50b86
push id49487
push userbmo:dmu@mozilla.com
push dateThu, 16 Mar 2017 03:47:12 +0000
reviewerskip
bugs1306493
milestone55.0a1
Bug 1306493 - Part 2: Make vrMockDisplay to be the global var in VRSimulationDriver; r?kip MozReview-Commit-ID: HTHqehkUMwC
dom/vr/test/VRSimulationDriver.js
--- a/dom/vr/test/VRSimulationDriver.js
+++ b/dom/vr/test/VRSimulationDriver.js
@@ -1,38 +1,45 @@
 
 var VRServiceTest;
+var vrMockDisplay;
 
 var VRSimulationDriver = (function() {
 "use strict";
 
 var AttachWebVRDisplay = function() {
-  return VRServiceTest.attachVRDisplay("VRDisplayTest");
+  var promise = VRServiceTest.attachVRDisplay("VRDisplayTest");
+  promise.then(function (display) {
+    assert_true(display != null, "AttachWebVRDisplay should success.");
+    vrMockDisplay = display;
+  });
+
+  return promise;
 };
 
-var SetVRDisplayPose = function(vrDisplay, position,
+var SetVRDisplayPose = function(position,
                                 linearVelocity, linearAcceleration,
                                 orientation, angularVelocity,
                                 angularAcceleration) {
-  vrDisplay.setPose(position, linearVelocity, linearAcceleration,
-                    orientation, angularVelocity, angularAcceleration);
+  vrMockDisplay.setPose(position, linearVelocity, linearAcceleration,
+                        orientation, angularVelocity, angularAcceleration);
 };
 
 var SetEyeResolution = function(width, height) {
-  vrDisplay.setEyeResolution(width, height);
+  vrMockDisplay.setEyeResolution(width, height);
 }
 
-var SetEyeParameter = function(vrDisplay, eye, offsetX, offsetY, offsetZ,
+var SetEyeParameter = function(eye, offsetX, offsetY, offsetZ,
                                upDegree, rightDegree, downDegree, leftDegree) {
-  vrDisplay.setEyeParameter(eye, offsetX, offsetY, offsetZ, upDegree, rightDegree,
-                            downDegree, leftDegree);
+  vrMockDisplay.setEyeParameter(eye, offsetX, offsetY, offsetZ, upDegree, rightDegree,
+                                downDegree, leftDegree);
 }
 
-var UpdateVRDisplay = function(vrDisplay) {
-  vrDisplay.update();
+var UpdateVRDisplay = function() {
+  vrMockDisplay.update();
 }
 
 var API = {
   AttachWebVRDisplay: AttachWebVRDisplay,
   SetVRDisplayPose: SetVRDisplayPose,
   SetEyeResolution: SetEyeResolution,
   SetEyeParameter: SetEyeParameter,
   UpdateVRDisplay: UpdateVRDisplay,