~josharenson/unity8/fix-greeter-password-focus

« back to all changes in this revision

Viewing changes to tests/plugins/Ubuntu/Gestures/GestureTest.cpp

  • Committer: Josh Arenson
  • Date: 2016-03-25 19:54:02 UTC
  • mfrom: (1979.1.9 session-chooser-gui)
  • Revision ID: joshua.arenson@canonical.com-20160325195402-867v3w2zvmjj0kq3
merge prereq

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
#include "GestureTest.h"
18
18
 
19
19
#include <qpa/qwindowsysteminterface.h>
 
20
#include <private/qquickwindow_p.h>
20
21
#include <QQmlEngine>
21
22
#include <QQuickView>
22
23
#include <QtTest>
72
73
    m_view = nullptr;
73
74
}
74
75
 
 
76
void GestureTest::sendTouchPress(qint64 timestamp, int id, QPointF pos)
 
77
{
 
78
    sendTouch(timestamp, id, pos, Qt::TouchPointPressed, QEvent::TouchBegin);
 
79
}
 
80
 
 
81
void GestureTest::sendTouchUpdate(qint64 timestamp, int id, QPointF pos)
 
82
{
 
83
    sendTouch(timestamp, id, pos, Qt::TouchPointMoved, QEvent::TouchUpdate);
 
84
}
 
85
 
 
86
void GestureTest::sendTouchRelease(qint64 timestamp, int id, QPointF pos)
 
87
{
 
88
    sendTouch(timestamp, id, pos, Qt::TouchPointReleased, QEvent::TouchEnd);
 
89
}
 
90
 
 
91
void GestureTest::sendTouch(qint64 timestamp, int id, QPointF pos,
 
92
                                 Qt::TouchPointState pointState, QEvent::Type eventType)
 
93
{
 
94
    m_fakeTimerFactory->updateTime(timestamp);
 
95
 
 
96
    QTouchEvent::TouchPoint point;
 
97
 
 
98
    point.setState(pointState);
 
99
    point.setId(id);
 
100
    point.setScenePos(pos);
 
101
    point.setPos(pos);
 
102
 
 
103
    QList<QTouchEvent::TouchPoint> points;
 
104
    points << point;
 
105
 
 
106
    QTouchEvent touchEvent(eventType, m_device, Qt::NoModifier, Qt::TouchPointPressed, points);
 
107
    QCoreApplication::sendEvent(m_view, &touchEvent);
 
108
 
 
109
    QQuickWindowPrivate *windowPrivate = QQuickWindowPrivate::get(m_view);
 
110
    windowPrivate->flushDelayedTouchEvent();
 
111
}
 
112
 
 
113
void GestureTest::passTime(qint64 timeSpanMs)
 
114
{
 
115
    qint64 finalTime = m_fakeTimerFactory->timeSource()->msecsSinceReference() + timeSpanMs;
 
116
    m_fakeTimerFactory->updateTime(finalTime);
 
117
}
 
118
 
75
119
////////////////////////// TouchMemento /////////////////////////////
76
120
 
77
121
TouchMemento::TouchMemento(const QTouchEvent *touchEvent)