2 * Copyright (C) 2012, 2013, 2014 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/>.
20#include <qpa/qwindowsysteminterface.h>
21#include <QtGui/QGuiApplication>
23#include <private/qquickbehavior_p.h>
24#include <private/qquickanimation_p.h>
27#include <TouchRegistry>
30using namespace UbuntuGestures;
32TestUtil::TestUtil(QObject *parent)
36 , m_putFakeTimerFactoryInTouchRegistry(false)
45TestUtil::isInstanceOf(QObject *obj, QString name)
47 if (!obj) return false;
48 bool result = obj->inherits(name.toUtf8());
50 const QMetaObject *metaObject = obj->metaObject();
51 while (!result && metaObject) {
52 const QString className = metaObject->className();
53 const QString qmlName = className.left(className.indexOf("_QMLTYPE_"));
54 result = qmlName == name;
55 metaObject = metaObject->superClass();
62TestUtil::waitForBehaviors(QObject *obj)
66 Q_FOREACH(auto c, obj->children()) {
67 if (auto *b = dynamic_cast<QQuickBehavior*>(c)) {
69 QTRY_COMPARE(b->animation()->isRunning(), false);
76TouchEventSequenceWrapper *TestUtil::touchEvent(QQuickItem *item)
81 // Tests can be *very* slow to run and we don't want things timing out because
82 // of that. So give it fake timers to use (they will never time out)
83 if (!m_putFakeTimerFactoryInTouchRegistry) {
84 TouchRegistry::instance()->setTimerFactory(new FakeTimerFactory);
85 m_putFakeTimerFactoryInTouchRegistry = true;
88 return new TouchEventSequenceWrapper(
89 QTest::touchEvent(m_targetWindow, m_touchDevice, /* autoCommit */ false), item);
92void TestUtil::ensureTargetWindow()
94 if (!m_targetWindow && !QGuiApplication::topLevelWindows().isEmpty())
95 m_targetWindow = QGuiApplication::topLevelWindows()[0];
98void TestUtil::ensureTouchDevice()
100 if (!m_touchDevice) {
101 m_touchDevice = new QTouchDevice;
102 m_touchDevice->setType(QTouchDevice::TouchScreen);
103 QWindowSystemInterface::registerTouchDevice(m_touchDevice);
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