diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-01-29 16:41:59 +0100 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-01-29 16:52:58 +0100 |
commit | b684ba219493fb7b0108ae367d6d033aaa28053b (patch) | |
tree | f1fec8922da198e231416b50ef8f441ef6db065b /tests | |
parent | 97a5cf86345fd72cdff83c03664c19a8f5cdf79a (diff) | |
parent | 8354851b628ebae567a9125cbd0ba69268470c1b (diff) |
Merge remote-tracking branch 'origin/dev' into wip/cmake
Conflicts:
dependencies.yaml
Change-Id: Ie3e9dc62031a85e5e81cbdf04694b95159d49fca
Diffstat (limited to 'tests')
94 files changed, 1190 insertions, 96 deletions
diff --git a/tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp b/tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp index d2cfd3897a..1c1f785560 100644 --- a/tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp +++ b/tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp @@ -88,8 +88,7 @@ public: QList<LogEntry> logBuffer; protected: - //inherited from QQmlDebugClient - void messageReceived(const QByteArray &data); + void messageReceived(const QByteArray &data) override; signals: void debugOutput(); diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp index 0ebf43eb6f..12befeb1ec 100644 --- a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp +++ b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp @@ -280,11 +280,11 @@ void tst_QQmlEngineDebugService::recursiveObjectTest( } else { QCOMPARE(ref.name, QString("<unknown value>")); } - } else if (pmeta.type() < QVariant::UserType && pmeta.userType() != QMetaType::QVariant) { + } else if (pmeta.userType() < QMetaType::User && pmeta.userType() != QMetaType::QVariant) { const QVariant expected = pmeta.read(o); QVERIFY2(p.value == expected, QString::fromLatin1("%1 != %2. Details: %3/%4/%5/%6") .arg(QTest::toString(p.value)).arg(QTest::toString(expected)).arg(p.name) - .arg(p.valueTypeName).arg(pmeta.type()).arg(pmeta.userType()).toUtf8()); + .arg(p.valueTypeName).arg(pmeta.userType()).arg(pmeta.userType()).toUtf8()); } if (p.name == "parent") diff --git a/tests/auto/qml/ecmascripttests/BLACKLIST b/tests/auto/qml/ecmascripttests/BLACKLIST new file mode 100644 index 0000000000..1ed255e9e2 --- /dev/null +++ b/tests/auto/qml/ecmascripttests/BLACKLIST @@ -0,0 +1,4 @@ +[runInterpreted] +macos ci +[runJitted] +macos diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp index 66a526fda8..7b59087a72 100644 --- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp @@ -264,6 +264,8 @@ private slots: void printCircularArray(); void typedArraySet(); + void uiLanguage(); + public: Q_INVOKABLE QJSValue throwingCppMethod1(); Q_INVOKABLE void throwingCppMethod2(); @@ -1543,7 +1545,7 @@ void tst_QJSEngine::valueConversion_QVariant() { QVariant tmp1; QVariant tmp2(QMetaType::QVariant, &tmp1); - QCOMPARE(QMetaType::Type(tmp2.type()), QMetaType::QVariant); + QCOMPARE(QMetaType::Type(tmp2.userType()), QMetaType::QVariant); QJSValue val1 = eng.toScriptValue(tmp1); QJSValue val2 = eng.toScriptValue(tmp2); @@ -1558,9 +1560,9 @@ void tst_QJSEngine::valueConversion_QVariant() QVariant tmp1(123); QVariant tmp2(QMetaType::QVariant, &tmp1); QVariant tmp3(QMetaType::QVariant, &tmp2); - QCOMPARE(QMetaType::Type(tmp1.type()), QMetaType::Int); - QCOMPARE(QMetaType::Type(tmp2.type()), QMetaType::QVariant); - QCOMPARE(QMetaType::Type(tmp3.type()), QMetaType::QVariant); + QCOMPARE(QMetaType::Type(tmp1.userType()), QMetaType::Int); + QCOMPARE(QMetaType::Type(tmp2.userType()), QMetaType::QVariant); + QCOMPARE(QMetaType::Type(tmp3.userType()), QMetaType::QVariant); QJSValue val1 = eng.toScriptValue(tmp2); QJSValue val2 = eng.toScriptValue(tmp3); @@ -5143,6 +5145,33 @@ void tst_QJSEngine::typedArraySet() } } +void tst_QJSEngine::uiLanguage() +{ + { + QJSEngine engine; + + QVERIFY(!engine.globalObject().hasProperty("Qt")); + + engine.installExtensions(QJSEngine::TranslationExtension); + QVERIFY(engine.globalObject().hasProperty("Qt")); + QVERIFY(engine.globalObject().property("Qt").hasProperty("uiLanguage")); + + engine.setUiLanguage("Blah"); + QCOMPARE(engine.globalObject().property("Qt").property("uiLanguage").toString(), "Blah"); + + engine.evaluate("Qt.uiLanguage = \"another\""); + QCOMPARE(engine.globalObject().property("Qt").property("uiLanguage").toString(), "another"); + } + + { + QQmlEngine qmlEngine; + QVERIFY(qmlEngine.globalObject().hasProperty("Qt")); + QVERIFY(qmlEngine.globalObject().property("Qt").hasProperty("uiLanguage")); + qmlEngine.setUiLanguage("Blah"); + QCOMPARE(qmlEngine.globalObject().property("Qt").property("uiLanguage").toString(), "Blah"); + } +} + QTEST_MAIN(tst_QJSEngine) #include "tst_qjsengine.moc" diff --git a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp index 95f554776f..d6e85f973f 100644 --- a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp +++ b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp @@ -1081,7 +1081,7 @@ void tst_QJSValue::toVariant() // We can't roundtrip a QRegExp this way, as toVariant() has no information on whether we // want QRegExp or QRegularExpression. It will always create a QRegularExpression. - QCOMPARE(var.type(), QMetaType::QRegularExpression); + QCOMPARE(var.userType(), QMetaType::QRegularExpression); QRegularExpression result = var.toRegularExpression(); QCOMPARE(result.pattern(), rx.pattern()); QCOMPARE(result.patternOptions() & QRegularExpression::CaseInsensitiveOption, 0); @@ -1134,7 +1134,7 @@ void tst_QJSValue::toVariant() QVERIFY(array.isArray()); QCOMPARE(array.property("length").toInt(), 2); QVariant ret = array.toVariant(); - QCOMPARE(ret.type(), QVariant::List); + QCOMPARE(ret.userType(), QVariant::List); QVariantList listOut = ret.toList(); QCOMPARE(listOut.size(), listIn.size()); for (int i = 0; i < listIn.size(); ++i) diff --git a/tests/auto/qml/qml.pro b/tests/auto/qml/qml.pro index d9f3fdf1b8..7a2ba10096 100644 --- a/tests/auto/qml/qml.pro +++ b/tests/auto/qml/qml.pro @@ -12,7 +12,6 @@ PUBLICTESTS += \ qqmlfileselector PUBLICTESTS += \ - qmlformat \ qqmlcomponent \ qqmlconsole \ qqmlengine \ @@ -91,7 +90,7 @@ SUBDIRS += $$METATYPETESTS qtConfig(process) { qtConfig(qml-debug): SUBDIRS += debugger !boot2qt { - SUBDIRS += qmllint qmlplugindump + SUBDIRS += qmlformat qmllint qmlplugindump } } diff --git a/tests/auto/qml/qmlformat/qmlformat.pro b/tests/auto/qml/qmlformat/qmlformat.pro index 9f8a44bc09..a6ae391711 100644 --- a/tests/auto/qml/qmlformat/qmlformat.pro +++ b/tests/auto/qml/qmlformat/qmlformat.pro @@ -3,6 +3,7 @@ TARGET = tst_qmlformat macos:CONFIG -= app_bundle SOURCES += tst_qmlformat.cpp +DEFINES += SRCDIR=\\\"$$PWD\\\" include (../../shared/util.pri) diff --git a/tests/auto/qml/qmlformat/tst_qmlformat.cpp b/tests/auto/qml/qmlformat/tst_qmlformat.cpp index 7ad9c99d83..95c8e88f21 100644 --- a/tests/auto/qml/qmlformat/tst_qmlformat.cpp +++ b/tests/auto/qml/qmlformat/tst_qmlformat.cpp @@ -42,11 +42,22 @@ private Q_SLOTS: void testFormat(); void testFormatNoSort(); + +#if !defined(QTEST_CROSS_COMPILED) // sources not available when cross compiled + void testExample(); + void testExample_data(); +#endif + private: QString readTestFile(const QString &path); QString runQmlformat(const QString &fileToFormat, bool sortImports, bool shouldSucceed); QString m_qmlformatPath; + QStringList m_excludedDirs; + QStringList m_invalidFiles; + + QStringList findFiles(const QDir &); + bool isInvalidFile(const QFileInfo &fileName) const; }; void TestQmlformat::initTestCase() @@ -60,6 +71,91 @@ void TestQmlformat::initTestCase() QString message = QStringLiteral("qmlformat executable not found (looked for %0)").arg(m_qmlformatPath); QFAIL(qPrintable(message)); } + + // Add directories you want excluded here + + // These snippets are not expected to run on their own. + m_excludedDirs << "doc/src/snippets/qml/visualdatamodel_rootindex"; + m_excludedDirs << "doc/src/snippets/qml/qtbinding"; + m_excludedDirs << "doc/src/snippets/qml/imports"; + m_excludedDirs << "doc/src/snippets/qtquick1/visualdatamodel_rootindex"; + m_excludedDirs << "doc/src/snippets/qtquick1/qtbinding"; + m_excludedDirs << "doc/src/snippets/qtquick1/imports"; + m_excludedDirs << "tests/manual/v4"; + m_excludedDirs << "tests/auto/qml/ecmascripttests"; + m_excludedDirs << "tests/auto/qml/qmllint"; + + // Add invalid files (i.e. files with syntax errors) + m_invalidFiles << "tests/auto/quick/qquickloader/data/InvalidSourceComponent.qml"; + m_invalidFiles << "tests/auto/qml/qqmllanguage/data/signal.2.qml"; + m_invalidFiles << "tests/auto/qml/qqmllanguage/data/signal.3.qml"; + m_invalidFiles << "tests/auto/qml/qqmllanguage/data/signal.5.qml"; + m_invalidFiles << "tests/auto/qml/qqmllanguage/data/property.4.qml"; + m_invalidFiles << "tests/auto/qml/qqmllanguage/data/empty.qml"; + m_invalidFiles << "tests/auto/qml/qqmllanguage/data/missingObject.qml"; + m_invalidFiles << "tests/auto/qml/qqmllanguage/data/insertedSemicolon.1.qml"; + m_invalidFiles << "tests/auto/qml/qqmllanguage/data/nonexistantProperty.5.qml"; + m_invalidFiles << "tests/auto/qml/qqmllanguage/data/invalidRoot.1.qml"; + m_invalidFiles << "tests/auto/qml/qqmllanguage/data/invalidQmlEnumValue.1.qml"; + m_invalidFiles << "tests/auto/qml/qqmllanguage/data/invalidQmlEnumValue.2.qml"; + m_invalidFiles << "tests/auto/qml/qquickfolderlistmodel/data/dummy.qml"; + m_invalidFiles << "tests/auto/qml/qqmlecmascript/data/stringParsing_error.1.qml"; + m_invalidFiles << "tests/auto/qml/qqmlecmascript/data/stringParsing_error.2.qml"; + m_invalidFiles << "tests/auto/qml/qqmlecmascript/data/stringParsing_error.3.qml"; + m_invalidFiles << "tests/auto/qml/qqmlecmascript/data/stringParsing_error.4.qml"; + m_invalidFiles << "tests/auto/qml/qqmlecmascript/data/stringParsing_error.5.qml"; + m_invalidFiles << "tests/auto/qml/qqmlecmascript/data/stringParsing_error.6.qml"; + m_invalidFiles << "tests/auto/qml/qqmlecmascript/data/numberParsing_error.1.qml"; + m_invalidFiles << "tests/auto/qml/qqmlecmascript/data/numberParsing_error.2.qml"; + m_invalidFiles << "tests/auto/qml/qqmlecmascript/data/incrDecrSemicolon_error1.qml"; + m_invalidFiles << "tests/auto/qml/debugger/qqmlpreview/data/broken.qml"; + m_invalidFiles << "tests/auto/qml/qqmllanguage/data/fuzzed.2.qml"; + m_invalidFiles << "tests/auto/qml/qqmllanguage/data/fuzzed.3.qml"; + m_invalidFiles << "tests/auto/qml/qqmllanguage/data/requiredProperties.2.qml"; + m_invalidFiles << "tests/auto/qml/qqmllanguage/data/requiredProperties.3.qml"; + m_invalidFiles << "tests/auto/qml/qqmllanguage/data/nullishCoalescing_LHS_And.qml"; + m_invalidFiles << "tests/auto/qml/qqmllanguage/data/nullishCoalescing_LHS_And.qml"; + m_invalidFiles << "tests/auto/qml/qqmllanguage/data/nullishCoalescing_LHS_Or.qml"; + m_invalidFiles << "tests/auto/qml/qqmllanguage/data/nullishCoalescing_RHS_And.qml"; + m_invalidFiles << "tests/auto/qml/qqmllanguage/data/nullishCoalescing_RHS_Or.qml"; + m_invalidFiles << "tests/auto/qml/qqmllanguage/data/typeAnnotations.2.qml"; + m_invalidFiles << "tests/auto/qml/qqmlparser/data/disallowedtypeannotations/qmlnestedfunction.qml"; +} + +QStringList TestQmlformat::findFiles(const QDir &d) +{ + for (int ii = 0; ii < m_excludedDirs.count(); ++ii) { + QString s = m_excludedDirs.at(ii); + if (d.absolutePath().endsWith(s)) + return QStringList(); + } + + QStringList rv; + + QStringList files = d.entryList(QStringList() << QLatin1String("*.qml"), + QDir::Files); + foreach (const QString &file, files) { + rv << d.absoluteFilePath(file); + } + + QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot | + QDir::NoSymLinks); + foreach (const QString &dir, dirs) { + QDir sub = d; + sub.cd(dir); + rv << findFiles(sub); + } + + return rv; +} + +bool TestQmlformat::isInvalidFile(const QFileInfo &fileName) const +{ + for (const QString &invalidFile : m_invalidFiles) { + if (fileName.absoluteFilePath().endsWith(invalidFile)) + return true; + } + return false; } QString TestQmlformat::readTestFile(const QString &path) @@ -74,18 +170,46 @@ QString TestQmlformat::readTestFile(const QString &path) void TestQmlformat::testFormat() { - QCOMPARE(runQmlformat("Example1.qml", true, true), readTestFile("Example1.formatted.qml")); + QCOMPARE(runQmlformat(testFile("Example1.qml"), true, true), readTestFile("Example1.formatted.qml")); } void TestQmlformat::testFormatNoSort() { - QCOMPARE(runQmlformat("Example1.qml", false, true), readTestFile("Example1.formatted.nosort.qml")); + QCOMPARE(runQmlformat(testFile("Example1.qml"), false, true), readTestFile("Example1.formatted.nosort.qml")); } +#if !defined(QTEST_CROSS_COMPILED) // sources not available when cross compiled +void TestQmlformat::testExample_data() +{ + QTest::addColumn<QString>("file"); + + QString examples = QLatin1String(SRCDIR) + "/../../../../examples/"; + QString tests = QLatin1String(SRCDIR) + "/../../../../tests/"; + + QStringList files; + files << findFiles(QDir(examples)); + files << findFiles(QDir(tests)); + + for (const QString &file : files) + QTest::newRow(qPrintable(file)) << file; +} +#endif + +#if !defined(QTEST_CROSS_COMPILED) // sources not available when cross compiled +void TestQmlformat::testExample() +{ + QFETCH(QString, file); + QString output = runQmlformat(file, true, !isInvalidFile(file)); + + if (!isInvalidFile(file)) + QVERIFY(!output.isEmpty()); +} +#endif + QString TestQmlformat::runQmlformat(const QString &fileToFormat, bool sortImports, bool shouldSucceed) { QStringList args; - args << testFile(fileToFormat); + args << fileToFormat; if (!sortImports) args << "-n"; diff --git a/tests/auto/qml/qqmlapplicationengine/data/i18n/qml_de_CH.qm b/tests/auto/qml/qqmlapplicationengine/data/i18n/qml_de_CH.qm Binary files differnew file mode 100644 index 0000000000..926d74f905 --- /dev/null +++ b/tests/auto/qml/qqmlapplicationengine/data/i18n/qml_de_CH.qm diff --git a/tests/auto/qml/qqmlapplicationengine/data/i18n/qml_de_CH.ts b/tests/auto/qml/qqmlapplicationengine/data/i18n/qml_de_CH.ts new file mode 100644 index 0000000000..2105cfb2cf --- /dev/null +++ b/tests/auto/qml/qqmlapplicationengine/data/i18n/qml_de_CH.ts @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1" language="de_CH" sourcelanguage="en"> +<context> + <name>loadTranslation</name> + <message> + <source>translate it</source> + <translation>Grüezi</translation> + </message> +</context> +</TS> diff --git a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp index 5e855efe1a..b019ff4535 100644 --- a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp +++ b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp @@ -53,6 +53,7 @@ private slots: void removeObjectsWhenDestroyed(); void loadTranslation_data(); void loadTranslation(); + void translationChange(); void setInitialProperties(); void failureToLoadTriggersWarningSignal(); @@ -278,6 +279,28 @@ void tst_qqmlapplicationengine::loadTranslation() QCOMPARE(rootObject->property("translation").toString(), translation); } +void tst_qqmlapplicationengine::translationChange() +{ + if (QLocale().language() == QLocale::SwissGerman) { + QSKIP("Skipping this when running under the Swiss locale as we would always load translation."); + } + + QQmlApplicationEngine engine(testFileUrl("loadTranslation.qml")); + + QCOMPARE(engine.uiLanguage(), QLocale().bcp47Name()); + + QObject *rootObject = engine.rootObjects().first(); + QVERIFY(rootObject); + + QCOMPARE(rootObject->property("translation").toString(), "translated"); + + engine.setUiLanguage("de_CH"); + QCOMPARE(rootObject->property("translation").toString(), QString::fromUtf8("Gr\u00FCezi")); + + engine.setUiLanguage(QString()); + QCOMPARE(rootObject->property("translation").toString(), "translate it"); +} + void tst_qqmlapplicationengine::setInitialProperties() { QQmlApplicationEngine test {}; diff --git a/tests/auto/qml/qqmlecmascript/testtypes.h b/tests/auto/qml/qqmlecmascript/testtypes.h index 3233e7f105..03e3262e7b 100644 --- a/tests/auto/qml/qqmlecmascript/testtypes.h +++ b/tests/auto/qml/qqmlecmascript/testtypes.h @@ -36,7 +36,6 @@ #include <QtCore/qregularexpression.h> #include <QtQml/qqmllist.h> #include <QtCore/qrect.h> -#include <QtGui/qmatrix.h> #include <QtGui/qcolor.h> #include <QtGui/qvector3d.h> #include <QtGui/QFont> diff --git a/tests/auto/qml/qqmlengine/data/uiLanguage.qml b/tests/auto/qml/qqmlengine/data/uiLanguage.qml new file mode 100644 index 0000000000..bc20351245 --- /dev/null +++ b/tests/auto/qml/qqmlengine/data/uiLanguage.qml @@ -0,0 +1,9 @@ +import QtQml 2.15 +QtObject { + property string chosenLanguage: Qt.uiLanguage + property string textToTranslate: { + numberOfTranslationBindingEvaluations++; + return qsTr("Translate me maybe"); + } + property int numberOfTranslationBindingEvaluations: 0 +} diff --git a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp index d782df3e7f..ab4c083b65 100644 --- a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp +++ b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp @@ -84,6 +84,7 @@ private slots: void aggressiveGc(); void cachedGetterLookup_qtbug_75335(); void createComponentOnSingletonDestruction(); + void uiLanguage(); public slots: QObject *createAQObjectForOwnershipTest () @@ -1175,6 +1176,38 @@ void tst_qqmlengine::createComponentOnSingletonDestruction() QVERIFY(obj); } +void tst_qqmlengine::uiLanguage() +{ + QQmlEngine engine; + + QObject::connect(&engine, &QJSEngine::uiLanguageChanged, [&engine]() { + engine.retranslate(); + }); + + QSignalSpy uiLanguageChangeSpy(&engine, SIGNAL(uiLanguageChanged())); + + QQmlComponent component(&engine, testFileUrl("uiLanguage.qml")); + + QTest::ignoreMessage(QtMsgType::QtWarningMsg, (component.url().toString() + ":2:1: QML QtObject: Binding loop detected for property \"textToTranslate\"").toLatin1()); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); + + QVERIFY(engine.uiLanguage().isEmpty()); + QCOMPARE(object->property("numberOfTranslationBindingEvaluations").toInt(), 1); + + QTest::ignoreMessage(QtMsgType::QtWarningMsg, (component.url().toString() + ":2:1: QML QtObject: Binding loop detected for property \"textToTranslate\"").toLatin1()); + engine.setUiLanguage("TestLanguage"); + QCOMPARE(object->property("numberOfTranslationBindingEvaluations").toInt(), 2); + QCOMPARE(object->property("chosenLanguage").toString(), "TestLanguage"); + + + QTest::ignoreMessage(QtMsgType::QtWarningMsg, (component.url().toString() + ":2:1: QML QtObject: Binding loop detected for property \"textToTranslate\"").toLatin1()); + engine.evaluate("Qt.uiLanguage = \"anotherLanguage\""); + QCOMPARE(engine.uiLanguage(), QString("anotherLanguage")); + QCOMPARE(object->property("numberOfTranslationBindingEvaluations").toInt(), 3); + QCOMPARE(object->property("chosenLanguage").toString(), "anotherLanguage"); +} + QTEST_MAIN(tst_qqmlengine) #include "tst_qqmlengine.moc" diff --git a/tests/auto/qml/qqmllanguage/data/InlineComponentBase.qml b/tests/auto/qml/qqmllanguage/data/InlineComponentBase.qml new file mode 100644 index 0000000000..0b297a7779 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/InlineComponentBase.qml @@ -0,0 +1,9 @@ +import QtQml 2.15 + +QtObject { + property alias i: icInstance.i + component IC : QtObject { + property int i: 42 + } + property QtObject ic: IC {id: icInstance} +} diff --git a/tests/auto/qml/qqmllanguage/data/InlineComponentChild.qml b/tests/auto/qml/qqmllanguage/data/InlineComponentChild.qml new file mode 100644 index 0000000000..49a90ab7da --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/InlineComponentChild.qml @@ -0,0 +1,7 @@ +import QtQml 2.15 + +InlineComponentBase { + component IC : QtObject { + property int i: 13 + } +} diff --git a/tests/auto/qml/qqmllanguage/data/InlineComponentProvider.qml b/tests/auto/qml/qqmllanguage/data/InlineComponentProvider.qml new file mode 100644 index 0000000000..6058e32b2f --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/InlineComponentProvider.qml @@ -0,0 +1,9 @@ +import QtQuick 2.15 + +Item { + component StyledRectangle: Rectangle { + width: 24 + height: 24 + color: "red" + } +} diff --git a/tests/auto/qml/qqmllanguage/data/InlineComponentProvider2.qml b/tests/auto/qml/qqmllanguage/data/InlineComponentProvider2.qml new file mode 100644 index 0000000000..b5a0efaccf --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/InlineComponentProvider2.qml @@ -0,0 +1,10 @@ +import QtQuick 2.15 + +Item { + property color myColor: "red" + component StyledRectangle: Rectangle { + width: 24 + height: 24 + color: myColor + } +} diff --git a/tests/auto/qml/qqmllanguage/data/InlineComponentProvider3.qml b/tests/auto/qml/qqmllanguage/data/InlineComponentProvider3.qml new file mode 100644 index 0000000000..9a4f1fd272 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/InlineComponentProvider3.qml @@ -0,0 +1,11 @@ +import QtQuick 2.15 + +Item { + Item { + component StyledRectangle: Rectangle { + width: 24 + height: 24 + color: "red" + } + } +} diff --git a/tests/auto/qml/qqmllanguage/data/InlineComponentProviderChild.qml b/tests/auto/qml/qqmllanguage/data/InlineComponentProviderChild.qml new file mode 100644 index 0000000000..ddb55e55e6 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/InlineComponentProviderChild.qml @@ -0,0 +1 @@ +InlineComponentProvider {} diff --git a/tests/auto/qml/qqmllanguage/data/InlineComponentReexporter.qml b/tests/auto/qml/qqmllanguage/data/InlineComponentReexporter.qml new file mode 100644 index 0000000000..24bf6f771e --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/InlineComponentReexporter.qml @@ -0,0 +1,8 @@ +import QtQuick 2.14 + +QtObject { + component StyledRectangle: InlineComponentProvider.StyledRectangle { + color: "green" + } + +} diff --git a/tests/auto/qml/qqmllanguage/data/icCycleViaProperty.qml b/tests/auto/qml/qqmllanguage/data/icCycleViaProperty.qml new file mode 100644 index 0000000000..c5aa4cfdf5 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/icCycleViaProperty.qml @@ -0,0 +1,9 @@ +import QtQuick 2.15 + +Item { + component A : Item { + property var test: B {} + } + component B: A {} + A {} +} diff --git a/tests/auto/qml/qqmllanguage/data/icSimpleCycle.qml b/tests/auto/qml/qqmllanguage/data/icSimpleCycle.qml new file mode 100644 index 0000000000..69e74f7c96 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/icSimpleCycle.qml @@ -0,0 +1,6 @@ +import QtQuick 2.15 + +Item { + component A : B {} + component B: A {} +} diff --git a/tests/auto/qml/qqmllanguage/data/inlineComponentOrder.qml b/tests/auto/qml/qqmllanguage/data/inlineComponentOrder.qml new file mode 100644 index 0000000000..a96f68e56a --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/inlineComponentOrder.qml @@ -0,0 +1,20 @@ +import QtQuick 2.15 + +Item { + width: 600 + height: 480 + IC2 { + objectName: "icInstance" + anchors.centerIn: parent + } + + component IC2: IC1 {} + component IC0: Rectangle { + height: 200 + width: 200 + color: "blue" + } + component IC1: IC0 {} + + +} diff --git a/tests/auto/qml/qqmllanguage/data/inlineComponentUser1.qml b/tests/auto/qml/qqmllanguage/data/inlineComponentUser1.qml new file mode 100644 index 0000000000..8968a20112 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/inlineComponentUser1.qml @@ -0,0 +1,13 @@ +import QtQuick 2.14 + +Item { + width: 600 + height: 480 + property InlineComponentProvider.StyledRectangle myProp: InlineComponentProvider.StyledRectangle {} + InlineComponentProvider.StyledRectangle { + objectName: "icInstance" + anchors.centerIn: parent + color: "blue" + } + +} diff --git a/tests/auto/qml/qqmllanguage/data/inlineComponentUser2.qml b/tests/auto/qml/qqmllanguage/data/inlineComponentUser2.qml new file mode 100644 index 0000000000..dc6e3850db --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/inlineComponentUser2.qml @@ -0,0 +1,10 @@ +import QtQuick 2.14 + +Item { + width: 600 + height: 480 + property InlineComponentProvider.StyledRectangle myProp: InlineComponentReexporter.StyledRectangle { + objectName: "icInstance" + } + +} diff --git a/tests/auto/qml/qqmllanguage/data/inlineComponentUser3.qml b/tests/auto/qml/qqmllanguage/data/inlineComponentUser3.qml new file mode 100644 index 0000000000..c57c4cad01 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/inlineComponentUser3.qml @@ -0,0 +1,16 @@ +import QtQuick 2.14 + +Item { + width: 600 + height: 480 + component StyledRectangle: Rectangle { + width: 24 + height: 24 + color: "blue" + } + StyledRectangle { + objectName: "icInstance" + anchors.centerIn: parent + } + +} diff --git a/tests/auto/qml/qqmllanguage/data/inlineComponentUser4.qml b/tests/auto/qml/qqmllanguage/data/inlineComponentUser4.qml new file mode 100644 index 0000000000..9f3903c8df --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/inlineComponentUser4.qml @@ -0,0 +1,12 @@ +import QtQuick 2.14 + +Item { + width: 600 + height: 480 + property color myColor: "blue" + InlineComponentProvider2.StyledRectangle { + objectName: "icInstance" + anchors.centerIn: parent + } + +} diff --git a/tests/auto/qml/qqmllanguage/data/inlineComponentUser5.qml b/tests/auto/qml/qqmllanguage/data/inlineComponentUser5.qml new file mode 100644 index 0000000000..150d0c2ded --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/inlineComponentUser5.qml @@ -0,0 +1,11 @@ +import QtQuick 2.15 + +Item { + width: 600 + height: 480 + property var test: InlineComponentProvider3.StyledRectangle { + objectName: "icInstance" + anchors.centerIn: parent + } + +} diff --git a/tests/auto/qml/qqmllanguage/data/invalidRoot.4.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidRoot.4.errors.txt index 3b90f573a2..41cb0eaac1 100644 --- a/tests/auto/qml/qqmllanguage/data/invalidRoot.4.errors.txt +++ b/tests/auto/qml/qqmllanguage/data/invalidRoot.4.errors.txt @@ -1 +1 @@ -3:1:Bar.Item - Bar is not a namespace +3:1:Bar.Item - Bar is neither a type nor a namespace diff --git a/tests/auto/qml/qqmllanguage/data/invalidTypeName.4.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidTypeName.4.errors.txt index 3b90f573a2..41cb0eaac1 100644 --- a/tests/auto/qml/qqmllanguage/data/invalidTypeName.4.errors.txt +++ b/tests/auto/qml/qqmllanguage/data/invalidTypeName.4.errors.txt @@ -1 +1 @@ -3:1:Bar.Item - Bar is not a namespace +3:1:Bar.Item - Bar is neither a type nor a namespace diff --git a/tests/auto/qml/qqmllanguage/data/nestedIC.qml b/tests/auto/qml/qqmllanguage/data/nestedIC.qml new file mode 100644 index 0000000000..04cef64d54 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/nestedIC.qml @@ -0,0 +1,7 @@ +import QtQuick 2.15 + +Item { + component Outer : Item { + component Inner : Item {} + } +} diff --git a/tests/auto/qml/qqmllanguage/data/nonExistingICUser1.qml b/tests/auto/qml/qqmllanguage/data/nonExistingICUser1.qml new file mode 100644 index 0000000000..a07a6a9838 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/nonExistingICUser1.qml @@ -0,0 +1,5 @@ +import QtQuick 2.15 + +Item { + property InlineComponentProvider.NonExisting myProp +} diff --git a/tests/auto/qml/qqmllanguage/data/nonExistingICUser2.qml b/tests/auto/qml/qqmllanguage/data/nonExistingICUser2.qml new file mode 100644 index 0000000000..5c24962def --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/nonExistingICUser2.qml @@ -0,0 +1,5 @@ +import QtQuick 2.15 + +Item { + InlineComponentProvider.NotExisting {} +} diff --git a/tests/auto/qml/qqmllanguage/data/nonExistingICUser3.qml b/tests/auto/qml/qqmllanguage/data/nonExistingICUser3.qml new file mode 100644 index 0000000000..34595707fc --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/nonExistingICUser3.qml @@ -0,0 +1,3 @@ +import QtQuick 2.15 + +InlineComponentProvider.NotExisting {} diff --git a/tests/auto/qml/qqmllanguage/data/nonExistingICUser4.qml b/tests/auto/qml/qqmllanguage/data/nonExistingICUser4.qml new file mode 100644 index 0000000000..2be01ccd96 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/nonExistingICUser4.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 +import "singleton" as MySingleton + +Item { + property MySingleton.SingletonTypeWithIC.NonExisting singletonIC +} diff --git a/tests/auto/qml/qqmllanguage/data/nonExistingICUser5.qml b/tests/auto/qml/qqmllanguage/data/nonExistingICUser5.qml new file mode 100644 index 0000000000..a2ca5db6de --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/nonExistingICUser5.qml @@ -0,0 +1,5 @@ +import QtQuick 2.15 + +Item { + property InlineComponentProviderChild.StyledRectangle myProp +} diff --git a/tests/auto/qml/qqmllanguage/data/singleton/SingletonTypeWithIC.qml b/tests/auto/qml/qqmllanguage/data/singleton/SingletonTypeWithIC.qml new file mode 100644 index 0000000000..bd724c4aeb --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/singleton/SingletonTypeWithIC.qml @@ -0,0 +1,16 @@ +import QtQuick 2.0 +pragma Singleton + +Item { + id: singletonId + component IC1: Item { + property int iProp: 42 + property string sProp: "Hello, world" + property Rectangle myRect: Rectangle {color: "green"} + } + component IC2: Item { + property int iProp: 13 + property string sProp: "Goodbye, world" + property Rectangle myRect: Rectangle {color: "red"} + } +} diff --git a/tests/auto/qml/qqmllanguage/data/singleton/qmldir b/tests/auto/qml/qqmllanguage/data/singleton/qmldir index 533fb6999a..727b09b4e8 100644 --- a/tests/auto/qml/qqmllanguage/data/singleton/qmldir +++ b/tests/auto/qml/qqmllanguage/data/singleton/qmldir @@ -1,3 +1,4 @@ singleton SingletonType SingletonType.qml +singleton SingletonTypeWithIC SingletonTypeWithIC.qml diff --git a/tests/auto/qml/qqmllanguage/data/singletonICTest.qml b/tests/auto/qml/qqmllanguage/data/singletonICTest.qml new file mode 100644 index 0000000000..d0d3b079be --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/singletonICTest.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 +import "singleton" as MySingleton + +Item { + property MySingleton.SingletonTypeWithIC.IC1 singleton1: MySingleton.SingletonTypeWithIC.IC1 {}; +} diff --git a/tests/auto/qml/qqmllanguage/data/unsupportedProperty.errors.txt b/tests/auto/qml/qqmllanguage/data/unsupportedProperty.errors.txt index 3cd626de86..b45c320c20 100644 --- a/tests/auto/qml/qqmllanguage/data/unsupportedProperty.errors.txt +++ b/tests/auto/qml/qqmllanguage/data/unsupportedProperty.errors.txt @@ -1 +1 @@ -3:13:Invalid property assignment: unsupported type "QMatrix" +3:16:Invalid property assignment: unsupported type "QTransform" diff --git a/tests/auto/qml/qqmllanguage/data/unsupportedProperty.qml b/tests/auto/qml/qqmllanguage/data/unsupportedProperty.qml index 9f19680368..ec8171dd2c 100644 --- a/tests/auto/qml/qqmllanguage/data/unsupportedProperty.qml +++ b/tests/auto/qml/qqmllanguage/data/unsupportedProperty.qml @@ -1,4 +1,4 @@ import Test 1.0 MyQmlObject { - matrix: "1,0,0,0,1,0,0,0,1" + transform: "1,0,0,0,1,0,0,0,1" } diff --git a/tests/auto/qml/qqmllanguage/testtypes.cpp b/tests/auto/qml/qqmllanguage/testtypes.cpp index 0ddb1b1491..31a4135d89 100644 --- a/tests/auto/qml/qqmllanguage/testtypes.cpp +++ b/tests/auto/qml/qqmllanguage/testtypes.cpp @@ -121,6 +121,7 @@ void registerTypes() qmlRegisterTypesAndRevisions<Extended, Foreign, ForeignExtended>("Test", 1); qmlRegisterTypesAndRevisions<BareSingleton>("Test", 1); + qmlRegisterTypesAndRevisions<UncreatableSingleton>("Test", 1); } QVariant myCustomVariantTypeConverter(const QString &data) @@ -213,3 +214,9 @@ bool MyQmlObject::event(QEvent *event) m_childAddedEventCount++; return QObject::event(event); } + +UncreatableSingleton *UncreatableSingleton::instance() +{ + static UncreatableSingleton instance; + return &instance; +} diff --git a/tests/auto/qml/qqmllanguage/testtypes.h b/tests/auto/qml/qqmllanguage/testtypes.h index a7410e190b..39502372e6 100644 --- a/tests/auto/qml/qqmllanguage/testtypes.h +++ b/tests/auto/qml/qqmllanguage/testtypes.h @@ -31,7 +31,7 @@ #include <QtCore/qobject.h> #include <QtCore/qrect.h> #include <QtCore/qdatetime.h> -#include <QtGui/qmatrix.h> +#include <QtGui/qtransform.h> #include <QtGui/qcolor.h> #include <QtGui/qvector2d.h> #include <QtGui/qvector3d.h> @@ -104,7 +104,7 @@ class MyQmlObject : public QObject, public MyInterface Q_PROPERTY(QString readOnlyString READ readOnlyString) Q_PROPERTY(bool enabled READ enabled WRITE setEnabled) Q_PROPERTY(QRect rect READ rect WRITE setRect) - Q_PROPERTY(QMatrix matrix READ matrix WRITE setMatrix) //assumed to be unsupported by QML + Q_PROPERTY(QTransform transform READ transform WRITE setTransform) //assumed to be unsupported by QML Q_PROPERTY(MyInterface *interfaceProperty READ interface WRITE setInterface) Q_PROPERTY(int onLiteralSignal READ onLiteralSignal WRITE setOnLiteralSignal) Q_PROPERTY(MyCustomVariantType customType READ customType WRITE setCustomType) @@ -129,8 +129,8 @@ public: QRect rect() const { return QRect(); } void setRect(const QRect&) {} - QMatrix matrix() const { return QMatrix(); } - void setMatrix(const QMatrix&) {} + QTransform transform() const { return QTransform(); } + void setTransform(const QTransform &) {} MyInterface *interface() const { return m_interface; } void setInterface(MyInterface *iface) { m_interface = iface; } @@ -1468,6 +1468,19 @@ public: } }; +class UncreatableSingleton : public QObject +{ + Q_OBJECT + QML_SINGLETON + QML_ELEMENT + +public: + static UncreatableSingleton *instance(); + +private: + UncreatableSingleton() { setObjectName("uncreatable"); } +}; + void registerTypes(); #endif // TESTTYPES_H diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 7b4662a5cd..4d2f773dbf 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -306,6 +306,16 @@ private slots: void extendedForeignTypes(); + void inlineComponent(); + void inlineComponent_data(); + void inlineComponentReferenceCycle_data(); + void inlineComponentReferenceCycle(); + void nestedInlineComponentNotAllowed(); + void inlineComponentStaticTypeResolution(); + void inlineComponentInSingleton(); + void nonExistingInlineComponent_data(); + void nonExistingInlineComponent(); + void selfReference(); void selfReferencingSingleton(); @@ -2780,12 +2790,12 @@ void tst_qqmllanguage::importsLocal_data() QTest::newRow("local import QTBUG-7721 A") << "subdir.Test {}" // no longer allowed (QTBUG-7721) << "" - << "subdir.Test - subdir is not a namespace"; + << "subdir.Test - subdir is neither a type nor a namespace"; QTest::newRow("local import QTBUG-7721 B") << "import \"subdir\" as X\n" "X.subsubdir.SubTest {}" // no longer allowed (QTBUG-7721) << "" - << "X.subsubdir.SubTest - nested namespaces not allowed"; + << "X.subsubdir.SubTest - subsubdir is not a type"; QTest::newRow("local import as") << "import \"subdir\" as T\n" "T.Test {}" @@ -5378,25 +5388,156 @@ void tst_qqmllanguage::listContainingDeletedObject() void tst_qqmllanguage::overrideSingleton() { - auto check = [](const QString &name) { + auto check = [](const QString &name, const QByteArray &singletonElement) { const QByteArray testQml = "import Test 1.0\n" "import QtQml 2.0\n" - "QtObject { objectName: BareSingleton.objectName }"; + "QtObject { objectName: " + singletonElement + ".objectName }"; QQmlEngine engine; QQmlComponent component(&engine, nullptr); - component.setData(testQml, QUrl()); + component.setData(testQml, QUrl("singleton.qml")); QVERIFY(component.isReady()); QScopedPointer<QObject> obj(component.create()); QCOMPARE(obj->objectName(), name); }; - check("statically registered"); + check("statically registered", "BareSingleton"); BareSingleton singleton; singleton.setObjectName("dynamically registered"); qmlRegisterSingletonInstance("Test", 1, 0, "BareSingleton", &singleton); - check("dynamically registered"); + check("dynamically registered", "BareSingleton"); + + QTest::ignoreMessage( + QtWarningMsg, + "singleton.qml:3: TypeError: Cannot read property 'objectName' of undefined"); + check("", "UncreatableSingleton"); + + qmlRegisterSingletonInstance("Test", 1, 0, "UncreatableSingleton", + UncreatableSingleton::instance()); + check("uncreatable", "UncreatableSingleton"); +} + +void tst_qqmllanguage::inlineComponent() +{ + QFETCH(QUrl, componentUrl); + QFETCH(QColor, color); + QFETCH(int, width); + QQmlEngine engine; + QQmlComponent component(&engine, componentUrl); + QScopedPointer<QObject> o(component.create()); + if (component.isError()) { + qDebug() << component.errorString(); + } + QVERIFY(!o.isNull()); + auto icInstance = o->findChild<QObject *>("icInstance"); + QVERIFY(icInstance); + QCOMPARE(icInstance->property("color").value<QColor>(),color); + QCOMPARE(icInstance->property("width").value<qreal>(), width); +} + +void tst_qqmllanguage::inlineComponent_data() +{ + QTest::addColumn<QUrl>("componentUrl"); + QTest::addColumn<QColor>("color"); + QTest::addColumn<int>("width"); + + QTest::newRow("Usage from other component") << testFileUrl("inlineComponentUser1.qml") << QColorConstants::Blue << 24; + QTest::newRow("Reexport") << testFileUrl("inlineComponentUser2.qml") << QColorConstants::Svg::green << 24; + QTest::newRow("Usage in same component") << testFileUrl("inlineComponentUser3.qml") << QColorConstants::Blue << 24; + + QTest::newRow("Resolution happens at instantiation") << testFileUrl("inlineComponentUser4.qml") << QColorConstants::Blue << 24; + QTest::newRow("Non-toplevel IC is found") << testFileUrl("inlineComponentUser5.qml") << QColorConstants::Svg::red << 24; + + QTest::newRow("Resolved in correct order") << testFileUrl("inlineComponentOrder.qml") << QColorConstants::Blue << 200; +} + +void tst_qqmllanguage::inlineComponentReferenceCycle_data() +{ + QTest::addColumn<QUrl>("componentUrl"); + + QTest::newRow("Simple cycle") << testFileUrl("icSimpleCycle.qml"); + QTest::newRow("Via property") << testFileUrl("icCycleViaProperty.qml"); +} + +void tst_qqmllanguage::inlineComponentReferenceCycle() +{ + QFETCH(QUrl, componentUrl); + QQmlEngine engine; + QTest::ignoreMessage(QtMsgType::QtWarningMsg, "QQmlComponent: Component is not ready"); + QQmlComponent component(&engine, componentUrl); + QScopedPointer<QObject> o(component.create()); + QVERIFY(o.isNull()); + QVERIFY(component.isError()); + QCOMPARE(component.errorString(), componentUrl.toString() + QLatin1String(":-1 Inline components form a cycle!\n")); +} + +void tst_qqmllanguage::nestedInlineComponentNotAllowed() +{ + QQmlEngine engine; + auto url = testFileUrl("nestedIC.qml"); + QQmlComponent component(&engine, url); + QTest::ignoreMessage(QtMsgType::QtWarningMsg, "QQmlComponent: Component is not ready"); + QScopedPointer<QObject> o(component.create()); + QVERIFY(component.isError()); + QCOMPARE(component.errorString(), QLatin1String("%1:%2").arg(url.toString(), QLatin1String("5 Nested inline components are not supported\n"))); +} + +void tst_qqmllanguage::inlineComponentStaticTypeResolution() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("InlineComponentChild.qml")); + VERIFY_ERRORS(0); + QScopedPointer<QObject> o(component.create()); + QVERIFY(o); + QCOMPARE(o->property("i").toInt(), 42); +} + +void tst_qqmllanguage::inlineComponentInSingleton() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("singletonICTest.qml")); + VERIFY_ERRORS(0); + QScopedPointer<QObject> o(component.create()); + QVERIFY(!o.isNull()); + auto untyped = o->property("singleton1"); + QVERIFY(untyped.isValid()); + auto singleton1 = untyped.value<QObject*>(); + QVERIFY(singleton1); + QCOMPARE(singleton1->property("iProp").value<int>(), 42); + QCOMPARE(singleton1->property("sProp").value<QString>(), QString::fromLatin1("Hello, world")); + QVERIFY(!o.isNull()); +} + +void tst_qqmllanguage::nonExistingInlineComponent_data() +{ + QTest::addColumn<QUrl>("componentUrl"); + QTest::addColumn<QString>("errorMessage"); + QTest::addColumn<int>("line"); + QTest::addColumn<int>("column"); + + QTest::newRow("Property type") << testFileUrl("nonExistingICUser1.qml") << QString("Type InlineComponentProvider has no inline component type called NonExisting") << 4 << 5; + QTest::newRow("Instantiation") << testFileUrl("nonExistingICUser2.qml") << QString("Type InlineComponentProvider has no inline component type called NotExisting") << 4 << 5; + QTest::newRow("Inheritance") << testFileUrl("nonExistingICUser3.qml") << QString("Type InlineComponentProvider has no inline component type called NotExisting") << 3 << 1; + QTest::newRow("From singleton") << testFileUrl("nonExistingICUser4.qml") << QString("Type MySingleton.SingletonTypeWithIC has no inline component type called NonExisting") << 5 << 5; + + QTest::newRow("Cannot access parent inline components from child") << testFileUrl("nonExistingICUser5.qml") << QString("Type InlineComponentProviderChild has no inline component type called StyledRectangle") << 4 << 5; +} + +void tst_qqmllanguage::nonExistingInlineComponent() +{ + QFETCH(QUrl, componentUrl); + QFETCH(QString, errorMessage); + QFETCH(int, line); + QFETCH(int, column); + QQmlEngine engine; + QQmlComponent component(&engine, componentUrl); + auto errors = component.errors(); + QCOMPARE(errors.size(), 1); + const auto &error = errors.first(); + QCOMPARE(error.description(), errorMessage); + QCOMPARE(error.line(), line); + QCOMPARE(error.column(), column); } QTEST_MAIN(tst_qqmllanguage) diff --git a/tests/auto/qml/qqmllistmodel/qqmllistmodel.pro b/tests/auto/qml/qqmllistmodel/qqmllistmodel.pro index 4d44d6b22b..c0808f8599 100644 --- a/tests/auto/qml/qqmllistmodel/qqmllistmodel.pro +++ b/tests/auto/qml/qqmllistmodel/qqmllistmodel.pro @@ -8,4 +8,4 @@ include (../../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private qml-private quick-private testlib qmlmodels-private +QT += core-private gui-private qml-private quick-private testlib qmlmodels-private diff --git a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp index 75a932b6f4..d54e3467b7 100644 --- a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp +++ b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp @@ -700,7 +700,7 @@ void tst_qqmllistmodel::error_data() QTest::newRow("unknown qualified ListElement not allowed") << "import QtQuick 2.0\nListModel { Foo.ListElement { a: 123 } }" - << "Foo.ListElement - Foo is not a namespace"; + << "Foo.ListElement - Foo is neither a type nor a namespace"; } void tst_qqmllistmodel::error() diff --git a/tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp b/tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp index 8efaedf5b5..e25d555d61 100644 --- a/tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp +++ b/tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp @@ -45,6 +45,9 @@ class tst_qqmllistreference : public QQmlDataTest public: tst_qqmllistreference() {} +private: + void modeData(); + private slots: void initTestCase(); void qmllistreference(); @@ -56,12 +59,19 @@ private slots: void canAt(); void canClear(); void canCount(); + void canReplace(); + void canRemoveLast(); void isReadable(); void isManipulable(); void append(); void at(); + void clear_data() { modeData(); } void clear(); void count(); + void replace_data() { modeData(); } + void replace(); + void removeLast_data() { modeData(); } + void removeLast(); void copy(); void qmlmetaproperty(); void engineTypes(); @@ -76,7 +86,67 @@ class TestType : public QObject Q_PROPERTY(int intProperty READ intProperty) public: - TestType() : property(this, data) {} + enum Mode { + SyntheticClear, + SyntheticReplace, + SyntheticClearAndReplace, + SyntheticRemoveLast, + SyntheticRemoveLastAndReplace, + AutomaticReference, + AutomaticPointer + }; + + static void append(QQmlListProperty<TestType> *p, TestType *v) { + reinterpret_cast<QList<TestType *> *>(p->data)->append(v); + } + static int count(QQmlListProperty<TestType> *p) { + return reinterpret_cast<QList<TestType *> *>(p->data)->count(); + } + static TestType *at(QQmlListProperty<TestType> *p, int idx) { + return reinterpret_cast<QList<TestType *> *>(p->data)->at(idx); + } + static void clear(QQmlListProperty<TestType> *p) { + return reinterpret_cast<QList<TestType *> *>(p->data)->clear(); + } + static void replace(QQmlListProperty<TestType> *p, int idx, TestType *v) { + return reinterpret_cast<QList<TestType *> *>(p->data)->replace(idx, v); + } + static void removeLast(QQmlListProperty<TestType> *p) { + return reinterpret_cast<QList<TestType *> *>(p->data)->removeLast(); + } + + TestType(Mode mode = AutomaticReference) + { + switch (mode) { + case SyntheticClear: + property = QQmlListProperty<TestType>(this, &data, append, count, at, nullptr, + replace, removeLast); + break; + case SyntheticReplace: + property = QQmlListProperty<TestType>(this, &data, append, count, at, clear, + nullptr, removeLast); + break; + case SyntheticClearAndReplace: + property = QQmlListProperty<TestType>(this, &data, append, count, at, nullptr, + nullptr, removeLast); + break; + case SyntheticRemoveLast: + property = QQmlListProperty<TestType>(this, &data, append, count, at, clear, + replace, nullptr); + break; + case SyntheticRemoveLastAndReplace: + property = QQmlListProperty<TestType>(this, &data, append, count, at, clear, + nullptr, nullptr); + break; + case AutomaticReference: + property = QQmlListProperty<TestType>(this, data); + break; + case AutomaticPointer: + property = QQmlListProperty<TestType>(this, &data); + break; + } + } + QQmlListProperty<TestType> dataProperty() { return property; } int intProperty() const { return 10; } @@ -84,6 +154,20 @@ public: QQmlListProperty<TestType> property; }; +Q_DECLARE_METATYPE(TestType::Mode) + +void tst_qqmllistreference::modeData() +{ + QTest::addColumn<TestType::Mode>("mode"); + QTest::addRow("AutomaticReference") << TestType::AutomaticReference; + QTest::addRow("AutomaticPointer") << TestType::AutomaticPointer; + QTest::addRow("SyntheticClear") << TestType::SyntheticClear; + QTest::addRow("SyntheticReplace") << TestType::SyntheticReplace; + QTest::addRow("SyntheticClearAndReplace") << TestType::SyntheticClearAndReplace; + QTest::addRow("SyntheticRemoveLast") << TestType::SyntheticRemoveLast; + QTest::addRow("SyntheticRemoveLastAndReplace") << TestType::SyntheticRemoveLastAndReplace; +} + void tst_qqmllistreference::initTestCase() { QQmlDataTest::initTestCase(); @@ -340,6 +424,64 @@ void tst_qqmllistreference::canCount() } } +void tst_qqmllistreference::canReplace() +{ + QScopedPointer<TestType> tt(new TestType); + + { + QQmlListReference ref; + QVERIFY(!ref.canReplace()); + } + + { + QQmlListReference ref(tt.data(), "blah"); + QVERIFY(!ref.canReplace()); + } + + { + QQmlListReference ref(tt.data(), "data"); + QVERIFY(ref.canReplace()); + tt.reset(); + QVERIFY(!ref.canReplace()); + } + + { + TestType tt; + tt.property.replace = nullptr; + QQmlListReference ref(&tt, "data"); + QVERIFY(!ref.canReplace()); + } +} + +void tst_qqmllistreference::canRemoveLast() +{ + QScopedPointer<TestType> tt(new TestType); + + { + QQmlListReference ref; + QVERIFY(!ref.canRemoveLast()); + } + + { + QQmlListReference ref(tt.data(), "blah"); + QVERIFY(!ref.canRemoveLast()); + } + + { + QQmlListReference ref(tt.data(), "data"); + QVERIFY(ref.canRemoveLast()); + tt.reset(); + QVERIFY(!ref.canRemoveLast()); + } + + { + TestType tt; + tt.property.removeLast = nullptr; + QQmlListReference ref(&tt, "data"); + QVERIFY(!ref.canRemoveLast()); + } +} + void tst_qqmllistreference::isReadable() { TestType *tt = new TestType; @@ -474,7 +616,8 @@ void tst_qqmllistreference::at() void tst_qqmllistreference::clear() { - TestType *tt = new TestType; + QFETCH(TestType::Mode, mode); + TestType *tt = new TestType(mode); tt->data.append(tt); tt->data.append(0); tt->data.append(tt); @@ -540,6 +683,70 @@ void tst_qqmllistreference::count() } } +void tst_qqmllistreference::replace() +{ + QFETCH(TestType::Mode, mode); + QScopedPointer<TestType> tt(new TestType(mode)); + tt->data.append(tt.get()); + tt->data.append(nullptr); + tt->data.append(tt.get()); + + { + QQmlListReference ref(tt.get(), "data"); + QVERIFY(ref.replace(1, tt.get())); + QCOMPARE(ref.at(1), tt.get()); + QVERIFY(ref.replace(2, nullptr)); + QCOMPARE(ref.at(2), nullptr); + QCOMPARE(ref.count(), 3); + tt.reset(); + QVERIFY(!ref.replace(0, tt.get())); + } + + { + TestType tt; + tt.data.append(&tt); + tt.property.replace = nullptr; + QQmlListReference ref(&tt, "data"); + QVERIFY(!ref.replace(0, nullptr)); + } +} + +void tst_qqmllistreference::removeLast() +{ + QFETCH(TestType::Mode, mode); + QScopedPointer<TestType> tt(new TestType(mode)); + tt->data.append(tt.get()); + tt->data.append(nullptr); + tt->data.append(tt.get()); + + { + QQmlListReference ref; + QVERIFY(!ref.removeLast()); + } + + { + QQmlListReference ref(tt.get(), "blah"); + QVERIFY(!ref.removeLast()); + } + + { + QQmlListReference ref(tt.get(), "data"); + QCOMPARE(tt->data.count(), 3); + QVERIFY(ref.removeLast()); + QCOMPARE(tt->data.count(), 2); + tt.reset(); + QVERIFY(!ref.removeLast()); + } + + { + TestType tt; + tt.property.removeLast = nullptr; + QQmlListReference ref(&tt, "data"); + ref.append(&tt); + QVERIFY(!ref.removeLast()); + } +} + void tst_qqmllistreference::copy() { TestType tt; diff --git a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp index c846ee32df..e3094db708 100644 --- a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp +++ b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp @@ -449,7 +449,7 @@ void tst_qqmllocale::firstDayOfWeek() Q_ARG(QVariant, QVariant(locale))); QVariant val = obj->property("firstDayOfWeek"); - QCOMPARE(val.type(), QVariant::Int); + QCOMPARE(val.userType(), QMetaType::Int); int day = int(QLocale(locale).firstDayOfWeek()); if (day == 7) // JS Date days in range 0(Sunday) to 6(Saturday) diff --git a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp index 72295044a5..296d1b14e0 100644 --- a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp +++ b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp @@ -157,7 +157,7 @@ void tst_qqmlmetatype::initTestCase() void tst_qqmlmetatype::qmlParserStatusCast() { - QVERIFY(!QQmlMetaType::qmlType(QVariant::Int).isValid()); + QVERIFY(!QQmlMetaType::qmlType(QMetaType::Int).isValid()); QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<TestType *>()).isValid()); QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId<TestType *>()).parserStatusCast(), -1); QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<ValueSourceTestType *>()).isValid()); @@ -177,7 +177,7 @@ void tst_qqmlmetatype::qmlParserStatusCast() void tst_qqmlmetatype::qmlPropertyValueSourceCast() { - QVERIFY(!QQmlMetaType::qmlType(QVariant::Int).isValid()); + QVERIFY(!QQmlMetaType::qmlType(QMetaType::Int).isValid()); QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<TestType *>()).isValid()); QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId<TestType *>()).propertyValueSourceCast(), -1); QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>()).isValid()); @@ -197,7 +197,7 @@ void tst_qqmlmetatype::qmlPropertyValueSourceCast() void tst_qqmlmetatype::qmlPropertyValueInterceptorCast() { - QVERIFY(!QQmlMetaType::qmlType(QVariant::Int).isValid()); + QVERIFY(!QQmlMetaType::qmlType(QMetaType::Int).isValid()); QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<TestType *>()).isValid()); QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId<TestType *>()).propertyValueInterceptorCast(), -1); QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>()).isValid()); @@ -256,8 +256,8 @@ void tst_qqmlmetatype::prettyTypeName() void tst_qqmlmetatype::isList() { - QCOMPARE(QQmlMetaType::isList(QVariant::Invalid), false); - QCOMPARE(QQmlMetaType::isList(QVariant::Int), false); + QCOMPARE(QQmlMetaType::isList(QMetaType::UnknownType), false); + QCOMPARE(QQmlMetaType::isList(QMetaType::Int), false); QQmlListProperty<TestType> list; @@ -327,10 +327,10 @@ void tst_qqmlmetatype::externalEnums() QScopedPointer<QObject> obj(c.create()); QVERIFY(obj); QVariant a = obj->property("a"); - QCOMPARE(a.type(), QVariant::Int); + QCOMPARE(a.userType(), QVariant::Int); QCOMPARE(a.toInt(), int(QStandardPaths::DocumentsLocation)); QVariant b = obj->property("b"); - QCOMPARE(b.type(), QVariant::Int); + QCOMPARE(b.userType(), QVariant::Int); QCOMPARE(b.toInt(), int(QStandardPaths::DocumentsLocation)); } @@ -394,10 +394,10 @@ void tst_qqmlmetatype::unregisterCustomType() QObject *controller = obj->findChild<QObject *>("controller"); QVERIFY(qobject_cast<Controller1 *>(controller)); QVariant stringVal = controller->property("string"); - QCOMPARE(stringVal.type(), QVariant::String); + QCOMPARE(stringVal.userType(), QVariant::String); QCOMPARE(stringVal.toString(), QStringLiteral("Controller #1")); QVariant enumVal = controller->property("enumVal"); - QCOMPARE(enumVal.type(), QVariant::Int); + QCOMPARE(enumVal.userType(), QVariant::Int); QCOMPARE(enumVal.toInt(), 1); } QQmlMetaType::unregisterType(controllerId); @@ -417,10 +417,10 @@ void tst_qqmlmetatype::unregisterCustomType() QObject *controller = obj->findChild<QObject *>("controller"); QVERIFY(qobject_cast<Controller2 *>(controller)); QVariant stringVal = controller->property("string"); - QCOMPARE(stringVal.type(), QVariant::String); + QCOMPARE(stringVal.userType(), QVariant::String); QCOMPARE(stringVal.toString(), QStringLiteral("Controller #2")); QVariant enumVal = controller->property("enumVal"); - QCOMPARE(enumVal.type(), QVariant::Int); + QCOMPARE(enumVal.userType(), QVariant::Int); QCOMPARE(enumVal.toInt(), 111); } QQmlMetaType::unregisterType(controllerId); @@ -440,10 +440,10 @@ void tst_qqmlmetatype::unregisterCustomType() QObject *controller = obj->findChild<QObject *>("controller"); QVERIFY(qobject_cast<Controller1 *>(controller)); QVariant stringVal = controller->property("string"); - QCOMPARE(stringVal.type(), QVariant::String); + QCOMPARE(stringVal.userType(), QVariant::String); QCOMPARE(stringVal.toString(), QStringLiteral("Controller #1")); QVariant enumVal = controller->property("enumVal"); - QCOMPARE(enumVal.type(), QVariant::Int); + QCOMPARE(enumVal.userType(), QVariant::Int); QCOMPARE(enumVal.toInt(), 1); } } @@ -489,7 +489,7 @@ void tst_qqmlmetatype::unregisterCustomSingletonType() QScopedPointer<QObject> obj(c.create()); QVERIFY(obj.data()); QVariant stringVal = obj->property("text"); - QCOMPARE(stringVal.type(), QVariant::String); + QCOMPARE(stringVal.userType(), QVariant::String); QCOMPARE(stringVal.toString(), QStringLiteral("StaticProvider #1")); } QQmlMetaType::unregisterType(staticProviderId); @@ -505,7 +505,7 @@ void tst_qqmlmetatype::unregisterCustomSingletonType() QScopedPointer<QObject> obj(c.create()); QVERIFY(obj.data()); QVariant stringVal = obj->property("text"); - QCOMPARE(stringVal.type(), QVariant::String); + QCOMPARE(stringVal.userType(), QVariant::String); QCOMPARE(stringVal.toString(), QStringLiteral("StaticProvider #2")); } QQmlMetaType::unregisterType(staticProviderId); @@ -521,7 +521,7 @@ void tst_qqmlmetatype::unregisterCustomSingletonType() QScopedPointer<QObject> obj(c.create()); QVERIFY(obj.data()); QVariant stringVal = obj->property("text"); - QCOMPARE(stringVal.type(), QVariant::String); + QCOMPARE(stringVal.userType(), QVariant::String); QCOMPARE(stringVal.toString(), QStringLiteral("StaticProvider #1")); } } diff --git a/tests/auto/qml/qqmlvaluetypes/data/font_write.qml b/tests/auto/qml/qqmlvaluetypes/data/font_write.qml index ff4d0a1004..4d3ae32025 100644 --- a/tests/auto/qml/qqmlvaluetypes/data/font_write.qml +++ b/tests/auto/qml/qqmlvaluetypes/data/font_write.qml @@ -3,7 +3,7 @@ import Test 1.0 MyTypeObject { font.family: if(1) "Helvetica" font.bold: if(1) false - font.weight: "Normal" + font.weight: 50 font.italic: if(1) false font.underline: if(1) false font.overline: if(1) false diff --git a/tests/auto/qml/qqmlvaluetypes/data/qmlproperty_read.qml b/tests/auto/qml/qqmlvaluetypes/data/qmlproperty_read.qml new file mode 100644 index 0000000000..b9c9ee779b --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/qmlproperty_read.qml @@ -0,0 +1,9 @@ +import Test 1.0 +import QtQml 2.0 + +MyTypeObject { + property QtObject colorPropertyObject: colorProperty.object + property string colorPropertyName: colorProperty.name + property QtObject invalidPropertyObject: invalidProperty.object + property string invalidPropertyName: invalidProperty.name +} diff --git a/tests/auto/qml/qqmlvaluetypes/testtypes.h b/tests/auto/qml/qqmlvaluetypes/testtypes.h index 798c96e188..e11d831236 100644 --- a/tests/auto/qml/qqmlvaluetypes/testtypes.h +++ b/tests/auto/qml/qqmlvaluetypes/testtypes.h @@ -71,6 +71,8 @@ class MyTypeObject : public QObject Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY changed) Q_PROPERTY(QColor invalidColor READ invalidColor CONSTANT) Q_PROPERTY(QVariant variant READ variant NOTIFY changed) + Q_PROPERTY(QQmlProperty colorProperty READ colorProperty CONSTANT) + Q_PROPERTY(QQmlProperty invalidProperty READ invalidProperty CONSTANT) public: MyTypeObject() : @@ -173,6 +175,10 @@ public: QVariant variant() const { return sizef(); } + QQmlProperty colorProperty() { return QQmlProperty(this, "color"); } + + QQmlProperty invalidProperty() const { return QQmlProperty(); } + void emitRunScript() { emit runScript(); } signals: diff --git a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp index 3e9047cc5a..7c75743311 100644 --- a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp +++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp @@ -67,6 +67,7 @@ private slots: void color(); void variant(); void locale(); + void qmlproperty(); void bindingAssignment(); void bindingRead(); @@ -360,6 +361,20 @@ void tst_qqmlvaluetypes::locale() } } +void tst_qqmlvaluetypes::qmlproperty() +{ + QQmlComponent component(&engine, testFileUrl("qmlproperty_read.qml")); + MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); + QVERIFY(object != nullptr); + + QCOMPARE(object->property("colorPropertyObject").value<QObject *>(), object); + QCOMPARE(object->property("colorPropertyName").toString(), "color"); + QCOMPARE(object->property("invalidPropertyObject").value<QObject *>(), nullptr); + QCOMPARE(object->property("invalidPropertyName").toString(), ""); + + delete object; +} + void tst_qqmlvaluetypes::sizereadonly() { { diff --git a/tests/auto/qmltest/animatedimage/BLACKLIST b/tests/auto/qmltest/animatedimage/BLACKLIST index 3a5ed393ea..25eb7a7cff 100644 --- a/tests/auto/qmltest/animatedimage/BLACKLIST +++ b/tests/auto/qmltest/animatedimage/BLACKLIST @@ -1,2 +1,2 @@ [AnimatedImage::test_crashRaceCondition_replyFinished] -osx-10.13 +macos diff --git a/tests/auto/qmltest/fontloader/daniel.ttf b/tests/auto/qmltest/fontloader/daniel.ttf Binary files differnew file mode 100644 index 0000000000..aae50d5035 --- /dev/null +++ b/tests/auto/qmltest/fontloader/daniel.ttf diff --git a/tests/auto/qmltest/fontloader/tst_fontloader.qml b/tests/auto/qmltest/fontloader/tst_fontloader.qml index 0d1831230e..48b92e02ba 100644 --- a/tests/auto/qmltest/fontloader/tst_fontloader.qml +++ b/tests/auto/qmltest/fontloader/tst_fontloader.qml @@ -81,10 +81,6 @@ Item { fontloader.source = "dummy.ttf"; tryCompare(fontloader, 'status', FontLoader.Error) compare(testinput.font.family, "") - fontloader.source = ""; - fontloader.name = "Courier"; - tryCompare(fontloader, 'status', FontLoader.Ready) - compare(testinput.font.family, "Courier") } function test_fontswitching() { @@ -92,10 +88,9 @@ Item { fontswitch.source = "tarzeau_ocr_a.ttf"; tryCompare(fontswitch, 'status', FontLoader.Ready) compare(fontswitch.name, "OCRA") - fontswitch.source = ""; - fontswitch.name = "Courier"; + fontswitch.source = "daniel.ttf"; tryCompare(fontswitch, 'status', FontLoader.Ready) - compare(fontswitch.name, "Courier") + compare(fontswitch.name, "Daniel") fontswitch.source = "tarzeau_ocr_a.ttf"; tryCompare(fontswitch, 'status', FontLoader.Ready) compare(fontswitch.name, "OCRA") diff --git a/tests/auto/qmltest/listview/data/MultiDelegate3.qml b/tests/auto/qmltest/listview/data/MultiDelegate3.qml new file mode 100644 index 0000000000..75116e0f9b --- /dev/null +++ b/tests/auto/qmltest/listview/data/MultiDelegate3.qml @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2020 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:BSD$ +** 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. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 +import QtQml.Models 2.12 +import Qt.labs.qmlmodels 1.0 + +ListView { + width: 400 + height: 400 + + property var item1: QtObject { + property string dataType: "rect" + property color color: "red" + } + property var item2: QtObject { + property string dataType: "text" + property string text: "Hello world" + } + model: [ item1, item2 ] + + delegate: DelegateChooser { + role: "dataType" + DelegateChoice { + roleValue: "rect" + delegate: Rectangle { + width: parent.width + height: 50 + color: modelData.color + } + } + DelegateChoice { + roleValue: "text" + delegate: Text { + width: parent.width + height: 50 + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + text: modelData.text + } + } + + DelegateChoice { + delegate: Item { + width: parent.width + height: 50 + } + } + } +} diff --git a/tests/auto/qmltest/listview/tst_listview.qml b/tests/auto/qmltest/listview/tst_listview.qml index 5e9bb22e8e..bea6b45c3a 100644 --- a/tests/auto/qmltest/listview/tst_listview.qml +++ b/tests/auto/qmltest/listview/tst_listview.qml @@ -213,6 +213,10 @@ Item { id: multiDelegate2 } + MultiDelegate3 { + id: multiDelegate3 + } + TestCase { name: "ListView" when: windowShown @@ -414,5 +418,18 @@ Item { var delegate = multiDelegate2.itemAt(10, row.y) compare(delegate.choiceType, row.type) } + + function test_multipleDelegates3_data() { + return [ + { y: 25, type: "Rectangle", property: "color", value: "#ff0000" }, + { y: 75, type: "Text", property: "text", value: "Hello world" } + ] + } + + function test_multipleDelegates3(row) { + var delegate = multiDelegate3.itemAt(10, row.y) + verify(delegate.toString().includes(row.type)) + compare(delegate[row.property], row.value) + } } } diff --git a/tests/auto/qmltest/textedit/BLACKLIST b/tests/auto/qmltest/textedit/BLACKLIST index e06cba3e8f..ac1ca6d8cf 100644 --- a/tests/auto/qmltest/textedit/BLACKLIST +++ b/tests/auto/qmltest/textedit/BLACKLIST @@ -1,6 +1,6 @@ # Blacklist for testing [TextEdit::test_textentry] -osx-10.12 +macos [TextEdit::test_textentry_char] -osx-10.12 +macos diff --git a/tests/auto/quick/nodes/tst_nodestest.cpp b/tests/auto/quick/nodes/tst_nodestest.cpp index 249ecd5aa5..1b2b355596 100644 --- a/tests/auto/quick/nodes/tst_nodestest.cpp +++ b/tests/auto/quick/nodes/tst_nodestest.cpp @@ -30,7 +30,7 @@ #include <QtTest/QtTest> #include <QtGui/QOffscreenSurface> -#include <QtGui/QOpenGLContext> +#include <QOpenGLContext> #include <QtQuick/qsgnode.h> #include <QtQuick/private/qsgbatchrenderer_p.h> #include <QtQuick/private/qsgnodeupdater_p.h> diff --git a/tests/auto/quick/nokeywords/nokeywords.pro b/tests/auto/quick/nokeywords/nokeywords.pro index 6872dac22a..69e1abe43e 100644 --- a/tests/auto/quick/nokeywords/nokeywords.pro +++ b/tests/auto/quick/nokeywords/nokeywords.pro @@ -7,3 +7,5 @@ SOURCES += tst_nokeywords.cpp CONFIG+=parallel_test QT += quick core-private gui-private qml-private quick-private testlib +qtConfig(opengl): \ + QT_PRIVATE += opengl-private diff --git a/tests/auto/quick/qquickcanvasitem/BLACKLIST b/tests/auto/quick/qquickcanvasitem/BLACKLIST new file mode 100644 index 0000000000..21580b6730 --- /dev/null +++ b/tests/auto/quick/qquickcanvasitem/BLACKLIST @@ -0,0 +1,14 @@ +[arcTo::test_transform] +macos +[canvas::test_paint] +macos +[canvas::test_save] +macos +[canvas::test_implicitlySizedParent] +macos ci +[canvas::test_toDataURL] +macos +[fillRect::test_fillRect] +macos +[imagedata::test_rounding] +macos ci diff --git a/tests/auto/quick/qquickfontloader/data/qtbug-20268.qml b/tests/auto/quick/qquickfontloader/data/qtbug-20268.qml index 0eafdfa17b..e9282bf2c7 100644 --- a/tests/auto/quick/qquickfontloader/data/qtbug-20268.qml +++ b/tests/auto/quick/qquickfontloader/data/qtbug-20268.qml @@ -4,7 +4,7 @@ Rectangle { id: test property variant fontloader: fontloaderelement height: 100; width: 100 - property bool usename: false + property bool useotherfont: false property int statenum: 1 property alias name: fontloaderelement.name property alias source: fontloaderelement.source @@ -15,11 +15,11 @@ Rectangle { } states: [ - State { name: "start"; when: !usename + State { name: "start"; when: !useotherfont PropertyChanges { target: fontloaderelement; source: "tarzeau_ocr_a.ttf" } }, - State { name: "changefont"; when: usename - PropertyChanges { target: fontloaderelement; name: "Tahoma" } + State { name: "changefont"; when: useotherfont + PropertyChanges { target: fontloaderelement; source: "daniel.ttf" } } ] diff --git a/tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp b/tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp index 87a5bd469a..8f6910bee4 100644 --- a/tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp +++ b/tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp @@ -45,7 +45,6 @@ public: private slots: void initTestCase(); void noFont(); - void namedFont(); void localFont(); void failLocalFont(); void webFont(); @@ -85,19 +84,6 @@ void tst_qquickfontloader::noFont() delete fontObject; } -void tst_qquickfontloader::namedFont() -{ - QString componentStr = "import QtQuick 2.0\nFontLoader { name: \"Helvetica\" }"; - QQmlComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickFontLoader *fontObject = qobject_cast<QQuickFontLoader*>(component.create()); - - QVERIFY(fontObject != nullptr); - QCOMPARE(fontObject->source(), QUrl("")); - QCOMPARE(fontObject->name(), QString("Helvetica")); - QTRY_COMPARE(fontObject->status(), QQuickFontLoader::Ready); -} - void tst_qquickfontloader::localFont() { QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"" + testFileUrl("tarzeau_ocr_a.ttf").toString() + "\" }"; @@ -223,16 +209,10 @@ void tst_qquickfontloader::changeFontSourceViaState() QVERIFY(fontObject->source() != QUrl("")); QTRY_COMPARE(fontObject->name(), QString("OCRA")); - window.rootObject()->setProperty("usename", true); - - // This warning should probably not be printed once QTBUG-20268 is fixed - QString warning = QString(testFileUrl("qtbug-20268.qml").toString()) + - QLatin1String(":13:5: QML FontLoader: Cannot load font: \"\""); - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + window.rootObject()->setProperty("useotherfont", true); - QEXPECT_FAIL("", "QTBUG-20268", Abort); QTRY_COMPARE(fontObject->status(), QQuickFontLoader::Ready); - QCOMPARE(window.rootObject()->property("name").toString(), QString("Tahoma")); + QCOMPARE(window.rootObject()->property("name").toString(), QString("Daniel")); } QTEST_MAIN(tst_qquickfontloader) diff --git a/tests/auto/quick/qquickitem2/data/mapCoordinates.qml b/tests/auto/quick/qquickitem2/data/mapCoordinates.qml index 596dedab90..3e34633338 100644 --- a/tests/auto/quick/qquickitem2/data/mapCoordinates.qml +++ b/tests/auto/quick/qquickitem2/data/mapCoordinates.qml @@ -49,11 +49,21 @@ Item { return Qt.point(pos.x, pos.y) } + function mapAToBPoint(x, y) { + var pos = itemA.mapToItem(itemB, Qt.point(x, y)) + return Qt.point(pos.x, pos.y) + } + function mapAFromB(x, y) { var pos = itemA.mapFromItem(itemB, x, y) return Qt.point(pos.x, pos.y) } + function mapAFromBPoint(x, y) { + var pos = itemA.mapFromItem(itemB, Qt.point(x, y)) + return Qt.point(pos.x, pos.y) + } + function mapAToNull(x, y) { var pos = itemA.mapToItem(null, x, y) return Qt.point(pos.x, pos.y) @@ -69,11 +79,21 @@ Item { return Qt.point(pos.x, pos.y) } + function mapAToGlobalPoint(x, y) { + var pos = itemA.mapToGlobal(Qt.point(x, y)) + return Qt.point(pos.x, pos.y) + } + function mapAFromGlobal(x, y) { var pos = itemA.mapFromGlobal(x, y) return Qt.point(pos.x, pos.y) } + function mapAFromGlobalPoint(x, y) { + var pos = itemA.mapFromGlobal(Qt.point(x, y)) + return Qt.point(pos.x, pos.y) + } + function mapOrphanToGlobal(x, y) { var obj = itemComponent.createObject(null); var pos = obj.mapToGlobal(x, y) diff --git a/tests/auto/quick/qquickitem2/data/mapCoordinatesRect.qml b/tests/auto/quick/qquickitem2/data/mapCoordinatesRect.qml index 2b856a27fc..c66d1e89b6 100644 --- a/tests/auto/quick/qquickitem2/data/mapCoordinatesRect.qml +++ b/tests/auto/quick/qquickitem2/data/mapCoordinatesRect.qml @@ -45,11 +45,21 @@ Item { return Qt.rect(pos.x, pos.y, pos.width, pos.height) } + function mapAToBRect(x, y, w, h) { + var pos = itemA.mapToItem(itemB, Qt.rect(x, y, w, h)) + return Qt.rect(pos.x, pos.y, pos.width, pos.height) + } + function mapAFromB(x, y, w, h) { var pos = itemA.mapFromItem(itemB, x, y, w, h) return Qt.rect(pos.x, pos.y, pos.width, pos.height) } + function mapAFromBRect(x, y, w, h) { + var pos = itemA.mapFromItem(itemB, Qt.rect(x, y, w, h)) + return Qt.rect(pos.x, pos.y, pos.width, pos.height) + } + function mapAToNull(x, y, w, h) { var pos = itemA.mapToItem(null, x, y, w, h) return Qt.rect(pos.x, pos.y, pos.width, pos.height) diff --git a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp index 607cf91bfe..a1b4a70217 100644 --- a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp +++ b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp @@ -2391,10 +2391,18 @@ void tst_QQuickItem::mapCoordinates() Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y))); QCOMPARE(result.value<QPointF>(), qobject_cast<QQuickItem*>(a)->mapToItem(b, QPointF(x, y))); + QVERIFY(QMetaObject::invokeMethod(root, "mapAToBPoint", + Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y))); + QCOMPARE(result.value<QPointF>(), qobject_cast<QQuickItem*>(a)->mapToItem(b, QPointF(x, y))); + QVERIFY(QMetaObject::invokeMethod(root, "mapAFromB", Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y))); QCOMPARE(result.value<QPointF>(), qobject_cast<QQuickItem*>(a)->mapFromItem(b, QPointF(x, y))); + QVERIFY(QMetaObject::invokeMethod(root, "mapAFromBPoint", + Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y))); + QCOMPARE(result.value<QPointF>(), qobject_cast<QQuickItem*>(a)->mapFromItem(b, QPointF(x, y))); + QVERIFY(QMetaObject::invokeMethod(root, "mapAToNull", Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y))); QCOMPARE(result.value<QPointF>(), qobject_cast<QQuickItem*>(a)->mapToScene(QPointF(x, y))); @@ -2407,10 +2415,18 @@ void tst_QQuickItem::mapCoordinates() Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y))); QCOMPARE(result.value<QPointF>(), qobject_cast<QQuickItem*>(a)->mapToGlobal(QPointF(x, y))); + QVERIFY(QMetaObject::invokeMethod(root, "mapAToGlobalPoint", + Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y))); + QCOMPARE(result.value<QPointF>(), qobject_cast<QQuickItem*>(a)->mapToGlobal(QPointF(x, y))); + QVERIFY(QMetaObject::invokeMethod(root, "mapAFromGlobal", Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y))); QCOMPARE(result.value<QPointF>(), qobject_cast<QQuickItem*>(a)->mapFromGlobal(QPointF(x, y))); + QVERIFY(QMetaObject::invokeMethod(root, "mapAFromGlobalPoint", + Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y))); + QCOMPARE(result.value<QPointF>(), qobject_cast<QQuickItem*>(a)->mapFromGlobal(QPointF(x, y))); + // for orphans we are primarily testing that we don't crash. // when orphaned the final position is the original position of the item translated by x,y QVERIFY(QMetaObject::invokeMethod(root, "mapOrphanToGlobal", @@ -2472,10 +2488,18 @@ void tst_QQuickItem::mapCoordinatesRect() Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y), Q_ARG(QVariant, width), Q_ARG(QVariant, height))); QCOMPARE(result.value<QRectF>(), qobject_cast<QQuickItem*>(a)->mapRectToItem(b, QRectF(x, y, width, height))); + QVERIFY(QMetaObject::invokeMethod(root, "mapAToBRect", + Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y), Q_ARG(QVariant, width), Q_ARG(QVariant, height))); + QCOMPARE(result.value<QRectF>(), qobject_cast<QQuickItem*>(a)->mapRectToItem(b, QRectF(x, y, width, height))); + QVERIFY(QMetaObject::invokeMethod(root, "mapAFromB", Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y), Q_ARG(QVariant, width), Q_ARG(QVariant, height))); QCOMPARE(result.value<QRectF>(), qobject_cast<QQuickItem*>(a)->mapRectFromItem(b, QRectF(x, y, width, height))); + QVERIFY(QMetaObject::invokeMethod(root, "mapAFromBRect", + Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y), Q_ARG(QVariant, width), Q_ARG(QVariant, height))); + QCOMPARE(result.value<QRectF>(), qobject_cast<QQuickItem*>(a)->mapRectFromItem(b, QRectF(x, y, width, height))); + QVERIFY(QMetaObject::invokeMethod(root, "mapAToNull", Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y), Q_ARG(QVariant, width), Q_ARG(QVariant, height))); QCOMPARE(result.value<QRectF>(), qobject_cast<QQuickItem*>(a)->mapRectToScene(QRectF(x, y, width, height))); diff --git a/tests/auto/quick/qquicklistview/BLACKLIST b/tests/auto/quick/qquicklistview/BLACKLIST index 1f3736328a..6ef69550a4 100644 --- a/tests/auto/quick/qquicklistview/BLACKLIST +++ b/tests/auto/quick/qquicklistview/BLACKLIST @@ -5,10 +5,10 @@ opensuse-leap [populateTransitions] opensuse-42.1 [contentHeightWithDelayRemove] -osx-10.12 +macos #QTBUG-75960 #QTBUG-76652 [currentIndex] -osx-10.12 +macos opensuse-leap ubuntu-18.04 diff --git a/tests/auto/quick/qquicklistview/data/changeModelAndDestroyTheOldOne.qml b/tests/auto/quick/qquicklistview/data/changeModelAndDestroyTheOldOne.qml new file mode 100644 index 0000000000..6a33decde6 --- /dev/null +++ b/tests/auto/quick/qquicklistview/data/changeModelAndDestroyTheOldOne.qml @@ -0,0 +1,34 @@ +import QtQuick 2.13 +import QtQml 2.13 +import QtQml.Models 2.13 + +Rectangle { + width: 640 + height: 480 + property var model1: null + property var model2: null + Component { + id: m1 + ObjectModel { + Rectangle { height: 30; width: 80; color: "red" } + Rectangle { height: 30; width: 80; color: "green" } + Rectangle { height: 30; width: 80; color: "blue" } + } + } + Component { + id: m2 + ObjectModel { + Rectangle { height: 30; width: 80; color: "red" } + } + } + ListView { + anchors.fill: parent + Component.onCompleted: { + model1 = m1.createObject() + model = model1 + model2 = m2.createObject() + model = model2 + model1.destroy() + } + } +} diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index e527853148..9a8dfee9d2 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -289,6 +289,7 @@ private slots: void reuse_reuseIsOffByDefault(); void reuse_checkThatItemsAreReused(); void moveObjectModelItemToAnotherObjectModel(); + void changeModelAndDestroyTheOldOne(); private: template <class T> void items(const QUrl &source); @@ -9415,6 +9416,21 @@ void tst_QQuickListView::moveObjectModelItemToAnotherObjectModel() QVERIFY(!QQuickItemPrivate::get(redRect)->culled); } +void tst_QQuickListView::changeModelAndDestroyTheOldOne() // QTBUG-80203 +{ + QScopedPointer<QQuickView> window(createView()); + window->setSource(testFileUrl("changeModelAndDestroyTheOldOne.qml")); + window->resize(640, 480); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); + + QQuickItem *root = window->rootObject(); + QVERIFY(root); + + QVERIFY(QQuickTest::qWaitForItemPolished(root)); + // no crash +} + QTEST_MAIN(tst_QQuickListView) #include "tst_qquicklistview.moc" diff --git a/tests/auto/quick/qquicktext/BLACKLIST b/tests/auto/quick/qquicktext/BLACKLIST index 594f9af3b3..b551575e9d 100644 --- a/tests/auto/quick/qquicktext/BLACKLIST +++ b/tests/auto/quick/qquicktext/BLACKLIST @@ -1,7 +1,7 @@ [dependentImplicitSizes] b2qt qemu -osx-10.12 +macos [fontSizeMode] opensuse-42.1 [contentSize] diff --git a/tests/auto/quick/qquicktext/data/displaySuperscriptedTag.qml b/tests/auto/quick/qquicktext/data/displaySuperscriptedTag.qml new file mode 100644 index 0000000000..b0ed21a0c8 --- /dev/null +++ b/tests/auto/quick/qquicktext/data/displaySuperscriptedTag.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +Rectangle { + width: 200 + height: 200 + color: "white" + Text { + objectName: "text" + textFormat: Text.RichText + anchors.fill: parent + color: "black" + // display a black rectangle at the top left of the text + text: "<span style=\"background-color:rgba(255,255,255,255);vertical-align:super;\">█</span>This is a test" + verticalAlignment: Text.AlignTop + horizontalAlignment: Text.AlignLeft + font.pixelSize: 30 + } +} diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp index 06ce730091..19a33f1861 100644 --- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp @@ -168,6 +168,8 @@ private slots: void transparentBackground(); + void displaySuperscriptedTag(); + private: QStringList standard; QStringList richText; @@ -1504,7 +1506,7 @@ void tst_qquicktext::weight() delete textObject; } { - QString componentStr = "import QtQuick 2.0\nText { font.weight: \"Bold\"; text: \"Hello world!\" }"; + QString componentStr = "import QtQuick 2.0\nText { font.weight: Font.Bold; text: \"Hello world!\" }"; QQmlComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create()); @@ -4507,6 +4509,32 @@ void tst_qquicktext::transparentBackground() QCOMPARE(color.blue(), 255); QCOMPARE(color.green(), 255); } + +void tst_qquicktext::displaySuperscriptedTag() +{ + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QSKIP("Skipping due to grabToImage not functional on offscreen/minimimal platforms"); + + QScopedPointer<QQuickView> window(new QQuickView); + window->setSource(testFileUrl("displaySuperscriptedTag.qml")); + QTRY_COMPARE(window->status(), QQuickView::Ready); + + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); + + QQuickText *text = window->findChild<QQuickText *>("text"); + QVERIFY(text); + + QImage img = window->grabWindow(); + QCOMPARE(img.isNull(), false); + + QColor color = img.pixelColor(1, static_cast<int>(text->contentHeight()) / 4 * 3); + QCOMPARE(color.red(), 255); + QCOMPARE(color.blue(), 255); + QCOMPARE(color.green(), 255); +} + QTEST_MAIN(tst_qquicktext) #include "tst_qquicktext.moc" diff --git a/tests/auto/quick/touchmouse/BLACKLIST b/tests/auto/quick/touchmouse/BLACKLIST index 0dfe28087a..9afc86c2fe 100644 --- a/tests/auto/quick/touchmouse/BLACKLIST +++ b/tests/auto/quick/touchmouse/BLACKLIST @@ -4,3 +4,7 @@ windows gcc developer-build # QTBUG-74517 [buttonOnFlickable] windows gcc developer-build + +# QTBUG-74517 +[touchButtonOnFlickable] +windows gcc developer-build diff --git a/tests/benchmarks/qml/holistic/testtypes.h b/tests/benchmarks/qml/holistic/testtypes.h index 6ff64c645d..55f094ae7e 100644 --- a/tests/benchmarks/qml/holistic/testtypes.h +++ b/tests/benchmarks/qml/holistic/testtypes.h @@ -36,7 +36,6 @@ #include <QtQml/qqmllist.h> #include <QtCore/qrandom.h> #include <QtCore/qrect.h> -#include <QtGui/qmatrix.h> #include <QtGui/qcolor.h> #include <QtGui/qpixmap.h> #include <QtGui/qvector3d.h> diff --git a/tests/benchmarks/qml/painting/painting.pro b/tests/benchmarks/qml/painting/painting.pro index 7e97915f43..633be76e30 100644 --- a/tests/benchmarks/qml/painting/painting.pro +++ b/tests/benchmarks/qml/painting/painting.pro @@ -1,6 +1,7 @@ requires(qtHaveModule(opengl)) +requires(qtHaveModule(widgets)) -QT += opengl +QT += opengl widgets CONFIG += console macx:CONFIG -= app_bundle diff --git a/tests/manual/nodetypes_ng/buildshaders.bat b/tests/manual/nodetypes_ng/compile.bat index 328b216c07..328b216c07 100755 --- a/tests/manual/nodetypes_ng/buildshaders.bat +++ b/tests/manual/nodetypes_ng/compile.bat diff --git a/tests/manual/nodetypes_ng/shadow_pass1.frag.qsb b/tests/manual/nodetypes_ng/shadow_pass1.frag.qsb Binary files differindex f90265a997..4c913fee08 100644 --- a/tests/manual/nodetypes_ng/shadow_pass1.frag.qsb +++ b/tests/manual/nodetypes_ng/shadow_pass1.frag.qsb diff --git a/tests/manual/nodetypes_ng/shadow_pass2.frag.qsb b/tests/manual/nodetypes_ng/shadow_pass2.frag.qsb Binary files differindex 9608763b61..4f6e6634e7 100644 --- a/tests/manual/nodetypes_ng/shadow_pass2.frag.qsb +++ b/tests/manual/nodetypes_ng/shadow_pass2.frag.qsb diff --git a/tests/manual/nodetypes_ng/wobble.frag.qsb b/tests/manual/nodetypes_ng/wobble.frag.qsb Binary files differindex 7d3105fd3c..f1766f4363 100644 --- a/tests/manual/nodetypes_ng/wobble.frag.qsb +++ b/tests/manual/nodetypes_ng/wobble.frag.qsb diff --git a/tests/manual/nodetypes_ng/wobble.vert.qsb b/tests/manual/nodetypes_ng/wobble.vert.qsb Binary files differindex 92b8ba9703..2715c84616 100644 --- a/tests/manual/nodetypes_ng/wobble.vert.qsb +++ b/tests/manual/nodetypes_ng/wobble.vert.qsb diff --git a/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/basic.frag b/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/basic.frag Binary files differindex c6da52fd32..15459ffdb9 100644 --- a/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/basic.frag +++ b/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/basic.frag diff --git a/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/cmyk.frag b/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/cmyk.frag Binary files differindex e9c48edbb9..5ef0333b6b 100644 --- a/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/cmyk.frag +++ b/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/cmyk.frag diff --git a/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/culling.frag b/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/culling.frag Binary files differindex 6f44fff112..edf2d11a93 100644 --- a/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/culling.frag +++ b/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/culling.frag diff --git a/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/edge.frag b/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/edge.frag Binary files differindex 01a1d1cb3d..aecaa621ef 100644 --- a/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/edge.frag +++ b/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/edge.frag diff --git a/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/gradient.frag b/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/gradient.frag Binary files differindex 78ac8a9c95..ef7a9c10ca 100644 --- a/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/gradient.frag +++ b/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/gradient.frag diff --git a/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/gradient2.frag b/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/gradient2.frag Binary files differindex 364fffab52..ca58580786 100644 --- a/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/gradient2.frag +++ b/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/gradient2.frag diff --git a/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/gradient3.frag b/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/gradient3.frag Binary files differindex 42bebf490a..e1fc8b0ce8 100644 --- a/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/gradient3.frag +++ b/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/gradient3.frag diff --git a/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/gradient4.frag b/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/gradient4.frag Binary files differindex ed31582cf9..2e0b809d7d 100644 --- a/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/gradient4.frag +++ b/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/gradient4.frag diff --git a/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/gradient5.frag b/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/gradient5.frag Binary files differindex 7fe041f0ae..106c2c5515 100644 --- a/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/gradient5.frag +++ b/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/gradient5.frag diff --git a/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/shadow.frag b/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/shadow.frag Binary files differindex cb3428b75f..788a047ab0 100644 --- a/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/shadow.frag +++ b/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/shadow.frag diff --git a/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/stencil.frag b/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/stencil.frag Binary files differindex ccf3633d64..e3907a90d2 100644 --- a/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/stencil.frag +++ b/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/stencil.frag diff --git a/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/wave.vert b/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/wave.vert Binary files differindex 04850feb27..14cb4e768f 100644 --- a/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/wave.vert +++ b/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/wave.vert |