2 * Copyright (C) 2013 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>
24#include <TouchRegistry.h>
26GestureTest::GestureTest(const QString &qmlFilename)
27 : QObject(), m_device(nullptr), m_view(nullptr), m_qmlFilename(qmlFilename)
31void GestureTest::initTestCase()
34 m_device = new QTouchDevice;
35 m_device->setType(QTouchDevice::TouchScreen);
36 QWindowSystemInterface::registerTouchDevice(m_device);
40void GestureTest::init()
42 m_view = new QQuickView;
43 m_view->setResizeMode(QQuickView::SizeViewToRootObject);
44 m_view->setSource(QUrl::fromLocalFile(m_qmlFilename));
46 QVERIFY(QTest::qWaitForWindowExposed(m_view));
47 QVERIFY(m_view->rootObject() != 0);
49 m_touchRegistry = new TouchRegistry;
50 m_view->installEventFilter(m_touchRegistry);
52 qApp->processEvents();
55void GestureTest::cleanup()
57 m_view->removeEventFilter(m_touchRegistry);
58 delete m_touchRegistry;
59 m_touchRegistry = nullptr;
65////////////////////////// TouchMemento /////////////////////////////
67TouchMemento::TouchMemento(const QTouchEvent *touchEvent)
68 : touchPointStates(touchEvent->touchPointStates()), touchPoints(touchEvent->touchPoints())
73bool TouchMemento::containsTouchWithId(int touchId) const
75 for (int i = 0; i < touchPoints.count(); ++i) {
76 if (touchPoints.at(i).id() == touchId) {
83////////////////////////// DummyItem /////////////////////////////
85DummyItem::DummyItem(QQuickItem *parent)
88 touchEventHandler = defaultTouchEventHandler;
89 mousePressEventHandler = defaultMouseEventHandler;
90 mouseMoveEventHandler = defaultMouseEventHandler;
91 mouseReleaseEventHandler = defaultMouseEventHandler;
92 mouseDoubleClickEventHandler = defaultMouseEventHandler;
95void DummyItem::touchEvent(QTouchEvent *event)
97 touchEvents.append(TouchMemento(event));
98 touchEventHandler(event);
101void DummyItem::mousePressEvent(QMouseEvent *event)
103 mousePressEventHandler(event);
106void DummyItem::mouseMoveEvent(QMouseEvent *event)
108 mouseMoveEventHandler(event);
111void DummyItem::mouseReleaseEvent(QMouseEvent *event)
113 mouseReleaseEventHandler(event);
116void DummyItem::mouseDoubleClickEvent(QMouseEvent *event)
118 mouseDoubleClickEventHandler(event);
121void DummyItem::defaultTouchEventHandler(QTouchEvent *event)
126void 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