2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2015-04-24 01:05:29 +03:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_GamepadServiceTest_h_
|
|
|
|
#define mozilla_dom_GamepadServiceTest_h_
|
|
|
|
|
2016-11-03 23:55:36 +03:00
|
|
|
#include "mozilla/DOMEventTargetHelper.h"
|
2016-10-04 05:57:04 +03:00
|
|
|
#include "mozilla/dom/GamepadBinding.h"
|
2015-04-24 01:05:29 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2016-06-28 01:26:00 +03:00
|
|
|
class GamepadChangeEvent;
|
2016-06-28 01:25:00 +03:00
|
|
|
class GamepadManager;
|
2016-06-28 01:26:00 +03:00
|
|
|
class GamepadTestChannelChild;
|
|
|
|
class Promise;
|
2015-04-24 01:05:29 +03:00
|
|
|
|
|
|
|
// Service for testing purposes
|
2017-10-24 13:02:40 +03:00
|
|
|
class GamepadServiceTest final : public DOMEventTargetHelper {
|
2015-04-24 01:05:29 +03:00
|
|
|
public:
|
2016-06-28 01:26:00 +03:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(GamepadServiceTest,
|
|
|
|
DOMEventTargetHelper)
|
2015-04-24 01:05:29 +03:00
|
|
|
|
2016-12-09 02:00:44 +03:00
|
|
|
GamepadMappingType NoMapping() const { return GamepadMappingType::_empty; }
|
|
|
|
GamepadMappingType StandardMapping() const {
|
|
|
|
return GamepadMappingType::Standard;
|
|
|
|
}
|
2017-02-02 10:00:51 +03:00
|
|
|
GamepadHand NoHand() const { return GamepadHand::_empty; }
|
|
|
|
GamepadHand LeftHand() const { return GamepadHand::Left; }
|
|
|
|
GamepadHand RightHand() const { return GamepadHand::Right; }
|
2015-04-24 01:05:29 +03:00
|
|
|
|
2019-05-30 01:15:25 +03:00
|
|
|
already_AddRefed<Promise> AddGamepad(
|
|
|
|
const nsAString& aID, GamepadMappingType aMapping, GamepadHand aHand,
|
|
|
|
uint32_t aNumButtons, uint32_t aNumAxes, uint32_t aNumHaptics,
|
|
|
|
uint32_t aNumLightIndicator, uint32_t aNumTouchEvents, ErrorResult& aRv);
|
2016-06-28 01:26:00 +03:00
|
|
|
void RemoveGamepad(uint32_t aIndex);
|
2017-04-07 04:35:13 +03:00
|
|
|
void NewButtonEvent(uint32_t aIndex, uint32_t aButton, bool aPressed,
|
|
|
|
bool aTouched);
|
|
|
|
void NewButtonValueEvent(uint32_t aIndex, uint32_t aButton, bool aPressed,
|
|
|
|
bool aTouched, double aValue);
|
2016-06-28 01:26:00 +03:00
|
|
|
void NewAxisMoveEvent(uint32_t aIndex, uint32_t aAxis, double aValue);
|
2017-02-02 10:00:51 +03:00
|
|
|
void NewPoseMove(uint32_t aIndex, const Nullable<Float32Array>& aOrient,
|
|
|
|
const Nullable<Float32Array>& aPos,
|
|
|
|
const Nullable<Float32Array>& aAngVelocity,
|
|
|
|
const Nullable<Float32Array>& aAngAcceleration,
|
|
|
|
const Nullable<Float32Array>& aLinVelocity,
|
|
|
|
const Nullable<Float32Array>& aLinAcceleration);
|
2019-05-30 01:15:25 +03:00
|
|
|
void NewTouch(uint32_t aIndex, uint32_t aTouchArrayIndex, uint32_t aTouchId,
|
|
|
|
uint8_t aSurfaceId, const Float32Array& aPos,
|
|
|
|
const Nullable<Float32Array>& aSurfDim);
|
2016-06-28 01:26:00 +03:00
|
|
|
void Shutdown();
|
|
|
|
|
|
|
|
static already_AddRefed<GamepadServiceTest> CreateTestService(
|
|
|
|
nsPIDOMWindowInner* aWindow);
|
|
|
|
nsPIDOMWindowInner* GetParentObject() const { return mWindow; }
|
|
|
|
JSObject* WrapObject(JSContext* aCx, JS::HandleObject aGivenProto) override;
|
2015-04-24 01:05:29 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Hold a reference to the gamepad service so we don't have to worry about
|
|
|
|
// execution order in tests.
|
2016-06-28 01:25:00 +03:00
|
|
|
RefPtr<GamepadManager> mService;
|
2016-06-28 01:26:00 +03:00
|
|
|
nsCOMPtr<nsPIDOMWindowInner> mWindow;
|
|
|
|
uint32_t mEventNumber;
|
|
|
|
bool mShuttingDown;
|
|
|
|
|
|
|
|
// IPDL Channel for us to send test events to GamepadPlatformService, it
|
|
|
|
// will only be used in this singleton class and deleted during the IPDL
|
|
|
|
// shutdown chain
|
|
|
|
GamepadTestChannelChild* MOZ_NON_OWNING_REF mChild;
|
|
|
|
|
|
|
|
explicit GamepadServiceTest(nsPIDOMWindowInner* aWindow);
|
|
|
|
~GamepadServiceTest();
|
|
|
|
void InitPBackgroundActor();
|
|
|
|
void DestroyPBackgroundActor();
|
2015-04-24 01:05:29 +03:00
|
|
|
};
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2015-04-24 01:05:29 +03:00
|
|
|
|
|
|
|
#endif
|