2 * Copyright (C) 2013,2015 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU 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 General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17#include "GestureTest.h"
19#include <qpa/qwindowsysteminterface.h>
25#include <TouchRegistry.h>
27using namespace UbuntuGestures;
29GestureTest::GestureTest(const QString &qmlFilename)
30 : QObject(), m_device(nullptr), m_view(nullptr), m_qmlFilename(qmlFilename)
34void GestureTest::initTestCase()
37 m_device = new QTouchDevice;
38 m_device->setType(QTouchDevice::TouchScreen);
39 QWindowSystemInterface::registerTouchDevice(m_device);
43void GestureTest::init()
45 m_view = new QQuickView;
46 m_view->setResizeMode(QQuickView::SizeViewToRootObject);
47 m_view->setSource(QUrl::fromLocalFile(m_qmlFilename));
49 QVERIFY(QTest::qWaitForWindowExposed(m_view));
50 QVERIFY(m_view->rootObject() != 0);
52 m_fakeTimerFactory = new FakeTimerFactory;
54 m_touchRegistry = new TouchRegistry(nullptr, m_fakeTimerFactory);
55 m_view->installEventFilter(m_touchRegistry);
57 qApp->processEvents();
60void GestureTest::cleanup()
62 m_view->removeEventFilter(m_touchRegistry);
63 delete m_touchRegistry;
64 m_touchRegistry = nullptr;
66 // TouchRegistry will take down the timer factory along with him
67 // delete m_fakeTimerFactory;
68 m_fakeTimerFactory = nullptr;
74////////////////////////// TouchMemento /////////////////////////////
76TouchMemento::TouchMemento(const QTouchEvent *touchEvent)
77 : touchPointStates(touchEvent->touchPointStates()), touchPoints(touchEvent->touchPoints())
82bool TouchMemento::containsTouchWithId(int touchId) const
84 for (int i = 0; i < touchPoints.count(); ++i) {
85 if (touchPoints.at(i).id() == touchId) {
92////////////////////////// DummyItem /////////////////////////////
94DummyItem::DummyItem(QQuickItem *parent)
97 touchEventHandler = defaultTouchEventHandler;
98 mousePressEventHandler = defaultMouseEventHandler;
99 mouseMoveEventHandler = defaultMouseEventHandler;
100 mouseReleaseEventHandler = defaultMouseEventHandler;
101 mouseDoubleClickEventHandler = defaultMouseEventHandler;
104void DummyItem::touchEvent(QTouchEvent *event)
106 touchEvents.append(TouchMemento(event));
107 touchEventHandler(event);
110void DummyItem::mousePressEvent(QMouseEvent *event)
112 mousePressEventHandler(event);
115void DummyItem::mouseMoveEvent(QMouseEvent *event)
117 mouseMoveEventHandler(event);
120void DummyItem::mouseReleaseEvent(QMouseEvent *event)
122 mouseReleaseEventHandler(event);
125void DummyItem::mouseDoubleClickEvent(QMouseEvent *event)
127 mouseDoubleClickEventHandler(event);
130void DummyItem::defaultTouchEventHandler(QTouchEvent *event)
135void DummyItem::defaultMouseEventHandler(QMouseEvent *event)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list