diff options
Diffstat (limited to 'tests')
74 files changed, 1090 insertions, 158 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/qqmlprofilerservice/tst_qqmlprofilerservice.cpp b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp index 6232a8a867..cc6083cb98 100644 --- a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp +++ b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp @@ -36,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 +587,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/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp index a3a2efd565..446f9b04a7 100644 --- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp @@ -145,6 +145,7 @@ private slots: void array_join_QTBUG_53672(); void regexpLastMatch(); + void regexpLastIndex(); void indexedAccesses(); void prototypeChainGc(); @@ -3289,6 +3290,28 @@ void tst_QJSEngine::regexpLastMatch() } +void tst_QJSEngine::regexpLastIndex() +{ + QJSEngine eng; + QJSValue result; + result = eng.evaluate("function test(text, rx) {" + " var res;" + " while (res = rx.exec(text)) { " + " return true;" + " }" + " return false;" + " }" + "function tester(text) {" + " return test(text, /,\\s*/g);" + "}"); + QVERIFY(!result.isError()); + + result = eng.evaluate("tester(\", \\n\");"); + QVERIFY(result.toBool()); + result = eng.evaluate("tester(\", \\n\");"); + QVERIFY(result.toBool()); +} + void tst_QJSEngine::indexedAccesses() { QJSEngine engine; diff --git a/tests/auto/qml/qml.pro b/tests/auto/qml/qml.pro index 9790f09d3e..a1180e12df 100644 --- a/tests/auto/qml/qml.pro +++ b/tests/auto/qml/qml.pro @@ -9,7 +9,6 @@ PUBLICTESTS += \ qjsonbinding \ qqmlfile \ -!boot2qt { PUBLICTESTS += \ qmlmin \ qqmlcomponent \ @@ -31,14 +30,12 @@ PUBLICTESTS += \ qqmlsettings \ qqmlstatemachine \ qmldiskcache -} PRIVATETESTS += \ qqmlcpputils \ qqmldirparser \ qmlcachegen -!boot2qt { PRIVATETESTS += \ animation \ qqmlecmascript \ @@ -73,19 +70,21 @@ PRIVATETESTS += \ qv4mm \ ecmascripttests \ bindingdependencyapi -} qtHaveModule(widgets) { PUBLICTESTS += \ qjsengine \ - qjsvalue + qjsvalue \ + qwidgetsinqml } SUBDIRS += $$PUBLICTESTS SUBDIRS += $$METATYPETESTS -qtConfig(process):!boot2qt { +qtConfig(process) { # !contains(QT_CONFIG, no-qml-debug): SUBDIRS += debugger - SUBDIRS += qmllint qmlplugindump + !boot2qt { + SUBDIRS += qmllint qmlplugindump + } } qtConfig(library) { diff --git a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp index 1f80ff46d0..7e81df93b9 100644 --- a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp +++ b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp @@ -44,6 +44,7 @@ private slots: void loadGeneratedFile(); void translationExpressionSupport(); void signalHandlerParameters(); + void errorOnArgumentsInSignalHandler(); }; // A wrapper around QQmlComponent to ensure the temporary reference counts @@ -68,15 +69,20 @@ public: } }; -static bool generateCache(const QString &qmlFileName) +static bool generateCache(const QString &qmlFileName, QByteArray *capturedStderr = nullptr) { QProcess proc; - proc.setProcessChannelMode(QProcess::ForwardedChannels); + if (capturedStderr == nullptr) + proc.setProcessChannelMode(QProcess::ForwardedChannels); proc.setProgram(QLibraryInfo::location(QLibraryInfo::BinariesPath) + QDir::separator() + QLatin1String("qmlcachegen")); proc.setArguments(QStringList() << (QLatin1String("--target-architecture=") + QSysInfo::buildCpuArchitecture()) << (QLatin1String("--target-abi=") + QSysInfo::buildAbi()) << qmlFileName); proc.start(); if (!proc.waitForFinished()) return false; + + if (capturedStderr) + *capturedStderr = proc.readAllStandardError(); + if (proc.exitStatus() != QProcess::NormalExit) return false; return proc.exitCode() == 0; @@ -194,6 +200,31 @@ void tst_qmlcachegen::signalHandlerParameters() QCOMPARE(obj->property("result").toInt(), 42); } +void tst_qmlcachegen::errorOnArgumentsInSignalHandler() +{ + QTemporaryDir tempDir; + QVERIFY(tempDir.isValid()); + + const auto writeTempFile = [&tempDir](const QString &fileName, const char *contents) { + QFile f(tempDir.path() + '/' + fileName); + const bool ok = f.open(QIODevice::WriteOnly | QIODevice::Truncate); + Q_ASSERT(ok); + f.write(contents); + return f.fileName(); + }; + + const QString testFilePath = writeTempFile("test.qml", "import QtQml 2.2\n" + "QtObject {\n" + " signal mySignal(var arguments);\n" + " onMySignal: console.log(arguments);\n" + "}"); + + + QByteArray errorOutput; + QVERIFY(!generateCache(testFilePath, &errorOutput)); + QVERIFY2(errorOutput.contains("error: The use of the arguments object in signal handlers is"), errorOutput); +} + QTEST_GUILESS_MAIN(tst_qmlcachegen) #include "tst_qmlcachegen.moc" diff --git a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp index a285d13001..cdc9f29aab 100644 --- a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp +++ b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp @@ -58,6 +58,7 @@ private slots: void cacheResources(); void stableOrderOfDependentCompositeTypes(); void singletonDependency(); + void cppRegisteredSingletonDependency(); }; // A wrapper around QQmlComponent to ensure the temporary reference counts @@ -792,6 +793,66 @@ void tst_qmldiskcache::singletonDependency() } } +void tst_qmldiskcache::cppRegisteredSingletonDependency() +{ + qmlClearTypeRegistrations(); + QScopedPointer<QQmlEngine> engine(new QQmlEngine); + + QTemporaryDir tempDir; + QVERIFY(tempDir.isValid()); + + const auto writeTempFile = [&tempDir](const QString &fileName, const char *contents) { + QFile f(tempDir.path() + '/' + fileName); + const bool ok = f.open(QIODevice::WriteOnly | QIODevice::Truncate); + Q_ASSERT(ok); + f.write(contents); + return f.fileName(); + }; + + writeTempFile("MySingleton.qml", "import QtQml 2.0\npragma Singleton\nQtObject { property int value: 42 }"); + + qmlRegisterSingletonType(QUrl::fromLocalFile(tempDir.path() + QLatin1String("/MySingleton.qml")), "CppRegisteredSingletonDependency", 1, 0, "Singly"); + + const QString testFilePath = writeTempFile("main.qml", "import QtQml 2.0\nimport CppRegisteredSingletonDependency 1.0\nQtObject {\n" + " function getValue() { return Singly.value; }\n" + "}"); + + { + CleanlyLoadingComponent component(engine.data(), QUrl::fromLocalFile(testFilePath)); + QScopedPointer<QObject> obj(component.create()); + QVERIFY(!obj.isNull()); + QVariant value; + QVERIFY(QMetaObject::invokeMethod(obj.data(), "getValue", Q_RETURN_ARG(QVariant, value))); + QCOMPARE(value.toInt(), 42); + } + + const QString testFileCachePath = testFilePath + QLatin1Char('c'); + QVERIFY(QFile::exists(testFileCachePath)); + QDateTime initialCacheTimeStamp = QFileInfo(testFileCachePath).lastModified(); + + engine.reset(new QQmlEngine); + waitForFileSystem(); + + writeTempFile("MySingleton.qml", "import QtQml 2.0\npragma Singleton\nQtObject { property int value: 100 }"); + waitForFileSystem(); + + { + CleanlyLoadingComponent component(engine.data(), QUrl::fromLocalFile(testFilePath)); + QScopedPointer<QObject> obj(component.create()); + QVERIFY(!obj.isNull()); + + { + QVERIFY(QFile::exists(testFileCachePath)); + QDateTime newCacheTimeStamp = QFileInfo(testFileCachePath).lastModified(); + QVERIFY2(newCacheTimeStamp > initialCacheTimeStamp, qPrintable(newCacheTimeStamp.toString())); + } + + QVariant value; + QVERIFY(QMetaObject::invokeMethod(obj.data(), "getValue", Q_RETURN_ARG(QVariant, value))); + QCOMPARE(value.toInt(), 100); + } +} + QTEST_MAIN(tst_qmldiskcache) #include "tst_qmldiskcache.moc" 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 31009e0182..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,9 +105,8 @@ void tst_qmlplugindump::singleton() { QProcess dumper; QStringList args; - auto dir = QFileInfo(QFINDTESTDATA("tests")).dir().path(); - args << QLatin1String("tests.dumper.CompositeSingleton") << QLatin1String("1.0") - << dir; + 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/qqmlcontext/data/Singleton.qml b/tests/auto/qml/qqmlcontext/data/Singleton.qml new file mode 100644 index 0000000000..68ef5850e3 --- /dev/null +++ b/tests/auto/qml/qqmlcontext/data/Singleton.qml @@ -0,0 +1,5 @@ +pragma Singleton +import QtQml 2.0 +QtObject { + readonly property string song: "Highway to Hell" +} diff --git a/tests/auto/qml/qqmlcontext/data/contextViaClosureAfterDestruction.qml b/tests/auto/qml/qqmlcontext/data/contextViaClosureAfterDestruction.qml new file mode 100644 index 0000000000..2e0e6f20e2 --- /dev/null +++ b/tests/auto/qml/qqmlcontext/data/contextViaClosureAfterDestruction.qml @@ -0,0 +1,14 @@ +import QtQml 2.0 + +import constants 1.0 + +QtObject { + function createClosure() { + return function() { return Sing.song; } + } + function createComponentFactory() { + return function(parentObj) { + return Qt.createQmlObject('import QtQml 2.0; QtObject { property string test: "ok"; }', parentObj); + } + } +} diff --git a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp index f49fd391ac..5f57b9ebb0 100644 --- a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp +++ b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp @@ -62,6 +62,7 @@ private slots: void evalAfterInvalidate(); void qobjectDerived(); void qtbug_49232(); + void contextViaClosureAfterDestruction(); private: QQmlEngine engine; @@ -723,6 +724,33 @@ void tst_qqmlcontext::qtbug_49232() QCOMPARE(obj->property("valueTwo"), QVariant(97)); } +void tst_qqmlcontext::contextViaClosureAfterDestruction() +{ + qmlRegisterSingletonType(testFileUrl("Singleton.qml"), "constants", 1, 0, "Sing"); + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("contextViaClosureAfterDestruction.qml")); + QJSValue valueClosure; + QJSValue componentFactoryClosure; + { + QScopedPointer<QObject> obj(component.create()); + QVERIFY(!obj.isNull()); + // meta-calls don't support QJSValue return types, so do the call "by hand" + valueClosure = engine.newQObject(obj.data()).property(QStringLiteral("createClosure")).call(); + QVERIFY(valueClosure.isCallable()); + componentFactoryClosure = engine.newQObject(obj.data()).property(QStringLiteral("createComponentFactory")).call(); + QVERIFY(componentFactoryClosure.isCallable()); + } + QCOMPARE(valueClosure.call().toString(), QLatin1String("Highway to Hell")); + + QScopedPointer<QObject> parent(new QObject); + QJSValue parentWrapper = engine.newQObject(parent.data()); + QQmlEngine::setObjectOwnership(parent.data(), QQmlEngine::CppOwnership); + + QJSValue subObject = componentFactoryClosure.callWithInstance(componentFactoryClosure, QJSValueList() << parentWrapper); + QVERIFY(subObject.isError()); + QCOMPARE(subObject.toString(), QLatin1String("Error: Qt.createQmlObject(): Cannot create a component in an invalid context")); +} + QTEST_MAIN(tst_qqmlcontext) #include "tst_qqmlcontext.moc" diff --git a/tests/auto/qml/qqmlecmascript/testtypes.cpp b/tests/auto/qml/qqmlecmascript/testtypes.cpp index c4692fdf31..80da5d7e52 100644 --- a/tests/auto/qml/qqmlecmascript/testtypes.cpp +++ b/tests/auto/qml/qqmlecmascript/testtypes.cpp @@ -245,9 +245,16 @@ public: MyWorkerObject *o; }; +MyWorkerObject::~MyWorkerObject() +{ + if (m_thread) + m_thread->wait(); +} + void MyWorkerObject::doIt() { - new MyWorkerObjectThread(this); + Q_ASSERT(!m_thread); + m_thread = new MyWorkerObjectThread(this); } class MyDateClass : public QObject diff --git a/tests/auto/qml/qqmlecmascript/testtypes.h b/tests/auto/qml/qqmlecmascript/testtypes.h index eedeb66647..e15a05a00c 100644 --- a/tests/auto/qml/qqmlecmascript/testtypes.h +++ b/tests/auto/qml/qqmlecmascript/testtypes.h @@ -1532,12 +1532,17 @@ private: class MyWorkerObject : public QObject { Q_OBJECT +public: + ~MyWorkerObject(); public Q_SLOTS: void doIt(); Q_SIGNALS: void done(const QString &result); + +private: + QThread *m_thread = 0; }; class MyUnregisteredEnumTypeObject : public QObject diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 7583579de6..899f14b51d 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -7447,21 +7447,17 @@ void tst_qqmlecmascript::signalEmitted() void tst_qqmlecmascript::threadSignal() { { - QQmlComponent c(&engine, testFileUrl("threadSignal.qml")); - QObject *object = c.create(); - QVERIFY(object != 0); - QTRY_VERIFY(object->property("passed").toBool()); - delete object; + QQmlComponent c(&engine, testFileUrl("threadSignal.qml")); + QScopedPointer<QObject> object(c.create()); + QVERIFY(!object.isNull()); + QTRY_VERIFY(object->property("passed").toBool()); } { - QQmlComponent c(&engine, testFileUrl("threadSignal.2.qml")); - QObject *object = c.create(); - QVERIFY(object != 0); - QSignalSpy doneSpy(object, SIGNAL(done(QString))); - QMetaObject::invokeMethod(object, "doIt"); - QTRY_VERIFY(object->property("passed").toBool()); - QCOMPARE(doneSpy.count(), 1); - delete object; + QQmlComponent c(&engine, testFileUrl("threadSignal.2.qml")); + QScopedPointer<QObject> object(c.create()); + QVERIFY(!object.isNull()); + QMetaObject::invokeMethod(object.data(), "doIt"); + QTRY_VERIFY(object->property("passed").toBool()); } } 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/qqmlenginecleanup/qqmlenginecleanup.pro b/tests/auto/qml/qqmlenginecleanup/qqmlenginecleanup.pro index 5bcec9f5b4..90508609a8 100644 --- a/tests/auto/qml/qqmlenginecleanup/qqmlenginecleanup.pro +++ b/tests/auto/qml/qqmlenginecleanup/qqmlenginecleanup.pro @@ -6,4 +6,4 @@ include (../../shared/util.pri) SOURCES += tst_qqmlenginecleanup.cpp -QT += testlib qml +QT += testlib qml qml-private diff --git a/tests/auto/qml/qqmlenginecleanup/tst_qqmlenginecleanup.cpp b/tests/auto/qml/qqmlenginecleanup/tst_qqmlenginecleanup.cpp index d0a8b6401f..7e9a1524b0 100644 --- a/tests/auto/qml/qqmlenginecleanup/tst_qqmlenginecleanup.cpp +++ b/tests/auto/qml/qqmlenginecleanup/tst_qqmlenginecleanup.cpp @@ -31,6 +31,8 @@ #include <QtQml/qqml.h> #include <QtQml/QQmlEngine> #include <QtQml/QQmlComponent> +#include <private/qhashedstring_p.h> +#include <private/qqmlmetatype_p.h> //Separate test, because if engine cleanup attempts fail they can easily break unrelated tests class tst_qqmlenginecleanup : public QQmlDataTest @@ -44,41 +46,82 @@ private slots: void test_valueTypeProviderModule(); // QTBUG-43004 }; +// A wrapper around QQmlComponent to ensure the temporary reference counts +// on the type data as a result of the main thread <> loader thread communication +// are dropped. Regular Synchronous loading will leave us with an event posted +// to the gui thread and an extra refcount that will only be dropped after the +// event delivery. A plain sendPostedEvents() however is insufficient because +// we can't be sure that the event is posted after the constructor finished. +class CleanlyLoadingComponent : public QQmlComponent +{ +public: + CleanlyLoadingComponent(QQmlEngine *engine, const QUrl &url) + : QQmlComponent(engine, url, QQmlComponent::Asynchronous) + { waitForLoad(); } + CleanlyLoadingComponent(QQmlEngine *engine, const QString &fileName) + : QQmlComponent(engine, fileName, QQmlComponent::Asynchronous) + { waitForLoad(); } + + void waitForLoad() + { + QTRY_VERIFY(status() == QQmlComponent::Ready || status() == QQmlComponent::Error); + } +}; + void tst_qqmlenginecleanup::test_qmlClearTypeRegistrations() { //Test for preventing memory leaks is in tests/manual/qmltypememory QQmlEngine* engine; - QQmlComponent* component; + CleanlyLoadingComponent* component; QUrl testFile = testFileUrl("types.qml"); + const auto qmlTypeForTestType = []() { + return QQmlMetaType::qmlType(QStringLiteral("TestTypeCpp"), QStringLiteral("Test"), 2, 0); + }; + + QVERIFY(!qmlTypeForTestType().isValid()); qmlRegisterType<QObject>("Test", 2, 0, "TestTypeCpp"); + QVERIFY(qmlTypeForTestType().isValid()); + engine = new QQmlEngine; - component = new QQmlComponent(engine, testFile); + component = new CleanlyLoadingComponent(engine, testFile); QVERIFY(component->isReady()); - delete engine; delete component; - qmlClearTypeRegistrations(); + delete engine; + + { + auto cppType = qmlTypeForTestType(); + + qmlClearTypeRegistrations(); + QVERIFY(!qmlTypeForTestType().isValid()); + + // cppType should hold the last ref, qmlClearTypeRegistration should have wiped + // all internal references. + QCOMPARE(QQmlType::refCount(cppType.priv()), 1); + } //2nd run verifies that types can reload after a qmlClearTypeRegistrations qmlRegisterType<QObject>("Test", 2, 0, "TestTypeCpp"); + QVERIFY(qmlTypeForTestType().isValid()); engine = new QQmlEngine; - component = new QQmlComponent(engine, testFile); + component = new CleanlyLoadingComponent(engine, testFile); QVERIFY(component->isReady()); - delete engine; delete component; + delete engine; qmlClearTypeRegistrations(); + QVERIFY(!qmlTypeForTestType().isValid()); //3nd run verifies that TestTypeCpp is no longer registered engine = new QQmlEngine; - component = new QQmlComponent(engine, testFile); + component = new CleanlyLoadingComponent(engine, testFile); QVERIFY(component->isError()); QCOMPARE(component->errorString(), testFile.toString() +":33 module \"Test\" is not installed\n"); - delete engine; delete component; + delete engine; } static void cleanState(QQmlEngine **e) 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/qqmllanguage/data/MyLazyDeferredSubObject.qml b/tests/auto/qml/qqmllanguage/data/MyLazyDeferredSubObject.qml new file mode 100644 index 0000000000..f311f6b602 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/MyLazyDeferredSubObject.qml @@ -0,0 +1,6 @@ +import QtQml 2.0 +import Test 1.0 +LazyDeferredSubObject { + subObject: QtObject { objectName: 'default' } + objectName: subObject.objectName +} diff --git a/tests/auto/qml/qqmllanguage/data/lazyDeferredSubObject.qml b/tests/auto/qml/qqmllanguage/data/lazyDeferredSubObject.qml new file mode 100644 index 0000000000..2465a18320 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/lazyDeferredSubObject.qml @@ -0,0 +1,5 @@ +import QtQml 2.0 +import Test 1.0 +MyLazyDeferredSubObject { + subObject.objectName: 'custom' +} diff --git a/tests/auto/qml/qqmllanguage/testtypes.cpp b/tests/auto/qml/qqmllanguage/testtypes.cpp index bdcdaa8137..72e06d26aa 100644 --- a/tests/auto/qml/qqmllanguage/testtypes.cpp +++ b/tests/auto/qml/qqmllanguage/testtypes.cpp @@ -103,6 +103,8 @@ void registerTypes() qmlRegisterSingletonType<MyTypeObjectSingleton>("Test", 1, 0, "MyTypeObjectSingleton", myTypeObjectSingleton); qmlRegisterType<MyArrayBufferTestClass>("Test", 1, 0, "MyArrayBufferTestClass"); + + qmlRegisterType<LazyDeferredSubObject>("Test", 1, 0, "LazyDeferredSubObject"); } QVariant myCustomVariantTypeConverter(const QString &data) diff --git a/tests/auto/qml/qqmllanguage/testtypes.h b/tests/auto/qml/qqmllanguage/testtypes.h index e4a76b4324..09c6992a51 100644 --- a/tests/auto/qml/qqmllanguage/testtypes.h +++ b/tests/auto/qml/qqmllanguage/testtypes.h @@ -1349,6 +1349,26 @@ private: QObject *obj; }; +class LazyDeferredSubObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(QObject *subObject READ subObject WRITE setSubObject NOTIFY subObjectChanged FINAL) + Q_CLASSINFO("DeferredPropertyNames", "subObject"); +public: + LazyDeferredSubObject() + : obj(0) + {} + + QObject *subObject() const { if (!obj) qmlExecuteDeferred(const_cast<LazyDeferredSubObject *>(this)); return obj; } + void setSubObject(QObject *o) { if (obj == o) return; obj = o; emit subObjectChanged(); } + +signals: + void subObjectChanged(); + +private: + QObject *obj; +}; + void registerTypes(); #endif // TESTTYPES_H diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index f09c130e38..e5366b5c48 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -250,6 +250,7 @@ private slots: void propertyCacheInSync(); void rootObjectInCreationNotForSubObjects(); + void lazyDeferredSubObject(); void noChildEvents(); @@ -2152,7 +2153,7 @@ void tst_qqmllanguage::scriptStringWithoutSourceCode() qmlUnit->flags &= ~QV4::CompiledData::Unit::StaticData; td->compilationUnit()->data = qmlUnit; - const QV4::CompiledData::Object *rootObject = qmlUnit->objectAt(qmlUnit->indexOfRootObject); + const QV4::CompiledData::Object *rootObject = qmlUnit->objectAt(/*root object*/0); QCOMPARE(qmlUnit->stringAt(rootObject->inheritedTypeNameIndex), QString("MyTypeObject")); quint32 i; for (i = 0; i < rootObject->nBindings; ++i) { @@ -4314,6 +4315,21 @@ void tst_qqmllanguage::rootObjectInCreationNotForSubObjects() QVERIFY(!ddata->rootObjectInCreation); } +// QTBUG-63036 +void tst_qqmllanguage::lazyDeferredSubObject() +{ + QQmlComponent component(&engine, testFile("lazyDeferredSubObject.qml")); + VERIFY_ERRORS(0); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); + + QObject *subObject = qvariant_cast<QObject *>(object->property("subObject")); + QVERIFY(subObject); + + QCOMPARE(object->objectName(), QStringLiteral("custom")); + QCOMPARE(subObject->objectName(), QStringLiteral("custom")); +} + void tst_qqmllanguage::noChildEvents() { QQmlComponent component(&engine); diff --git a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp index e442dd1421..4089673d68 100644 --- a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp +++ b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp @@ -123,6 +123,7 @@ private slots: void about_to_be_signals(); void modify_through_delegate(); void bindingsOnGetResult(); + void stringifyModelEntry(); }; bool tst_qqmllistmodel::compareVariantList(const QVariantList &testList, QVariant object) @@ -1482,6 +1483,28 @@ void tst_qqmllistmodel::bindingsOnGetResult() QVERIFY(obj->property("success").toBool()); } +void tst_qqmllistmodel::stringifyModelEntry() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData( + "import QtQuick 2.0\n" + "Item {\n" + " ListModel {\n" + " id: testModel\n" + " objectName: \"testModel\"\n" + " ListElement { name: \"Joe\"; age: 22 }\n" + " }\n" + "}\n", QUrl()); + QScopedPointer<QObject> scene(component.create()); + QQmlListModel *model = scene->findChild<QQmlListModel*>("testModel"); + QQmlExpression expr(engine.rootContext(), model, "JSON.stringify(get(0));"); + QVariant v = expr.evaluate(); + QVERIFY2(!expr.hasError(), QTest::toString(expr.error().toString())); + const QString expectedString = QStringLiteral("{\"age\":22,\"name\":\"Joe\"}"); + QCOMPARE(v.toString(), expectedString); +} + QTEST_MAIN(tst_qqmllistmodel) #include "tst_qqmllistmodel.moc" 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/qqmltranslation/tst_qqmltranslation.cpp b/tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp index 1c9523fc38..80c54bdf8e 100644 --- a/tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp +++ b/tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp @@ -86,7 +86,7 @@ void tst_qqmltranslation::translation() << QStringLiteral("singular") << QStringLiteral("plural"); const QV4::CompiledData::Unit *unit = compilationUnit->data; - const QV4::CompiledData::Object *rootObject = unit->objectAt(unit->indexOfRootObject); + const QV4::CompiledData::Object *rootObject = unit->objectAt(/*root object*/0); const QV4::CompiledData::Binding *binding = rootObject->bindingTable(); for (quint32 i = 0; i < rootObject->nBindings; ++i, ++binding) { const QString propertyName = unit->stringAt(binding->propertyNameIndex); @@ -141,7 +141,7 @@ void tst_qqmltranslation::idTranslation() QVERIFY(compilationUnit); const QV4::CompiledData::Unit *unit = compilationUnit->data; - const QV4::CompiledData::Object *rootObject = unit->objectAt(unit->indexOfRootObject); + const QV4::CompiledData::Object *rootObject = unit->objectAt(/*root object*/0); const QV4::CompiledData::Binding *binding = rootObject->bindingTable(); for (quint32 i = 0; i < rootObject->nBindings; ++i, ++binding) { const QString propertyName = unit->stringAt(binding->propertyNameIndex); 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/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..140a3b583e 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; diff --git a/tests/auto/quick/pointerhandlers/flickableinterop/data/Slider.qml b/tests/auto/quick/pointerhandlers/flickableinterop/data/Slider.qml index d01bcf74ed..d64527cc0f 100644 --- a/tests/auto/quick/pointerhandlers/flickableinterop/data/Slider.qml +++ b/tests/auto/quick/pointerhandlers/flickableinterop/data/Slider.qml @@ -47,7 +47,7 @@ Item { property int maximumValue: 99 property alias label: label.text property alias tapEnabled: tap.enabled - property alias pressed: tap.isPressed + property alias pressed: tap.pressed signal tapped Rectangle { @@ -72,7 +72,7 @@ Item { anchors.horizontalCenterOffset: 1 radius: 5 color: "#4400FFFF" - opacity: tap.isPressed || tapFlash.running ? 1 : 0 + opacity: tap.pressed || tapFlash.running ? 1 : 0 FlashAnimation on visible { id: tapFlash } diff --git a/tests/auto/quick/pointerhandlers/flickableinterop/data/TapHandlerButton.qml b/tests/auto/quick/pointerhandlers/flickableinterop/data/TapHandlerButton.qml index 4aac89402b..9e65290d84 100644 --- a/tests/auto/quick/pointerhandlers/flickableinterop/data/TapHandlerButton.qml +++ b/tests/auto/quick/pointerhandlers/flickableinterop/data/TapHandlerButton.qml @@ -44,7 +44,7 @@ import Qt.labs.handlers 1.0 Rectangle { id: root property alias label: label.text - property alias pressed: tap.isPressed + property alias pressed: tap.pressed property bool checked: false property alias gesturePolicy: tap.gesturePolicy property alias enabled: tap.enabled @@ -54,7 +54,7 @@ Rectangle { border.color: "#9f9d9a"; border.width: 1; radius: height / 4; antialiasing: true gradient: Gradient { - GradientStop { position: 0.0; color: tap.isPressed ? "#b8b5b2" : "#efebe7" } + GradientStop { position: 0.0; color: tap.pressed ? "#b8b5b2" : "#efebe7" } GradientStop { position: 1.0; color: "#b8b5b2" } } @@ -86,7 +86,7 @@ Rectangle { Rectangle { objectName: "expandingCircle" radius: tap.timeHeld * 100 - visible: radius > 0 && tap.isPressed + visible: radius > 0 && tap.pressed border.width: 3 border.color: "cyan" color: "transparent" diff --git a/tests/auto/quick/pointerhandlers/qquickdraghandler/data/DragAnywhereSlider.qml b/tests/auto/quick/pointerhandlers/qquickdraghandler/data/DragAnywhereSlider.qml index 9b0ef81635..315da81d04 100644 --- a/tests/auto/quick/pointerhandlers/qquickdraghandler/data/DragAnywhereSlider.qml +++ b/tests/auto/quick/pointerhandlers/qquickdraghandler/data/DragAnywhereSlider.qml @@ -48,7 +48,7 @@ Item { property int maximumValue: 99 property alias label: label.text property alias tapEnabled: tap.enabled - property alias pressed: tap.isPressed + property alias pressed: tap.pressed signal tapped width: 140 height: 400 @@ -84,7 +84,7 @@ Item { anchors.horizontalCenterOffset: 1 radius: 5 color: "#4400FFFF" - opacity: tap.isPressed || tapFlash.running ? 1 : 0 + opacity: tap.pressed || tapFlash.running ? 1 : 0 FlashAnimation on visible { id: tapFlash } diff --git a/tests/auto/quick/pointerhandlers/qquickdraghandler/data/Slider.qml b/tests/auto/quick/pointerhandlers/qquickdraghandler/data/Slider.qml index 81c261fc7a..52555bc8d7 100644 --- a/tests/auto/quick/pointerhandlers/qquickdraghandler/data/Slider.qml +++ b/tests/auto/quick/pointerhandlers/qquickdraghandler/data/Slider.qml @@ -48,7 +48,7 @@ Item { property int maximumValue: 99 property alias label: label.text property alias tapEnabled: tap.enabled - property alias pressed: tap.isPressed + property alias pressed: tap.pressed signal tapped width: 140 height: 400 @@ -75,7 +75,7 @@ Item { anchors.horizontalCenterOffset: 1 radius: 5 color: "#4400FFFF" - opacity: tap.isPressed || tapFlash.running ? 1 : 0 + opacity: tap.pressed || tapFlash.running ? 1 : 0 FlashAnimation on visible { id: tapFlash } diff --git a/tests/auto/quick/pointerhandlers/qquicktaphandler/data/Button.qml b/tests/auto/quick/pointerhandlers/qquicktaphandler/data/Button.qml index 6203a6769d..63c30b4d34 100644 --- a/tests/auto/quick/pointerhandlers/qquicktaphandler/data/Button.qml +++ b/tests/auto/quick/pointerhandlers/qquicktaphandler/data/Button.qml @@ -44,7 +44,7 @@ import Qt.labs.handlers 1.0 Rectangle { id: root property alias label: label.text - property alias pressed: tap.isPressed + property alias pressed: tap.pressed property bool checked: false property alias gesturePolicy: tap.gesturePolicy signal tapped @@ -53,7 +53,7 @@ Rectangle { border.color: "#9f9d9a"; border.width: 1; radius: height / 4; antialiasing: true gradient: Gradient { - GradientStop { position: 0.0; color: tap.isPressed ? "#b8b5b2" : "#efebe7" } + GradientStop { position: 0.0; color: tap.pressed ? "#b8b5b2" : "#efebe7" } GradientStop { position: 1.0; color: "#b8b5b2" } } @@ -85,7 +85,7 @@ Rectangle { Rectangle { objectName: "expandingCircle" radius: tap.timeHeld * 100 - visible: radius > 0 && tap.isPressed + visible: radius > 0 && tap.pressed border.width: 3 border.color: "blue" color: "transparent" diff --git a/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp b/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp index 34b9fb6b07..e303495944 100644 --- a/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp +++ b/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp @@ -132,6 +132,16 @@ void tst_qquickanimatedimage::frameCount() QVERIFY(anim->isPlaying()); QCOMPARE(anim->frameCount(), 3); + QSignalSpy frameCountChangedSpy(anim, &QQuickAnimatedImage::frameCountChanged); + + const QUrl origSource = anim->source(); + anim->setSource(QUrl()); + QCOMPARE(anim->frameCount(), 0); + QCOMPARE(frameCountChangedSpy.count(), 1); + anim->setSource(origSource); + QCOMPARE(anim->frameCount(), 3); + QCOMPARE(frameCountChangedSpy.count(), 2); + delete anim; } 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/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/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp index b2d6584701..2b14842658 100644 --- a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp +++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp @@ -46,6 +46,8 @@ #include <QtGui/qguiapplication.h> #include "qplatformdefs.h" +#include <math.h> + Q_DECLARE_METATYPE(QQuickGridView::Flow) Q_DECLARE_METATYPE(Qt::LayoutDirection) Q_DECLARE_METATYPE(QQuickItemView::VerticalLayoutDirection) 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/qquickitem2/tst_qquickitem.cpp b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp index 09e89ff85f..00aa5ef726 100644 --- a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp +++ b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp @@ -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/qquicklistview/BLACKLIST b/tests/auto/quick/qquicklistview/BLACKLIST index d259c11219..bb4d9fa08a 100644 --- a/tests/auto/quick/qquicklistview/BLACKLIST +++ b/tests/auto/quick/qquicklistview/BLACKLIST @@ -5,3 +5,6 @@ osx #QTBUG-53863 [populateTransitions] opensuse-42.1 +#QTBUG-63909 +[flickBothDirections] +windows msvc-2015 64bit developer-build diff --git a/tests/auto/quick/qquicklistview/data/programmaticFlickAtBounds3.qml b/tests/auto/quick/qquicklistview/data/programmaticFlickAtBounds3.qml new file mode 100644 index 0000000000..bd913b2ce1 --- /dev/null +++ b/tests/auto/quick/qquicklistview/data/programmaticFlickAtBounds3.qml @@ -0,0 +1,19 @@ +import QtQuick 2.9 + +ListView { + id: view + width: 200; height: 400 + + property real minOvershoot + onVerticalOvershootChanged: if (verticalOvershoot < minOvershoot) minOvershoot = verticalOvershoot + + highlightRangeMode: ListView.StrictlyEnforceRange + preferredHighlightBegin: 0 + preferredHighlightEnd: 0 + + model: 10 + delegate: Rectangle { + width: 200; height: 50 + color: index % 2 ? "red" : "green" + } +} diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index 2eb87b9431..0d0f234d33 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -236,6 +236,7 @@ private slots: void QTBUG_38209(); void programmaticFlickAtBounds(); void programmaticFlickAtBounds2(); + void programmaticFlickAtBounds3(); void layoutChange(); @@ -8069,6 +8070,35 @@ void tst_QQuickListView::programmaticFlickAtBounds2() QTRY_COMPARE(listview->contentY(), qreal(100.0)); } +void tst_QQuickListView::programmaticFlickAtBounds3() +{ + QScopedPointer<QQuickView> window(createView()); + window->setSource(testFileUrl("programmaticFlickAtBounds3.qml")); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); + + QQuickListView *listview = qobject_cast<QQuickListView *>(window->rootObject()); + QVERIFY(listview); + + // flick down + listview->flick(0, 2000); + + // verify scope of the movement + QTRY_VERIFY(listview->property("minOvershoot").toReal() < qreal(-50.0)); + + // reset, and test a second time + listview->cancelFlick(); + listview->returnToBounds(); + QTRY_COMPARE(listview->contentY(), qreal(0.0)); + listview->setProperty("minOvershoot", qreal(0.0)); + + // flick down + listview->flick(0, 2000); + + // verify scope of the movement is the same + QTRY_VERIFY(listview->property("minOvershoot").toReal() < qreal(-50.0)); +} + void tst_QQuickListView::layoutChange() { RandomSortModel *model = new RandomSortModel; 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/qquickmultipointtoucharea/data/nonOverlapping.qml b/tests/auto/quick/qquickmultipointtoucharea/data/nonOverlapping.qml index 039607e26c..027f90c7f4 100644 --- a/tests/auto/quick/qquickmultipointtoucharea/data/nonOverlapping.qml +++ b/tests/auto/quick/qquickmultipointtoucharea/data/nonOverlapping.qml @@ -11,9 +11,21 @@ Rectangle { maximumTouchPoints: 2 onGestureStarted: gesture.grab() touchPoints: [ - TouchPoint { objectName: "point11" }, - TouchPoint { objectName: "point12" } + TouchPoint { id: point11; objectName: "point11" }, + TouchPoint { id: point12; objectName: "point12" } ] + Rectangle { + color: "red" + width: 10; height: 10; radius: 5 + x: point11.x - radius; y: point11.y - radius + visible: point11.pressed + } + Rectangle { + color: "tomato" + width: 10; height: 10; radius: 5 + x: point12.x - radius; y: point12.y - radius + visible: point12.pressed + } } MultiPointTouchArea { @@ -24,9 +36,27 @@ Rectangle { maximumTouchPoints: 3 onGestureStarted: gesture.grab() touchPoints: [ - TouchPoint { objectName: "point21" }, - TouchPoint { objectName: "point22" }, - TouchPoint { objectName: "point23" } + TouchPoint { id: point21; objectName: "point21" }, + TouchPoint { id: point22; objectName: "point22" }, + TouchPoint { id: point23; objectName: "point23" } ] + Rectangle { + color: "lightgreen" + width: 10; height: 10; radius: 5 + x: point21.x - radius; y: point21.y - radius + visible: point21.pressed + } + Rectangle { + color: "green" + width: 10; height: 10; radius: 5 + x: point22.x - radius; y: point22.y - radius + visible: point22.pressed + } + Rectangle { + color: "darkgreen" + width: 10; height: 10; radius: 5 + x: point23.x - radius; y: point23.y - radius + visible: point23.pressed + } } } 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/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp index b01d0c3cec..cbef0fcc8d 100644 --- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp +++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp @@ -48,6 +48,8 @@ #include "../shared/viewtestutil.h" #include "../shared/visualtestutil.h" +#include <math.h> + using namespace QQuickViewTestUtil; using namespace QQuickVisualTestUtil; 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 ac57a05176..c5c07fd28b 100644 --- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp @@ -158,6 +158,7 @@ private slots: #endif void implicitSize_data(); void implicitSize(); + void implicitSize_QTBUG_63153(); void contentSize(); void boundingRect(); void clipRect(); @@ -904,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); @@ -3388,6 +3393,18 @@ void tst_qquicktextedit::implicitSize() QCOMPARE(textObject->height(), textObject->implicitHeight()); } +void tst_qquicktextedit::implicitSize_QTBUG_63153() +{ + QString componentStr = "import QtQuick 2.0\nTextEdit { }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickTextEdit *textObject = qobject_cast<QQuickTextEdit*>(textComponent.create()); + textObject->setText("short"); + qreal shortImplicitWidth = textObject->implicitWidth(); + textObject->setText("in contrast to short this is long"); + QVERIFY2(shortImplicitWidth < textObject->implicitWidth(), qPrintable(QString("%1 < %2").arg(textObject->implicitWidth()).arg(shortImplicitWidth))); +} + void tst_qquicktextedit::contentSize() { QString componentStr = "import QtQuick 2.0\nTextEdit { width: 75; height: 16; font.pixelSize: 10 }"; diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index d4b505a74a..9620d81357 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -1270,6 +1270,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); @@ -2349,6 +2353,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) @@ -2417,13 +2424,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); @@ -2604,7 +2611,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 9b7740646a..65333e166e 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 a33c5eae96..32842a9fde 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 537fe99012..c0db9c733d 100644 --- a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp +++ b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp @@ -368,6 +368,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(); diff --git a/tests/manual/pointer/content/MultiButton.qml b/tests/manual/pointer/content/MultiButton.qml index 4a737dc9b0..fec8462ea0 100644 --- a/tests/manual/pointer/content/MultiButton.qml +++ b/tests/manual/pointer/content/MultiButton.qml @@ -44,7 +44,7 @@ import Qt.labs.handlers 1.0 Rectangle { id: root property alias label: label.text - property alias pressed: tap.isPressed + property alias pressed: tap.pressed property bool checked: false property alias gesturePolicy: tap.gesturePolicy signal tapped @@ -53,7 +53,7 @@ Rectangle { border.color: "#9f9d9a"; border.width: 1; radius: height / 4; antialiasing: true gradient: Gradient { - GradientStop { position: 0.0; color: tap.isPressed ? "#b8b5b2" : "#efebe7" } + GradientStop { position: 0.0; color: tap.pressed ? "#b8b5b2" : "#efebe7" } GradientStop { position: 1.0; color: "#b8b5b2" } } diff --git a/tests/manual/pointer/content/Slider.qml b/tests/manual/pointer/content/Slider.qml index 809e4c5f1c..d38805023a 100644 --- a/tests/manual/pointer/content/Slider.qml +++ b/tests/manual/pointer/content/Slider.qml @@ -47,7 +47,7 @@ Item { property int maximumValue: 99 property alias label: label.text property alias tapEnabled: tap.enabled - property alias pressed: tap.isPressed + property alias pressed: tap.pressed signal tapped DragHandler { @@ -82,7 +82,7 @@ Item { anchors.horizontalCenterOffset: 1 radius: 5 color: "#4400FFFF" - opacity: tap.isPressed || tapFlash.running ? 1 : 0 + opacity: tap.pressed || tapFlash.running ? 1 : 0 FlashAnimation on visible { id: tapFlash } diff --git a/tests/manual/pointer/content/TapHandlerButton.qml b/tests/manual/pointer/content/TapHandlerButton.qml index e40c539686..6724ea896d 100644 --- a/tests/manual/pointer/content/TapHandlerButton.qml +++ b/tests/manual/pointer/content/TapHandlerButton.qml @@ -48,7 +48,7 @@ Item { property alias text: buttonLabel.text property alias label: buttonLabel signal clicked - property alias pressed: th.isPressed + property alias pressed: th.pressed implicitHeight: Math.max(Screen.pixelDensity * 7, buttonLabel.implicitHeight * 1.2) implicitWidth: Math.max(Screen.pixelDensity * 11, buttonLabel.implicitWidth * 1.3) height: implicitHeight diff --git a/tests/manual/pointer/tapHandler.qml b/tests/manual/pointer/tapHandler.qml index 5dac99a899..fcd7dfd443 100644 --- a/tests/manual/pointer/tapHandler.qml +++ b/tests/manual/pointer/tapHandler.qml @@ -50,7 +50,7 @@ Item { id: rect anchors.fill: parent; anchors.margins: 40 border.width: 3; border.color: "transparent" - color: handler.isPressed ? "lightsteelblue" : "darkgrey" + color: handler.pressed ? "lightsteelblue" : "darkgrey" TapHandler { id: handler @@ -111,7 +111,7 @@ Item { Rectangle { id: expandingCircle radius: handler.timeHeld * 100 - visible: radius > 0 && handler.isPressed + visible: radius > 0 && handler.pressed border.width: 3 border.color: borderBlink.blinkColor color: "transparent" |