1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
/*
* Copyright 2015 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GESTURETEST_H
#define GESTURETEST_H
#include <functional>
#include <QtGui/QTouchEvent>
#include <QtQuick/QQuickItem>
#include <LomiriGestures/lomirigesturesglobal.h>
class LomiriTestCase;
class QTouchDevice;
UG_FORWARD_DECLARE_CLASS(FakeTimerFactory)
UG_FORWARD_DECLARE_CLASS(TouchRegistry)
/*
The common stuff among tests come here
*/
class TouchMemento {
public:
TouchMemento(const QTouchEvent *touchEvent);
Qt::TouchPointStates touchPointStates;
QList<QTouchEvent::TouchPoint> touchPoints;
bool containsTouchWithId(int touchId) const;
};
class DummyItem : public QQuickItem
{
Q_OBJECT
public:
DummyItem(QQuickItem *parent = 0);
QList<TouchMemento> touchEvents;
std::function<void(QTouchEvent*)> touchEventHandler;
std::function<void(QMouseEvent*)> mousePressEventHandler;
std::function<void(QMouseEvent*)> mouseMoveEventHandler;
std::function<void(QMouseEvent*)> mouseReleaseEventHandler;
std::function<void(QMouseEvent*)> mouseDoubleClickEventHandler;
protected:
void touchEvent(QTouchEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
void mouseDoubleClickEvent(QMouseEvent *event) override;
private:
static void defaultTouchEventHandler(QTouchEvent *event);
static void defaultMouseEventHandler(QMouseEvent *event);
};
class GestureTest : public QObject
{
Q_OBJECT
public:
// \param qmlFilename name of the qml file to be loaded by the QQuickView
GestureTest(const QString &qmlFilename);
protected Q_SLOTS:
void initTestCase(); // will be called before the first test function is executed
virtual void init(); // called right before each and every test function is executed
virtual void cleanup(); // called right after each and every test function is executed
protected:
QTouchDevice *m_device;
LomiriTestCase *m_view;
TouchRegistry *m_touchRegistry;
UG_PREPEND_NAMESPACE(FakeTimerFactory) *m_fakeTimerFactory;
QString m_qmlFilename;
};
#endif // GESTURETEST_H
|