1// Copyright (C) 2018 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QTESTSUPPORT_GUI_H
5#define QTESTSUPPORT_GUI_H
6
7#include <QtGui/qtguiglobal.h>
8#include <QtGui/qevent.h>
9#include <QtCore/qmap.h>
10
11QT_BEGIN_NAMESPACE
12
13class QWindow;
14
15Q_GUI_EXPORT void qt_handleTouchEvent(QWindow *w, const QPointingDevice *device,
16 const QList<QEventPoint> &points,
17 Qt::KeyboardModifiers mods = Qt::NoModifier);
18
19Q_GUI_EXPORT bool qt_handleTouchEventv2(QWindow *w, const QPointingDevice *device,
20 const QList<QEventPoint> &points,
21 Qt::KeyboardModifiers mods = Qt::NoModifier);
22
23namespace QTest {
24
25[[nodiscard]] Q_GUI_EXPORT bool qWaitForWindowActive(QWindow *window, int timeout = 5000);
26[[nodiscard]] Q_GUI_EXPORT bool qWaitForWindowExposed(QWindow *window, int timeout = 5000);
27
28Q_GUI_EXPORT QPointingDevice * createTouchDevice(QInputDevice::DeviceType devType = QInputDevice::DeviceType::TouchScreen,
29 QInputDevice::Capabilities caps = QInputDevice::Capability::Position);
30
31class Q_GUI_EXPORT QTouchEventSequence
32{
33public:
34 virtual ~QTouchEventSequence();
35 QTouchEventSequence& press(int touchId, const QPoint &pt, QWindow *window = nullptr);
36 QTouchEventSequence& move(int touchId, const QPoint &pt, QWindow *window = nullptr);
37 QTouchEventSequence& release(int touchId, const QPoint &pt, QWindow *window = nullptr);
38 virtual QTouchEventSequence& stationary(int touchId);
39
40 virtual bool commit(bool processEvents = true);
41
42protected:
43 QTouchEventSequence(QWindow *window, QPointingDevice *aDevice, bool autoCommit);
44
45 QPoint mapToScreen(QWindow *window, const QPoint &pt);
46
47 QEventPoint &point(int touchId);
48
49 QEventPoint &pointOrPreviousPoint(int touchId);
50
51 QMap<int, QEventPoint> previousPoints;
52 QMap<int, QEventPoint> points;
53 QWindow *targetWindow;
54 QPointingDevice *device;
55 bool commitWhenDestroyed;
56 friend QTouchEventSequence touchEvent(QWindow *window, QPointingDevice *device, bool autoCommit);
57};
58
59} // namespace QTest
60
61QT_END_NAMESPACE
62
63#endif
64

source code of qtbase/src/gui/kernel/qtestsupport_gui.h