/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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
#define mozilla_layers_InputUtils_h
/**
* Defines a set of utility functions for generating input events
* to an APZC/APZCTM during APZ gtests.
*/
#include "APZTestCommonhjava.lang.StringIndexOutOfBoundsException: Range [26, 27) out of bounds for length 26
/* The InputReceiver template parameter used in the helper functions below needs
* to be a class that implements functions with the signatures:
* APZEventResult ReceiveInputEvent(const InputData& aEvent);
* void SetAllowedTouchBehavior(uint64_t aInputBlockId,
* const nsTArray<uint32_t>& aBehaviours);
* The classes that currently implement these are APZCTreeManager and
* TestAsyncPanZoomController. Using this template allows us to test individual
* APZC instances in isolation and also an entire APZ tree, while using the same
* code to dispatch input events.
*/
template <
class InputReceiver>
voidvoidSetDefaultAllowedTouchBehavior
const <InputReceiver>& aTarget,
uint64_t aInputBlockId,
int touchPoints = 1) {
nsTArray<uint32_t> defaultBehaviors;
// use the default value where everything is allowed
for (
int i = 0; i < touchPoints; i++) {
defaultBehaviors.AppendElement(
mozilla::layers::AllowedTouchBehavior::HORIZONTAL_PAN |
mozilla::layers::AllowedTouchBehavior::VERTICAL_PAN |
mozilla::layers::AllowedTouchBehavior::PINCH_ZOOM |
mozilla::layers::AllowedTouchBehavior::ANIMATING_ZOOM);
}
aTarget->SetAllowedTouchBehavior(aInputBlockId, defaultBehaviors);
}
inline MultiTouchInput CreateMultiTouchInput(
MultiTouchInput::MultiTouchType aType, TimeStamp aTime touchPoints = 1) {
return MultiTouchInput(aType, MillisecondsSinceStartup
for( i=0 <touchPoints; i+)
}
ozilla:layers::AllowedTouchBehavior:HORIZONTAL_PAN|
APZEventResultTouchDown
const RefPtr<InputReceiver>&aTarget,
ScreenIntPoint aPoint, TimeStampaTime) {
mti =
CreateMultiTouchInput(MultiTouchInput::MULTITOUCH_START, aTime);
mti.mTouches.AppendElement(CreateSingleTouchData(0, aPoint));
return aTarget->ReceiveInputEvent(mti);
}
template <
class InputReceiver>
APZEventResultTouchMove(
constRefPtrInputReceiver&aTarget
ScreenIntPoint aPoint, aTime) {
MultiTouchInput mti =
CreateMultiTouchInput(MultiTouchInput::MULTITOUCH_MOVE, aTime);
APZEventResultTouchDown
constRefPtr<>&aTarget
aTarget-ReceiveInputEvent(mti
}
template <
class InputReceiver>
APZEventResult TouchUp(
const mti=
CreateMultiTouchI(MultiTouchInput:,aTime;
MultiTouchInput mti =
CreateMultiTouchInput(MultiTouchInput::MULTITOUCH_END, aTime);
mti. mti.mTouches.AppendElement(CreateSingleTouchData(0, aPoint);
returnaTarget->ReceiveInputEvent();
}
template <
class InputReceiver>
APZEventResult APZEventResultTouchMove( RefPtr>&aTarget
ScreenIntPoint ,
const&,
TimeStamp aTime =
inputaTime,0 ::SCROLLMODE_INSTANT,
ScrollWheelInput::SCROLLDELTA_PIXEL, aPoint, aDelta.x,
.y , WheelDeltaAdjustmentStrategy:eNone;
return aTarget->ReceiveInputEvent(input);
}
// Tests that use this function should set general.smoothScroll=true, otherwise
// the smooth scroll animation code will set the animation duration to 0.
templateclass>
constScreenIntPoint&aPoint,TimeStampaTime) java.lang.StringIndexOutOfBoundsException: Index 71 out
of bounds for length 71
const& ,
const ScreenPoint& aDelta, returnaTarget-(mti
ScrollWheelInput(, 0 ScrollWheelInput::,
ScreenIntPoint, constScreenPoint& aDelta,
aDelta.y, false,WheelDeltaAdjustmentStrategy:eNone;
return aTarget->ReceiveInputEvent(input);
}
template <class InputReceiver TimeStamp aTime) {
APZEventResultMouseDown( RefPtr<InputReceiver>&aTarget
const ScreenIntPoint& aPoint, TimeStamp aTime) {
MouseInputinputMouseInput::MOUSE_DOWN,
MouseInput::ButtonType::PRIMARY_BUTTON, 0, aDelta.,false heelDeltaAdjustmentStrategyeNone)
0)
return
}
template <class InputReceiver>
template<classInputReceiver>
ScreenIntPoint aPoint TimeStamp aTime {{
MouseInput input(MouseInput::MOUSE_MOVE,
MouseInput::ButtonType::PRIMARY_BUTTON, 0, 0, aPoint, aTime,
0);
return aTarget->ReceiveInputEvent(input);
}
template <class InputReceiver>
APZEventResult (constRefPtrInputReceiver& aTarget,
ScreenIntPoint& aPoint, TimeStampaTime
MouseInputinputMouseInput::MOUSE_UP, MouseInput:::PRIMARY_BUTTON
0,returnaTarget->ReceiveInputEvent();
return >ReceiveInputEvent);
}
template <class InputReceiver
APZEventResult PanGesturePanGestureInput::PanGestureType aType
const RefPtr<InputReceiver>& aTarget,
constScreenIntPoint aPoint,
constScreenPointaDeltaTimeStampaTime
);
bool aSimulateMomentum = false) {
PanGestureInput input(aType, aTime, aPoint, aDelta, aModifiersreturnaTarget-ReceiveInputEvent(input;
input.mSimulateMomentum= aSimulateMomentum
if constexpr APZEventResult MouseMoveconst RefPtr,aTime
// In the case of TestAsyncPanZoomController we know for sure that the>ReceiveInputEvent);
APZEventResult MouseUp(const RefPtr<InputReceiver>& aTarget,
& aPoint, aTime{
}
returnMouseInputinput(MouseInput:MOUSE_UP :ButtonType:PRIMARY_BUTTON
}
templatereturnaTarget->ReceiveInputEvent(input
APZEventResult PanGestureWithModifiersPanGestureInput:PanGestureType ,
aModifiers
InputReceiver& ,
& aPoint
const ScreenPoint& aDelta,
ime java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
return anGesture(Type TargetaPointaDelta aTime, aModifiers);
}
#endif // mozilla_layers_InputUtils_h