30 #include <QtTest/QTest>
31 #include <QtWidgets/QApplication>
32 #include <QtWidgets/QWidget>
33 #include <QtWidgets/QGestureEvent>
34 #include <QtGui/QScreen>
35 #include <QtGui/QPointingDevice>
36 #include <QtCore/QList>
37 #include <QtCore/QString>
38 #include <QtCore/QHash>
39 #include <QtCore/QDebug>
49 #ifndef QT_NO_GESTURES
50 void panGesture_data();
52 void pinchGesture_data();
54 void swipeGesture_data();
60 const int m_fingerDistance;
68 qputenv(
"QT_PAN_TOUCHPOINTS",
"2");
71 void tst_QGestureRecognizer::initTestCase()
75 #ifndef QT_NO_GESTURES
85 {
return m_receivedGestures.
value(gestureType); }
92 GestureTypeHash m_receivedGestures;
101 m_receivedGestures.
insert(gestureType,
false);
112 switch (
event->type()) {
133 const int pointCount =
points.size();
134 for (
int p = 0;
p < pointCount; ++
p)
142 const int pointCount =
points.size();
143 for (
int s = 0;
s <
n; ++
s) {
144 for (
int p = 0;
p < pointCount; ++
p) {
155 const int pointCount =
points.size();
156 for (
int p = 0;
p < pointCount; ++
p)
167 void tst_QGestureRecognizer::panGesture_data()
169 QTest::addColumn<int>(
"panSubTest");
170 QTest::addColumn<bool>(
"gestureExpected");
174 void tst_QGestureRecognizer::panGesture()
177 QFETCH(
bool, gestureExpected);
181 const int panPoints = 2;
189 for (
int i = 0;
i < panPoints; ++
i)
197 if (gestureExpected) {
211 void tst_QGestureRecognizer::pinchGesture_data()
213 QTest::addColumn<int>(
"pinchSubTest");
214 QTest::addColumn<bool>(
"gestureExpected");
218 void tst_QGestureRecognizer::pinchGesture()
220 QFETCH(
int, pinchSubTest);
221 QFETCH(
bool, gestureExpected);
238 for (
int s = 0;
s < 5; ++
s) {
248 if (gestureExpected) {
264 void tst_QGestureRecognizer::swipeGesture_data()
266 QTest::addColumn<int>(
"swipeSubTest");
267 QTest::addColumn<bool>(
"gestureExpected");
273 void tst_QGestureRecognizer::swipeGesture()
275 enum { swipePoints = 3 };
277 QFETCH(
int, swipeSubTest);
278 QFETCH(
bool, gestureExpected);
287 const QPoint fingerDistance(m_fingerDistance, m_fingerDistance);
289 for (
int i = 0;
i < swipePoints - 1; ++
i)
290 points.append(fingerDistance +
i * fingerDistance);
302 const QPoint moveDelta(60, 20);
303 switch (swipeSubTest) {
305 linearSequence(5, moveDelta, swipeSequence,
points, &
widget);
308 linearSequence(5, moveDelta, swipeSequence,
points, &
widget);
309 linearSequence(3,
QPoint(-moveDelta.x(), moveDelta.y()), swipeSequence,
points, &
widget);
312 const QPoint smallChangeMoveDelta(50, 1);
313 linearSequence(5, smallChangeMoveDelta, swipeSequence,
points, &
widget);
314 linearSequence(1,
QPoint(smallChangeMoveDelta.x(), -3), swipeSequence,
points, &
widget);
315 linearSequence(5, smallChangeMoveDelta, swipeSequence,
points, &
widget);
322 if (gestureExpected) {
330 void tst_QGestureRecognizer::touchReplay()
353 #include "tst_qgesturerecognizer.moc"
small capitals from c petite p scientific i
[1]
static void processEvents(QEventLoop::ProcessEventsFlags flags=QEventLoop::AllEvents)
The QEvent class is the base class of all event classes. Event objects contain event parameters.
The QGestureEvent class provides the description of triggered gestures.
QGesture * gesture(Qt::GestureType type) const
The QGesture class represents a gesture, containing properties that describe the corresponding user i...
The QGuiApplication class manages the GUI application's control flow and main settings.
QScreen * primaryScreen
the primary (or default) screen of the application.
T value(const Key &key) const noexcept
iterator insert(const Key &key, const T &value)
The QObject class is the base class of all Qt objects.
The QPoint class defines a point in the plane using integer precision.
The QPointingDevice class describes a device from which mouse, touch or tablet events originate.
constexpr QPointF center() const noexcept
constexpr QSizeF size() const noexcept
The QRect class defines a rectangle in the plane using integer precision.
constexpr QPoint center() const noexcept
QRect availableGeometry
the screen's available geometry in pixels
The QSize class defines the size of a two-dimensional object using integer point precision.
QTouchEventSequence & press(int touchId, const QPoint &pt, QWindow *window=nullptr)
QTouchEventSequence & release(int touchId, const QPoint &pt, QWindow *window=nullptr)
The QWindow class represents a window in the underlying windowing system.
Q_TESTLIB_EXPORT QTestData & newRow(const char *dataTag)
Q_TESTLIB_EXPORT const char * currentTestFunction()
Q_GUI_EXPORT QPointingDevice * createTouchDevice(QInputDevice::DeviceType devType=QInputDevice::DeviceType::TouchScreen, QInputDevice::Capabilities caps=QInputDevice::Capability::Position)
Q_GUI_EXPORT bool qWaitForWindowActive(QWindow *window, int timeout=5000)
Q_GUI_EXPORT bool qWaitForWindowExposed(QWindow *window, int timeout=5000)
QTouchEventSequence touchEvent(QWindow *window, QPointingDevice *device, bool autoCommit=true)
int qRound(qfloat16 d) noexcept
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLfixed GLfixed GLint GLint GLfixed points
#define QTEST_MAIN(TestObject)
#define QFETCH(Type, name)
#define QVERIFY(statement)
#define QTRY_VERIFY(expr)
@ SwipeSmallDirectionChangeSubTest
@ SwipeDirectionChangeSubTest
QList< Qt::GestureType > GestureTypeVector