LCOV - code coverage report
Current view: top level - dom/gamepad - GamepadServiceTest.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 10 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 13 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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 "nsIIPCBackgroundChildCreateCallback.h"
      11             : #include "mozilla/DOMEventTargetHelper.h"
      12             : #include "mozilla/dom/GamepadBinding.h"
      13             : 
      14             : namespace mozilla {
      15             : namespace dom {
      16             : 
      17             : class GamepadChangeEvent;
      18             : class GamepadManager;
      19             : class GamepadTestChannelChild;
      20             : class Promise;
      21             : 
      22             : // Service for testing purposes
      23             : class GamepadServiceTest final : public DOMEventTargetHelper,
      24             :                                  public nsIIPCBackgroundChildCreateCallback
      25             : {
      26             : public:
      27             :   NS_DECL_NSIIPCBACKGROUNDCHILDCREATECALLBACK
      28             :   NS_DECL_ISUPPORTS_INHERITED
      29           0 :   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(GamepadServiceTest,
      30             :                                            DOMEventTargetHelper)
      31             : 
      32           0 :   GamepadMappingType NoMapping() const { return GamepadMappingType::_empty; }
      33           0 :   GamepadMappingType StandardMapping() const { return GamepadMappingType::Standard; }
      34           0 :   GamepadHand NoHand() const { return GamepadHand::_empty; }
      35           0 :   GamepadHand LeftHand() const { return GamepadHand::Left; }
      36           0 :   GamepadHand RightHand() const { return GamepadHand::Right; }
      37             : 
      38             :   already_AddRefed<Promise> AddGamepad(const nsAString& aID,
      39             :                                        GamepadMappingType aMapping,
      40             :                                        GamepadHand aHand,
      41             :                                        uint32_t aNumButtons,
      42             :                                        uint32_t aNumAxes,
      43             :                                        uint32_t aNumHaptics,
      44             :                                        ErrorResult& aRv);
      45             :   void RemoveGamepad(uint32_t aIndex);
      46             :   void NewButtonEvent(uint32_t aIndex, uint32_t aButton, bool aPressed, bool aTouched);
      47             :   void NewButtonValueEvent(uint32_t aIndex, uint32_t aButton, bool aPressed, bool aTouched,
      48             :                            double aValue);
      49             :   void NewAxisMoveEvent(uint32_t aIndex, uint32_t aAxis, double aValue);
      50             :   void NewPoseMove(uint32_t aIndex,
      51             :                    const Nullable<Float32Array>& aOrient,
      52             :                    const Nullable<Float32Array>& aPos,
      53             :                    const Nullable<Float32Array>& aAngVelocity,
      54             :                    const Nullable<Float32Array>& aAngAcceleration,
      55             :                    const Nullable<Float32Array>& aLinVelocity,
      56             :                    const Nullable<Float32Array>& aLinAcceleration);
      57             :   void Shutdown();
      58             : 
      59             :   static already_AddRefed<GamepadServiceTest> CreateTestService(nsPIDOMWindowInner* aWindow);
      60           0 :   nsPIDOMWindowInner* GetParentObject() const { return mWindow; }
      61             :   JSObject* WrapObject(JSContext* aCx, JS::HandleObject aGivenProto) override;
      62             : 
      63             : private:
      64             : 
      65             :   // We need to asynchronously create IPDL channel, it is possible that
      66             :   // we send commands before the channel is created, so we have to buffer
      67             :   // them until the channel is created in that case.
      68           0 :   struct PendingOperation {
      69           0 :     explicit PendingOperation(const uint32_t& aID,
      70             :                               const GamepadChangeEvent& aEvent,
      71             :                               Promise* aPromise = nullptr)
      72           0 :                : mID(aID), mEvent(aEvent), mPromise(aPromise) {}
      73             :     uint32_t mID;
      74             :     const GamepadChangeEvent& mEvent;
      75             :     RefPtr<Promise> mPromise;
      76             :   };
      77             : 
      78             :   // Hold a reference to the gamepad service so we don't have to worry about
      79             :   // execution order in tests.
      80             :   RefPtr<GamepadManager> mService;
      81             :   nsCOMPtr<nsPIDOMWindowInner> mWindow;
      82             :   nsTArray<PendingOperation> mPendingOperations;
      83             :   uint32_t mEventNumber;
      84             :   bool mShuttingDown;
      85             : 
      86             :   // IPDL Channel for us to send test events to GamepadPlatformService, it
      87             :   // will only be used in this singleton class and deleted during the IPDL
      88             :   // shutdown chain
      89             :   GamepadTestChannelChild* MOZ_NON_OWNING_REF mChild;
      90             : 
      91             :   explicit GamepadServiceTest(nsPIDOMWindowInner* aWindow);
      92             :   ~GamepadServiceTest();
      93             :   void InitPBackgroundActor();
      94             :   void DestroyPBackgroundActor();
      95             :   void FlushPendingOperations();
      96             : 
      97             : };
      98             : 
      99             : } // namespace dom
     100             : } // namespace mozilla
     101             : 
     102             : #endif

Generated by: LCOV version 1.13