Commit 93ee2f68 authored by Xaver Hugl's avatar Xaver Hugl Committed by Aleix Pol Gonzalez
Browse files

Add test for TouchInputRedirection::m_touches

parent 3c231940
......@@ -38,6 +38,7 @@ private Q_SLOTS:
void testMultipleTouchPoints();
void testCancel();
void testTouchMouseAction();
void testTouchPointCount();
private:
AbstractClient *showWindow(bool decorated = false);
......@@ -263,7 +264,25 @@ void TouchInputTest::testTouchMouseAction()
QCOMPARE(sequenceStartedSpy.count(), 1);
// cleanup
kwinApp()->platform()->touchCancel();
kwinApp()->platform()->cancelTouchSequence();
}
void TouchInputTest::testTouchPointCount()
{
QCOMPARE(kwinApp()->platform()->touchPointCount(), 0);
quint32 timestamp = 1;
kwinApp()->platform()->touchDown(0, QPointF(125, 125), timestamp++);
kwinApp()->platform()->touchDown(1, QPointF(125, 125), timestamp++);
kwinApp()->platform()->touchDown(2, QPointF(125, 125), timestamp++);
QCOMPARE(kwinApp()->platform()->touchPointCount(), 3);
kwinApp()->platform()->touchUp(1, timestamp++);
QCOMPARE(kwinApp()->platform()->touchPointCount(), 2);
kwinApp()->platform()->cancelTouchSequence();
QCOMPARE(kwinApp()->platform()->touchPointCount(), 1);
kwinApp()->platform()->cancelTouchSequence();
QCOMPARE(kwinApp()->platform()->touchPointCount(), 0);
}
}
......
......@@ -2517,6 +2517,11 @@ void InputRedirection::processTouchMotion(qint32 id, const QPointF &pos, quint32
m_touch->processMotion(id, pos, time);
}
void InputRedirection::cancelTouchSequence()
{
m_touch->processCancel();
}
void InputRedirection::cancelTouch()
{
m_touch->cancel();
......@@ -2527,6 +2532,11 @@ void InputRedirection::touchFrame()
m_touch->frame();
}
int InputRedirection::touchPointCount()
{
return m_touch->touchPointCount();
}
Qt::MouseButtons InputRedirection::qtButtonStates() const
{
return m_pointer->buttons();
......
......@@ -168,8 +168,14 @@ public:
void processTouchDown(qint32 id, const QPointF &pos, quint32 time);
void processTouchUp(qint32 id, quint32 time);
void processTouchMotion(qint32 id, const QPointF &pos, quint32 time);
/**
* triggers the same code path as LIBINPUT_TOUCH_CANCEL_EVENT.
* Only intended for autotests
*/
void cancelTouchSequence();
void cancelTouch();
void touchFrame();
int touchPointCount();
bool supportsPointerWarping() const;
void warpPointer(const QPointF &pos);
......
......@@ -311,6 +311,14 @@ void Platform::pointerButtonReleased(quint32 button, quint32 time)
input()->processPointerButton(button, InputRedirection::PointerButtonReleased, time);
}
int Platform::touchPointCount()
{
if (!input()) {
return 0;
}
return input()->touchPointCount();
}
void Platform::pointerMotion(const QPointF &position, quint32 time)
{
if (!input()) {
......@@ -319,6 +327,14 @@ void Platform::pointerMotion(const QPointF &position, quint32 time)
input()->processPointerMotion(position, time);
}
void Platform::cancelTouchSequence()
{
if (!input()) {
return;
}
input()->cancelTouchSequence();
}
void Platform::touchCancel()
{
if (!input()) {
......
......@@ -483,8 +483,10 @@ public Q_SLOTS:
void touchDown(qint32 id, const QPointF &pos, quint32 time);
void touchUp(qint32 id, quint32 time);
void touchMotion(qint32 id, const QPointF &pos, quint32 time);
void cancelTouchSequence();
void touchCancel();
void touchFrame();
int touchPointCount();
void processSwipeGestureBegin(int fingerCount, quint32 time);
void processSwipeGestureUpdate(const QSizeF &delta, quint32 time);
......
......@@ -71,6 +71,10 @@ public:
return m_lastPosition;
}
int touchPointCount() const {
return m_touches;
}
private:
void cleanupInternalWindow(QWindow *old, QWindow *now) override;
void cleanupDecoration(Decoration::DecoratedClientImpl *old, Decoration::DecoratedClientImpl *now) override;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment