2
* Copyright 2015 Canonical Ltd.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser General Public License as published by
6
* the Free Software Foundation; version 3.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19
#endif // GESTURETEST_H
21
#include <QtQuick/QQuickItem>
22
#include <QtGui/QTouchEvent>
27
namespace UbuntuGestures {
28
class FakeTimerFactory;
36
The common stuff among tests come here
41
TouchMemento(const QTouchEvent *touchEvent);
42
Qt::TouchPointStates touchPointStates;
43
QList<QTouchEvent::TouchPoint> touchPoints;
45
bool containsTouchWithId(int touchId) const;
48
class DummyItem : public QQuickItem
52
DummyItem(QQuickItem *parent = 0);
54
QList<TouchMemento> touchEvents;
55
std::function<void(QTouchEvent*)> touchEventHandler;
56
std::function<void(QMouseEvent*)> mousePressEventHandler;
57
std::function<void(QMouseEvent*)> mouseMoveEventHandler;
58
std::function<void(QMouseEvent*)> mouseReleaseEventHandler;
59
std::function<void(QMouseEvent*)> mouseDoubleClickEventHandler;
61
void touchEvent(QTouchEvent *event) override;
63
void mousePressEvent(QMouseEvent *event) override;
64
void mouseMoveEvent(QMouseEvent *event) override;
65
void mouseReleaseEvent(QMouseEvent *event) override;
66
void mouseDoubleClickEvent(QMouseEvent *event) override;
68
static void defaultTouchEventHandler(QTouchEvent *event);
69
static void defaultMouseEventHandler(QMouseEvent *event);
72
class GestureTest : public QObject
76
// \param qmlFilename name of the qml file to be loaded by the QQuickView
77
GestureTest(const QString &qmlFilename);
80
void initTestCase(); // will be called before the first test function is executed
81
virtual void init(); // called right before each and every test function is executed
82
virtual void cleanup(); // called right after each and every test function is executed
85
QTouchDevice *m_device;
86
UbuntuTestCase *m_view;
87
TouchRegistry *m_touchRegistry;
88
UbuntuGestures::FakeTimerFactory *m_fakeTimerFactory;
89
QString m_qmlFilename;