diff options
Diffstat (limited to 'src/qmltest')
-rw-r--r-- | src/qmltest/qmltest.pro | 4 | ||||
-rw-r--r-- | src/qmltest/qtestoptions_p.h | 11 | ||||
-rw-r--r-- | src/qmltest/quicktest.cpp | 2 | ||||
-rw-r--r-- | src/qmltest/quicktest.h | 11 | ||||
-rw-r--r-- | src/qmltest/quicktestevent.cpp | 45 | ||||
-rw-r--r-- | src/qmltest/quicktestevent_p.h | 14 | ||||
-rw-r--r-- | src/qmltest/quicktestresult.cpp | 21 | ||||
-rw-r--r-- | src/qmltest/quicktestresult_p.h | 13 |
8 files changed, 97 insertions, 24 deletions
diff --git a/src/qmltest/qmltest.pro b/src/qmltest/qmltest.pro index 24b87588b8..289a0584e0 100644 --- a/src/qmltest/qmltest.pro +++ b/src/qmltest/qmltest.pro @@ -1,8 +1,8 @@ TARGET = QtQuickTest DEFINES += QT_NO_URL_CAST_FROM_STRING -QT = core -QT_PRIVATE = testlib-private quick qml-private gui core-private +QT = core testlib-private +QT_PRIVATE = quick qml-private gui core-private # Testlib is only a private dependency, which results in our users not # inheriting testlibs's MODULE_CONFIG transitively. Make it explicit. diff --git a/src/qmltest/qtestoptions_p.h b/src/qmltest/qtestoptions_p.h index af6764f98b..48d1c3f473 100644 --- a/src/qmltest/qtestoptions_p.h +++ b/src/qmltest/qtestoptions_p.h @@ -34,6 +34,17 @@ #ifndef QTESTOPTIONS_P_H #define QTESTOPTIONS_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <QtTest/qtest_global.h> #include <QtCore/qstring.h> diff --git a/src/qmltest/quicktest.cpp b/src/qmltest/quicktest.cpp index 5e9712d202..c90308cf1a 100644 --- a/src/qmltest/quicktest.cpp +++ b/src/qmltest/quicktest.cpp @@ -315,6 +315,8 @@ int quick_test_main(int argc, char **argv, const char *name, const char *sourceD return 1; } + qputenv("QT_QTESTLIB_RUNNING", "1"); + // Register the test object qmlRegisterSingletonType<QTestRootObject>("Qt.test.qtestroot", 1, 0, "QTestRootObject", testRootObject); // Scan through all of the "tst_*.qml" files and run each of them diff --git a/src/qmltest/quicktest.h b/src/qmltest/quicktest.h index 49bd7edfaa..b317a07db4 100644 --- a/src/qmltest/quicktest.h +++ b/src/qmltest/quicktest.h @@ -35,9 +35,12 @@ #define QUICKTEST_H #include <QtQuickTest/quicktestglobal.h> +#include <QtTest/qtest.h> QT_BEGIN_NAMESPACE +QTEST_ADD_GPU_BLACKLIST_SUPPORT_DEFS + Q_QUICK_TEST_EXPORT int quick_test_main(int argc, char **argv, const char *name, const char *sourceDir); #ifdef QUICK_TEST_SOURCE_DIR @@ -45,12 +48,16 @@ Q_QUICK_TEST_EXPORT int quick_test_main(int argc, char **argv, const char *name, #define QUICK_TEST_MAIN(name) \ int main(int argc, char **argv) \ { \ + QTEST_ADD_GPU_BLACKLIST_SUPPORT \ + QTEST_SET_MAIN_SOURCE_PATH \ return quick_test_main(argc, argv, #name, QUICK_TEST_SOURCE_DIR); \ } #define QUICK_TEST_OPENGL_MAIN(name) \ int main(int argc, char **argv) \ { \ + QTEST_ADD_GPU_BLACKLIST_SUPPORT \ + QTEST_SET_MAIN_SOURCE_PATH \ return quick_test_main(argc, argv, #name, QUICK_TEST_SOURCE_DIR); \ } @@ -59,12 +66,16 @@ Q_QUICK_TEST_EXPORT int quick_test_main(int argc, char **argv, const char *name, #define QUICK_TEST_MAIN(name) \ int main(int argc, char **argv) \ { \ + QTEST_ADD_GPU_BLACKLIST_SUPPORT \ + QTEST_SET_MAIN_SOURCE_PATH \ return quick_test_main(argc, argv, #name, 0); \ } #define QUICK_TEST_OPENGL_MAIN(name) \ int main(int argc, char **argv) \ { \ + QTEST_ADD_GPU_BLACKLIST_SUPPORT \ + QTEST_SET_MAIN_SOURCE_PATH \ return quick_test_main(argc, argv, #name, 0); \ } diff --git a/src/qmltest/quicktestevent.cpp b/src/qmltest/quicktestevent.cpp index df8de14c14..cfa80c4f19 100644 --- a/src/qmltest/quicktestevent.cpp +++ b/src/qmltest/quicktestevent.cpp @@ -50,7 +50,7 @@ QuickTestEvent::~QuickTestEvent() bool QuickTestEvent::keyPress(int key, int modifiers, int delay) { - QWindow *window = eventWindow(); + QWindow *window = activeWindow(); if (!window) return false; QTest::keyPress(window, Qt::Key(key), Qt::KeyboardModifiers(modifiers), delay); @@ -59,7 +59,7 @@ bool QuickTestEvent::keyPress(int key, int modifiers, int delay) bool QuickTestEvent::keyRelease(int key, int modifiers, int delay) { - QWindow *window = eventWindow(); + QWindow *window = activeWindow(); if (!window) return false; QTest::keyRelease(window, Qt::Key(key), Qt::KeyboardModifiers(modifiers), delay); @@ -68,7 +68,7 @@ bool QuickTestEvent::keyRelease(int key, int modifiers, int delay) bool QuickTestEvent::keyClick(int key, int modifiers, int delay) { - QWindow *window = eventWindow(); + QWindow *window = activeWindow(); if (!window) return false; QTest::keyClick(window, Qt::Key(key), Qt::KeyboardModifiers(modifiers), delay); @@ -78,7 +78,7 @@ bool QuickTestEvent::keyClick(int key, int modifiers, int delay) bool QuickTestEvent::keyPressChar(const QString &character, int modifiers, int delay) { QTEST_ASSERT(character.length() == 1); - QWindow *window = eventWindow(); + QWindow *window = activeWindow(); if (!window) return false; QTest::keyPress(window, character[0].toLatin1(), Qt::KeyboardModifiers(modifiers), delay); @@ -88,7 +88,7 @@ bool QuickTestEvent::keyPressChar(const QString &character, int modifiers, int d bool QuickTestEvent::keyReleaseChar(const QString &character, int modifiers, int delay) { QTEST_ASSERT(character.length() == 1); - QWindow *window = eventWindow(); + QWindow *window = activeWindow(); if (!window) return false; QTest::keyRelease(window, character[0].toLatin1(), Qt::KeyboardModifiers(modifiers), delay); @@ -98,7 +98,7 @@ bool QuickTestEvent::keyReleaseChar(const QString &character, int modifiers, int bool QuickTestEvent::keyClickChar(const QString &character, int modifiers, int delay) { QTEST_ASSERT(character.length() == 1); - QWindow *window = eventWindow(); + QWindow *window = activeWindow(); if (!window) return false; QTest::keyClick(window, character[0].toLatin1(), Qt::KeyboardModifiers(modifiers), delay); @@ -211,7 +211,7 @@ bool QuickTestEvent::mousePress (QObject *item, qreal x, qreal y, int button, int modifiers, int delay) { - QWindow *view = eventWindow(); + QWindow *view = eventWindow(item); if (!view) return false; QtQuickTest::mouseEvent(QtQuickTest::MousePress, view, item, @@ -226,7 +226,7 @@ bool QuickTestEvent::mouseWheel( QObject *item, qreal x, qreal y, int buttons, int modifiers, int xDelta, int yDelta, int delay) { - QWindow *view = eventWindow(); + QWindow *view = eventWindow(item); if (!view) return false; QtQuickTest::mouseWheel(view, item, Qt::MouseButtons(buttons), @@ -240,7 +240,7 @@ bool QuickTestEvent::mouseRelease (QObject *item, qreal x, qreal y, int button, int modifiers, int delay) { - QWindow *view = eventWindow(); + QWindow *view = eventWindow(item); if (!view) return false; QtQuickTest::mouseEvent(QtQuickTest::MouseRelease, view, item, @@ -254,7 +254,7 @@ bool QuickTestEvent::mouseClick (QObject *item, qreal x, qreal y, int button, int modifiers, int delay) { - QWindow *view = eventWindow(); + QWindow *view = eventWindow(item); if (!view) return false; QtQuickTest::mouseEvent(QtQuickTest::MouseClick, view, item, @@ -268,7 +268,7 @@ bool QuickTestEvent::mouseDoubleClick (QObject *item, qreal x, qreal y, int button, int modifiers, int delay) { - QWindow *view = eventWindow(); + QWindow *view = eventWindow(item); if (!view) return false; QtQuickTest::mouseEvent(QtQuickTest::MouseDoubleClick, view, item, @@ -282,7 +282,7 @@ bool QuickTestEvent::mouseDoubleClickSequence (QObject *item, qreal x, qreal y, int button, int modifiers, int delay) { - QWindow *view = eventWindow(); + QWindow *view = eventWindow(item); if (!view) return false; QtQuickTest::mouseEvent(QtQuickTest::MouseDoubleClickSequence, view, item, @@ -295,7 +295,7 @@ bool QuickTestEvent::mouseDoubleClickSequence bool QuickTestEvent::mouseMove (QObject *item, qreal x, qreal y, int delay, int buttons) { - QWindow *view = eventWindow(); + QWindow *view = eventWindow(item); if (!view) return false; QtQuickTest::mouseEvent(QtQuickTest::MouseMove, view, item, @@ -304,12 +304,23 @@ bool QuickTestEvent::mouseMove return true; } -QWindow *QuickTestEvent::eventWindow() +QWindow *QuickTestEvent::eventWindow(QObject *item) { - QQuickItem *sgitem = qobject_cast<QQuickItem *>(parent()); - if (sgitem) - return sgitem->window(); + QQuickItem *quickItem = qobject_cast<QQuickItem *>(item); + if (quickItem) + return quickItem->window(); + + QQuickItem *testParentitem = qobject_cast<QQuickItem *>(parent()); + if (testParentitem) + return testParentitem->window(); return 0; } +QWindow *QuickTestEvent::activeWindow() +{ + if (QWindow *window = QGuiApplication::focusWindow()) + return window; + return eventWindow(); +} + QT_END_NAMESPACE diff --git a/src/qmltest/quicktestevent_p.h b/src/qmltest/quicktestevent_p.h index b7f8f3eda2..0cba644cba 100644 --- a/src/qmltest/quicktestevent_p.h +++ b/src/qmltest/quicktestevent_p.h @@ -34,6 +34,17 @@ #ifndef QUICKTESTEVENT_P_H #define QUICKTESTEVENT_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <QtQuickTest/quicktestglobal.h> #include <QtCore/qobject.h> #include <QtGui/QWindow> @@ -73,7 +84,8 @@ public Q_SLOTS: #endif private: - QWindow *eventWindow(); + QWindow *eventWindow(QObject *item = 0); + QWindow *activeWindow(); }; QT_END_NAMESPACE diff --git a/src/qmltest/quicktestresult.cpp b/src/qmltest/quicktestresult.cpp index 3f91ce85a8..57ba65e588 100644 --- a/src/qmltest/quicktestresult.cpp +++ b/src/qmltest/quicktestresult.cpp @@ -34,6 +34,7 @@ #include "quicktestresult_p.h" #include <QtTest/qtestcase.h> #include <QtTest/qtestsystem.h> +#include <QtTest/private/qtestblacklist_p.h> #include <QtTest/private/qtestresult_p.h> #include <QtTest/private/qtesttable_p.h> #include <QtTest/private/qtestlog_p.h> @@ -108,6 +109,14 @@ public Q_SLOTS: pixel += x; return QColor::fromRgba(*pixel); } + + bool equals(QuickTestImageObject *other) const + { + if (!other) + return m_image.isNull(); + + return m_image == other->m_image; + } private: QImage m_image; }; @@ -205,6 +214,7 @@ void QuickTestResult::setFunctionName(const QString &name) QString fullName = d->testCaseName + QLatin1String("::") + name; QTestResult::setCurrentTestFunction (d->intern(fullName).constData()); + QTestPrivate::checkBlackLists(fullName.toUtf8().constData(), 0); } } else { QTestResult::setCurrentTestFunction(0); @@ -233,6 +243,7 @@ void QuickTestResult::setDataTag(const QString &tag) if (!tag.isEmpty()) { QTestData *data = &(QTest::newRow(tag.toUtf8().constData())); QTestResult::setCurrentTestData(data); + QTestPrivate::checkBlackLists((testCaseName() + QStringLiteral("::") + functionName()).toUtf8().constData(), tag.toUtf8().constData()); emit dataTagChanged(); } else { QTestResult::setCurrentTestData(0); @@ -270,6 +281,8 @@ bool QuickTestResult::isSkipped() const void QuickTestResult::setSkipped(bool skip) { QTestResult::setSkipCurrentTest(skip); + if (!skip) + QTestResult::setBlacklistCurrentTest(false); emit skippedChanged(); } @@ -478,8 +491,8 @@ void QuickTestResult::stringify(QQmlV4Function *args) //Check for Object Type if (value->isObject() - && !value->asFunctionObject() - && !value->asArrayObject()) { + && !value->as<QV4::FunctionObject>() + && !value->as<QV4::ArrayObject>()) { QVariant v = scope.engine->toVariant(value, QMetaType::UnknownType); if (v.isValid()) { switch (v.type()) { @@ -500,7 +513,7 @@ void QuickTestResult::stringify(QQmlV4Function *args) if (result.isEmpty()) { QString tmp = value->toQStringNoThrow(); - if (value->asArrayObject()) + if (value->as<QV4::ArrayObject>()) result.append(QString::fromLatin1("[%1]").arg(tmp)); else result.append(tmp); @@ -707,6 +720,8 @@ void QuickTestResult::parseArgs(int argc, char *argv[]) void QuickTestResult::setProgramName(const char *name) { if (name) { + QTestPrivate::parseBlackList(); + QTestPrivate::parseGpuBlackList(); QTestResult::reset(); } else if (!name && loggingStarted) { QTestResult::setCurrentTestObject(globalProgramName); diff --git a/src/qmltest/quicktestresult_p.h b/src/qmltest/quicktestresult_p.h index 80f84bfa55..ee38c07498 100644 --- a/src/qmltest/quicktestresult_p.h +++ b/src/qmltest/quicktestresult_p.h @@ -34,6 +34,17 @@ #ifndef QUICKTESTRESULT_P_H #define QUICKTESTRESULT_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <QtQuickTest/quicktestglobal.h> #include <QtCore/qobject.h> #include <QtCore/qstring.h> @@ -50,7 +61,6 @@ class QuickTestResultPrivate; class Q_QUICK_TEST_EXPORT QuickTestResult : public QObject { Q_OBJECT - Q_ENUMS(RunMode) Q_PROPERTY(QString testCaseName READ testCaseName WRITE setTestCaseName NOTIFY testCaseNameChanged) Q_PROPERTY(QString functionName READ functionName WRITE setFunctionName NOTIFY functionNameChanged) Q_PROPERTY(QString dataTag READ dataTag WRITE setDataTag NOTIFY dataTagChanged) @@ -70,6 +80,7 @@ public: RepeatUntilValidMeasurement, RunOnce }; + Q_ENUM(RunMode) QString testCaseName() const; void setTestCaseName(const QString &name); |