~loic.molinari/ubuntu-ui-toolkit/ubuntu-ui-toolkit-ubuntushape-new-button-style-support

« back to all changes in this revision

Viewing changes to tests/unit_x11/tst_swipearea/GestureTest.h

  • Committer: Tarmac
  • Author(s): Zsombor Egri, Zoltán Balogh, Benjamin Zeller
  • Date: 2015-11-17 14:44:49 UTC
  • mfrom: (1693.4.43 migrate_unity8_gestures)
  • Revision ID: tarmac-20151117144449-p0s2lj04nx4fuq80
Migrate DirectionalDragArea from Unity8, named as SwipeArea. Original code (from lp:unity8) by: Daniel d'Andrada <daniel.dandrada@canonical.com>.

Approved by PS Jenkins bot, Christian Dywan, Benjamin Zeller, Zsombor Egri, Daniel d'Andrada.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2015 Canonical Ltd.
 
3
 *
 
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.
 
7
 *
 
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.
 
12
 *
 
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/>.
 
15
 *
 
16
 */
 
17
 
 
18
#ifndef GESTURETEST_H
 
19
#endif // GESTURETEST_H
 
20
 
 
21
#include <QtQuick/QQuickItem>
 
22
#include <QtGui/QTouchEvent>
 
23
 
 
24
class UbuntuTestCase;
 
25
class QTouchDevice;
 
26
 
 
27
namespace UbuntuGestures {
 
28
    class FakeTimerFactory;
 
29
}
 
30
class TouchRegistry;
 
31
 
 
32
// C++ std lib
 
33
#include <functional>
 
34
 
 
35
/*
 
36
    The common stuff among tests come here
 
37
 */
 
38
 
 
39
class TouchMemento {
 
40
public:
 
41
    TouchMemento(const QTouchEvent *touchEvent);
 
42
    Qt::TouchPointStates touchPointStates;
 
43
    QList<QTouchEvent::TouchPoint> touchPoints;
 
44
 
 
45
    bool containsTouchWithId(int touchId) const;
 
46
};
 
47
 
 
48
class DummyItem : public QQuickItem
 
49
{
 
50
    Q_OBJECT
 
51
public:
 
52
    DummyItem(QQuickItem *parent = 0);
 
53
 
 
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;
 
60
protected:
 
61
    void touchEvent(QTouchEvent *event) override;
 
62
 
 
63
    void mousePressEvent(QMouseEvent *event) override;
 
64
    void mouseMoveEvent(QMouseEvent *event) override;
 
65
    void mouseReleaseEvent(QMouseEvent *event) override;
 
66
    void mouseDoubleClickEvent(QMouseEvent *event) override;
 
67
private:
 
68
    static void defaultTouchEventHandler(QTouchEvent *event);
 
69
    static void defaultMouseEventHandler(QMouseEvent *event);
 
70
};
 
71
 
 
72
class GestureTest : public QObject
 
73
{
 
74
    Q_OBJECT
 
75
public:
 
76
    // \param qmlFilename name of the qml file to be loaded by the QQuickView
 
77
    GestureTest(const QString &qmlFilename);
 
78
 
 
79
protected Q_SLOTS:
 
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
 
83
 
 
84
protected:
 
85
    QTouchDevice *m_device;
 
86
    UbuntuTestCase *m_view;
 
87
    TouchRegistry *m_touchRegistry;
 
88
    UbuntuGestures::FakeTimerFactory *m_fakeTimerFactory;
 
89
    QString m_qmlFilename;
 
90
};
 
91
 
 
92
#define GESTURETEST_H