Bug 1523562 [wpt PR 15079] - Pass the full path to the flake8 config files, a=testonly
[gecko.git] / dom / vr / VRServiceTest.h
blob979fbca834a80fc915bb3530cb7afadd55fae2ee
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"
13 #include "gfxVR.h"
15 namespace mozilla {
16 namespace dom {
18 class VRMockDisplay final : public DOMEventTargetHelper {
19 public:
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;
38 void Update();
39 virtual JSObject* WrapObject(JSContext* aCx,
40 JS::Handle<JSObject*> aGivenProto) override;
42 private:
43 ~VRMockDisplay() = default;
45 uint32_t mDeviceID;
46 gfx::VRDisplayInfo mDisplayInfo;
47 gfx::VRHMDSensorState mSensorState;
48 TimeStamp mTimestamp;
51 class VRMockController : public DOMEventTargetHelper {
52 public:
53 NS_DECL_ISUPPORTS_INHERITED
54 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(VRMockController,
55 DOMEventTargetHelper)
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;
69 private:
70 ~VRMockController() = default;
72 nsCString mID;
73 uint32_t mDeviceID;
76 class VRServiceTest final : public DOMEventTargetHelper {
77 public:
78 NS_DECL_ISUPPORTS_INHERITED
79 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(VRServiceTest, DOMEventTargetHelper)
81 already_AddRefed<Promise> AttachVRDisplay(const nsAString& aID,
82 ErrorResult& aRv);
83 already_AddRefed<Promise> AttachVRController(const nsAString& aID,
84 ErrorResult& aRv);
85 void Shutdown();
87 static already_AddRefed<VRServiceTest> CreateTestService(
88 nsPIDOMWindowInner* aWindow);
89 virtual JSObject* WrapObject(JSContext* aCx,
90 JS::Handle<JSObject*> aGivenProto) override;
92 private:
93 explicit VRServiceTest(nsPIDOMWindowInner* aWindow);
94 ~VRServiceTest() = default;
96 nsCOMPtr<nsPIDOMWindowInner> mWindow;
97 bool mShuttingDown;
100 } // namespace dom
101 } // namespace mozilla
103 #endif // mozilla_dom_VRServiceTest_h_