/work/obj-fuzz/dist/include/mozilla/dom/GamepadServiceTest.h
Line | Count | Source (jump to first uncovered line) |
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/. */ |
6 | | |
7 | | #ifndef mozilla_dom_GamepadServiceTest_h_ |
8 | | #define mozilla_dom_GamepadServiceTest_h_ |
9 | | |
10 | | #include "mozilla/DOMEventTargetHelper.h" |
11 | | #include "mozilla/dom/GamepadBinding.h" |
12 | | |
13 | | namespace mozilla { |
14 | | namespace dom { |
15 | | |
16 | | class GamepadChangeEvent; |
17 | | class GamepadManager; |
18 | | class GamepadTestChannelChild; |
19 | | class Promise; |
20 | | |
21 | | // Service for testing purposes |
22 | | class GamepadServiceTest final : public DOMEventTargetHelper |
23 | | { |
24 | | public: |
25 | | NS_DECL_ISUPPORTS_INHERITED |
26 | | NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(GamepadServiceTest, |
27 | | DOMEventTargetHelper) |
28 | | |
29 | 0 | GamepadMappingType NoMapping() const { return GamepadMappingType::_empty; } |
30 | 0 | GamepadMappingType StandardMapping() const { return GamepadMappingType::Standard; } |
31 | 0 | GamepadHand NoHand() const { return GamepadHand::_empty; } |
32 | 0 | GamepadHand LeftHand() const { return GamepadHand::Left; } |
33 | 0 | GamepadHand RightHand() const { return GamepadHand::Right; } |
34 | | |
35 | | already_AddRefed<Promise> AddGamepad(const nsAString& aID, |
36 | | GamepadMappingType aMapping, |
37 | | GamepadHand aHand, |
38 | | uint32_t aNumButtons, |
39 | | uint32_t aNumAxes, |
40 | | uint32_t aNumHaptics, |
41 | | ErrorResult& aRv); |
42 | | void RemoveGamepad(uint32_t aIndex); |
43 | | void NewButtonEvent(uint32_t aIndex, uint32_t aButton, bool aPressed, bool aTouched); |
44 | | void NewButtonValueEvent(uint32_t aIndex, uint32_t aButton, bool aPressed, bool aTouched, |
45 | | double aValue); |
46 | | void NewAxisMoveEvent(uint32_t aIndex, uint32_t aAxis, double aValue); |
47 | | void NewPoseMove(uint32_t aIndex, |
48 | | const Nullable<Float32Array>& aOrient, |
49 | | const Nullable<Float32Array>& aPos, |
50 | | const Nullable<Float32Array>& aAngVelocity, |
51 | | const Nullable<Float32Array>& aAngAcceleration, |
52 | | const Nullable<Float32Array>& aLinVelocity, |
53 | | const Nullable<Float32Array>& aLinAcceleration); |
54 | | void Shutdown(); |
55 | | |
56 | | static already_AddRefed<GamepadServiceTest> CreateTestService(nsPIDOMWindowInner* aWindow); |
57 | 0 | nsPIDOMWindowInner* GetParentObject() const { return mWindow; } |
58 | | JSObject* WrapObject(JSContext* aCx, JS::HandleObject aGivenProto) override; |
59 | | |
60 | | private: |
61 | | |
62 | | // Hold a reference to the gamepad service so we don't have to worry about |
63 | | // execution order in tests. |
64 | | RefPtr<GamepadManager> mService; |
65 | | nsCOMPtr<nsPIDOMWindowInner> mWindow; |
66 | | uint32_t mEventNumber; |
67 | | bool mShuttingDown; |
68 | | |
69 | | // IPDL Channel for us to send test events to GamepadPlatformService, it |
70 | | // will only be used in this singleton class and deleted during the IPDL |
71 | | // shutdown chain |
72 | | GamepadTestChannelChild* MOZ_NON_OWNING_REF mChild; |
73 | | |
74 | | explicit GamepadServiceTest(nsPIDOMWindowInner* aWindow); |
75 | | ~GamepadServiceTest(); |
76 | | void InitPBackgroundActor(); |
77 | | void DestroyPBackgroundActor(); |
78 | | |
79 | | }; |
80 | | |
81 | | } // namespace dom |
82 | | } // namespace mozilla |
83 | | |
84 | | #endif |