diff options
Diffstat (limited to 'tests/auto')
90 files changed, 1695 insertions, 570 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index f9c1fcce91..1e80f1bf65 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -18,7 +18,4 @@ qtHaveModule(gui):qtConfig(opengl(es1|es2)?) { # console applications not supported uikit: SUBDIRS -= qmltest -# Restricted sub-set for now -boot2qt: SUBDIRS = qml - installed_cmake.depends = cmake diff --git a/tests/auto/particles/qquickimageparticle/BLACKLIST b/tests/auto/particles/qquickimageparticle/BLACKLIST new file mode 100644 index 0000000000..a615dcd6e6 --- /dev/null +++ b/tests/auto/particles/qquickimageparticle/BLACKLIST @@ -0,0 +1,16 @@ +# QTBUG-63055 +[test_colored] +b2qt + +# QTBUG-63055 +[test_colorVariance] +b2qt + +# QTBUG-63055 +[test_deformed] +b2qt + +# QTBUG-63055 +[test_sprite] +b2qt + diff --git a/tests/auto/particles/qquickspritegoal/BLACKLIST b/tests/auto/particles/qquickspritegoal/BLACKLIST new file mode 100644 index 0000000000..bd64621f77 --- /dev/null +++ b/tests/auto/particles/qquickspritegoal/BLACKLIST @@ -0,0 +1,3 @@ +# QTBUG-63057 +[test_instantTransition] +b2qt diff --git a/tests/auto/qml/debugger/debugger.pro b/tests/auto/qml/debugger/debugger.pro index a50411e18b..63721cc575 100644 --- a/tests/auto/qml/debugger/debugger.pro +++ b/tests/auto/qml/debugger/debugger.pro @@ -10,7 +10,8 @@ PUBLICTESTS += \ qqmlenginedebuginspectorintegrationtest \ qqmlenginecontrol \ qqmldebuggingenabler \ - qqmlnativeconnector + qqmlnativeconnector \ + qqmldebugprocess PRIVATETESTS += \ qqmldebugclient \ diff --git a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp index 134de44858..a76740a3f9 100644 --- a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp +++ b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp @@ -27,6 +27,7 @@ ****************************************************************************/ #include "debugutil_p.h" +#include "qqmldebugprocess_p.h" #include "../../../shared/util.h" #include <private/qqmldebugclient_p.h> diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/tst_qqmldebugjs.cpp b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/tst_qqmldebugjs.cpp index 59483d75da..3cd359cf48 100644 --- a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/tst_qqmldebugjs.cpp +++ b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/tst_qqmldebugjs.cpp @@ -27,6 +27,7 @@ ****************************************************************************/ #include "debugutil_p.h" +#include "qqmldebugprocess_p.h" #include "../../shared/qqmlenginedebugclient.h" #include "../../../../shared/util.h" @@ -1188,6 +1189,14 @@ void tst_QQmlDebugJS::stepNext() QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE)); } +static QVariantMap responseBody(QJSDebugClient *client) +{ + const QString jsonString(client->response); + const QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)) + .toVariant().toMap(); + return value.value("body").toMap(); +} + void tst_QQmlDebugJS::stepIn() { //void continueDebugging(StepAction stepAction, int stepCount = 1); @@ -1196,21 +1205,18 @@ void tst_QQmlDebugJS::stepIn() QFETCH(bool, namesAsObjects); int sourceLine = 41; - int actualLine = 37; + int actualLine = 36; QCOMPARE(init(qmlscene, STEPACTION_QMLFILE), ConnectSuccess); m_client->setBreakpoint(QLatin1String(STEPACTION_QMLFILE), sourceLine, 1, true); m_client->connect(redundantRefs, namesAsObjects); QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(stopped()))); + QCOMPARE(responseBody(m_client).value("sourceLine").toInt(), sourceLine); m_client->continueDebugging(QJSDebugClient::In); QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(stopped()))); - QString jsonString(m_client->response); - QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); - - QVariantMap body = value.value("body").toMap(); - + const QVariantMap body = responseBody(m_client); QCOMPARE(body.value("sourceLine").toInt(), actualLine); QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE)); } @@ -1229,15 +1235,12 @@ void tst_QQmlDebugJS::stepOut() m_client->setBreakpoint(QLatin1String(STEPACTION_QMLFILE), sourceLine, -1, true); m_client->connect(redundantRefs, namesAsObjects); QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(stopped()))); + QCOMPARE(responseBody(m_client).value("sourceLine").toInt(), sourceLine); m_client->continueDebugging(QJSDebugClient::Out); QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(stopped()))); - QString jsonString(m_client->response); - QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); - - QVariantMap body = value.value("body").toMap(); - + const QVariantMap body = responseBody(m_client); QCOMPARE(body.value("sourceLine").toInt(), actualLine); QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE)); } @@ -1331,16 +1334,15 @@ void tst_QQmlDebugJS::evaluateInGlobalScope() m_client->connect(); - do { + for (int i = 0; i < 10; ++i) { // The engine might not be initialized, yet. We just try until it shows up. m_client->evaluate(QLatin1String("console.log('Hello World')")); - } while (!QQmlDebugTest::waitForSignal(m_client, SIGNAL(result()), 500)); + if (QQmlDebugTest::waitForSignal(m_client, SIGNAL(result()), 500)) + break; + } //Verify the return value of 'console.log()', which is "undefined" - QString jsonString(m_client->response); - QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); - QVariantMap body = value.value("body").toMap(); - QCOMPARE(body.value("type").toString(),QLatin1String("undefined")); + QCOMPARE(responseBody(m_client).value("type").toString(), QLatin1String("undefined")); } void tst_QQmlDebugJS::evaluateInLocalScope() @@ -1425,11 +1427,7 @@ void tst_QQmlDebugJS::evaluateInContext() m_client->evaluate(QLatin1String("a + 10"), -1, object.debugId); QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(result()))); - QString jsonString = m_client->response; - QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); - - QVariantMap body = value.value("body").toMap(); - QTRY_COMPARE(body.value("value").toInt(), 20); + QTRY_COMPARE(responseBody(m_client).value("value").toInt(), 20); } void tst_QQmlDebugJS::getScripts() diff --git a/tests/auto/qml/debugger/qqmldebuglocal/tst_qqmldebuglocal.cpp b/tests/auto/qml/debugger/qqmldebuglocal/tst_qqmldebuglocal.cpp index 8d21a8a45a..4b28857fc0 100644 --- a/tests/auto/qml/debugger/qqmldebuglocal/tst_qqmldebuglocal.cpp +++ b/tests/auto/qml/debugger/qqmldebuglocal/tst_qqmldebuglocal.cpp @@ -32,6 +32,9 @@ #include <private/qqmldebugconnector_p.h> #include <private/qqmldebugconnection_p.h> +#include <QtQml/qqmldebug.h> +#include <QtQml/qqmlengine.h> + #include <QtTest/qtest.h> #include <QtTest/qsignalspy.h> #include <QtNetwork/qhostaddress.h> diff --git a/tests/auto/qml/debugger/qqmldebugprocess/qqmldebugprocess.pro b/tests/auto/qml/debugger/qqmldebugprocess/qqmldebugprocess.pro new file mode 100644 index 0000000000..331d87b9f1 --- /dev/null +++ b/tests/auto/qml/debugger/qqmldebugprocess/qqmldebugprocess.pro @@ -0,0 +1,4 @@ +TEMPLATE = subdirs +SUBDIRS = qqmldebugprocess qqmldebugprocessprocess + +qqmldebugprocess.depends = qqmldebugprocessprocess diff --git a/tests/auto/qml/debugger/qqmldebugprocess/qqmldebugprocess/qqmldebugprocess.pro b/tests/auto/qml/debugger/qqmldebugprocess/qqmldebugprocess/qqmldebugprocess.pro new file mode 100644 index 0000000000..9bea2d222c --- /dev/null +++ b/tests/auto/qml/debugger/qqmldebugprocess/qqmldebugprocess/qqmldebugprocess.pro @@ -0,0 +1,14 @@ +CONFIG += testcase +TARGET = tst_qqmldebugprocess +QT = core testlib +CONFIG -= debug_and_release_target +macos:CONFIG -= app_bundle + +SOURCES += \ + ../../shared/qqmldebugprocess.cpp \ + tst_qqmldebugprocess.cpp + +HEADERS += \ + ../../shared/qqmldebugprocess_p.h + +INCLUDEPATH += ../../shared diff --git a/tests/auto/qml/debugger/qqmldebugprocess/qqmldebugprocess/tst_qqmldebugprocess.cpp b/tests/auto/qml/debugger/qqmldebugprocess/qqmldebugprocess/tst_qqmldebugprocess.cpp new file mode 100644 index 0000000000..993a1d5f63 --- /dev/null +++ b/tests/auto/qml/debugger/qqmldebugprocess/qqmldebugprocess/tst_qqmldebugprocess.cpp @@ -0,0 +1,126 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <qqmldebugprocess_p.h> +#include <QtTest> + +#include <QtCore/qcoreapplication.h> +#include <QtCore/qscopedpointer.h> + +class tst_QQmlDebugProcess : public QObject +{ + Q_OBJECT + +private slots: + void sessionStart_data(); + void sessionStart(); +}; + +void tst_QQmlDebugProcess::sessionStart_data() +{ + QTest::addColumn<int>("delay"); + QTest::addColumn<QString>("arg"); + QTest::addColumn<bool>("sessionExpected"); + QTest::addColumn<bool>("outputExpected"); + + QTest::addRow("synchronous / waiting") << -1 + << "QML Debugger: Waiting for connection on port 2423..." + << true << false; + QTest::addRow("synchronous / failed") << -1 << "QML Debugger: Unable to listen to port 242." + << false << false; + QTest::addRow("synchronous / unknown") << -1 << "QML Debugger: You don't know this string." + << false << true; + QTest::addRow("synchronous / appout") << -1 << "Output from app itself." + << false << true; + + QTest::addRow("no delay / waiting") << 0 + << "QML Debugger: Waiting for connection on port 2423..." + << true << false; + QTest::addRow("no delay / failed") << 0 << "QML Debugger: Unable to listen to port 242." + << false << false; + QTest::addRow("no delay / unknown") << 0 << "QML Debugger: You don't know this string." + << false << true; + QTest::addRow("no delay / appout") << 0 << "Output from app itself." + << false << true; + + QTest::addRow("delay / waiting") << 1000 + << "QML Debugger: Waiting for connection on port 2423..." + << true << false; + QTest::addRow("delay / failed") << 1000 << "QML Debugger: Unable to listen to port 242." + << false << false; + QTest::addRow("delay / unknown") << 1000 << "QML Debugger: You don't know this string." + << false << true; + QTest::addRow("delay / appout") << 1000 << "Output from app itself." + << false << true; +} + +void tst_QQmlDebugProcess::sessionStart() +{ + QFETCH(int, delay); + QFETCH(QString, arg); + QFETCH(bool, sessionExpected); + QFETCH(bool, outputExpected); + + QScopedPointer<QQmlDebugProcess> process( + new QQmlDebugProcess(QCoreApplication::applicationDirPath() + + QLatin1String("/qqmldebugprocessprocess"), this)); + QVERIFY(process); + + bool outputReceived = false; + connect(process.data(), &QQmlDebugProcess::readyReadStandardOutput, this, [&]() { + QVERIFY(outputExpected); + QVERIFY(!outputReceived); + QCOMPARE(process->output().trimmed(), arg); + outputReceived = true; + QTimer::singleShot(qMax(delay, 0), process.data(), &QQmlDebugProcess::stop); + }); + + if (!outputExpected && !sessionExpected) + QTest::ignoreMessage(QtWarningMsg, "App was unable to bind to port!"); + process->start(QStringList({arg})); + + bool done = false; + auto wait = [&](){ + QCOMPARE(process->waitForSessionStart(), sessionExpected); + QCOMPARE(outputReceived, outputExpected); + process->stop(); + done = true; + }; + + if (delay < 0) + wait(); + else + QTimer::singleShot(delay, process.data(), wait); + + QTRY_VERIFY(done); + QVERIFY(process->state().startsWith("not running")); +} + +QTEST_MAIN(tst_QQmlDebugProcess) + +#include "tst_qqmldebugprocess.moc" diff --git a/tests/auto/qml/debugger/qqmldebugprocess/qqmldebugprocessprocess/qqmldebugprocessprocess.cpp b/tests/auto/qml/debugger/qqmldebugprocess/qqmldebugprocessprocess/qqmldebugprocessprocess.cpp new file mode 100644 index 0000000000..21cce53fc3 --- /dev/null +++ b/tests/auto/qml/debugger/qqmldebugprocess/qqmldebugprocessprocess/qqmldebugprocessprocess.cpp @@ -0,0 +1,39 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtCore/qdebug.h> +#include <QtCore/qcoreapplication.h> + +// Process that just outputs a fake "Waiting" message. +int main(int argc, char **argv) +{ + QCoreApplication app(argc, argv); + if (argc > 1) + qDebug() << argv[1]; + return app.exec(); +} diff --git a/tests/auto/qml/debugger/qqmldebugprocess/qqmldebugprocessprocess/qqmldebugprocessprocess.pro b/tests/auto/qml/debugger/qqmldebugprocess/qqmldebugprocessprocess/qqmldebugprocessprocess.pro new file mode 100644 index 0000000000..55a77d830d --- /dev/null +++ b/tests/auto/qml/debugger/qqmldebugprocess/qqmldebugprocessprocess/qqmldebugprocessprocess.pro @@ -0,0 +1,10 @@ +QT = core +macos:CONFIG -= app_bundle +CONFIG -= debug_and_release_target +SOURCES += qqmldebugprocessprocess.cpp + +DESTDIR = ../qqmldebugprocess + +target.path = $$[QT_INSTALL_TESTS]/tst_qqmldebugprocess +INSTALLS += target + diff --git a/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp b/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp index 06e4a4bfcc..4e103e9a65 100644 --- a/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp +++ b/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp @@ -29,6 +29,7 @@ #include "qqmldebugtestservice.h" #include "debugutil_p.h" +#include "qqmldebugprocess_p.h" #include "../../../shared/util.h" #include <private/qqmldebugclient_p.h> diff --git a/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/BLACKLIST b/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/BLACKLIST deleted file mode 100644 index 5fb1dc193b..0000000000 --- a/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/BLACKLIST +++ /dev/null @@ -1,2 +0,0 @@ -# QTQAINFRA-1334 -windows gcc diff --git a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp index a4cf932ee1..5c9506eb21 100644 --- a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp +++ b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp @@ -28,6 +28,7 @@ #include "qqmlinspectorclient.h" #include "../shared/debugutil_p.h" +#include "../shared/qqmldebugprocess_p.h" #include "../../../shared/util.h" #include <private/qqmldebugconnection_p.h> diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/BLACKLIST b/tests/auto/qml/debugger/qqmlprofilerservice/BLACKLIST deleted file mode 100644 index 5fb1dc193b..0000000000 --- a/tests/auto/qml/debugger/qqmlprofilerservice/BLACKLIST +++ /dev/null @@ -1,2 +0,0 @@ -# QTQAINFRA-1334 -windows gcc diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp index 4d37f16e41..1bf700aea4 100644 --- a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp +++ b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp @@ -27,6 +27,7 @@ ****************************************************************************/ #include "debugutil_p.h" +#include "qqmldebugprocess_p.h" #include "../../../shared/util.h" #include <private/qqmlprofilerclient_p.h> @@ -35,6 +36,9 @@ #include <QtTest/qtest.h> #include <QtCore/qlibraryinfo.h> +#include <QtGui/private/qguiapplication_p.h> +#include <QtGui/qpa/qplatformintegration.h> + struct QQmlProfilerData { QQmlProfilerData(qint64 time = -2, int messageType = -1, int detailType = -1, @@ -584,16 +588,18 @@ void tst_QQmlProfilerService::scenegraphData() qint64 contextFrameTime = -1; qint64 renderFrameTime = -1; #if QT_CONFIG(opengl) //Software renderer doesn't have context frames - foreach (const QQmlProfilerData &msg, m_client->asynchronousMessages) { - if (msg.messageType == QQmlProfilerDefinitions::SceneGraphFrame) { - if (msg.detailType == QQmlProfilerDefinitions::SceneGraphContextFrame) { - contextFrameTime = msg.time; - break; + if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)) { + foreach (const QQmlProfilerData &msg, m_client->asynchronousMessages) { + if (msg.messageType == QQmlProfilerDefinitions::SceneGraphFrame) { + if (msg.detailType == QQmlProfilerDefinitions::SceneGraphContextFrame) { + contextFrameTime = msg.time; + break; + } } } - } - QVERIFY(contextFrameTime != -1); + QVERIFY(contextFrameTime != -1); + } #endif foreach (const QQmlProfilerData &msg, m_client->asynchronousMessages) { if (msg.detailType == QQmlProfilerDefinitions::SceneGraphRendererFrame) { diff --git a/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp b/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp index fd74135727..9da4a63ce6 100644 --- a/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp +++ b/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp @@ -38,7 +38,6 @@ #include <private/qv4debugging_p.h> #include <private/qv8engine_p.h> #include <private/qv4objectiterator_p.h> -#include <private/qv4isel_moth_p.h> #include <private/qv4string_p.h> #include <private/qqmlbuiltinfunctions_p.h> #include <private/qqmldebugservice_p.h> @@ -46,7 +45,7 @@ using namespace QV4; using namespace QV4::Debugging; -typedef void (*InjectedFunction)(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData); +typedef QV4::ReturnedValue (*InjectedFunction)(const QV4::BuiltinFunction *, QV4::CallData *callData); Q_DECLARE_METATYPE(InjectedFunction) static bool waitForSignal(QObject* obj, const char* signal, int timeout = 10000) @@ -343,7 +342,6 @@ void tst_qv4debugger::init() m_javaScriptThread = new QThread; m_engine = new TestEngine; m_v4 = m_engine->v4Engine(); - m_v4->iselFactory.reset(new QV4::Moth::ISelFactory); m_v4->setDebugger(new QV4Debugger(m_v4)); m_engine->moveToThread(m_javaScriptThread); m_javaScriptThread->start(); @@ -438,9 +436,9 @@ void tst_qv4debugger::addBreakPointWhilePaused() QCOMPARE(state.lineNumber, 2); } -static void someCall(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *) +static QV4::ReturnedValue someCall(const QV4::BuiltinFunction *function, QV4::CallData *) { - static_cast<QV4Debugger *>(scope.engine->debugger()) + static_cast<QV4Debugger *>(function->engine()->debugger()) ->removeBreakPoint("removeBreakPointForNextInstruction", 2); RETURN_UNDEFINED(); } @@ -464,7 +462,7 @@ void tst_qv4debugger::conditionalBreakPoint() { m_debuggerAgent->m_captureContextInfo = true; QString script = - "function test() {\n" + "var test = function() {\n" " for (var i = 0; i < 15; ++i) {\n" " var x = i;\n" " }\n" @@ -491,7 +489,6 @@ void tst_qv4debugger::conditionalBreakPointInQml() QQmlEngine engine; QV4::ExecutionEngine *v4 = QV8Engine::getV4(&engine); QV4Debugger *v4Debugger = new QV4Debugger(v4); - v4->iselFactory.reset(new QV4::Moth::ISelFactory); v4->setDebugger(v4Debugger); QScopedPointer<QThread> debugThread(new QThread); @@ -531,7 +528,7 @@ void tst_qv4debugger::readArguments() m_debuggerAgent->m_captureContextInfo = true; QString script = - "function f(a, b, c, d) {\n" + "var f = function(a, b, c, d) {\n" " return a === b\n" "}\n" "var four;\n" @@ -557,7 +554,7 @@ void tst_qv4debugger::readLocals() m_debuggerAgent->m_captureContextInfo = true; QString script = - "function f(a, b) {\n" + "var f = function(a, b) {\n" " var c = a + b\n" " var d = a - b\n" // breakpoint, c should be set, d should be undefined " return c === d\n" @@ -583,7 +580,7 @@ void tst_qv4debugger::readObject() m_debuggerAgent->m_captureContextInfo = true; QString script = - "function f(a) {\n" + "var f = function(a) {\n" " var b = a\n" " return b\n" "}\n" @@ -641,7 +638,7 @@ void tst_qv4debugger::readContextInAllFrames() m_debuggerAgent->m_captureContextInfo = true; QString script = - "function fact(n) {\n" + "var fact = function(n) {\n" " if (n > 1) {\n" " var n_1 = n - 1;\n" " n_1 = fact(n_1);\n" @@ -814,13 +811,13 @@ void tst_qv4debugger::lastLineOfConditional_data() QTest::newRow("do..while {block}") << "do {\n" << "} while (ret < 10);" << 4 << 7; QTest::newRow("if true {block}") << "if (true) {\n" << "}" - << 4 << 7; + << 4 << 8; QTest::newRow("if false {block}") << "if (false) {\n" << "}" << 2 << 8; QTest::newRow("if true else {block}") << "if (true) {\n" << "} else {\n ret += 8;\n}" - << 4 << 7; + << 4 << 10; QTest::newRow("if false else {block}") << "if (false) {\n" << "} else {\n ret += 8;\n}" - << 8 << 9; + << 8 << 10; QTest::newRow("for statement") << "for (var i = 0; i < 10; ++i)\n" << "" << 4 << 2; QTest::newRow("for..in statement") << "for (var i in [0, 1, 2, 3, 4])\n" << "" << 4 << 2; @@ -829,11 +826,11 @@ void tst_qv4debugger::lastLineOfConditional_data() // For two nested if statements without blocks, we need to map the jump from the inner to the // outer one on the outer "if". There is just no better place. - QTest::newRow("if true statement") << "if (true)\n" << "" << 4 << 2; + QTest::newRow("if true statement") << "if (true)\n" << "" << 4 << 8; QTest::newRow("if false statement") << "if (false)\n" << "" << 2 << 8; // Also two nested ifs without blocks. - QTest::newRow("if true else statement") << "if (true)\n" << "else\n ret += 8;" << 4 << 2; + QTest::newRow("if true else statement") << "if (true)\n" << "else\n ret += 8;" << 4 << 9; QTest::newRow("if false else statement") << "if (false)\n" << "else\n ret += 8;" << 8 << 9; } diff --git a/tests/auto/qml/debugger/shared/debugutil.cpp b/tests/auto/qml/debugger/shared/debugutil.cpp index 40e51f3a05..8ecbe53822 100644 --- a/tests/auto/qml/debugger/shared/debugutil.cpp +++ b/tests/auto/qml/debugger/shared/debugutil.cpp @@ -27,13 +27,14 @@ ****************************************************************************/ #include "debugutil_p.h" +#include "qqmldebugprocess_p.h" #include <private/qqmldebugconnection_p.h> +#include <QtQml/qqmldebug.h> + #include <QtCore/qeventloop.h> #include <QtCore/qtimer.h> -#include <QtCore/qfileinfo.h> -#include <QtCore/qdir.h> bool QQmlDebugTest::waitForSignal(QObject *receiver, const char *member, int timeout) { QEventLoop loop; @@ -116,196 +117,6 @@ void QQmlDebugTestClient::messageReceived(const QByteArray &ba) emit serverMessage(ba); } -QQmlDebugProcess::QQmlDebugProcess(const QString &executable, QObject *parent) - : QObject(parent) - , m_executable(executable) - , m_started(false) - , m_port(0) - , m_maximumBindErrors(0) - , m_receivedBindErrors(0) -{ - m_process.setProcessChannelMode(QProcess::MergedChannels); - m_timer.setSingleShot(true); - m_timer.setInterval(15000); - connect(&m_process, SIGNAL(readyReadStandardOutput()), this, SLOT(processAppOutput())); - connect(&m_process, SIGNAL(errorOccurred(QProcess::ProcessError)), - this, SLOT(processError(QProcess::ProcessError))); - connect(&m_timer, SIGNAL(timeout()), SLOT(timeout())); -} - -QQmlDebugProcess::~QQmlDebugProcess() -{ - stop(); -} - -QString QQmlDebugProcess::state() -{ - QString stateStr; - switch (m_process.state()) { - case QProcess::NotRunning: { - stateStr = "not running"; - if (m_process.exitStatus() == QProcess::CrashExit) - stateStr += " (crashed!)"; - else - stateStr += ", return value " + QString::number(m_process.exitCode()); - break; - } - case QProcess::Starting: stateStr = "starting"; break; - case QProcess::Running: stateStr = "running"; break; - } - return stateStr; -} - -void QQmlDebugProcess::start(const QStringList &arguments) -{ -#ifdef Q_OS_MAC - // make sure m_executable points to the actual binary even if it's inside an app bundle - QFileInfo binFile(m_executable); - if (!binFile.isExecutable()) { - QDir bundleDir(m_executable + ".app"); - if (bundleDir.exists()) { - m_executable = bundleDir.absoluteFilePath("Contents/MacOS/" + binFile.baseName()); - //qDebug() << Q_FUNC_INFO << "found bundled binary" << m_executable; - } - } -#endif - m_mutex.lock(); - m_port = 0; - m_process.setEnvironment(QProcess::systemEnvironment() + m_environment); - m_process.start(m_executable, arguments); - if (!m_process.waitForStarted()) { - qWarning() << "QML Debug Client: Could not launch app " << m_executable - << ": " << m_process.errorString(); - m_eventLoop.quit(); - } else { - m_timer.start(); - } - m_mutex.unlock(); -} - -void QQmlDebugProcess::stop() -{ - if (m_process.state() != QProcess::NotRunning) { - m_process.kill(); - m_process.waitForFinished(5000); - } -} - -void QQmlDebugProcess::setMaximumBindErrors(int ignore) -{ - m_maximumBindErrors = ignore; -} - -void QQmlDebugProcess::timeout() -{ - qWarning() << "Timeout while waiting for QML debugging messages " - "in application output. Process is in state" << m_process.state() << ", Output:" << m_output << "."; - m_eventLoop.quit(); -} - -bool QQmlDebugProcess::waitForSessionStart() -{ - if (m_process.state() != QProcess::Running) { - qWarning() << "Could not start up " << m_executable; - return false; - } else if (m_started) { - return true; - } - - m_eventLoop.exec(); - - return m_started; -} - -int QQmlDebugProcess::debugPort() const -{ - return m_port; -} - -bool QQmlDebugProcess::waitForFinished() -{ - return m_process.waitForFinished(); -} - -QProcess::ExitStatus QQmlDebugProcess::exitStatus() const -{ - return m_process.exitStatus(); -} - -void QQmlDebugProcess::addEnvironment(const QString &environment) -{ - m_environment.append(environment); -} - -QString QQmlDebugProcess::output() const -{ - return m_output; -} - -void QQmlDebugProcess::processAppOutput() -{ - m_mutex.lock(); - - bool outputFromAppItself = false; - - QString newOutput = m_process.readAll(); - m_output.append(newOutput); - m_outputBuffer.append(newOutput); - - while (true) { - const int nlIndex = m_outputBuffer.indexOf(QLatin1Char('\n')); - if (nlIndex < 0) // no further complete lines - break; - const QString line = m_outputBuffer.left(nlIndex); - m_outputBuffer = m_outputBuffer.right(m_outputBuffer.size() - nlIndex - 1); - - if (line.contains("QML Debugger:")) { - const QRegExp portRx("Waiting for connection on port (\\d+)"); - if (portRx.indexIn(line) != -1) { - m_port = portRx.cap(1).toInt(); - m_timer.stop(); - m_started = true; - m_eventLoop.quit(); - continue; - } - if (line.contains("Unable to listen")) { - if (++m_receivedBindErrors >= m_maximumBindErrors) { - if (m_maximumBindErrors == 0) - qWarning() << "App was unable to bind to port!"; - m_timer.stop(); - m_eventLoop.quit(); - } - continue; - } - } else { - // set to true if there is output not coming from the debugger - outputFromAppItself = true; - } - } - m_mutex.unlock(); - - if (outputFromAppItself) - emit readyReadStandardOutput(); -} - -void QQmlDebugProcess::processError(QProcess::ProcessError error) -{ - if (!m_eventLoop.isRunning()) - return; - - qDebug() << "An error occurred while waiting for debug process to become available:"; - switch (error) { - case QProcess::FailedToStart: qDebug() << "Process failed to start."; break; - case QProcess::Crashed: qDebug() << "Process crashed."; break; - case QProcess::Timedout: qDebug() << "Process timed out."; break; - case QProcess::WriteError: qDebug() << "Error while writing to process."; break; - case QProcess::ReadError: qDebug() << "Error while reading from process."; break; - case QProcess::UnknownError: qDebug() << "Unknown process error."; break; - } - - m_eventLoop.exit(); -} - template<typename F> struct Finalizer { F m_lambda; diff --git a/tests/auto/qml/debugger/shared/debugutil.pri b/tests/auto/qml/debugger/shared/debugutil.pri index 44e8e0f999..13dcdb91d8 100644 --- a/tests/auto/qml/debugger/shared/debugutil.pri +++ b/tests/auto/qml/debugger/shared/debugutil.pri @@ -3,5 +3,9 @@ QT += qmldebug-private INCLUDEPATH += $$PWD include($$PWD/../../../shared/util.pri) -HEADERS += $$PWD/debugutil_p.h -SOURCES += $$PWD/debugutil.cpp +HEADERS += \ + $$PWD/debugutil_p.h \ + $$PWD/qqmldebugprocess_p.h +SOURCES += \ + $$PWD/debugutil.cpp \ + $$PWD/qqmldebugprocess.cpp diff --git a/tests/auto/qml/debugger/shared/debugutil_p.h b/tests/auto/qml/debugger/shared/debugutil_p.h index f1b25d5f6d..94ad83bfce 100644 --- a/tests/auto/qml/debugger/shared/debugutil_p.h +++ b/tests/auto/qml/debugger/shared/debugutil_p.h @@ -1,4 +1,3 @@ - /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. @@ -44,14 +43,6 @@ #include <../../../shared/util.h> #include <private/qqmldebugclient_p.h> -#include <QtCore/qeventloop.h> -#include <QtCore/qtimer.h> -#include <QtCore/qthread.h> -#include <QtCore/qprocess.h> -#include <QtCore/qmutex.h> -#include <QtTest/qtest.h> -#include <QtQml/qqmlengine.h> - class QQmlDebugProcess; class QQmlDebugTest : public QQmlDataTest { @@ -108,51 +99,6 @@ private: QByteArray lastMsg; }; -class QQmlDebugProcess : public QObject -{ - Q_OBJECT -public: - QQmlDebugProcess(const QString &executable, QObject *parent = 0); - ~QQmlDebugProcess(); - - QString state(); - - void addEnvironment(const QString &environment); - - void start(const QStringList &arguments); - bool waitForSessionStart(); - int debugPort() const; - - bool waitForFinished(); - QProcess::ExitStatus exitStatus() const; - - QString output() const; - void stop(); - void setMaximumBindErrors(int numErrors); - -signals: - void readyReadStandardOutput(); - -private slots: - void timeout(); - void processAppOutput(); - void processError(QProcess::ProcessError error); - -private: - QString m_executable; - QProcess m_process; - QString m_outputBuffer; - QString m_output; - QTimer m_timer; - QEventLoop m_eventLoop; - QMutex m_mutex; - bool m_started; - QStringList m_environment; - int m_port; - int m_maximumBindErrors; - int m_receivedBindErrors; -}; - class QQmlInspectorResultRecipient : public QObject { Q_OBJECT diff --git a/tests/auto/qml/debugger/shared/qqmldebugprocess.cpp b/tests/auto/qml/debugger/shared/qqmldebugprocess.cpp new file mode 100644 index 0000000000..816fec6a2f --- /dev/null +++ b/tests/auto/qml/debugger/shared/qqmldebugprocess.cpp @@ -0,0 +1,245 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmldebugprocess_p.h" + +#include <QtCore/qdebug.h> +#include <QtCore/qfileinfo.h> +#include <QtCore/qdir.h> + +QQmlDebugProcess::QQmlDebugProcess(const QString &executable, QObject *parent) + : QObject(parent) + , m_executable(executable) + , m_state(SessionUnknown) + , m_port(0) + , m_maximumBindErrors(0) + , m_receivedBindErrors(0) +{ + m_process.setProcessChannelMode(QProcess::MergedChannels); + m_timer.setSingleShot(true); + m_timer.setInterval(15000); + connect(&m_process, &QProcess::readyReadStandardOutput, + this, &QQmlDebugProcess::processAppOutput); + connect(&m_process, &QProcess::errorOccurred, + this, &QQmlDebugProcess::processError); + connect(&m_process, static_cast<void(QProcess::*)(int)>(&QProcess::finished), + this, [this]() { + m_timer.stop(); + m_eventLoop.quit(); + }); + connect(&m_timer, &QTimer::timeout, + this, &QQmlDebugProcess::timeout); +} + +QQmlDebugProcess::~QQmlDebugProcess() +{ + stop(); +} + +QString QQmlDebugProcess::state() +{ + QString stateStr; + switch (m_process.state()) { + case QProcess::NotRunning: { + stateStr = "not running"; + if (m_process.exitStatus() == QProcess::CrashExit) + stateStr += " (crashed!)"; + else + stateStr += ", return value " + QString::number(m_process.exitCode()); + break; + } + case QProcess::Starting: + stateStr = "starting"; + break; + case QProcess::Running: + stateStr = "running"; + break; + } + return stateStr; +} + +void QQmlDebugProcess::start(const QStringList &arguments) +{ +#ifdef Q_OS_MAC + // make sure m_executable points to the actual binary even if it's inside an app bundle + QFileInfo binFile(m_executable); + if (!binFile.isExecutable()) { + QDir bundleDir(m_executable + ".app"); + if (bundleDir.exists()) { + m_executable = bundleDir.absoluteFilePath("Contents/MacOS/" + binFile.baseName()); + //qDebug() << Q_FUNC_INFO << "found bundled binary" << m_executable; + } + } +#endif + m_mutex.lock(); + m_port = 0; + m_process.setEnvironment(QProcess::systemEnvironment() + m_environment); + m_process.start(m_executable, arguments); + if (!m_process.waitForStarted()) { + qWarning() << "QML Debug Client: Could not launch app " << m_executable + << ": " << m_process.errorString(); + m_eventLoop.quit(); + } + m_mutex.unlock(); +} + +void QQmlDebugProcess::stop() +{ + if (m_process.state() != QProcess::NotRunning) { + disconnect(&m_process, &QProcess::errorOccurred, this, &QQmlDebugProcess::processError); + m_process.kill(); + m_process.waitForFinished(5000); + } +} + +void QQmlDebugProcess::setMaximumBindErrors(int ignore) +{ + m_maximumBindErrors = ignore; +} + +void QQmlDebugProcess::timeout() +{ + qWarning() << "Timeout while waiting for QML debugging messages " + "in application output. Process is in state" << m_process.state() + << ", Output:" << m_output << "."; + m_eventLoop.quit(); +} + +bool QQmlDebugProcess::waitForSessionStart() +{ + if (m_process.state() != QProcess::Running) { + qWarning() << "Could not start up " << m_executable; + return false; + } else if (m_state == SessionStarted) { + return true; + } else if (m_state == SessionFailed) { + return false; + } + + m_timer.start(); + m_eventLoop.exec(); + + return m_state == SessionStarted; +} + +int QQmlDebugProcess::debugPort() const +{ + return m_port; +} + +bool QQmlDebugProcess::waitForFinished() +{ + return m_process.waitForFinished(); +} + +QProcess::ExitStatus QQmlDebugProcess::exitStatus() const +{ + return m_process.exitStatus(); +} + +void QQmlDebugProcess::addEnvironment(const QString &environment) +{ + m_environment.append(environment); +} + +QString QQmlDebugProcess::output() const +{ + return m_output; +} + +void QQmlDebugProcess::processAppOutput() +{ + m_mutex.lock(); + + bool outputFromAppItself = false; + + QString newOutput = m_process.readAll(); + m_output.append(newOutput); + m_outputBuffer.append(newOutput); + + while (true) { + const int nlIndex = m_outputBuffer.indexOf(QLatin1Char('\n')); + if (nlIndex < 0) // no further complete lines + break; + const QString line = m_outputBuffer.left(nlIndex); + m_outputBuffer = m_outputBuffer.right(m_outputBuffer.size() - nlIndex - 1); + + if (line.contains("QML Debugger:")) { + const QRegExp portRx("Waiting for connection on port (\\d+)"); + if (portRx.indexIn(line) != -1) { + m_port = portRx.cap(1).toInt(); + m_timer.stop(); + m_state = SessionStarted; + m_eventLoop.quit(); + continue; + } + if (line.contains("Unable to listen")) { + if (++m_receivedBindErrors >= m_maximumBindErrors) { + if (m_maximumBindErrors == 0) + qWarning() << "App was unable to bind to port!"; + m_timer.stop(); + m_state = SessionFailed; + m_eventLoop.quit(); + } + continue; + } + } + + // set to true if there is output not coming from the debugger or we don't understand it + outputFromAppItself = true; + } + m_mutex.unlock(); + + if (outputFromAppItself) + emit readyReadStandardOutput(); +} + +void QQmlDebugProcess::processError(QProcess::ProcessError error) +{ + qDebug() << "An error occurred while waiting for debug process to become available:"; + switch (error) { + case QProcess::FailedToStart: + qDebug() << "Process failed to start."; + break; + case QProcess::Crashed: + qDebug() << "Process crashed."; + break; + case QProcess::Timedout: + qDebug() << "Process timed out."; + break; + case QProcess::WriteError: + qDebug() << "Error while writing to process."; + break; + case QProcess::ReadError: + qDebug() << "Error while reading from process."; + break; + case QProcess::UnknownError: + qDebug() << "Unknown process error."; + break; + } +} diff --git a/tests/auto/qml/debugger/shared/qqmldebugprocess_p.h b/tests/auto/qml/debugger/shared/qqmldebugprocess_p.h new file mode 100644 index 0000000000..fd2c89bb41 --- /dev/null +++ b/tests/auto/qml/debugger/shared/qqmldebugprocess_p.h @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLDEBUGPROCESS_P_H +#define QQMLDEBUGPROCESS_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 <QtCore/qprocess.h> +#include <QtCore/qtimer.h> +#include <QtCore/qeventloop.h> +#include <QtCore/qmutex.h> + +class QQmlDebugProcess : public QObject +{ + Q_OBJECT +public: + QQmlDebugProcess(const QString &executable, QObject *parent = 0); + ~QQmlDebugProcess(); + + QString state(); + + void addEnvironment(const QString &environment); + + void start(const QStringList &arguments); + bool waitForSessionStart(); + int debugPort() const; + + bool waitForFinished(); + QProcess::ExitStatus exitStatus() const; + + QString output() const; + void stop(); + void setMaximumBindErrors(int numErrors); + +signals: + void readyReadStandardOutput(); + +private slots: + void timeout(); + void processAppOutput(); + void processError(QProcess::ProcessError error); + +private: + enum SessionState { + SessionUnknown, + SessionStarted, + SessionFailed + }; + + QString m_executable; + QProcess m_process; + QString m_outputBuffer; + QString m_output; + QTimer m_timer; + QEventLoop m_eventLoop; + QMutex m_mutex; + SessionState m_state; + QStringList m_environment; + int m_port; + int m_maximumBindErrors; + int m_receivedBindErrors; +}; + +#endif // QQMLDEBUGPROCESS_P_H diff --git a/tests/auto/qml/ecmascripttests/TestExpectations b/tests/auto/qml/ecmascripttests/TestExpectations index 27498de473..589f25d174 100644 --- a/tests/auto/qml/ecmascripttests/TestExpectations +++ b/tests/auto/qml/ecmascripttests/TestExpectations @@ -15,7 +15,6 @@ S15.1.2.3_A2_T10 15.5.4.20-3-5 15.5.4.20-3-6 -10.4.3-1-106 failing 11.2.3-3_3 failing S13_A15_T4 failing S15.4.4.3_A1_T1 failing diff --git a/tests/auto/qml/ecmascripttests/test262 b/tests/auto/qml/ecmascripttests/test262 -Subproject fe58b18c13d1ea5d42951e5b698efc3bfab6dc8 +Subproject d60c4ed97e69639bc5bc1db43a98828debf80c8 diff --git a/tests/auto/qml/ecmascripttests/test262.py b/tests/auto/qml/ecmascripttests/test262.py index 437cd1b27d..ae4c54df9d 100755 --- a/tests/auto/qml/ecmascripttests/test262.py +++ b/tests/auto/qml/ecmascripttests/test262.py @@ -552,10 +552,10 @@ class TestSuite(object): def Main(): - # Some date tests rely on being run in pacific time. # Uncomment the next line for more logging info. #logging.basicConfig(level=logging.DEBUG) - os.environ["TZ"] = "PST8PDT" + # Some date tests rely on being run in pacific time and the USA's locale: + os.environ["TZ"] = "America/Vancouver" os.environ["LANG"] = "en_US.UTF-8" os.environ["LC_TIME"] = "en_US.UTF-8" parser = BuildOptions() diff --git a/tests/auto/qml/ecmascripttests/tst_ecmascripttests.cpp b/tests/auto/qml/ecmascripttests/tst_ecmascripttests.cpp index 880e254543..0d58d045b9 100644 --- a/tests/auto/qml/ecmascripttests/tst_ecmascripttests.cpp +++ b/tests/auto/qml/ecmascripttests/tst_ecmascripttests.cpp @@ -34,29 +34,29 @@ class tst_EcmaScriptTests : public QObject { Q_OBJECT -private slots: - void runTests_data(); - void runTests(); -}; -void tst_EcmaScriptTests::runTests_data() -{ - QTest::addColumn<QString>("qmljsParameter"); + void runTests(bool interpret); - QTest::newRow("jit") << QStringLiteral("--jit"); - QTest::newRow("interpreter") << QStringLiteral("--interpret"); -} +private slots: + void runInterpreted(); + void runJitted(); +}; -void tst_EcmaScriptTests::runTests() +void tst_EcmaScriptTests::runTests(bool interpret) { #if defined(Q_OS_LINUX) && defined(Q_PROCESSOR_X86_64) - QFETCH(QString, qmljsParameter); + QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); + if (interpret) + env.insert("QV4_FORCE_INTERPRETER", "1"); + else + env.insert("QV4_JIT_CALL_THRESHOLD", "0"); QProcess process; process.setProcessChannelMode(QProcess::ForwardedChannels); process.setWorkingDirectory(QLatin1String(SRCDIR)); process.setProgram("python"); - process.setArguments(QStringList() << "test262.py" << "--command=" + QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmljs " + qmljsParameter << "--parallel" << "--with-test-expectations"); + process.setProcessEnvironment(env); + process.setArguments(QStringList() << "test262.py" << "--command=" + QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmljs" << "--parallel" << "--with-test-expectations"); qDebug() << "Going to run" << process.program() << process.arguments() << "in" << process.workingDirectory(); @@ -71,6 +71,16 @@ void tst_EcmaScriptTests::runTests() #endif } +void tst_EcmaScriptTests::runInterpreted() +{ + runTests(true); +} + +void tst_EcmaScriptTests::runJitted() +{ + runTests(false); +} + QTEST_GUILESS_MAIN(tst_EcmaScriptTests) #include "tst_ecmascripttests.moc" diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp index 446f9b04a7..519c57efb2 100644 --- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp @@ -201,6 +201,8 @@ private slots: void malformedExpression(); + void scriptScopes(); + signals: void testSignal(); }; @@ -4118,6 +4120,22 @@ void tst_QJSEngine::malformedExpression() engine.evaluate("5%55555&&5555555\n7-0"); } +void tst_QJSEngine::scriptScopes() +{ + QJSEngine engine; + + QJSValue def = engine.evaluate("'use strict'; function foo() { return 42 }"); + QVERIFY(!def.isError()); + QJSValue globalObject = engine.globalObject(); + QJSValue foo = globalObject.property("foo"); + QVERIFY(foo.isObject()); + QVERIFY(foo.isCallable()); + + QJSValue use = engine.evaluate("'use strict'; foo()"); + QVERIFY(use.isNumber()); + QCOMPARE(use.toInt(), 42); +} + QTEST_MAIN(tst_QJSEngine) #include "tst_qjsengine.moc" diff --git a/tests/auto/qml/qml.pro b/tests/auto/qml/qml.pro index 69af3cd13b..8471d6466f 100644 --- a/tests/auto/qml/qml.pro +++ b/tests/auto/qml/qml.pro @@ -1,4 +1,5 @@ TEMPLATE = subdirs +QT_FOR_CONFIG += qml METATYPETESTS += \ qqmlmetatype @@ -9,7 +10,6 @@ PUBLICTESTS += \ qjsonbinding \ qqmlfile \ -!boot2qt { PUBLICTESTS += \ qmlmin \ qqmlcomponent \ @@ -31,15 +31,12 @@ PUBLICTESTS += \ qqmlsettings \ qqmlstatemachine \ qmldiskcache -} PRIVATETESTS += \ qqmlcpputils \ qqmldirparser \ - v4misc \ qmlcachegen -!boot2qt { PRIVATETESTS += \ animation \ qqmlecmascript \ @@ -74,19 +71,21 @@ PRIVATETESTS += \ qv4mm \ ecmascripttests \ bindingdependencyapi -} qtHaveModule(widgets) { PUBLICTESTS += \ qjsengine \ - qjsvalue + qjsvalue \ +# qwidgetsinqml } SUBDIRS += $$PUBLICTESTS SUBDIRS += $$METATYPETESTS -qtConfig(process):!boot2qt { - !contains(QT_CONFIG, no-qml-debug): SUBDIRS += debugger - SUBDIRS += qmllint qmlplugindump +qtConfig(process) { + qtConfig(qml-debug): SUBDIRS += debugger + !boot2qt { + SUBDIRS += qmllint qmlplugindump + } } qtConfig(library) { diff --git a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp index e75e51ed29..cdc9f29aab 100644 --- a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp +++ b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp @@ -30,10 +30,9 @@ #include <private/qv4compileddata_p.h> #include <private/qv4compiler_p.h> -#include <private/qv4jsir_p.h> -#include <private/qv4isel_p.h> #include <private/qv8engine_p.h> #include <private/qv4engine_p.h> +#include <private/qv4codegen_p.h> #include <QQmlComponent> #include <QQmlEngine> #include <QQmlFileSelector> @@ -174,9 +173,8 @@ struct TestCompiler bool verify() { - QV4::ExecutionEngine *v4 = QV8Engine::getV4(engine); - QQmlRefPointer<QV4::CompiledData::CompilationUnit> unit = v4->iselFactory->createUnitForLoading(); - return unit->loadFromDisk(QUrl::fromLocalFile(testFilePath), QFileInfo(testFilePath).lastModified(), v4->iselFactory.data(), &lastErrorString); + QQmlRefPointer<QV4::CompiledData::CompilationUnit> unit = QV4::Compiler::Codegen::createUnitForLoading(); + return unit->loadFromDisk(QUrl::fromLocalFile(testFilePath), QFileInfo(testFilePath).lastModified(), &lastErrorString); } void closeMapping() @@ -231,12 +229,14 @@ void tst_qmldiskcache::regenerateAfterChange() const QV4::CompiledData::Object *obj = testUnit->objectAt(0); QCOMPARE(quint32(obj->nBindings), quint32(1)); QCOMPARE(quint32(obj->bindingTable()->type), quint32(QV4::CompiledData::Binding::Type_Script)); - QCOMPARE(quint32(obj->bindingTable()->value.compiledScriptIndex), quint32(1)); + QCOMPARE(quint32(obj->bindingTable()->value.compiledScriptIndex), quint32(0)); - QCOMPARE(quint32(testUnit->functionTableSize), quint32(2)); + QCOMPARE(quint32(testUnit->functionTableSize), quint32(1)); - const QV4::CompiledData::Function *bindingFunction = testUnit->functionAt(1); - QVERIFY(bindingFunction->codeOffset > testUnit->unitSize); + const QV4::CompiledData::Function *bindingFunction = testUnit->functionAt(0); + QCOMPARE(testUnit->stringAt(bindingFunction->nameIndex), QString("expression for blah")); // check if we have the correct function + QVERIFY(bindingFunction->codeSize > 0); + QVERIFY(bindingFunction->codeOffset < testUnit->unitSize); } { @@ -257,10 +257,12 @@ void tst_qmldiskcache::regenerateAfterChange() QCOMPARE(quint32(obj->bindingTable()->type), quint32(QV4::CompiledData::Binding::Type_Number)); QCOMPARE(obj->bindingTable()->valueAsNumber(), double(42)); - QCOMPARE(quint32(testUnit->functionTableSize), quint32(2)); + QCOMPARE(quint32(testUnit->functionTableSize), quint32(1)); - const QV4::CompiledData::Function *bindingFunction = testUnit->functionAt(1); - QVERIFY(bindingFunction->codeOffset > testUnit->unitSize); + const QV4::CompiledData::Function *bindingFunction = testUnit->functionAt(0); + QCOMPARE(testUnit->stringAt(bindingFunction->nameIndex), QString("expression for blah")); // check if we have the correct function + QVERIFY(bindingFunction->codeSize > 0); + QVERIFY(bindingFunction->codeOffset < testUnit->unitSize); } } @@ -364,7 +366,7 @@ void tst_qmldiskcache::basicVersionChecks() }); QVERIFY(!testCompiler.verify()); - QCOMPARE(testCompiler.lastErrorString, QString::fromUtf8("Code generator mismatch. Found code generated by but expected %1").arg(QV8Engine::getV4(&engine)->iselFactory->codeGeneratorName)); + QCOMPARE(testCompiler.lastErrorString, QString::fromUtf8("Code generator mismatch. Found code generated by but expected %1").arg(QStringLiteral("moth"))); } } diff --git a/tests/auto/qml/qmlmin/qmlmin.pro b/tests/auto/qml/qmlmin/qmlmin.pro index 6af6653270..93e5caabcf 100644 --- a/tests/auto/qml/qmlmin/qmlmin.pro +++ b/tests/auto/qml/qmlmin/qmlmin.pro @@ -6,5 +6,7 @@ macx:CONFIG -= app_bundle SOURCES += tst_qmlmin.cpp DEFINES += SRCDIR=\\\"$$PWD\\\" - -cross_compile: DEFINES += QTEST_CROSS_COMPILED +# Boot2qt is cross compiled but it has sources available +!boot2qt { + cross_compile: DEFINES += QTEST_CROSS_COMPILED +} diff --git a/tests/auto/qml/qmlplugindump/tests/dumper/CompositeSingleton/Singleton.qml b/tests/auto/qml/qmlplugindump/data/dumper/CompositeSingleton/Singleton.qml index b47d2e98f4..b47d2e98f4 100644 --- a/tests/auto/qml/qmlplugindump/tests/dumper/CompositeSingleton/Singleton.qml +++ b/tests/auto/qml/qmlplugindump/data/dumper/CompositeSingleton/Singleton.qml diff --git a/tests/auto/qml/qmlplugindump/tests/dumper/CompositeSingleton/qmldir b/tests/auto/qml/qmlplugindump/data/dumper/CompositeSingleton/qmldir index 8df57f6d47..8df57f6d47 100644 --- a/tests/auto/qml/qmlplugindump/tests/dumper/CompositeSingleton/qmldir +++ b/tests/auto/qml/qmlplugindump/data/dumper/CompositeSingleton/qmldir diff --git a/tests/auto/qml/qmlplugindump/qmlplugindump.pro b/tests/auto/qml/qmlplugindump/qmlplugindump.pro index c713edc541..76f3fe2299 100644 --- a/tests/auto/qml/qmlplugindump/qmlplugindump.pro +++ b/tests/auto/qml/qmlplugindump/qmlplugindump.pro @@ -1,6 +1,8 @@ CONFIG += testcase TARGET = tst_qmlplugindump -QT += testlib gui-private +QT += testlib gui-private qml macx:CONFIG -= app_bundle +include(../../shared/util.pri) + SOURCES += tst_qmlplugindump.cpp diff --git a/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp b/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp index 68e11e3551..6915e789c6 100644 --- a/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp +++ b/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp @@ -26,6 +26,8 @@ ** ****************************************************************************/ +#include "util.h" + #include <qtest.h> #include <QLibraryInfo> #include <QDir> @@ -33,7 +35,7 @@ #include <QDebug> #include <cstdlib> -class tst_qmlplugindump : public QObject +class tst_qmlplugindump : public QQmlDataTest { Q_OBJECT public: @@ -54,6 +56,7 @@ tst_qmlplugindump::tst_qmlplugindump() void tst_qmlplugindump::initTestCase() { + QQmlDataTest::initTestCase(); qmlplugindumpPath = QLibraryInfo::location(QLibraryInfo::BinariesPath); #if defined(Q_OS_WIN) @@ -102,8 +105,8 @@ void tst_qmlplugindump::singleton() { QProcess dumper; QStringList args; - args << QLatin1String("tests.dumper.CompositeSingleton") << QLatin1String("1.0") - << QLatin1String("."); + args << QLatin1String("dumper.CompositeSingleton") << QLatin1String("1.0") + << testFile("."); dumper.start(qmlplugindumpPath, args); QVERIFY2(dumper.waitForStarted(), qPrintable(dumper.errorString())); QVERIFY2(dumper.waitForFinished(), qPrintable(dumper.errorString())); diff --git a/tests/auto/qml/qqmlecmascript/data/assignDate.1.qml b/tests/auto/qml/qqmlecmascript/data/assignDate.1.qml index efca6cdb80..8912d2a314 100644 --- a/tests/auto/qml/qqmlecmascript/data/assignDate.1.qml +++ b/tests/auto/qml/qqmlecmascript/data/assignDate.1.qml @@ -11,25 +11,26 @@ MyTypeObject { dateTimeProperty = dateTimeVar dateTimeProperty2 = dateTimeVar2 - // Commented properties do not currently test true: - boolProperty = //(dateProperty.getTime() == dateVar.getTime()) && + boolProperty = (dateProperty.getTime() == dateVar.getTime()) && (dateProperty.getFullYear() == 2009) && (dateProperty.getMonth() == 5-1) && - //(dateProperty.getDate() == 12) && - (dateProperty.getHours() == 0) && + (dateProperty.getUTCDate() == 12) && + (dateProperty.getUTCHours() == 0) && + (dateProperty.getUTCMinutes() == 0) && + (dateProperty.getUTCSeconds() == 0) && (dateTimeProperty.getTime() == dateTimeVar.getTime()) && (dateTimeProperty.getFullYear() == 2009) && (dateTimeProperty.getMonth() == 5-1) && - //(dateTimeProperty.getDate() == 12) && - //(dateTimeProperty.getHours() == 0) && - (dateTimeProperty.getMinutes() == 0) && - (dateTimeProperty.getSeconds() == 1) && + (dateTimeProperty.getUTCDate() == 12) && + (dateTimeProperty.getUTCHours() == 0) && + (dateTimeProperty.getUTCMinutes() == 0) && + (dateTimeProperty.getUTCSeconds() == 1) && (dateTimeProperty2.getTime() == dateTimeVar2.getTime()) && (dateTimeProperty2.getFullYear() == 2009) && (dateTimeProperty2.getMonth() == 5-1) && - //(dateTimeProperty2.getDate() == 12) && - //(dateTimeProperty2.getHours() == 23) && - (dateTimeProperty2.getMinutes() == 59) && - (dateTimeProperty2.getSeconds() == 59) + (dateTimeProperty2.getUTCDate() == 12) && + (dateTimeProperty2.getUTCHours() == 23) && + (dateTimeProperty2.getUTCMinutes() == 59) && + (dateTimeProperty2.getUTCSeconds() == 59) } } diff --git a/tests/auto/qml/qqmlecmascript/data/assignDate.2.qml b/tests/auto/qml/qqmlecmascript/data/assignDate.2.qml index 71dd188f05..f8c1f6eb8f 100644 --- a/tests/auto/qml/qqmlecmascript/data/assignDate.2.qml +++ b/tests/auto/qml/qqmlecmascript/data/assignDate.2.qml @@ -12,24 +12,25 @@ MyTypeObject { var dateTimeVar = new Date("2009-05-12T00:00:01") var dateTimeVar2 = new Date("2009-05-12T23:59:59") - // Commented properties do not currently test true: - boolProperty = //(dateProperty.getTime() == dateVar.getTime()) && + boolProperty = (dateProperty.getTime() == dateVar.getTime()) && (dateProperty.getFullYear() == 2009) && (dateProperty.getMonth() == 5-1) && - //(dateProperty.getDate() == 12) && - (dateProperty.getHours() == 0) && + (dateProperty.getUTCDate() == 12) && + (dateProperty.getUTCHours() == 0) && + (dateProperty.getUTCMinutes() == 0) && + (dateProperty.getUTCSeconds() == 0) && (dateTimeProperty.getTime() == dateTimeVar.getTime()) && (dateTimeProperty.getFullYear() == 2009) && (dateTimeProperty.getMonth() == 5-1) && - //(dateTimeProperty.getDate() == 12) && - //(dateTimeProperty.getHours() == 0) && + (dateTimeProperty.getDate() == 12) && + (dateTimeProperty.getHours() == 0) && (dateTimeProperty.getMinutes() == 0) && (dateTimeProperty.getSeconds() == 1) && (dateTimeProperty2.getTime() == dateTimeVar2.getTime()) && (dateTimeProperty2.getFullYear() == 2009) && (dateTimeProperty2.getMonth() == 5-1) && - //(dateTimeProperty2.getDate() == 12) && - //(dateTimeProperty2.getHours() == 23) && + (dateTimeProperty2.getDate() == 12) && + (dateTimeProperty2.getHours() == 23) && (dateTimeProperty2.getMinutes() == 59) && (dateTimeProperty2.getSeconds() == 59) } diff --git a/tests/auto/qml/qqmlecmascript/data/assignDate.3.qml b/tests/auto/qml/qqmlecmascript/data/assignDate.3.qml index 2cf740645c..e960eef193 100644 --- a/tests/auto/qml/qqmlecmascript/data/assignDate.3.qml +++ b/tests/auto/qml/qqmlecmascript/data/assignDate.3.qml @@ -2,35 +2,36 @@ import Qt.test 1.0 import QtQuick 2.0 MyTypeObject { - dateProperty: if (1) "2009-05-12Z" + dateProperty: if (1) "2009-05-12" dateTimeProperty: if (1) "2009-05-12T00:00:01Z" dateTimeProperty2: if (1) "2009-05-12T23:59:59Z" boolProperty: false Component.onCompleted: { - var dateVar = new Date("2009-05-12Z") + var dateVar = new Date("2009-05-12") var dateTimeVar = new Date("2009-05-12T00:00:01Z") var dateTimeVar2 = new Date("2009-05-12T23:59:59Z") - // Commented properties do not currently test true: - boolProperty = //(dateProperty.getTime() == dateVar.getTime()) && + boolProperty = (dateProperty.getTime() == dateVar.getTime()) && (dateProperty.getFullYear() == 2009) && (dateProperty.getMonth() == 5-1) && - //(dateProperty.getDate() == 12) && - (dateProperty.getHours() == 0) && + (dateProperty.getUTCDate() == 12) && + (dateProperty.getUTCHours() == 0) && + (dateProperty.getUTCMinutes() == 0) && + (dateProperty.getUTCSeconds() == 0) && (dateTimeProperty.getTime() == dateTimeVar.getTime()) && (dateTimeProperty.getFullYear() == 2009) && (dateTimeProperty.getMonth() == 5-1) && - //(dateTimeProperty.getDate() == 12) && - //(dateTimeProperty.getHours() == 0) && - (dateTimeProperty.getMinutes() == 0) && - (dateTimeProperty.getSeconds() == 1) && + (dateTimeProperty.getUTCDate() == 12) && + (dateTimeProperty.getUTCHours() == 0) && + (dateTimeProperty.getUTCMinutes() == 0) && + (dateTimeProperty.getUTCSeconds() == 1) && (dateTimeProperty2.getTime() == dateTimeVar2.getTime()) && (dateTimeProperty2.getFullYear() == 2009) && (dateTimeProperty2.getMonth() == 5-1) && - //(dateTimeProperty2.getDate() == 12) && - //(dateTimeProperty2.getHours() == 23) && - (dateTimeProperty2.getMinutes() == 59) && - (dateTimeProperty2.getSeconds() == 59) + (dateTimeProperty2.getUTCDate() == 12) && + (dateTimeProperty2.getUTCHours() == 23) && + (dateTimeProperty2.getUTCMinutes() == 59) && + (dateTimeProperty2.getUTCSeconds() == 59) } } diff --git a/tests/auto/qml/qqmlecmascript/data/assignDate.4.qml b/tests/auto/qml/qqmlecmascript/data/assignDate.4.qml index 9b4975c833..6dd29afbc9 100644 --- a/tests/auto/qml/qqmlecmascript/data/assignDate.4.qml +++ b/tests/auto/qml/qqmlecmascript/data/assignDate.4.qml @@ -2,35 +2,36 @@ import Qt.test 1.0 import QtQuick 2.0 MyTypeObject { - dateProperty: if (1) new Date("2009-05-12Z") + dateProperty: if (1) new Date("2009-05-12") dateTimeProperty: if (1) new Date("2009-05-12T00:00:01Z") dateTimeProperty2: if (1) new Date("2009-05-12T23:59:59Z") boolProperty: false Component.onCompleted: { - var dateVar = new Date("2009-05-12Z") + var dateVar = new Date("2009-05-12") var dateTimeVar = new Date("2009-05-12T00:00:01Z") var dateTimeVar2 = new Date("2009-05-12T23:59:59Z") - // Commented properties do not currently test true: - boolProperty = //(dateProperty.getTime() == dateVar.getTime()) && + boolProperty = (dateProperty.getTime() == dateVar.getTime()) && (dateProperty.getFullYear() == 2009) && (dateProperty.getMonth() == 5-1) && - //(dateProperty.getDate() == 12) && - (dateProperty.getHours() == 0) && + (dateProperty.getUTCDate() == 12) && + (dateProperty.getUTCHours() == 0) && + (dateProperty.getUTCMinutes() == 0) && + (dateProperty.getUTCSeconds() == 0) && (dateTimeProperty.getTime() == dateTimeVar.getTime()) && (dateTimeProperty.getFullYear() == 2009) && (dateTimeProperty.getMonth() == 5-1) && - //(dateTimeProperty.getDate() == 12) && - //(dateTimeProperty.getHours() == 0) && - (dateTimeProperty.getMinutes() == 0) && - (dateTimeProperty.getSeconds() == 1) && + (dateTimeProperty.getUTCDate() == 12) && + (dateTimeProperty.getUTCHours() == 0) && + (dateTimeProperty.getUTCMinutes() == 0) && + (dateTimeProperty.getUTCSeconds() == 1) && (dateTimeProperty2.getTime() == dateTimeVar2.getTime()) && (dateTimeProperty2.getFullYear() == 2009) && (dateTimeProperty2.getMonth() == 5-1) && - //(dateTimeProperty2.getDate() == 12) && - //(dateTimeProperty2.getHours() == 23) && - (dateTimeProperty2.getMinutes() == 59) && - (dateTimeProperty2.getSeconds() == 59) + (dateTimeProperty2.getUTCDate() == 12) && + (dateTimeProperty2.getUTCHours() == 23) && + (dateTimeProperty2.getUTCMinutes() == 59) && + (dateTimeProperty2.getUTCSeconds() == 59) } } diff --git a/tests/auto/qml/qqmlecmascript/data/assignDate.5.qml b/tests/auto/qml/qqmlecmascript/data/assignDate.5.qml index 2cf740645c..cfadaafc54 100644 --- a/tests/auto/qml/qqmlecmascript/data/assignDate.5.qml +++ b/tests/auto/qml/qqmlecmascript/data/assignDate.5.qml @@ -2,35 +2,36 @@ import Qt.test 1.0 import QtQuick 2.0 MyTypeObject { - dateProperty: if (1) "2009-05-12Z" - dateTimeProperty: if (1) "2009-05-12T00:00:01Z" - dateTimeProperty2: if (1) "2009-05-12T23:59:59Z" + dateProperty: if (1) "2009-05-12" + dateTimeProperty: if (1) "2009-05-12T00:00:01+02:00" + dateTimeProperty2: if (1) "2009-05-12T23:59:59+02:00" boolProperty: false Component.onCompleted: { - var dateVar = new Date("2009-05-12Z") - var dateTimeVar = new Date("2009-05-12T00:00:01Z") - var dateTimeVar2 = new Date("2009-05-12T23:59:59Z") + var dateVar = new Date("2009-05-12") + var dateTimeVar = new Date("2009-05-12T00:00:01+02:00") + var dateTimeVar2 = new Date("2009-05-12T23:59:59+02:00") - // Commented properties do not currently test true: - boolProperty = //(dateProperty.getTime() == dateVar.getTime()) && + boolProperty = (dateProperty.getTime() == dateVar.getTime()) && (dateProperty.getFullYear() == 2009) && (dateProperty.getMonth() == 5-1) && - //(dateProperty.getDate() == 12) && - (dateProperty.getHours() == 0) && + (dateProperty.getUTCDate() == 12) && + (dateProperty.getUTCHours() == 0) && + (dateProperty.getUTCMinutes() == 0) && + (dateProperty.getUTCSeconds() == 0) && (dateTimeProperty.getTime() == dateTimeVar.getTime()) && (dateTimeProperty.getFullYear() == 2009) && (dateTimeProperty.getMonth() == 5-1) && - //(dateTimeProperty.getDate() == 12) && - //(dateTimeProperty.getHours() == 0) && - (dateTimeProperty.getMinutes() == 0) && - (dateTimeProperty.getSeconds() == 1) && + (dateTimeProperty.getUTCDate() == 11) && + (dateTimeProperty.getUTCHours() == 22) && + (dateTimeProperty.getUTCMinutes() == 0) && + (dateTimeProperty.getUTCSeconds() == 1) && (dateTimeProperty2.getTime() == dateTimeVar2.getTime()) && (dateTimeProperty2.getFullYear() == 2009) && (dateTimeProperty2.getMonth() == 5-1) && - //(dateTimeProperty2.getDate() == 12) && - //(dateTimeProperty2.getHours() == 23) && - (dateTimeProperty2.getMinutes() == 59) && - (dateTimeProperty2.getSeconds() == 59) + (dateTimeProperty2.getUTCDate() == 12) && + (dateTimeProperty2.getUTCHours() == 21) && + (dateTimeProperty2.getUTCMinutes() == 59) && + (dateTimeProperty2.getUTCSeconds() == 59) } } diff --git a/tests/auto/qml/qqmlecmascript/data/assignDate.6.qml b/tests/auto/qml/qqmlecmascript/data/assignDate.6.qml index 73e26db0c8..97cd0d1e60 100644 --- a/tests/auto/qml/qqmlecmascript/data/assignDate.6.qml +++ b/tests/auto/qml/qqmlecmascript/data/assignDate.6.qml @@ -3,34 +3,35 @@ import QtQuick 2.0 MyTypeObject { dateProperty: if (1) new Date("2009-05-12") - dateTimeProperty: if (1) new Date("2009-05-12T02:00:01+02:00") - dateTimeProperty2: if (1) new Date("2009-05-13T01:59:59+02:00") + dateTimeProperty: if (1) new Date("2009-05-12T00:00:01+02:00") + dateTimeProperty2: if (1) new Date("2009-05-12T23:59:59+02:00") boolProperty: false Component.onCompleted: { var dateVar = new Date("2009-05-12") - var dateTimeVar = new Date("2009-05-12T02:00:01+02:00") - var dateTimeVar2 = new Date("2009-05-13T01:59:59+02:00") + var dateTimeVar = new Date("2009-05-12T00:00:01+02:00") + var dateTimeVar2 = new Date("2009-05-12T23:59:59+02:00") - // Commented properties do not currently test true: - boolProperty = //(dateProperty.getTime() == dateVar.getTime()) && + boolProperty = (dateProperty.getTime() == dateVar.getTime()) && (dateProperty.getFullYear() == 2009) && (dateProperty.getMonth() == 5-1) && - //(dateProperty.getDate() == 12) && - (dateProperty.getHours() == 0) && + (dateProperty.getUTCDate() == 12) && + (dateProperty.getUTCHours() == 0) && + (dateProperty.getUTCMinutes() == 0) && + (dateProperty.getUTCSeconds() == 0) && (dateTimeProperty.getTime() == dateTimeVar.getTime()) && (dateTimeProperty.getFullYear() == 2009) && (dateTimeProperty.getMonth() == 5-1) && - //(dateTimeProperty.getDate() == 12) && - //(dateTimeProperty.getHours() == 0) && - (dateTimeProperty.getMinutes() == 0) && - (dateTimeProperty.getSeconds() == 1) && + (dateTimeProperty.getUTCDate() == 11) && + (dateTimeProperty.getUTCHours() == 22) && + (dateTimeProperty.getUTCMinutes() == 0) && + (dateTimeProperty.getUTCSeconds() == 1) && (dateTimeProperty2.getTime() == dateTimeVar2.getTime()) && (dateTimeProperty2.getFullYear() == 2009) && (dateTimeProperty2.getMonth() == 5-1) && - //(dateTimeProperty2.getDate() == 12) && - //(dateTimeProperty2.getHours() == 23) && - (dateTimeProperty2.getMinutes() == 59) && - (dateTimeProperty2.getSeconds() == 59) + (dateTimeProperty2.getUTCDate() == 12) && + (dateTimeProperty2.getUTCHours() == 21) && + (dateTimeProperty2.getUTCMinutes() == 59) && + (dateTimeProperty2.getUTCSeconds() == 59) } } diff --git a/tests/auto/qml/qqmlecmascript/data/assignDate.qml b/tests/auto/qml/qqmlecmascript/data/assignDate.qml index 14fe20787b..73677e99f1 100644 --- a/tests/auto/qml/qqmlecmascript/data/assignDate.qml +++ b/tests/auto/qml/qqmlecmascript/data/assignDate.qml @@ -7,28 +7,31 @@ MyTypeObject { var dateTimeVar = new Date("2009-05-12T00:00:01") var dateTimeVar2 = new Date("2009-05-12T23:59:59") + // Date, with no zone specified, is implicitly UTC dateProperty = dateVar + // Date-time, with no zone, is implicitly local-time dateTimeProperty = dateTimeVar dateTimeProperty2 = dateTimeVar2 - // Commented properties do not currently test true: - boolProperty = //(dateProperty.getTime() == dateVar.getTime()) && + boolProperty = (dateProperty.getTime() == dateVar.getTime()) && (dateProperty.getFullYear() == 2009) && (dateProperty.getMonth() == 5-1) && - //(dateProperty.getDate() == 12) && - (dateProperty.getHours() == 0) && + (dateProperty.getDate() == 12) && + (dateProperty.getUTCHours() == 0) && + (dateProperty.getUTCMinutes() == 0) && + (dateProperty.getUTCSeconds() == 0) && (dateTimeProperty.getTime() == dateTimeVar.getTime()) && (dateTimeProperty.getFullYear() == 2009) && (dateTimeProperty.getMonth() == 5-1) && - //(dateTimeProperty.getDate() == 12) && - //(dateTimeProperty.getHours() == 0) && + (dateTimeProperty.getDate() == 12) && + (dateTimeProperty.getHours() == 0) && (dateTimeProperty.getMinutes() == 0) && (dateTimeProperty.getSeconds() == 1) && (dateTimeProperty2.getTime() == dateTimeVar2.getTime()) && (dateTimeProperty2.getFullYear() == 2009) && (dateTimeProperty2.getMonth() == 5-1) && - //(dateTimeProperty2.getDate() == 12) && - //(dateTimeProperty2.getHours() == 23) && + (dateTimeProperty2.getDate() == 12) && + (dateTimeProperty2.getHours() == 23) && (dateTimeProperty2.getMinutes() == 59) && (dateTimeProperty2.getSeconds() == 59) } diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 35f1534478..71bb357a43 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -43,6 +43,7 @@ #include "../../shared/util.h" #include <private/qv4functionobject_p.h> #include <private/qv4scopedvalue_p.h> +#include <private/qv4jscall_p.h> #include <private/qv4alloca_p.h> #include <private/qv4runtime_p.h> #include <private/qv4object_p.h> @@ -342,6 +343,10 @@ private slots: void freeze_empty_object(); void singleBlockLoops(); void qtbug_60547(); + void delayLoadingArgs(); + void manyArguments(); + void forInIterator(); + void localForInIterator(); private: // static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter); @@ -443,29 +448,37 @@ void tst_qqmlecmascript::assignBasicTypes() void tst_qqmlecmascript::assignDate_data() { QTest::addColumn<QUrl>("source"); + QTest::addColumn<int>("timeOffset"); // -1 for local-time, else minutes from UTC - QTest::newRow("Component.onComplete JS Parse") << testFileUrl("assignDate.qml"); - QTest::newRow("Component.onComplete JS") << testFileUrl("assignDate.1.qml"); - QTest::newRow("Binding JS") << testFileUrl("assignDate.2.qml"); - QTest::newRow("Binding UTC") << testFileUrl("assignDate.3.qml"); - QTest::newRow("Binding JS UTC") << testFileUrl("assignDate.4.qml"); - QTest::newRow("Binding UTC+2") << testFileUrl("assignDate.5.qml"); - QTest::newRow("Binding JS UTC+2 ") << testFileUrl("assignDate.6.qml"); + QTest::newRow("Component.onComplete JS Parse") << testFileUrl("assignDate.qml") << -1; + QTest::newRow("Component.onComplete JS") << testFileUrl("assignDate.1.qml") << 0; + QTest::newRow("Binding JS") << testFileUrl("assignDate.2.qml") << -1; + QTest::newRow("Binding UTC") << testFileUrl("assignDate.3.qml") << 0; + QTest::newRow("Binding JS UTC") << testFileUrl("assignDate.4.qml") << 0; + QTest::newRow("Binding UTC+2") << testFileUrl("assignDate.5.qml") << 120; + QTest::newRow("Binding JS UTC+2 ") << testFileUrl("assignDate.6.qml") << 120; } void tst_qqmlecmascript::assignDate() { QFETCH(QUrl, source); + QFETCH(int, timeOffset); QQmlComponent component(&engine, source); QScopedPointer<QObject> obj(component.create()); MyTypeObject *object = qobject_cast<MyTypeObject *>(obj.data()); QVERIFY(object != 0); - // Dates received from JS are automatically converted to local time - QDate expectedDate(QDateTime(QDate(2009, 5, 12), QTime(0, 0, 0), Qt::UTC).toLocalTime().date()); - QDateTime expectedDateTime(QDateTime(QDate(2009, 5, 12), QTime(0, 0, 1), Qt::UTC).toLocalTime()); - QDateTime expectedDateTime2(QDateTime(QDate(2009, 5, 12), QTime(23, 59, 59), Qt::UTC).toLocalTime()); + QDate expectedDate(2009, 5, 12); + QDateTime expectedDateTime; + QDateTime expectedDateTime2; + if (timeOffset == -1) { + expectedDateTime = QDateTime(QDate(2009, 5, 12), QTime(0, 0, 1), Qt::LocalTime); + expectedDateTime2 = QDateTime(QDate(2009, 5, 12), QTime(23, 59, 59), Qt::LocalTime); + } else { + expectedDateTime = QDateTime(QDate(2009, 5, 12), QTime(0, 0, 1), Qt::OffsetFromUTC, timeOffset * 60); + expectedDateTime2 = QDateTime(QDate(2009, 5, 12), QTime(23, 59, 59), Qt::OffsetFromUTC, timeOffset * 60); + } QCOMPARE(object->dateProperty(), expectedDate); QCOMPARE(object->dateTimeProperty(), expectedDateTime); @@ -2338,7 +2351,7 @@ static inline bool evaluate_error(QV8Engine *engine, const QV4::Value &o, const QLatin1String(source) + QLatin1String(" })"); QV4::Scope scope(QV8Engine::getV4(engine)); - QV4::Script program(QV4::ScopedContext(scope, scope.engine->rootContext()), functionSource); + QV4::Script program(QV4::ScopedContext(scope, scope.engine->rootContext()), QV4::Compiler::EvalCode, functionSource); program.inheritContext = true; QV4::ScopedFunctionObject function(scope, program.run()); @@ -2346,10 +2359,10 @@ static inline bool evaluate_error(QV8Engine *engine, const QV4::Value &o, const scope.engine->catchException(); return true; } - QV4::ScopedCallData d(scope, 1); - d->args[0] = o; - d->thisObject = engine->global(); - function->call(scope, d); + QV4::JSCallData jsCallData(scope, 1); + jsCallData->args[0] = o; + *jsCallData->thisObject = engine->global(); + function->call(jsCallData); if (scope.engine->hasException) { scope.engine->catchException(); return true; @@ -2364,7 +2377,7 @@ static inline bool evaluate_value(QV8Engine *engine, const QV4::Value &o, QLatin1String(source) + QLatin1String(" })"); QV4::Scope scope(QV8Engine::getV4(engine)); - QV4::Script program(QV4::ScopedContext(scope, scope.engine->rootContext()), functionSource); + QV4::Script program(QV4::ScopedContext(scope, scope.engine->rootContext()), QV4::Compiler::EvalCode, functionSource); program.inheritContext = true; QV4::ScopedFunctionObject function(scope, program.run()); @@ -2375,15 +2388,16 @@ static inline bool evaluate_value(QV8Engine *engine, const QV4::Value &o, if (!function) return false; - QV4::ScopedCallData d(scope, 1); - d->args[0] = o; - d->thisObject = engine->global(); - function->call(scope, d); + QV4::ScopedValue value(scope); + QV4::JSCallData jsCallData(scope, 1); + jsCallData->args[0] = o; + *jsCallData->thisObject = engine->global(); + value = function->call(jsCallData); if (scope.engine->hasException) { scope.engine->catchException(); return false; } - return QV4::Runtime::method_strictEqual(scope.result, result); + return QV4::Runtime::method_strictEqual(value, result); } static inline QV4::ReturnedValue evaluate(QV8Engine *engine, const QV4::Value &o, @@ -2394,7 +2408,7 @@ static inline QV4::ReturnedValue evaluate(QV8Engine *engine, const QV4::Value &o QV4::Scope scope(QV8Engine::getV4(engine)); - QV4::Script program(QV4::ScopedContext(scope, scope.engine->rootContext()), functionSource); + QV4::Script program(QV4::ScopedContext(scope, scope.engine->rootContext()), QV4::Compiler::EvalCode, functionSource); program.inheritContext = true; QV4::ScopedFunctionObject function(scope, program.run()); @@ -2404,15 +2418,15 @@ static inline QV4::ReturnedValue evaluate(QV8Engine *engine, const QV4::Value &o } if (!function) return QV4::Encode::undefined(); - QV4::ScopedCallData d(scope, 1); - d->args[0] = o; - d->thisObject = engine->global(); - function->call(scope, d); + QV4::JSCallData jsCallData(scope, 1); + jsCallData->args[0] = o; + *jsCallData->thisObject = engine->global(); + QV4::ScopedValue result(scope, function->call(jsCallData)); if (scope.engine->hasException) { scope.engine->catchException(); return QV4::Encode::undefined(); } - return scope.result.asReturnedValue(); + return result->asReturnedValue(); } #define EVALUATE_ERROR(source) evaluate_error(engine, object, source) @@ -7281,8 +7295,8 @@ class WeakReferenceMutator : public QObject Q_OBJECT public: WeakReferenceMutator() - : resultPtr(Q_NULLPTR) - , weakRef(Q_NULLPTR) + : resultPtr(nullptr) + , weakRef(nullptr) {} void init(QV4::ExecutionEngine *v4, QV4::WeakValue *weakRef, bool *resultPtr) @@ -8365,6 +8379,55 @@ void tst_qqmlecmascript::qtbug_60547() QCOMPARE(object->property("counter"), QVariant(int(1))); } +void tst_qqmlecmascript::delayLoadingArgs() +{ + QJSEngine engine; + QJSValue ret = engine.evaluate("(function(x){return x + (x+=2)})(20)"); + QCOMPARE(ret.toInt(), 42); // esp. not 44. +} + +void tst_qqmlecmascript::manyArguments() +{ + const char *testCase = + "function x() { var sum; for (var i = 0; i < arguments.length; ++i) sum += arguments[i][0]; }" + "x([0],[1],[2],[3],[4],[5],[6],[7],[8],[9], [0],[1],[2],[3],[4],[5],[6],[7],[8],[9], [0],[1],[2],[3],[4],[5],[6],[7],[8],[9])"; + + QJSEngine engine; + engine.evaluate(testCase); +} + +void tst_qqmlecmascript::forInIterator() +{ + auto testCase = + "(function(){\n" + "var x = 'yoyo'\n" + "var i\n" + "for (i in x) {\n" + "}\n" + "return i\n" + "})()"; + QJSEngine engine; + QJSValue ret = engine.evaluate(testCase); + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), QStringLiteral("3")); +} + +void tst_qqmlecmascript::localForInIterator() +{ + auto testCase = + "(function(){\n" + "var x = 'yoyo'\n" + "for (var i in x) {\n" + "}\n" + "return i\n" + "})()"; + QJSEngine engine; + QJSValue ret = engine.evaluate(testCase); + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), QStringLiteral("3")); +} + + QTEST_MAIN(tst_qqmlecmascript) #include "tst_qqmlecmascript.moc" diff --git a/tests/auto/qml/qqmlengine/qqmlengine.pro b/tests/auto/qml/qqmlengine/qqmlengine.pro index e7952d8e3a..8d1e149d62 100644 --- a/tests/auto/qml/qqmlengine/qqmlengine.pro +++ b/tests/auto/qml/qqmlengine/qqmlengine.pro @@ -7,3 +7,8 @@ include (../../shared/util.pri) SOURCES += tst_qqmlengine.cpp QT += core-private gui-private qml-private network testlib + +boot2qt: { + # GC corruption test is too heavy for qemu-arm + DEFINES += SKIP_GCCORRUPTION_TEST +} diff --git a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp index 7aca830297..b332ab2194 100644 --- a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp +++ b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp @@ -862,6 +862,10 @@ void tst_qqmlengine::qmlContextProperties() void tst_qqmlengine::testGCCorruption() { +#ifdef SKIP_GCCORRUPTION_TEST + QSKIP("Test too heavy for qemu"); +#endif + QQmlEngine e; QQmlComponent c(&e, testFileUrl("testGCCorruption.qml")); diff --git a/tests/auto/qml/qqmlextensionplugin/tst_qqmlextensionplugin.cpp b/tests/auto/qml/qqmlextensionplugin/tst_qqmlextensionplugin.cpp index 268010ead8..2511eebefe 100644 --- a/tests/auto/qml/qqmlextensionplugin/tst_qqmlextensionplugin.cpp +++ b/tests/auto/qml/qqmlextensionplugin/tst_qqmlextensionplugin.cpp @@ -105,7 +105,7 @@ void tst_qqmlextensionplugin::iidCheck() QPluginLoader loader(filePath); QVERIFY2(loader.load(), qPrintable(loader.errorString())); - QVERIFY(loader.instance() != Q_NULLPTR); + QVERIFY(loader.instance() != nullptr); if (qobject_cast<QQmlExtensionPlugin *>(loader.instance())) { QString iid = loader.metaData().value(QStringLiteral("IID")).toString(); diff --git a/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp b/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp index 68739886c4..70aaa9678e 100644 --- a/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp +++ b/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp @@ -54,7 +54,7 @@ void tst_QQmlImport::cleanup() void tst_QQmlImport::testDesignerSupported() { QQuickView *window = new QQuickView(); - window->engine()->addImportPath(QT_TESTCASE_BUILDDIR); + window->engine()->addImportPath(directory()); window->setSource(testFileUrl("testfile_supported.qml")); QVERIFY(window->errors().isEmpty()); @@ -68,7 +68,7 @@ void tst_QQmlImport::testDesignerSupported() delete window; window = new QQuickView(); - window->engine()->addImportPath(QT_TESTCASE_BUILDDIR); + window->engine()->addImportPath(directory()); window->engine()->clearComponentCache(); window->setSource(testFileUrl("testfile_supported.qml")); @@ -91,7 +91,7 @@ void tst_QQmlImport::uiFormatLoading() int size = 0; QQmlApplicationEngine *test = new QQmlApplicationEngine(testFileUrl("TestForm.ui.qml")); - test->addImportPath(QT_TESTCASE_BUILDDIR); + test->addImportPath(directory()); QCOMPARE(test->rootObjects().size(), ++size); QVERIFY(test->rootObjects()[size -1]); QVERIFY(test->rootObjects()[size -1]->property("success").toBool()); diff --git a/tests/auto/qml/qqmlinstantiator/stringmodel.h b/tests/auto/qml/qqmlinstantiator/stringmodel.h index 0bd4ada55e..b01817375a 100644 --- a/tests/auto/qml/qqmlinstantiator/stringmodel.h +++ b/tests/auto/qml/qqmlinstantiator/stringmodel.h @@ -65,7 +65,7 @@ public: return items.count(); } - virtual QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE + QHash<int, QByteArray> roleNames() const override { return roles; } @@ -75,7 +75,7 @@ public: return 1; } - virtual bool hasChildren(const QModelIndex &) const Q_DECL_OVERRIDE + bool hasChildren(const QModelIndex &) const override { return rowCount(QModelIndex()) > 0; } diff --git a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp index d0ce83b997..4f4deaafe5 100644 --- a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp +++ b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp @@ -1268,8 +1268,8 @@ void tst_qqmllocale::timeZoneUpdated() { QByteArray original(qgetenv("TZ")); - // Set the timezone to Brisbane time - setTimeZone(QByteArray("AEST-10:00")); + // Set the timezone to Brisbane time, AEST-10:00 + setTimeZone(QByteArray("Australia/Brisbane")); DateFormatter formatter; @@ -1281,8 +1281,8 @@ void tst_qqmllocale::timeZoneUpdated() QVERIFY(obj); QVERIFY(obj->property("success").toBool()); - // Change to Indian time - setTimeZone(QByteArray("IST-05:30")); + // Change to Indian time, IST-05:30 + setTimeZone(QByteArray("Asia/Kolkata")); QMetaObject::invokeMethod(obj.data(), "check"); diff --git a/tests/auto/qml/qqmlnotifier/tst_qqmlnotifier.cpp b/tests/auto/qml/qqmlnotifier/tst_qqmlnotifier.cpp index beb60925bb..88a5d41975 100644 --- a/tests/auto/qml/qqmlnotifier/tst_qqmlnotifier.cpp +++ b/tests/auto/qml/qqmlnotifier/tst_qqmlnotifier.cpp @@ -98,7 +98,7 @@ public: } protected: - void connectNotify(const QMetaMethod &signal) Q_DECL_OVERRIDE { + void connectNotify(const QMetaMethod &signal) override { if (signal.name() == "qmlObjectPropChanged") qmlObjectPropConnections++; if (signal.name() == "cppObjectPropChanged") cppObjectPropConnections++; if (signal.name() == "unboundPropChanged") unboundPropConnections++; @@ -112,7 +112,7 @@ protected: //qDebug() << Q_FUNC_INFO << this << signal.name(); } - void disconnectNotify(const QMetaMethod &signal) Q_DECL_OVERRIDE { + void disconnectNotify(const QMetaMethod &signal) override { if (signal.name() == "qmlObjectPropChanged") qmlObjectPropConnections--; if (signal.name() == "cppObjectPropChanged") cppObjectPropConnections--; if (signal.name() == "unboundPropChanged") unboundPropConnections--; @@ -146,7 +146,7 @@ public: {} private slots: - void initTestCase() Q_DECL_OVERRIDE; + void initTestCase() override; void cleanupTestCase(); void testConnectNotify(); diff --git a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp index 0576650d01..0bc1127069 100644 --- a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp +++ b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp @@ -888,7 +888,8 @@ void tst_qqmlqt::dateTimeFormattingVariants_data() QTest::newRow("formatTime, qtime") << "formatTime" << QVariant::fromValue(time) << (QStringList() << temporary.time().toString(Qt::DefaultLocaleShortDate) << temporary.time().toString(Qt::DefaultLocaleLongDate) << temporary.time().toString("H:m:s a") << temporary.time().toString("hh:mm:ss.zzz")); QDate date(2011,5,31); - temporary = QDateTime(date); + // V4 reads the date in UTC but DateObject::toQDateTime() gives it back in local time: + temporary = QDateTime(date, QTime(0, 0, 0), Qt::UTC).toLocalTime(); QTest::newRow("formatDate, qdate") << "formatDate" << QVariant::fromValue(date) << (QStringList() << temporary.date().toString(Qt::DefaultLocaleShortDate) << temporary.date().toString(Qt::DefaultLocaleLongDate) << temporary.date().toString("ddd MMMM d yy")); QTest::newRow("formatDateTime, qdate") << "formatDateTime" << QVariant::fromValue(date) << (QStringList() << temporary.toString(Qt::DefaultLocaleShortDate) << temporary.toString(Qt::DefaultLocaleLongDate) << temporary.toString("M/d/yy H:m:s a")); QTest::newRow("formatTime, qdate") << "formatTime" << QVariant::fromValue(date) << (QStringList() << temporary.time().toString(Qt::DefaultLocaleShortDate) << temporary.time().toString(Qt::DefaultLocaleLongDate) << temporary.time().toString("H:m:s a") << temporary.time().toString("hh:mm:ss.zzz")); @@ -997,7 +998,7 @@ void tst_qqmlqt::exit() QSignalSpy spy(&engine, &QQmlEngine::exit); QObject *object = component.create(); - QVERIFY(object != Q_NULLPTR); + QVERIFY(object != nullptr); QCOMPARE(spy.count(), 1); QList<QVariant> arguments = spy.takeFirst(); QVERIFY(arguments.at(0).toInt() == object->property("returnCode").toInt()); diff --git a/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp b/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp index a8a6456dff..59716acc0d 100644 --- a/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp +++ b/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp @@ -291,7 +291,7 @@ class TestThreadedHTTPServer : public QObject Q_OBJECT public: TestThreadedHTTPServer(const QUrl &expectUrl, const QUrl &replyUrl, const QUrl &bodyUrl) - : m_server(Q_NULLPTR) { + : m_server(nullptr) { QMutexLocker locker(&m_lock); moveToThread(&m_thread); m_thread.start(); diff --git a/tests/auto/qml/qwidgetsinqml/qwidgetsinqml.pro b/tests/auto/qml/qwidgetsinqml/qwidgetsinqml.pro new file mode 100644 index 0000000000..c86365d5ea --- /dev/null +++ b/tests/auto/qml/qwidgetsinqml/qwidgetsinqml.pro @@ -0,0 +1,7 @@ +CONFIG += testcase +CONFIG += parallel_test +TARGET = tst_qwidgetsinqml +macos:CONFIG -= app_bundle +QT += qml widgets testlib gui-private +SOURCES += tst_qwidgetsinqml.cpp +DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/qml/qwidgetsinqml/tst_qwidgetsinqml.cpp b/tests/auto/qml/qwidgetsinqml/tst_qwidgetsinqml.cpp new file mode 100644 index 0000000000..bbe717859b --- /dev/null +++ b/tests/auto/qml/qwidgetsinqml/tst_qwidgetsinqml.cpp @@ -0,0 +1,288 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtQml module 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$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include <QQmlEngine> +#include <QtQml> +#include <QWidget> + +class tst_QWidgetsInQml : public QObject +{ + Q_OBJECT +public: + tst_QWidgetsInQml(); + +private slots: + void instantiateWidget(); + void instantiateWidgetWithoutParentWidget(); + void widgetAsDefaultPropertyCollected(); + void widgetAsDefaultPropertyKept(); + void widgetAsDefaultPropertyKeptDuringCreation(); +}; + +static void gc(QQmlEngine &engine) +{ + engine.collectGarbage(); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::processEvents(); +} + +// Like QtObject, but with default property +class QObjectContainer : public QObject +{ + Q_OBJECT + Q_CLASSINFO("DefaultProperty", "data"); + Q_PROPERTY(QQmlListProperty<QObject> data READ data DESIGNABLE false); +public: + QObjectContainer() + : widgetParent(0) + , gcOnAppend(false) + {} + + QQmlListProperty<QObject> data() { + return QQmlListProperty<QObject>(this, 0, children_append, children_count, children_at, children_clear); + } + + static void children_append(QQmlListProperty<QObject> *prop, QObject *o) + { + QObjectContainer *that = static_cast<QObjectContainer*>(prop->object); + that->dataChildren.append(o); + QObject::connect(o, SIGNAL(destroyed(QObject*)), prop->object, SLOT(childDestroyed(QObject*))); + QWidget *widget = qobject_cast<QWidget*>(o); + if (widget && that->widgetParent) + widget->setParent(that->widgetParent); + + if (that->gcOnAppend) { + QQmlEngine *engine = qmlEngine(that); + gc(*engine); + } + } + + static int children_count(QQmlListProperty<QObject> *prop) + { + return static_cast<QObjectContainer*>(prop->object)->dataChildren.count(); + } + + static QObject *children_at(QQmlListProperty<QObject> *prop, int index) + { + return static_cast<QObjectContainer*>(prop->object)->dataChildren.at(index); + } + + static void children_clear(QQmlListProperty<QObject> *prop) + { + QObjectContainer *that = static_cast<QObjectContainer*>(prop->object); + foreach (QObject *c, that->dataChildren) + QObject::disconnect(c, SIGNAL(destroyed(QObject*)), that, SLOT(childDestroyed(QObject*))); + that->dataChildren.clear(); + } + + QList<QObject*> dataChildren; + QWidget *widgetParent; + bool gcOnAppend; + +protected slots: + void childDestroyed(QObject *child) { + dataChildren.removeAll(child); + } +}; + +class QWidgetContainer : public QObjectContainer +{ + Q_OBJECT +public: + QWidgetContainer() + { + widgetParent = new QWidget; + QQmlEngine::setObjectOwnership(widgetParent, QQmlEngine::CppOwnership); + } + virtual ~QWidgetContainer() + { + delete widgetParent; + widgetParent = 0; + } +}; + +class QObjectContainerWithGCOnAppend : public QObjectContainer +{ + Q_OBJECT +public: + QObjectContainerWithGCOnAppend() + { + gcOnAppend = true; + } +}; + +tst_QWidgetsInQml::tst_QWidgetsInQml() +{ + qmlRegisterType<QWidget>("Qt.Widgets", 1, 0, "QWidget"); + qmlRegisterType<QObjectContainer>("Qt.Widgets", 1, 0, "QObjectContainer"); + qmlRegisterType<QWidgetContainer>("Qt.Widgets", 1, 0, "QWidgetContainer"); + qmlRegisterType<QObjectContainerWithGCOnAppend>("Qt.Widgets", 1, 0, "QObjectContainerWithGCOnAppend"); +} + +void tst_QWidgetsInQml::instantiateWidget() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData("import Qt.Widgets 1.0;\nQWidget { property QWidget child: QWidget { objectName: 'child' } }", QUrl()); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); + QWidget *rootWidget = qobject_cast<QWidget*>(object.data()); + QVERIFY(rootWidget != 0); + QCOMPARE(rootWidget->children().count(), 1); + QWidget *firstChildWidget = qobject_cast<QWidget*>(rootWidget->children().first()); + QVERIFY(firstChildWidget != 0); + + QWidget *widgetProperty = qvariant_cast<QWidget*>(object->property("child")); + QVERIFY(widgetProperty != 0); + QCOMPARE(firstChildWidget, widgetProperty); + QCOMPARE(firstChildWidget->objectName(), QString("child")); +} + +void tst_QWidgetsInQml::instantiateWidgetWithoutParentWidget() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData("import Qt.Widgets 1.0;\n" + "import QtQml 2.0;\n" + "QtObject { property QtObject child: QWidget { objectName: 'child' } }", QUrl()); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); + + QPointer<QWidget> widgetProperty = qvariant_cast<QWidget*>(object->property("child")); + QVERIFY(!widgetProperty.isNull()); + QCOMPARE(widgetProperty->objectName(), QString("child")); + + QVERIFY(!widgetProperty->parent()); + gc(engine); + // Don't collect, the property reference should keep it alive + QVERIFY(!widgetProperty.isNull()); +} + +void tst_QWidgetsInQml::widgetAsDefaultPropertyCollected() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData("import Qt.Widgets 1.0;\n" + "import QtQml 2.0;\n" + "QObjectContainer {\n" + " QWidget {\n" + " id: parentLessChild;\n" + " objectName: 'child'\n" + " }\n" + " property var widgetHolder;\n" + " Component.onCompleted: {\n" + " widgetHolder = parentLessChild;\n" + " }\n" + "}", QUrl()); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); + + QObjectContainer *container = qobject_cast<QObjectContainer*>(object.data()); + QCOMPARE(container->dataChildren.count(), 1); + + QJSValue holder = qvariant_cast<QJSValue>(object->property("widgetHolder")); + QVERIFY(!holder.isNull()); + gc(engine); + QCOMPARE(container->dataChildren.count(), 1); + + holder = QJSValue(); + object->setProperty("widgetHolder", QVariant::fromValue(holder)); + + gc(engine); + // The QWidget is without a parent and nobody is referencing it anymore (the children + // list in QObjectContainer is weak!), so it should get collected. + QCOMPARE(container->dataChildren.count(), 0); +} + +void tst_QWidgetsInQml::widgetAsDefaultPropertyKept() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData("import Qt.Widgets 1.0;\n" + "import QtQml 2.0;\n" + "QWidgetContainer {\n" + " QWidget {\n" + " id: parentLessChild;\n" + " objectName: 'child'\n" + " }\n" + " property var widgetHolder;\n" + " Component.onCompleted: {\n" + " widgetHolder = parentLessChild;\n" + " }\n" + "}", QUrl()); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); + + QWidgetContainer *container = qobject_cast<QWidgetContainer*>(object.data()); + QCOMPARE(container->dataChildren.count(), 1); + + QJSValue holder = qvariant_cast<QJSValue>(object->property("widgetHolder")); + QVERIFY(!holder.isNull()); + gc(engine); + QCOMPARE(container->dataChildren.count(), 1); + + holder = QJSValue(); + object->setProperty("widgetHolder", QVariant::fromValue(holder)); + + gc(engine); + QCOMPARE(container->dataChildren.count(), 1); +} + +void tst_QWidgetsInQml::widgetAsDefaultPropertyKeptDuringCreation() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData("import Qt.Widgets 1.0;\n" + "import QtQml 2.0;\n" + "QObjectContainerWithGCOnAppend {\n" + " QWidget {\n" + " id: parentLessChild;\n" + " objectName: 'child'\n" + " property var blah;\n" // Ensures that we have a JS wrapper + " }\n" + "}", QUrl()); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); + + QObjectContainer *container = qobject_cast<QObjectContainer*>(object.data()); + QCOMPARE(container->dataChildren.count(), 1); + + gc(engine); + QCOMPARE(container->dataChildren.count(), 0); + +} + +QTEST_MAIN(tst_QWidgetsInQml) + +#include "tst_qwidgetsinqml.moc" diff --git a/tests/auto/qmltest/itemgrabber/tst_itemgrabber.qml b/tests/auto/qmltest/itemgrabber/tst_itemgrabber.qml index 53ed3658c2..af1b4db0e0 100644 --- a/tests/auto/qmltest/itemgrabber/tst_itemgrabber.qml +++ b/tests/auto/qmltest/itemgrabber/tst_itemgrabber.qml @@ -40,6 +40,10 @@ Item { when: imageOnDisk.ready && imageOnDiskSmall.ready function test_endresult_disk() { + if ((Qt.platform.pluginName === "offscreen") + || (Qt.platform.pluginName === "minimal")) + skip("grabImage does not work on offscreen/minimal platforms"); + var image = grabImage(root); // imageOnDisk at (0, 0) - (100x100) @@ -73,6 +77,10 @@ Item { } function test_endresult_cache(data) { + if ((Qt.platform.pluginName === "offscreen") + || (Qt.platform.pluginName === "minimal")) + skip("grabImage does not work on offscreen/minimal platforms"); + imageInCache.cache = data.cache; imageInCache.sourceSize = data.sourceSize; imageInCache.fillMode = data.fillMode; diff --git a/tests/auto/qmltest/listmodel/tst_listmodel.qml b/tests/auto/qmltest/listmodel/tst_listmodel.qml index 11f2019e08..2867897b0c 100644 --- a/tests/auto/qmltest/listmodel/tst_listmodel.qml +++ b/tests/auto/qmltest/listmodel/tst_listmodel.qml @@ -61,6 +61,16 @@ Item { ListModel { id: secondmodel; ListElement { name: "SecondModelElement0" } ListElement { name: "SecondModelElement1" } } ListModel { id: altermodel; ListElement { name: "AlterModelElement0" } ListElement { name: "AlterModelElement1" } } + property string funcResult + ListModel { + id: funcModel + property string modelProp + ListElement { friendlyText: "one"; action: function(obj) { funcResult = obj.friendlyText } } + ListElement { friendlyText: "two"; action: function() {} } + ListElement { friendlyText: "three"; action: function() { modelProp = "fail" } } + ListElement { friendlyText: "four"; action: function() { funcResult = friendlyText } } + } + TestCase { name: "ListModel" @@ -138,5 +148,51 @@ Item { tryCompare(altermodel, 'count', 0) compare(altermodel.get(0), undefined) } + + function test_functions() { + // test different ways of calling + funcModel.get(0).action(funcModel.get(0)) + compare(funcResult, "one") + funcModel.get(0).action.call(this, { friendlyText: "seven" }) + compare(funcResult, "seven") + + // test different ways of setting + funcResult = "" + funcModel.get(1).action() + compare(funcResult, "") + + funcModel.set(1, { friendlyText: "two", action: function() { funcResult = "set" } }) + funcModel.get(1).action() + compare(funcResult, "set") + + funcModel.setProperty(1, "action", function() { top.funcResult = "setProperty" }) + funcModel.get(1).action() + compare(funcResult, "setProperty") + + funcModel.get(1).action = function() { funcResult = "jsSet" } + funcModel.get(1).action() + compare(funcResult, "jsSet") + + // test unsupported features + var didThrow = false + try { + funcModel.get(2).action() + } catch(ex) { + verify(ex.toString().includes("Error: Invalid write to global property")) + didThrow = true + } + verify(didThrow) + + didThrow = false + try { + funcModel.get(3).action() + } catch(ex) { + verify(ex.toString().includes("ReferenceError: friendlyText is not defined")) + didThrow = true + } + verify(didThrow) + + + } } } diff --git a/tests/auto/qmltest/listview/tst_listview.qml b/tests/auto/qmltest/listview/tst_listview.qml index 2b5246b116..f7a34cbce2 100644 --- a/tests/auto/qmltest/listview/tst_listview.qml +++ b/tests/auto/qmltest/listview/tst_listview.qml @@ -161,6 +161,15 @@ Item { } } + ListView { + id: viewWithActionModel + property string funcResult + model: ListModel { ListElement { friendlyText: "one"; action: function(text) { viewWithActionModel.funcResult = text } } } + delegate: Item { + Component.onCompleted: action(model.friendlyText) + } + } + Component { id: delegateModelAfterCreateComponent Rectangle { @@ -350,5 +359,9 @@ Item { singleElementList.heightForDelegate = 200; compare(singleElementList.contentHeightOnDelegateResize, 200); } + + function test_viewWithAction() { + compare(viewWithActionModel.funcResult, "one") + } } } diff --git a/tests/auto/qmltest/shadersource/tst_DynamicallyCreatedSource.qml b/tests/auto/qmltest/shadersource/tst_DynamicallyCreatedSource.qml index 2c6d4cc28f..74dc63a972 100644 --- a/tests/auto/qmltest/shadersource/tst_DynamicallyCreatedSource.qml +++ b/tests/auto/qmltest/shadersource/tst_DynamicallyCreatedSource.qml @@ -67,6 +67,10 @@ Item { when: root.source != undefined function test_endresult() { + if ((Qt.platform.pluginName === "offscreen") + || (Qt.platform.pluginName === "minimal")) + skip("grabImage does not work on offscreen/minimal platforms"); + var image = grabImage(root); compare(image.red(0,0), 255); compare(image.green(0,0), 0); diff --git a/tests/auto/quick/drawingmodes/tst_drawingmodes.cpp b/tests/auto/quick/drawingmodes/tst_drawingmodes.cpp index d4065e3d38..fe794cf952 100644 --- a/tests/auto/quick/drawingmodes/tst_drawingmodes.cpp +++ b/tests/auto/quick/drawingmodes/tst_drawingmodes.cpp @@ -149,6 +149,10 @@ void tst_drawingmodes::points() if (QGuiApplication::primaryScreen()->depth() < 24) QSKIP("This test does not work at display depths < 24"); + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms"); + #ifdef Q_OS_WIN if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES) QSKIP("ANGLE cannot draw GL_POINTS."); @@ -187,6 +191,11 @@ void tst_drawingmodes::lines() DrawingModeItem::drawingMode = GL_LINES; if (QGuiApplication::primaryScreen()->depth() < 24) QSKIP("This test does not work at display depths < 24"); + + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms"); + QImage fb = runTest("DrawingModes.qml"); QCOMPARE(fb.width(), 200); @@ -213,6 +222,11 @@ void tst_drawingmodes::lineStrip() DrawingModeItem::drawingMode = GL_LINE_STRIP; if (QGuiApplication::primaryScreen()->depth() < 24) QSKIP("This test does not work at display depths < 24"); + + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms"); + QImage fb = runTest("DrawingModes.qml"); QCOMPARE(fb.width(), 200); @@ -241,6 +255,11 @@ void tst_drawingmodes::lineLoop() DrawingModeItem::drawingMode = GL_LINE_LOOP; if (QGuiApplication::primaryScreen()->depth() < 24) QSKIP("This test does not work at display depths < 24"); + + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms"); + QImage fb = runTest("DrawingModes.qml"); QCOMPARE(fb.width(), 200); @@ -269,6 +288,11 @@ void tst_drawingmodes::triangles() DrawingModeItem::drawingMode = GL_TRIANGLES; if (QGuiApplication::primaryScreen()->depth() < 24) QSKIP("This test does not work at display depths < 24"); + + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms"); + QImage fb = runTest("DrawingModes.qml"); QCOMPARE(fb.width(), 200); @@ -293,6 +317,11 @@ void tst_drawingmodes::triangleStrip() DrawingModeItem::drawingMode = GL_TRIANGLE_STRIP; if (QGuiApplication::primaryScreen()->depth() < 24) QSKIP("This test does not work at display depths < 24"); + + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms"); + QImage fb = runTest("DrawingModes.qml"); QCOMPARE(fb.width(), 200); @@ -316,6 +345,11 @@ void tst_drawingmodes::triangleFan() DrawingModeItem::drawingMode = GL_TRIANGLE_FAN; if (QGuiApplication::primaryScreen()->depth() < 24) QSKIP("This test does not work at display depths < 24"); + + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms"); + QImage fb = runTest("DrawingModes.qml"); QCOMPARE(fb.width(), 200); diff --git a/tests/auto/quick/nodes/tst_nodestest.cpp b/tests/auto/quick/nodes/tst_nodestest.cpp index 63e0aeb324..e7303604b4 100644 --- a/tests/auto/quick/nodes/tst_nodestest.cpp +++ b/tests/auto/quick/nodes/tst_nodestest.cpp @@ -41,6 +41,9 @@ #include <QtQuick/qsgsimpletexturenode.h> #include <QtQuick/private/qsgtexture_p.h> +#include <QtGui/private/qguiapplication_p.h> +#include <QtGui/qpa/qplatformintegration.h> + QT_BEGIN_NAMESPACE inline bool operator==(const QSGGeometry::TexturedPoint2D& l, const QSGGeometry::TexturedPoint2D& r) { @@ -80,6 +83,9 @@ private: void NodesTest::initTestCase() { + if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)) + QSKIP("OpenGL not supported by the platform"); + QSGRenderLoop *renderLoop = QSGRenderLoop::instance(); surface = new QOffscreenSurface; @@ -141,9 +147,9 @@ public: int DummyRenderer::globalRendereringOrder; NodesTest::NodesTest() - : surface(Q_NULLPTR) - , context(Q_NULLPTR) - , renderContext(Q_NULLPTR) + : surface(nullptr) + , context(nullptr) + , renderContext(nullptr) { } diff --git a/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp b/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp index 820c804065..dcb0e01b5d 100644 --- a/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp +++ b/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp @@ -292,7 +292,7 @@ class KillerThread : public QThread { Q_OBJECT protected: - void run() Q_DECL_OVERRIDE { + void run() override { sleep(3); qFatal("Either the GUI or the render thread is stuck in an infinite loop."); } diff --git a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp index 4a7a77416a..d28d065d17 100644 --- a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp +++ b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp @@ -120,12 +120,16 @@ void tst_qquickanimations::simpleProperty() { QQuickRectangle rect; QQuickPropertyAnimation animation; + QSignalSpy fromChangedSpy(&animation, &QQuickPropertyAnimation::fromChanged); + QSignalSpy toChangedSpy(&animation, &QQuickPropertyAnimation::toChanged); animation.setTargetObject(&rect); animation.setProperty("x"); animation.setTo(200); QCOMPARE(animation.target(), &rect); QCOMPARE(animation.property(), QLatin1String("x")); QCOMPARE(animation.to().toReal(), 200.0); + QCOMPARE(fromChangedSpy.count(), 0); + QCOMPARE(toChangedSpy.count(), 1); animation.start(); QVERIFY(animation.isRunning()); QTest::qWait(animation.duration()); @@ -139,18 +143,25 @@ void tst_qquickanimations::simpleProperty() animation.setCurrentTime(125); QCOMPARE(animation.currentTime(), 125); QCOMPARE(rect.x(),100.0); + animation.setFrom(100); + QCOMPARE(fromChangedSpy.count(), 1); + QCOMPARE(toChangedSpy.count(), 1); } void tst_qquickanimations::simpleNumber() { QQuickRectangle rect; QQuickNumberAnimation animation; + QSignalSpy fromChangedSpy(&animation, &QQuickNumberAnimation::fromChanged); + QSignalSpy toChangedSpy(&animation, &QQuickNumberAnimation::toChanged); animation.setTargetObject(&rect); animation.setProperty("x"); animation.setTo(200); QCOMPARE(animation.target(), &rect); QCOMPARE(animation.property(), QLatin1String("x")); QCOMPARE(animation.to(), qreal(200)); + QCOMPARE(fromChangedSpy.count(), 0); + QCOMPARE(toChangedSpy.count(), 1); animation.start(); QVERIFY(animation.isRunning()); QTest::qWait(animation.duration()); @@ -164,18 +175,25 @@ void tst_qquickanimations::simpleNumber() animation.setCurrentTime(125); QCOMPARE(animation.currentTime(), 125); QCOMPARE(rect.x(), qreal(100)); + animation.setFrom(100); + QCOMPARE(fromChangedSpy.count(), 1); + QCOMPARE(toChangedSpy.count(), 1); } void tst_qquickanimations::simpleColor() { QQuickRectangle rect; QQuickColorAnimation animation; + QSignalSpy fromChangedSpy(&animation, &QQuickColorAnimation::fromChanged); + QSignalSpy toChangedSpy(&animation, &QQuickColorAnimation::toChanged); animation.setTargetObject(&rect); animation.setProperty("color"); animation.setTo(QColor("red")); QCOMPARE(animation.target(), &rect); QCOMPARE(animation.property(), QLatin1String("color")); QCOMPARE(animation.to(), QColor("red")); + QCOMPARE(fromChangedSpy.count(), 0); + QCOMPARE(toChangedSpy.count(), 1); animation.start(); QVERIFY(animation.isRunning()); QTest::qWait(animation.duration()); @@ -193,6 +211,8 @@ void tst_qquickanimations::simpleColor() rect.setColor(QColor("green")); animation.setFrom(QColor("blue")); QCOMPARE(animation.from(), QColor("blue")); + QCOMPARE(fromChangedSpy.count(), 1); + QCOMPARE(toChangedSpy.count(), 1); animation.restart(); QCOMPARE(rect.color(), QColor("blue")); QVERIFY(animation.isRunning()); @@ -204,6 +224,8 @@ void tst_qquickanimations::simpleRotation() { QQuickRectangle rect; QQuickRotationAnimation animation; + QSignalSpy fromChangedSpy(&animation, &QQuickRotationAnimation::fromChanged); + QSignalSpy toChangedSpy(&animation, &QQuickRotationAnimation::toChanged); animation.setTargetObject(&rect); animation.setProperty("rotation"); animation.setTo(270); @@ -211,6 +233,8 @@ void tst_qquickanimations::simpleRotation() QCOMPARE(animation.property(), QLatin1String("rotation")); QCOMPARE(animation.to(), qreal(270)); QCOMPARE(animation.direction(), QQuickRotationAnimation::Numerical); + QCOMPARE(fromChangedSpy.count(), 0); + QCOMPARE(toChangedSpy.count(), 1); animation.start(); QVERIFY(animation.isRunning()); QTest::qWait(animation.duration()); @@ -224,6 +248,9 @@ void tst_qquickanimations::simpleRotation() animation.setCurrentTime(125); QCOMPARE(animation.currentTime(), 125); QCOMPARE(rect.rotation(), qreal(135)); + animation.setFrom(90); + QCOMPARE(fromChangedSpy.count(), 1); + QCOMPARE(toChangedSpy.count(), 1); } void tst_qquickanimations::simplePath() diff --git a/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp b/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp index e428a1fc6e..89b7924618 100644 --- a/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp +++ b/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp @@ -67,7 +67,7 @@ void tst_qquickapplication::cleanup() { if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ApplicationState)) { QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationInactive); - QTest::waitForEvents(); + QCoreApplication::processEvents(); } } diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_imagedata.qml b/tests/auto/quick/qquickcanvasitem/data/tst_imagedata.qml index 7095602ea2..76b99a765e 100644 --- a/tests/auto/quick/qquickcanvasitem/data/tst_imagedata.qml +++ b/tests/auto/quick/qquickcanvasitem/data/tst_imagedata.qml @@ -6,6 +6,10 @@ CanvasTestCase { name: "imagedata" function init_data() { return testData("2d"); } function test_rounding(row) { + if ((Qt.platform.pluginName === "offscreen") + || (Qt.platform.pluginName === "minimal")) + skip("ctx.getImageData crashes on offscreen/minimal platforms"); + var canvas = createCanvasObject(row); var ctx = canvas.getContext('2d'); var size = 17 diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp index 3f66daf87f..04cfac70ad 100644 --- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp +++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp @@ -1348,7 +1348,8 @@ void tst_qquickflickable::flickOnRelease() #ifdef Q_OS_MAC # if QT_CONFIG(opengl) - QEXPECT_FAIL("", "QTBUG-26094 stopping on a full pixel doesn't work on OS X", Continue); + // QEXPECT_FAIL("", "QTBUG-26094 stopping on a full pixel doesn't work on OS X", Continue); + QSKIP("This should be fixed after qt5 dev integrated again, see QTBUG-65343"); # endif #endif // Stop on a full pixel after user interaction diff --git a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp index 388ecc2ab8..dddda7e2bf 100644 --- a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp +++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp @@ -6711,7 +6711,7 @@ void tst_QQuickGridView::QTBUG_48870_fastModelUpdates() QQuickItemViewPrivate *priv = QQuickItemViewPrivate::get(view); bool nonUnique; - FxViewItem *item = Q_NULLPTR; + FxViewItem *item = nullptr; int expectedIdx; QVERIFY(testVisibleItems(priv, &nonUnique, &item, &expectedIdx)); diff --git a/tests/auto/quick/qquickimage/tst_qquickimage.cpp b/tests/auto/quick/qquickimage/tst_qquickimage.cpp index a2a65aa803..256e667980 100644 --- a/tests/auto/quick/qquickimage/tst_qquickimage.cpp +++ b/tests/auto/quick/qquickimage/tst_qquickimage.cpp @@ -301,6 +301,10 @@ void tst_qquickimage::smooth() void tst_qquickimage::mirror() { + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms"); + QMap<QQuickImage::FillMode, QImage> screenshots; QList<QQuickImage::FillMode> fillModes; fillModes << QQuickImage::Stretch << QQuickImage::PreserveAspectFit << QQuickImage::PreserveAspectCrop @@ -501,6 +505,10 @@ void tst_qquickimage::big() void tst_qquickimage::tiling_QTBUG_6716() { + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms"); + QFETCH(QString, source); QQuickView view(testFileUrl(source)); @@ -1034,6 +1042,10 @@ void tst_qquickimage::highDpiFillModesAndSizes() void tst_qquickimage::hugeImages() { + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms"); + QQuickView view; view.setSource(testFileUrl("hugeImages.qml")); view.setGeometry(0, 0, 200, 200); diff --git a/tests/auto/quick/qquickitem/BLACKLIST b/tests/auto/quick/qquickitem/BLACKLIST index d94a3ef102..f00b061356 100644 --- a/tests/auto/quick/qquickitem/BLACKLIST +++ b/tests/auto/quick/qquickitem/BLACKLIST @@ -1,2 +1,4 @@ [contains:hollow square: testing points inside] xcb +[ignoreButtonPressNotInAcceptedMouseButtons] +* diff --git a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp index 09e89ff85f..b66dc1708f 100644 --- a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp +++ b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp @@ -301,7 +301,7 @@ class TabFenceItem : public QQuickItem Q_OBJECT public: - TabFenceItem(QQuickItem *parent = Q_NULLPTR) + TabFenceItem(QQuickItem *parent = nullptr) : QQuickItem(parent) { QQuickItemPrivate *d = QQuickItemPrivate::get(this); @@ -316,7 +316,7 @@ class TabFenceItem2 : public QQuickItem Q_OBJECT public: - TabFenceItem2(QQuickItem *parent = Q_NULLPTR) + TabFenceItem2(QQuickItem *parent = nullptr) : QQuickItem(parent) { QQuickItemPrivate *d = QQuickItemPrivate::get(this); @@ -1188,12 +1188,12 @@ void tst_QQuickItem::tabFence() QVERIFY(window->rootObject()->hasActiveFocus()); const char *rootTabFocusChain[] = { - "input1", "input2", "input3", "input1", Q_NULLPTR + "input1", "input2", "input3", "input1", nullptr }; verifyTabFocusChain(window, rootTabFocusChain, true /* forward */); const char *rootBacktabFocusChain[] = { - "input3", "input2", "input1", "input3", Q_NULLPTR + "input3", "input2", "input1", "input3", nullptr }; verifyTabFocusChain(window, rootBacktabFocusChain, false /* forward */); @@ -1204,12 +1204,12 @@ void tst_QQuickItem::tabFence() QVERIFY(item->hasActiveFocus()); const char *fence1TabFocusChain[] = { - "input12", "input13", "input11", "input12", Q_NULLPTR + "input12", "input13", "input11", "input12", nullptr }; verifyTabFocusChain(window, fence1TabFocusChain, true /* forward */); const char *fence1BacktabFocusChain[] = { - "input11", "input13", "input12", "input11", Q_NULLPTR + "input11", "input13", "input12", "input11", nullptr }; verifyTabFocusChain(window, fence1BacktabFocusChain, false /* forward */); } @@ -3305,6 +3305,10 @@ void tst_QQuickItem::childAt() void tst_QQuickItem::grab() { + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QSKIP("Skipping due to grabToImage not functional on offscreen/minimimal platforms"); + QQuickView view; view.setSource(testFileUrl("grabToImage.qml")); view.show(); diff --git a/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp index 5419778cfc..a8a00b51e9 100644 --- a/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp +++ b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp @@ -36,6 +36,9 @@ #include "../../shared/util.h" +#include <QtGui/private/qguiapplication_p.h> +#include <QtGui/qpa/qplatformintegration.h> + class tst_QQuickItemLayer: public QQmlDataTest { Q_OBJECT @@ -54,7 +57,7 @@ public: } private slots: - void initTestCase() Q_DECL_OVERRIDE; + void initTestCase() override; void layerEnabled(); void layerSmooth(); #if QT_CONFIG(opengl) @@ -102,35 +105,37 @@ void tst_QQuickItemLayer::initTestCase() { QQmlDataTest::initTestCase(); #if QT_CONFIG(opengl) - QWindow window; - QOpenGLContext context; - window.setSurfaceType(QWindow::OpenGLSurface); - window.create(); - QVERIFY(context.create()); - QVERIFY(context.makeCurrent(&window)); - const char *vendor = (const char *)context.functions()->glGetString(GL_VENDOR); - const char *renderer = (const char *)context.functions()->glGetString(GL_RENDERER); - m_isMesaSoftwareRasterizer = strcmp(vendor, "Mesa Project") == 0 - && strcmp(renderer, "Software Rasterizer") == 0; - if (m_isMesaSoftwareRasterizer) { - // Expects format: <OpenGL version> Mesa <Mesa version>[-devel] [...] - const char *version = (const char *)context.functions()->glGetString(GL_VERSION); - QList<QByteArray> list = QByteArray(version).split(' '); - if (list.size() >= 3) { - list = list.at(2).split('-').at(0).split('.'); - int major = 0; - int minor = 0; - int patch = 0; - if (list.size() >= 1) - major = list.at(0).toInt(); - if (list.size() >= 2) - minor = list.at(1).toInt(); - if (list.size() >= 3) - patch = list.at(2).toInt(); - m_mesaVersion = QT_VERSION_CHECK(major, minor, patch); + if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)) { + QWindow window; + QOpenGLContext context; + window.setSurfaceType(QWindow::OpenGLSurface); + window.create(); + QVERIFY(context.create()); + QVERIFY(context.makeCurrent(&window)); + const char *vendor = (const char *)context.functions()->glGetString(GL_VENDOR); + const char *renderer = (const char *)context.functions()->glGetString(GL_RENDERER); + m_isMesaSoftwareRasterizer = strcmp(vendor, "Mesa Project") == 0 + && strcmp(renderer, "Software Rasterizer") == 0; + if (m_isMesaSoftwareRasterizer) { + // Expects format: <OpenGL version> Mesa <Mesa version>[-devel] [...] + const char *version = (const char *)context.functions()->glGetString(GL_VERSION); + QList<QByteArray> list = QByteArray(version).split(' '); + if (list.size() >= 3) { + list = list.at(2).split('-').at(0).split('.'); + int major = 0; + int minor = 0; + int patch = 0; + if (list.size() >= 1) + major = list.at(0).toInt(); + if (list.size() >= 2) + minor = list.at(1).toInt(); + if (list.size() >= 3) + patch = list.at(2).toInt(); + m_mesaVersion = QT_VERSION_CHECK(major, minor, patch); + } } + window.create(); } - window.create(); #endif QQuickView view; view.showNormal(); @@ -147,6 +152,11 @@ void tst_QQuickItemLayer::layerSmooth() { if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0)) QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly."); + + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms"); + QImage fb = runTest("Smooth.qml"); QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0)); QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0, 0xff)); @@ -166,6 +176,11 @@ void tst_QQuickItemLayer::layerEnabled() { if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0)) QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly."); + + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms"); + QImage fb = runTest("Enabled.qml"); // Verify the banding QCOMPARE(fb.pixel(0, 0), fb.pixel(0, 1)); @@ -181,6 +196,7 @@ void tst_QQuickItemLayer::layerMipmap() { if (m_isMesaSoftwareRasterizer) QSKIP("Mipmapping does not work with the Mesa Software Rasterizer."); + QImage fb = runTest("Mipmap.qml"); QVERIFY(fb.pixel(0, 0) != 0xff000000); QVERIFY(fb.pixel(0, 0) != 0xffffffff); @@ -195,6 +211,11 @@ void tst_QQuickItemLayer::layerEffect() { if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0)) QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly."); + + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms"); + QImage fb = runTest("Effect.qml"); QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0)); QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0xff, 0)); @@ -451,6 +472,10 @@ void tst_QQuickItemLayer::itemEffect() void tst_QQuickItemLayer::rectangleEffect() { + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms"); + QImage fb = runTest("RectangleEffect.qml"); QCOMPARE(fb.pixel(0, 0), qRgb(0, 0xff, 0)); QCOMPARE(fb.pixel(199, 0), qRgb(0, 0xff, 0)); diff --git a/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml b/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml index 4346c5283e..4ff1017116 100644 --- a/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml +++ b/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml @@ -263,6 +263,41 @@ Item { col.destroy() } + function test_dynamicSizeAdaptationsForInitiallyInvisibleItemsInLayout() { + var test_layoutStr = + 'import QtQuick 2.2; \ + import QtQuick.Layouts 1.0; \ + RowLayout { \ + id: row; \ + width: 10; \ + spacing: 0; \ + property alias r1: _r1; \ + Rectangle { \ + id: _r1; \ + visible: false; \ + height: 10; \ + Layout.fillWidth: true; \ + color: "#8080ff"; \ + } \ + property alias r2: _r2; \ + Rectangle { \ + id: _r2; \ + height: 10; \ + Layout.fillWidth: true; \ + color: "#c0c0ff"; \ + } \ + } ' + + var lay = Qt.createQmlObject(test_layoutStr, container, ''); + compare(lay.r1.width, 0) + compare(lay.r2.width, 10) + lay.r1.visible = true; + waitForRendering(lay) + compare(lay.r1.width, 5) + compare(lay.r2.width, 5) + lay.destroy() + } + Component { id: layoutItem_Component Rectangle { diff --git a/tests/auto/quick/qquicklistview/data/flickBothDirections.qml b/tests/auto/quick/qquicklistview/data/flickBothDirections.qml index 754e91a732..b491981edb 100644 --- a/tests/auto/quick/qquicklistview/data/flickBothDirections.qml +++ b/tests/auto/quick/qquicklistview/data/flickBothDirections.qml @@ -63,6 +63,7 @@ Rectangle { contentWidth: initialContentWidth contentHeight: initialContentHeight flickableDirection: initialFlickableDirection + pixelAligned: true delegate: Rectangle { width: list.orientation == ListView.Vertical ? 120 : 10 height: list.orientation == ListView.Vertical ? 20 : 110 diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index f06a118976..32f61884f5 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -8515,7 +8515,7 @@ void tst_QQuickListView::QTBUG_48870_fastModelUpdates() QQuickItemViewPrivate *priv = QQuickItemViewPrivate::get(listview); bool nonUnique; - FxViewItem *item = Q_NULLPTR; + FxViewItem *item = nullptr; int expectedIdx; QVERIFY(testVisibleItems(priv, &nonUnique, &item, &expectedIdx)); diff --git a/tests/auto/quick/qquickloader/BLACKLIST b/tests/auto/quick/qquickloader/BLACKLIST new file mode 100644 index 0000000000..a45a300607 --- /dev/null +++ b/tests/auto/quick/qquickloader/BLACKLIST @@ -0,0 +1,4 @@ +# Test fails on qemu when bound to one core, passes on real ARM +# QTBUG-63049 +[asyncToSync1] +b2qt diff --git a/tests/auto/quick/qquickmousearea/BLACKLIST b/tests/auto/quick/qquickmousearea/BLACKLIST new file mode 100644 index 0000000000..817eb472a4 --- /dev/null +++ b/tests/auto/quick/qquickmousearea/BLACKLIST @@ -0,0 +1,3 @@ +# QTBUG-63786 +[pressedMultipleButtons] +* diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp index 01bce46ccb..dada49cfc2 100644 --- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp +++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp @@ -77,7 +77,7 @@ public: {} private slots: - void initTestCase() Q_DECL_OVERRIDE; + void initTestCase() override; void dragProperties(); void resetDrag(); void dragging_data() { acceptedButton_data(); } @@ -1293,6 +1293,10 @@ void tst_QQuickMouseArea::hoverPropagation() void tst_QQuickMouseArea::hoverVisible() { + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms"); + QQuickView window; QByteArray errorMessage; QVERIFY2(initView(window, testFileUrl("hoverVisible.qml"), true, &errorMessage), errorMessage.constData()); diff --git a/tests/auto/quick/qquickpainteditem/BLACKLIST b/tests/auto/quick/qquickpainteditem/BLACKLIST new file mode 100644 index 0000000000..9b58325f6c --- /dev/null +++ b/tests/auto/quick/qquickpainteditem/BLACKLIST @@ -0,0 +1,27 @@ +# QTBUG-63053 +[opaquePainting] +b2qt + +# QTBUG-63053 +[antialiasing] +b2qt + +# QTBUG-63053 +[mipmap] +b2qt + +# QTBUG-63053 +[performanceHints] +b2qt + +# QTBUG-63053 +[contentScale] +b2qt + +# QTBUG-63053 +[contentsBoundingRect] +b2qt + +# QTBUG-63053 +[fillColor] +b2qt diff --git a/tests/auto/quick/qquickpath/data/anglearc.qml b/tests/auto/quick/qquickpath/data/anglearc.qml new file mode 100644 index 0000000000..cbe41c1ac8 --- /dev/null +++ b/tests/auto/quick/qquickpath/data/anglearc.qml @@ -0,0 +1,12 @@ +import QtQuick 2.11 + +Path { + PathAngleArc { + centerX: 100 + centerY: 100 + radiusX: 50 + radiusY: 50 + startAngle: 45 + sweepAngle: 90 + } +} diff --git a/tests/auto/quick/qquickpath/tst_qquickpath.cpp b/tests/auto/quick/qquickpath/tst_qquickpath.cpp index 2ec95840e1..106d7afd85 100644 --- a/tests/auto/quick/qquickpath/tst_qquickpath.cpp +++ b/tests/auto/quick/qquickpath/tst_qquickpath.cpp @@ -41,6 +41,7 @@ public: private slots: void arc(); + void angleArc(); void catmullromCurve(); void closedCatmullromCurve(); void svg(); @@ -82,6 +83,45 @@ void tst_QuickPath::arc() QCOMPARE(pos, QPointF(100,100)); } +void tst_QuickPath::angleArc() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("anglearc.qml")); + QQuickPath *obj = qobject_cast<QQuickPath*>(c.create()); + QVERIFY(obj != 0); + + QQmlListReference list(obj, "pathElements"); + QCOMPARE(list.count(), 1); + + QQuickPathAngleArc* arc = qobject_cast<QQuickPathAngleArc*>(list.at(0)); + QVERIFY(arc != 0); + QCOMPARE(arc->centerX(), 100.); + QCOMPARE(arc->centerY(), 100.); + QCOMPARE(arc->radiusX(), 50.); + QCOMPARE(arc->radiusY(), 50.); + QCOMPARE(arc->startAngle(), 45.); + QCOMPARE(arc->sweepAngle(), 90.); + QCOMPARE(arc->moveToStart(), true); + + QPainterPath path = obj->path(); + QVERIFY(path != QPainterPath()); + + // using QPoint to do fuzzy compare + QPointF pos = obj->pointAt(0); + QCOMPARE(pos.toPoint(), QPoint(135,135)); + pos = obj->pointAt(.25); + QCOMPARE(pos.toPoint(), QPoint(119,146)); + pos = obj->pointAt(.75); + QCOMPARE(pos.toPoint(), QPoint(81,146)); + pos = obj->pointAt(1); + QCOMPARE(pos.toPoint(), QPoint(65,135)); + + // if moveToStart is false, we should have a line starting from startX/Y + arc->setMoveToStart(false); + pos = obj->pointAt(0); + QCOMPARE(pos, QPointF(0,0)); +} + void tst_QuickPath::catmullromCurve() { QQmlEngine engine; diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp index cbef0fcc8d..061f71aeb0 100644 --- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp +++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp @@ -2351,7 +2351,7 @@ void tst_QQuickPathView::qtbug37815() QTest::qWait(1000); QQuickPathView *pathView = findItem<QQuickPathView>(window->rootObject(), "pathView"); - QVERIFY(pathView != Q_NULLPTR); + QVERIFY(pathView != nullptr); const int pathItemCount = pathView->pathItemCount(); const int cacheItemCount = pathView->cacheItemCount(); @@ -2421,7 +2421,7 @@ void tst_QQuickPathView::qtbug53464() QVERIFY(QTest::qWaitForWindowActive(window.data())); QQuickPathView *pathView = findItem<QQuickPathView>(window->rootObject(), "pathView"); - QVERIFY(pathView != Q_NULLPTR); + QVERIFY(pathView != nullptr); const int currentIndex = pathView->currentIndex(); QCOMPARE(currentIndex, 8); diff --git a/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp b/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp index 0d79592e37..2aaad867bf 100644 --- a/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp +++ b/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp @@ -70,6 +70,10 @@ void tst_qquickrectangle::color() QVERIFY(QTest::qWaitForWindowExposed(&view)); + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QEXPECT_FAIL("", "Failure due to grabWindow not functional on offscreen/minimimal platforms", Abort); + QImage image = view.grabWindow(); QVERIFY(image.pixel(0,0) == QColor("#020202").rgba()); } diff --git a/tests/auto/quick/qquickshape/tst_qquickshape.cpp b/tests/auto/quick/qquickshape/tst_qquickshape.cpp index 1b5b345d19..2a349d2013 100644 --- a/tests/auto/quick/qquickshape/tst_qquickshape.cpp +++ b/tests/auto/quick/qquickshape/tst_qquickshape.cpp @@ -223,6 +223,10 @@ void tst_QQuickShape::render() window->show(); QVERIFY(QTest::qWaitForWindowExposed(window.data())); + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QEXPECT_FAIL("", "Failure due to grabWindow not functional on offscreen/minimimal platforms", Abort); + QImage img = window->grabWindow(); QVERIFY(!img.isNull()); @@ -240,6 +244,10 @@ void tst_QQuickShape::renderWithMultipleSp() window->show(); QVERIFY(QTest::qWaitForWindowExposed(window.data())); + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QEXPECT_FAIL("", "Failure due to grabWindow not functional on offscreen/minimimal platforms", Abort); + QImage img = window->grabWindow(); QVERIFY(!img.isNull()); @@ -257,6 +265,10 @@ void tst_QQuickShape::radialGrad() window->show(); QVERIFY(QTest::qWaitForWindowExposed(window.data())); + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QEXPECT_FAIL("", "Failure due to grabWindow not functional on offscreen/minimimal platforms", Abort); + QImage img = window->grabWindow(); QVERIFY(!img.isNull()); @@ -274,6 +286,10 @@ void tst_QQuickShape::conicalGrad() window->show(); QVERIFY(QTest::qWaitForWindowExposed(window.data())); + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QEXPECT_FAIL("", "Failure due to grabWindow not functional on offscreen/minimimal platforms", Abort); + QImage img = window->grabWindow(); QVERIFY(!img.isNull()); diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp index 4e643bb9d9..51c04a109d 100644 --- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp @@ -984,6 +984,10 @@ void tst_qquicktext::hAlignImplicitWidth() const int centeredSection3End = centeredSection3 + sectionWidth; { + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QEXPECT_FAIL("", "Failure due to grabWindow not functional on offscreen/minimimal platforms", Abort); + // Left Align QImage image = view.grabWindow(); const int left = numberOfNonWhitePixels(centeredSection1, centeredSection2, image); diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp index f4fef1f946..d0031e397b 100644 --- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp @@ -905,6 +905,10 @@ void tst_qquicktextedit::hAlignVisual() const int centeredSection3End = centeredSection3 + sectionWidth; { + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QEXPECT_FAIL("", "Failure due to grabWindow not functional on offscreen/minimimal platforms", Abort); + // Left Align QImage image = view.grabWindow(); const int left = numberOfNonWhitePixels(centeredSection1, centeredSection2, image); diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index f20a1a7e1a..666f80fce1 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -1310,6 +1310,10 @@ void tst_qquickwindow::grab_data() void tst_qquickwindow::grab() { + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms"); + QFETCH(bool, visible); QFETCH(bool, alpha); @@ -2394,6 +2398,9 @@ void tst_qquickwindow::testRenderJob() window.scheduleRenderJob(new RenderJob(QQuickWindow::NoStage, &completedJobs), QQuickWindow::NoStage); QTRY_COMPARE(RenderJob::deleted, 1); + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QEXPECT_FAIL("", "NoStage job fails on offscreen/minimimal platforms", Continue); QCOMPARE(completedJobs.size(), 1); #if QT_CONFIG(opengl) @@ -2462,13 +2469,13 @@ public: m_childMouseEventFilterEventCount.clear(); } protected: - bool childMouseEventFilter(QQuickItem *, QEvent *event) Q_DECL_OVERRIDE + bool childMouseEventFilter(QQuickItem *, QEvent *event) override { m_childMouseEventFilterEventCount[event->type()]++; return m_returnTrueForType.contains(event->type()); } - bool event(QEvent *event) Q_DECL_OVERRIDE + bool event(QEvent *event) override { m_eventCount[event->type()]++; return QQuickRectangle::event(event); @@ -2649,7 +2656,7 @@ public: return false; } - virtual bool contains(const QPointF &pos) const override { + bool contains(const QPointF &pos) const override { // returns true if the point is inside the the embedded circle inside the (square) rect const float radius = (float)width()/2; const QVector2D center(radius, radius); diff --git a/tests/auto/quick/quick.pro b/tests/auto/quick/quick.pro index 0f904e0c09..a54a707f4a 100644 --- a/tests/auto/quick/quick.pro +++ b/tests/auto/quick/quick.pro @@ -92,6 +92,9 @@ QUICKTESTS += \ SUBDIRS += $$PUBLICTESTS +# Following tests are too slow on qemu + software backend +boot2qt: QUICKTESTS -= qquickgridview qquicklistview qquickpositioners + !qtConfig(accessibility):QUICKTESTS -= qquickaccessible qtConfig(private_tests) { diff --git a/tests/auto/quick/rendernode/tst_rendernode.cpp b/tests/auto/quick/rendernode/tst_rendernode.cpp index e0fe2c42fc..d6e1982b1e 100644 --- a/tests/auto/quick/rendernode/tst_rendernode.cpp +++ b/tests/auto/quick/rendernode/tst_rendernode.cpp @@ -213,6 +213,11 @@ void tst_rendernode::renderOrder() { if (QGuiApplication::primaryScreen()->depth() < 24) QSKIP("This test does not work at display depths < 24"); + + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms"); + QImage fb = runTest("RenderOrder.qml"); const qreal scaleFactor = QGuiApplication::primaryScreen()->devicePixelRatio(); @@ -237,6 +242,11 @@ void tst_rendernode::messUpState() { if (QGuiApplication::primaryScreen()->depth() < 24) QSKIP("This test does not work at display depths < 24"); + + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms"); + QImage fb = runTest("MessUpState.qml"); int x1 = 0; int x2 = fb.width() / 2; @@ -290,6 +300,10 @@ public: void tst_rendernode::matrix() { + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms"); + qmlRegisterType<StateRecordingRenderNodeItem>("RenderNode", 1, 0, "StateRecorder"); StateRecordingRenderNode::matrices.clear(); runTest("matrix.qml"); diff --git a/tests/auto/quick/scenegraph/tst_scenegraph.cpp b/tests/auto/quick/scenegraph/tst_scenegraph.cpp index 2cd3a041c8..d8d9cd26e0 100644 --- a/tests/auto/quick/scenegraph/tst_scenegraph.cpp +++ b/tests/auto/quick/scenegraph/tst_scenegraph.cpp @@ -47,6 +47,9 @@ #include "../../shared/util.h" #include "../shared/visualtestutil.h" +#include <QtGui/private/qguiapplication_p.h> +#include <QtGui/qpa/qplatformintegration.h> + using namespace QQuickVisualTestUtil; class PerPixelRect : public QQuickItem @@ -114,6 +117,7 @@ private slots: private: bool m_brokenMipmapSupport; QQuickView *createView(const QString &file, QWindow *parent = 0, int x = -1, int y = -1, int w = -1, int h = -1); + bool isRunningOnOpenGL(); }; template <typename T> class ScopedList : public QList<T> { @@ -131,38 +135,40 @@ void tst_SceneGraph::initTestCase() qDebug() << "RenderLoop: " << loop; #if QT_CONFIG(opengl) - QOpenGLContext context; - context.setFormat(loop->sceneGraphContext()->defaultSurfaceFormat()); - context.create(); - QSurfaceFormat format = context.format(); - - QOffscreenSurface surface; - surface.setFormat(format); - surface.create(); - if (!context.makeCurrent(&surface)) - qFatal("Failed to create a GL context..."); - - QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); - qDebug() << "R/G/B/A Buffers: " << format.redBufferSize() << format.greenBufferSize() << format.blueBufferSize() << format.alphaBufferSize(); - qDebug() << "Depth Buffer: " << format.depthBufferSize(); - qDebug() << "Stencil Buffer: " << format.stencilBufferSize(); - qDebug() << "Samples: " << format.samples(); - int textureSize; - funcs->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &textureSize); - qDebug() << "Max Texture Size: " << textureSize; - qDebug() << "GL_VENDOR: " << (const char *) funcs->glGetString(GL_VENDOR); - qDebug() << "GL_RENDERER: " << (const char *) funcs->glGetString(GL_RENDERER); - QByteArray version = (const char *) funcs->glGetString(GL_VERSION); - qDebug() << "GL_VERSION: " << version.constData(); - QSet<QByteArray> exts = context.extensions(); - QByteArray all; - foreach (const QByteArray &e, exts) all += ' ' + e; - qDebug() << "GL_EXTENSIONS: " << all.constData(); - - m_brokenMipmapSupport = version.contains("Mesa 10.1") || version.contains("Mesa 9."); - qDebug() << "Broken Mipmap: " << m_brokenMipmapSupport; - - context.doneCurrent(); + if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)) { + QOpenGLContext context; + context.setFormat(loop->sceneGraphContext()->defaultSurfaceFormat()); + context.create(); + QSurfaceFormat format = context.format(); + + QOffscreenSurface surface; + surface.setFormat(format); + surface.create(); + if (!context.makeCurrent(&surface)) + qFatal("Failed to create a GL context..."); + + QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); + qDebug() << "R/G/B/A Buffers: " << format.redBufferSize() << format.greenBufferSize() << format.blueBufferSize() << format.alphaBufferSize(); + qDebug() << "Depth Buffer: " << format.depthBufferSize(); + qDebug() << "Stencil Buffer: " << format.stencilBufferSize(); + qDebug() << "Samples: " << format.samples(); + int textureSize; + funcs->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &textureSize); + qDebug() << "Max Texture Size: " << textureSize; + qDebug() << "GL_VENDOR: " << (const char *) funcs->glGetString(GL_VENDOR); + qDebug() << "GL_RENDERER: " << (const char *) funcs->glGetString(GL_RENDERER); + QByteArray version = (const char *) funcs->glGetString(GL_VERSION); + qDebug() << "GL_VERSION: " << version.constData(); + QSet<QByteArray> exts = context.extensions(); + QByteArray all; + foreach (const QByteArray &e, exts) all += ' ' + e; + qDebug() << "GL_EXTENSIONS: " << all.constData(); + + m_brokenMipmapSupport = version.contains("Mesa 10.1") || version.contains("Mesa 9."); + qDebug() << "Broken Mipmap: " << m_brokenMipmapSupport; + + context.doneCurrent(); + } #endif } @@ -231,6 +237,10 @@ public: void tst_SceneGraph::manyWindows() { + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms"); + QFETCH(QString, file); QFETCH(bool, toplevel); QFETCH(bool, shared); @@ -430,12 +440,8 @@ void tst_SceneGraph::render_data() void tst_SceneGraph::render() { - QQuickView dummy; - dummy.show(); - QTest::qWaitForWindowExposed(&dummy); - if (dummy.rendererInterface()->graphicsApi() != QSGRendererInterface::OpenGL) + if (!isRunningOnOpenGL()) QSKIP("Skipping complex rendering tests due to not running with OpenGL"); - dummy.hide(); QFETCH(QString, file); QFETCH(QList<Sample>, baseStage); @@ -485,6 +491,9 @@ void tst_SceneGraph::render() // current on the other window. void tst_SceneGraph::hideWithOtherContext() { + if (!isRunningOnOpenGL()) + QSKIP("Skipping OpenGL context test due to not running with OpenGL"); + QWindow window; window.setSurfaceType(QWindow::OpenGLSurface); window.resize(100, 100); @@ -500,9 +509,6 @@ void tst_SceneGraph::hideWithOtherContext() view.show(); QVERIFY(QTest::qWaitForWindowExposed(&view)); - if (view.rendererInterface()->graphicsApi() != QSGRendererInterface::OpenGL) - QSKIP("Skipping OpenGL context test due to not running with OpenGL"); - renderingOnMainThread = view.openglContext()->thread() == QGuiApplication::instance()->thread(); // Make the local context current on the local window... @@ -549,6 +555,17 @@ void tst_SceneGraph::createTextureFromImage() QCOMPARE(texture->hasAlphaChannel(), expectedAlpha); } +bool tst_SceneGraph::isRunningOnOpenGL() +{ + bool retval = false; + QQuickView dummy; + dummy.show(); + QTest::qWaitForWindowExposed(&dummy); + if (dummy.rendererInterface()->graphicsApi() == QSGRendererInterface::OpenGL) + retval = true; + dummy.hide(); + return retval; +} #include "tst_scenegraph.moc" diff --git a/tests/auto/quick/shared/viewtestutil.cpp b/tests/auto/quick/shared/viewtestutil.cpp index d5bf0110c4..dc813b9d59 100644 --- a/tests/auto/quick/shared/viewtestutil.cpp +++ b/tests/auto/quick/shared/viewtestutil.cpp @@ -398,7 +398,7 @@ bool QQuickViewTestUtil::testVisibleItems(const QQuickItemViewPrivate *priv, boo for (int i = 0; i < priv->visibleItems.count(); ++i) { FxViewItem *item = priv->visibleItems.at(i); if (!item) { - *failItem = Q_NULLPTR; + *failItem = nullptr; return false; } #if 0 diff --git a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp index 0bf2f8d7d8..c0b2d8e5d8 100644 --- a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp +++ b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp @@ -369,6 +369,10 @@ void tst_qquickwidget::reparentToNewWindow() QSignalSpy afterRenderingSpy(qqw->quickWindow(), &QQuickWindow::afterRendering); qqw->setParent(&window2); qqw->show(); + + if (QGuiApplication::platformName() == QLatin1String("offscreen")) + QEXPECT_FAIL("", "afterRendering not emitted after reparenting on offscreen", Continue); + QTRY_VERIFY(afterRenderingSpy.size() > 0); QImage img = qqw->grabFramebuffer(); |