1 | // Copyright (C) 2016 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 QUICKTESTEVENT_P_H |
5 | #define QUICKTESTEVENT_P_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <QtQuickTest/private/quicktestglobal_p.h> |
19 | |
20 | #include <QtCore/qobject.h> |
21 | #include <QtGui/QWindow> |
22 | #include <QtQml/qqml.h> |
23 | #include <QtTest/qtesttouch.h> |
24 | |
25 | QT_BEGIN_NAMESPACE |
26 | |
27 | class QuickTestEvent; |
28 | class Q_QUICK_TEST_PRIVATE_EXPORT QQuickTouchEventSequence : public QObject |
29 | { |
30 | Q_OBJECT |
31 | QML_ANONYMOUS |
32 | QML_ADDED_IN_VERSION(1, 0) |
33 | |
34 | public: |
35 | explicit QQuickTouchEventSequence(QuickTestEvent *testEvent, QObject *item = nullptr); |
36 | public Q_SLOTS: |
37 | QObject* press(int touchId, QObject *item, qreal x, qreal y); |
38 | QObject* move(int touchId, QObject *item, qreal x, qreal y); |
39 | QObject* release(int touchId, QObject *item, qreal x, qreal y); |
40 | QObject* stationary(int touchId); |
41 | QObject* commit(); |
42 | |
43 | private: |
44 | QTest::QTouchEventSequence m_sequence; |
45 | QuickTestEvent * const m_testEvent; |
46 | }; |
47 | |
48 | class Q_QUICK_TEST_PRIVATE_EXPORT QuickTestEvent : public QObject |
49 | { |
50 | Q_OBJECT |
51 | Q_PROPERTY(int defaultMouseDelay READ defaultMouseDelay FINAL) |
52 | QML_NAMED_ELEMENT(TestEvent) |
53 | QML_ADDED_IN_VERSION(1, 0) |
54 | public: |
55 | QuickTestEvent(QObject *parent = nullptr); |
56 | ~QuickTestEvent() override; |
57 | int defaultMouseDelay() const; |
58 | |
59 | public Q_SLOTS: |
60 | bool keyPress(int key, int modifiers, int delay); |
61 | bool keyRelease(int key, int modifiers, int delay); |
62 | bool keyClick(int key, int modifiers, int delay); |
63 | |
64 | bool keyPressChar(const QString &character, int modifiers, int delay); |
65 | bool keyReleaseChar(const QString &character, int modifiers, int delay); |
66 | bool keyClickChar(const QString &character, int modifiers, int delay); |
67 | |
68 | Q_REVISION(1, 2) bool keySequence(const QVariant &keySequence); |
69 | |
70 | bool mousePress(QObject *item, qreal x, qreal y, int button, |
71 | int modifiers, int delay); |
72 | bool mouseRelease(QObject *item, qreal x, qreal y, int button, |
73 | int modifiers, int delay); |
74 | bool mouseClick(QObject *item, qreal x, qreal y, int button, |
75 | int modifiers, int delay); |
76 | bool mouseDoubleClick(QObject *item, qreal x, qreal y, int button, |
77 | int modifiers, int delay); |
78 | bool mouseDoubleClickSequence(QObject *item, qreal x, qreal y, int button, |
79 | int modifiers, int delay); |
80 | bool mouseMove(QObject *item, qreal x, qreal y, int delay, int buttons); |
81 | |
82 | #if QT_CONFIG(wheelevent) |
83 | bool mouseWheel(QObject *item, qreal x, qreal y, int buttons, |
84 | int modifiers, int xDelta, int yDelta, int delay); |
85 | #endif |
86 | |
87 | QQuickTouchEventSequence *touchEvent(QObject *item = nullptr); |
88 | private: |
89 | QWindow *eventWindow(QObject *item = nullptr); |
90 | QWindow *activeWindow(); |
91 | QPointingDevice *touchDevice(); |
92 | |
93 | Qt::MouseButtons m_pressedButtons; |
94 | |
95 | friend class QQuickTouchEventSequence; |
96 | }; |
97 | |
98 | QT_END_NAMESPACE |
99 | |
100 | #endif |
101 | |