diff options
Diffstat (limited to 'tests/plugins')
7 files changed, 93 insertions, 7 deletions
diff --git a/tests/plugins/declarativetestplugin/declarativetestplugin.pro b/tests/plugins/declarativetestplugin/declarativetestplugin.pro index a27267d7..0a99e7a7 100644 --- a/tests/plugins/declarativetestplugin/declarativetestplugin.pro +++ b/tests/plugins/declarativetestplugin/declarativetestplugin.pro @@ -7,13 +7,15 @@ QT += gui-private qml quick location testlib INCLUDEPATH += ../../../src/imports/location INCLUDEPATH += ../../../src/location -HEADERS += qdeclarativepinchgenerator_p.h \ - qdeclarativelocationtestmodel_p.h - - -SOURCES += locationtest.cpp \ - qdeclarativepinchgenerator.cpp \ - qdeclarativelocationtestmodel.cpp +HEADERS += \ + qdeclarativepinchgenerator_p.h \ + qdeclarativelocationtestmodel_p.h \ + testhelper.h + +SOURCES += \ + locationtest.cpp \ + qdeclarativepinchgenerator.cpp \ + qdeclarativelocationtestmodel.cpp IMPORT_FILES = \ qmldir diff --git a/tests/plugins/declarativetestplugin/locationtest.cpp b/tests/plugins/declarativetestplugin/locationtest.cpp index cde1d97f..7f579196 100644 --- a/tests/plugins/declarativetestplugin/locationtest.cpp +++ b/tests/plugins/declarativetestplugin/locationtest.cpp @@ -33,6 +33,7 @@ #include "qdeclarativepinchgenerator_p.h" #include "qdeclarativelocationtestmodel_p.h" +#include "testhelper.h" #include <QtQml/QQmlExtensionPlugin> #include <QtQml/qqml.h> @@ -41,6 +42,14 @@ QT_BEGIN_NAMESPACE +static QObject *helper_factory(QQmlEngine *engine, QJSEngine *scriptEngine) +{ + Q_UNUSED(engine); + Q_UNUSED(scriptEngine); + TestHelper *helper = new TestHelper(); + return helper; +} + class QLocationDeclarativeTestModule: public QQmlExtensionPlugin { Q_OBJECT @@ -51,6 +60,7 @@ public: if (QLatin1String(uri) == QLatin1String("QtLocation.Test")) { qmlRegisterType<QDeclarativePinchGenerator>(uri, 5, 5, "PinchGenerator"); qmlRegisterType<QDeclarativeLocationTestModel>(uri, 5, 5, "TestModel"); + qmlRegisterSingletonType<TestHelper>(uri, 5, 6, "LocationTestHelper", helper_factory); } else { qWarning() << "Unsupported URI given to load location test QML plugin: " << QLatin1String(uri); } diff --git a/tests/plugins/declarativetestplugin/qdeclarativelocationtestmodel.cpp b/tests/plugins/declarativetestplugin/qdeclarativelocationtestmodel.cpp index f0b03746..87e5c9f2 100644 --- a/tests/plugins/declarativetestplugin/qdeclarativelocationtestmodel.cpp +++ b/tests/plugins/declarativetestplugin/qdeclarativelocationtestmodel.cpp @@ -36,6 +36,8 @@ #include <QtCore/QTime> #include <QtCore> +QT_BEGIN_NAMESPACE + QDeclarativeLocationTestModel::QDeclarativeLocationTestModel(QObject *parent): QAbstractListModel(parent), delay_(0), @@ -247,3 +249,5 @@ QHash<int, QByteArray> QDeclarativeLocationTestModel::roleNames() const roles.insert(TestDataRole, "modeldata"); return roles; } + +QT_END_NAMESPACE diff --git a/tests/plugins/declarativetestplugin/qdeclarativelocationtestmodel_p.h b/tests/plugins/declarativetestplugin/qdeclarativelocationtestmodel_p.h index 19564336..91f152ac 100644 --- a/tests/plugins/declarativetestplugin/qdeclarativelocationtestmodel_p.h +++ b/tests/plugins/declarativetestplugin/qdeclarativelocationtestmodel_p.h @@ -41,6 +41,8 @@ #include <QList> #include <QtPositioning/QGeoCoordinate> +QT_BEGIN_NAMESPACE + class DataObject: public QObject { Q_OBJECT @@ -128,4 +130,6 @@ private: bool crazyMode_; }; +QT_END_NAMESPACE + #endif diff --git a/tests/plugins/declarativetestplugin/qdeclarativepinchgenerator.cpp b/tests/plugins/declarativetestplugin/qdeclarativepinchgenerator.cpp index 98da18d0..632f9fa9 100644 --- a/tests/plugins/declarativetestplugin/qdeclarativepinchgenerator.cpp +++ b/tests/plugins/declarativetestplugin/qdeclarativepinchgenerator.cpp @@ -38,6 +38,8 @@ #include <QtGui/qpa/qwindowsysteminterface.h> #include <QtGui/QStyleHints> +QT_BEGIN_NAMESPACE + QDeclarativePinchGenerator::QDeclarativePinchGenerator(): target_(0), state_(Invalid), @@ -381,3 +383,5 @@ int QDeclarativePinchGenerator::startDragDistance() { return qApp->styleHints()->startDragDistance(); } + +QT_END_NAMESPACE diff --git a/tests/plugins/declarativetestplugin/qdeclarativepinchgenerator_p.h b/tests/plugins/declarativetestplugin/qdeclarativepinchgenerator_p.h index b2a4e77c..db5c9131 100644 --- a/tests/plugins/declarativetestplugin/qdeclarativepinchgenerator_p.h +++ b/tests/plugins/declarativetestplugin/qdeclarativepinchgenerator_p.h @@ -46,6 +46,8 @@ #define SWIPES_REQUIRED 2 +QT_BEGIN_NAMESPACE + typedef struct { QList<QPoint> touchPoints; QList<int> durations; @@ -137,4 +139,6 @@ private: QTouchDevice* device_; }; +QT_END_NAMESPACE + #endif diff --git a/tests/plugins/declarativetestplugin/testhelper.h b/tests/plugins/declarativetestplugin/testhelper.h new file mode 100644 index 00000000..c6d9f3b3 --- /dev/null +++ b/tests/plugins/declarativetestplugin/testhelper.h @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef TESTHELPER_H +#define TESTHELPER_H + +#include <QObject> +#include <QSignalSpy> +#include <QQuickItem> +#include <QQuickWindow> + +QT_BEGIN_NAMESPACE + +class TestHelper: public QObject +{ + Q_OBJECT +public: + TestHelper(QObject *parent = Q_NULLPTR):QObject(parent){} + Q_INVOKABLE bool waitForPolished(QQuickItem *item, int timeout = 10000) const + { + QSignalSpy spy(item->window(), &QQuickWindow::afterAnimating); + return spy.wait(timeout); + } +}; + +QT_END_NAMESPACE + +#endif // TESTHELPER_H |