Add all required input simulation methods

[4/6] Make autotests create fake input devices

This translates all required input simulating methods from
kwinApp()->platform()->... to seperate functions in the Test namespace.
This commit is contained in:
Julius Zint 2022-03-10 11:15:26 +01:00 committed by Vlad Zahorodnii
parent 33487c06d6
commit 93305f6041
2 changed files with 88 additions and 0 deletions

View file

@ -516,6 +516,20 @@ private:
bool m_touch = false;
};
void keyboardKeyPressed(quint32 key, quint32 time);
void keyboardKeyReleased(quint32 key, quint32 time);
void pointerAxisHorizontal(qreal delta, quint32 time, qint32 discreteDelta = 0,
InputRedirection::PointerAxisSource source = InputRedirection::PointerAxisSourceUnknown);
void pointerAxisVertical(qreal delta, quint32 time, qint32 discreteDelta = 0,
InputRedirection::PointerAxisSource source = InputRedirection::PointerAxisSourceUnknown);
void pointerButtonPressed(quint32 button, quint32 time);
void pointerButtonReleased(quint32 button, quint32 time);
void pointerMotion(const QPointF &position, quint32 time);
void touchCancel();
void touchDown(qint32 id, const QPointF &pos, quint32 time);
void touchMotion(qint32 id, const QPointF &pos, quint32 time);
void touchUp(qint32 id, quint32 time);
/**
* Creates a Wayland Connection in a dedicated thread and creates various
* client side objects which can be used to create windows.

View file

@ -1371,5 +1371,79 @@ bool VirtualInputDevice::isLidSwitch() const
{
return false;
}
void keyboardKeyPressed(quint32 key, quint32 time)
{
auto virtualKeyboard = static_cast<WaylandTestApplication*>(kwinApp())->virtualKeyboard();
Q_EMIT virtualKeyboard->keyChanged(key, InputRedirection::KeyboardKeyState::KeyboardKeyPressed, time, virtualKeyboard);
}
void keyboardKeyReleased(quint32 key, quint32 time)
{
auto virtualKeyboard = static_cast<WaylandTestApplication*>(kwinApp())->virtualKeyboard();
Q_EMIT virtualKeyboard->keyChanged(key, InputRedirection::KeyboardKeyState::KeyboardKeyReleased, time, virtualKeyboard);
}
void pointerAxisHorizontal(qreal delta, quint32 time, qint32 discreteDelta,
InputRedirection::PointerAxisSource source)
{
auto virtualPointer = static_cast<WaylandTestApplication*>(kwinApp())->virtualPointer();
Q_EMIT virtualPointer->pointerAxisChanged(InputRedirection::PointerAxis::PointerAxisHorizontal,
delta, discreteDelta, source, time, virtualPointer);
}
void pointerAxisVertical(qreal delta, quint32 time, qint32 discreteDelta,
InputRedirection::PointerAxisSource source)
{
auto virtualPointer = static_cast<WaylandTestApplication*>(kwinApp())->virtualPointer();
Q_EMIT virtualPointer->pointerAxisChanged(InputRedirection::PointerAxis::PointerAxisVertical,
delta, discreteDelta, source, time, virtualPointer);
}
void pointerButtonPressed(quint32 button, quint32 time)
{
auto virtualPointer = static_cast<WaylandTestApplication*>(kwinApp())->virtualPointer();
Q_EMIT virtualPointer->pointerButtonChanged(button,
InputRedirection::PointerButtonState::PointerButtonPressed,
time, virtualPointer);
}
void pointerButtonReleased(quint32 button, quint32 time)
{
auto virtualPointer = static_cast<WaylandTestApplication*>(kwinApp())->virtualPointer();
Q_EMIT virtualPointer->pointerButtonChanged(button,
InputRedirection::PointerButtonState::PointerButtonReleased,
time, virtualPointer);
}
void pointerMotion(const QPointF &position, quint32 time)
{
auto virtualPointer = static_cast<WaylandTestApplication*>(kwinApp())->virtualPointer();
Q_EMIT virtualPointer->pointerMotionAbsolute(position, time, virtualPointer);
}
void touchCancel()
{
auto virtualTouch = static_cast<WaylandTestApplication*>(kwinApp())->virtualTouch();
Q_EMIT virtualTouch->touchCanceled(virtualTouch);
}
void touchDown(qint32 id, const QPointF &pos, quint32 time)
{
auto virtualTouch = static_cast<WaylandTestApplication*>(kwinApp())->virtualTouch();
Q_EMIT virtualTouch->touchDown(id, pos, time, virtualTouch);
}
void touchMotion(qint32 id, const QPointF &pos, quint32 time)
{
auto virtualTouch = static_cast<WaylandTestApplication*>(kwinApp())->virtualTouch();
Q_EMIT virtualTouch->touchMotion(id, pos, time, virtualTouch);
}
void touchUp(qint32 id, quint32 time)
{
auto virtualTouch = static_cast<WaylandTestApplication*>(kwinApp())->virtualTouch();
Q_EMIT virtualTouch->touchUp(id, time, virtualTouch);
}
}
}