1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_VRServiceTest_h_
8 #define mozilla_dom_VRServiceTest_h_
10 #include "mozilla/DOMEventTargetHelper.h"
11 #include "mozilla/dom/VRServiceTestBinding.h"
18 class VRMockDisplay final
: public DOMEventTargetHelper
{
20 NS_DECL_ISUPPORTS_INHERITED
21 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(VRMockDisplay
, DOMEventTargetHelper
)
23 VRMockDisplay(const nsCString
& aID
, uint32_t aDeviceID
);
24 void SetEyeParameter(VREye aEye
, double aOffsetX
, double aOffsetY
,
25 double aOffsetZ
, double aUpDegree
, double aRightDegree
,
26 double aDownDegree
, double aLeftDegree
);
27 void SetEyeResolution(unsigned long aRenderWidth
,
28 unsigned long aRenderHeight
);
29 void SetPose(const Nullable
<Float32Array
>& aPosition
,
30 const Nullable
<Float32Array
>& aLinearVelocity
,
31 const Nullable
<Float32Array
>& aLinearAcceleration
,
32 const Nullable
<Float32Array
>& aOrientation
,
33 const Nullable
<Float32Array
>& aAngularVelocity
,
34 const Nullable
<Float32Array
>& aAngularAcceleration
);
35 void SetMountState(bool aIsMounted
) {
36 mDisplayInfo
.mDisplayState
.isMounted
= aIsMounted
;
39 virtual JSObject
* WrapObject(JSContext
* aCx
,
40 JS::Handle
<JSObject
*> aGivenProto
) override
;
43 ~VRMockDisplay() = default;
46 gfx::VRDisplayInfo mDisplayInfo
;
47 gfx::VRHMDSensorState mSensorState
;
51 class VRMockController
: public DOMEventTargetHelper
{
53 NS_DECL_ISUPPORTS_INHERITED
54 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(VRMockController
,
57 VRMockController(const nsCString
& aID
, uint32_t aDeviceID
);
58 void NewButtonEvent(unsigned long aButton
, bool aPressed
);
59 void NewAxisMoveEvent(unsigned long aAxis
, double aValue
);
60 void NewPoseMove(const Nullable
<Float32Array
>& aPosition
,
61 const Nullable
<Float32Array
>& aLinearVelocity
,
62 const Nullable
<Float32Array
>& aLinearAcceleration
,
63 const Nullable
<Float32Array
>& aOrientation
,
64 const Nullable
<Float32Array
>& aAngularVelocity
,
65 const Nullable
<Float32Array
>& aAngularAcceleration
);
66 virtual JSObject
* WrapObject(JSContext
* aCx
,
67 JS::Handle
<JSObject
*> aGivenProto
) override
;
70 ~VRMockController() = default;
76 class VRServiceTest final
: public DOMEventTargetHelper
{
78 NS_DECL_ISUPPORTS_INHERITED
79 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(VRServiceTest
, DOMEventTargetHelper
)
81 already_AddRefed
<Promise
> AttachVRDisplay(const nsAString
& aID
,
83 already_AddRefed
<Promise
> AttachVRController(const nsAString
& aID
,
87 static already_AddRefed
<VRServiceTest
> CreateTestService(
88 nsPIDOMWindowInner
* aWindow
);
89 virtual JSObject
* WrapObject(JSContext
* aCx
,
90 JS::Handle
<JSObject
*> aGivenProto
) override
;
93 explicit VRServiceTest(nsPIDOMWindowInner
* aWindow
);
94 ~VRServiceTest() = default;
96 nsCOMPtr
<nsPIDOMWindowInner
> mWindow
;
101 } // namespace mozilla
103 #endif // mozilla_dom_VRServiceTest_h_