From c091f3f4b4889ac6be26e018c5e8b673adee7c47 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Mon, 18 Mar 2019 11:49:05 +0100 Subject: V4: Do not invert non-reflexive comparison binops This is only useful for the few (4) comparisons where we have specialized instructions, and it's very error-prone. Change-Id: I37efe94f54ba0adf393d9236df2d13aa6685eb46 Fixes: QTBUG-74476 Reviewed-by: Simon Hausmann --- tests/auto/qml/qjsengine/tst_qjsengine.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests/auto/qml') diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp index 42d8f37ca8..0491ccd473 100644 --- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp @@ -235,6 +235,8 @@ private slots: void importModuleWithLexicallyScopedVars(); void importExportErrors(); + void equality(); + public: Q_INVOKABLE QJSValue throwingCppMethod1(); Q_INVOKABLE void throwingCppMethod2(); @@ -4622,6 +4624,14 @@ void tst_QJSEngine::importExportErrors() } } +void tst_QJSEngine::equality() +{ + QJSEngine engine; + QJSValue ok = engine.evaluate("(0 < 0) ? 'ko' : 'ok'"); + QVERIFY(ok.isString()); + QCOMPARE(ok.toString(), QString("ok")); +} + QTEST_MAIN(tst_QJSEngine) #include "tst_qjsengine.moc" -- cgit v1.2.3 From 497a795081b95d487f0ec33746cc2a12ffeae5a0 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 21 Mar 2019 16:25:55 +0100 Subject: Initialize TranslationData padding before writing cache files Otherwise the resulting files differ subtly. Fixes: QTBUG-74532 Change-Id: I12b4f1ba6dda781d63ad50cce87861ba24582bf7 Reviewed-by: Simon Hausmann --- tests/auto/qml/qmlcachegen/Enums.qml | 9 --- tests/auto/qml/qmlcachegen/data/Enums.qml | 9 +++ .../auto/qml/qmlcachegen/data/componentInItem.qml | 15 ++++ tests/auto/qml/qmlcachegen/data/jsimport.qml | 6 ++ tests/auto/qml/qmlcachegen/data/jsmoduleimport.qml | 6 ++ tests/auto/qml/qmlcachegen/data/library.js | 4 + tests/auto/qml/qmlcachegen/data/script.js | 6 ++ tests/auto/qml/qmlcachegen/data/script.mjs | 4 + tests/auto/qml/qmlcachegen/data/trickypaths.qml | 4 + tests/auto/qml/qmlcachegen/data/umlaut.qml | 4 + .../data/versionStyleSuffix-1.2-core-yc.qml | 4 + .../data/versionStyleSuffix-1.2-more.qml | 4 + tests/auto/qml/qmlcachegen/data/versionchecks.qml | 4 + tests/auto/qml/qmlcachegen/data/worker.js | 3 + tests/auto/qml/qmlcachegen/data/worker.qml | 12 +++ tests/auto/qml/qmlcachegen/jsimport.qml | 6 -- tests/auto/qml/qmlcachegen/jsmoduleimport.qml | 6 -- tests/auto/qml/qmlcachegen/library.js | 4 - tests/auto/qml/qmlcachegen/qmlcachegen.pro | 30 +++++--- tests/auto/qml/qmlcachegen/script.js | 6 -- tests/auto/qml/qmlcachegen/script.mjs | 4 - tests/auto/qml/qmlcachegen/trickypaths.qml | 4 - tests/auto/qml/qmlcachegen/trickypaths.qrc | 6 +- tests/auto/qml/qmlcachegen/trickypaths_umlaut.qrc | 2 +- tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp | 86 ++++++++++++++++------ tests/auto/qml/qmlcachegen/umlaut.qml | 4 - .../qmlcachegen/versionStyleSuffix-1.2-core-yc.qml | 4 - .../qmlcachegen/versionStyleSuffix-1.2-more.qml | 4 - tests/auto/qml/qmlcachegen/versionchecks.qml | 4 - tests/auto/qml/qmlcachegen/worker.js | 3 - tests/auto/qml/qmlcachegen/worker.qml | 12 --- 31 files changed, 173 insertions(+), 106 deletions(-) delete mode 100644 tests/auto/qml/qmlcachegen/Enums.qml create mode 100644 tests/auto/qml/qmlcachegen/data/Enums.qml create mode 100644 tests/auto/qml/qmlcachegen/data/componentInItem.qml create mode 100644 tests/auto/qml/qmlcachegen/data/jsimport.qml create mode 100644 tests/auto/qml/qmlcachegen/data/jsmoduleimport.qml create mode 100644 tests/auto/qml/qmlcachegen/data/library.js create mode 100644 tests/auto/qml/qmlcachegen/data/script.js create mode 100644 tests/auto/qml/qmlcachegen/data/script.mjs create mode 100644 tests/auto/qml/qmlcachegen/data/trickypaths.qml create mode 100644 tests/auto/qml/qmlcachegen/data/umlaut.qml create mode 100644 tests/auto/qml/qmlcachegen/data/versionStyleSuffix-1.2-core-yc.qml create mode 100644 tests/auto/qml/qmlcachegen/data/versionStyleSuffix-1.2-more.qml create mode 100644 tests/auto/qml/qmlcachegen/data/versionchecks.qml create mode 100644 tests/auto/qml/qmlcachegen/data/worker.js create mode 100644 tests/auto/qml/qmlcachegen/data/worker.qml delete mode 100644 tests/auto/qml/qmlcachegen/jsimport.qml delete mode 100644 tests/auto/qml/qmlcachegen/jsmoduleimport.qml delete mode 100644 tests/auto/qml/qmlcachegen/library.js delete mode 100644 tests/auto/qml/qmlcachegen/script.js delete mode 100644 tests/auto/qml/qmlcachegen/script.mjs delete mode 100644 tests/auto/qml/qmlcachegen/trickypaths.qml delete mode 100644 tests/auto/qml/qmlcachegen/umlaut.qml delete mode 100644 tests/auto/qml/qmlcachegen/versionStyleSuffix-1.2-core-yc.qml delete mode 100644 tests/auto/qml/qmlcachegen/versionStyleSuffix-1.2-more.qml delete mode 100644 tests/auto/qml/qmlcachegen/versionchecks.qml delete mode 100644 tests/auto/qml/qmlcachegen/worker.js delete mode 100644 tests/auto/qml/qmlcachegen/worker.qml (limited to 'tests/auto/qml') diff --git a/tests/auto/qml/qmlcachegen/Enums.qml b/tests/auto/qml/qmlcachegen/Enums.qml deleted file mode 100644 index 830babb73e..0000000000 --- a/tests/auto/qml/qmlcachegen/Enums.qml +++ /dev/null @@ -1,9 +0,0 @@ -import QtQml 2.0 -QtObject { - enum Test { - First = 100, - Second = 200 - } - property int value: 0 - Component.onCompleted: value = Enums.Second -} diff --git a/tests/auto/qml/qmlcachegen/data/Enums.qml b/tests/auto/qml/qmlcachegen/data/Enums.qml new file mode 100644 index 0000000000..830babb73e --- /dev/null +++ b/tests/auto/qml/qmlcachegen/data/Enums.qml @@ -0,0 +1,9 @@ +import QtQml 2.0 +QtObject { + enum Test { + First = 100, + Second = 200 + } + property int value: 0 + Component.onCompleted: value = Enums.Second +} diff --git a/tests/auto/qml/qmlcachegen/data/componentInItem.qml b/tests/auto/qml/qmlcachegen/data/componentInItem.qml new file mode 100644 index 0000000000..820b9fddcd --- /dev/null +++ b/tests/auto/qml/qmlcachegen/data/componentInItem.qml @@ -0,0 +1,15 @@ +import QtQuick 2.12 + +Item { + Component { + Rectangle { + id: xxx + Text { + text: qsTr("&Undo") + } + Text { + text: qsTr("&Redo") + } + } + } +} diff --git a/tests/auto/qml/qmlcachegen/data/jsimport.qml b/tests/auto/qml/qmlcachegen/data/jsimport.qml new file mode 100644 index 0000000000..9c40878e60 --- /dev/null +++ b/tests/auto/qml/qmlcachegen/data/jsimport.qml @@ -0,0 +1,6 @@ +import QtQml 2.0 +import "script.js" as Script + +QtObject { + property int value: Script.getter() +} diff --git a/tests/auto/qml/qmlcachegen/data/jsmoduleimport.qml b/tests/auto/qml/qmlcachegen/data/jsmoduleimport.qml new file mode 100644 index 0000000000..c1fad7fee2 --- /dev/null +++ b/tests/auto/qml/qmlcachegen/data/jsmoduleimport.qml @@ -0,0 +1,6 @@ +import QtQml 2.0 +import "script.mjs" as Script + +QtObject { + property bool ok: Script.ok() +} diff --git a/tests/auto/qml/qmlcachegen/data/library.js b/tests/auto/qml/qmlcachegen/data/library.js new file mode 100644 index 0000000000..51fb41dc23 --- /dev/null +++ b/tests/auto/qml/qmlcachegen/data/library.js @@ -0,0 +1,4 @@ + +function getter() { + return 42; +} diff --git a/tests/auto/qml/qmlcachegen/data/script.js b/tests/auto/qml/qmlcachegen/data/script.js new file mode 100644 index 0000000000..fa55f9069e --- /dev/null +++ b/tests/auto/qml/qmlcachegen/data/script.js @@ -0,0 +1,6 @@ + +.import "library.js" as Library + +function getter() { + return Library.getter() +} diff --git a/tests/auto/qml/qmlcachegen/data/script.mjs b/tests/auto/qml/qmlcachegen/data/script.mjs new file mode 100644 index 0000000000..459c336125 --- /dev/null +++ b/tests/auto/qml/qmlcachegen/data/script.mjs @@ -0,0 +1,4 @@ + +export function ok() { + return true +} diff --git a/tests/auto/qml/qmlcachegen/data/trickypaths.qml b/tests/auto/qml/qmlcachegen/data/trickypaths.qml new file mode 100644 index 0000000000..0836808dc2 --- /dev/null +++ b/tests/auto/qml/qmlcachegen/data/trickypaths.qml @@ -0,0 +1,4 @@ +import QtQml 2.0 +QtObject { + property int success: 42 +} diff --git a/tests/auto/qml/qmlcachegen/data/umlaut.qml b/tests/auto/qml/qmlcachegen/data/umlaut.qml new file mode 100644 index 0000000000..0836808dc2 --- /dev/null +++ b/tests/auto/qml/qmlcachegen/data/umlaut.qml @@ -0,0 +1,4 @@ +import QtQml 2.0 +QtObject { + property int success: 42 +} diff --git a/tests/auto/qml/qmlcachegen/data/versionStyleSuffix-1.2-core-yc.qml b/tests/auto/qml/qmlcachegen/data/versionStyleSuffix-1.2-core-yc.qml new file mode 100644 index 0000000000..0836808dc2 --- /dev/null +++ b/tests/auto/qml/qmlcachegen/data/versionStyleSuffix-1.2-core-yc.qml @@ -0,0 +1,4 @@ +import QtQml 2.0 +QtObject { + property int success: 42 +} diff --git a/tests/auto/qml/qmlcachegen/data/versionStyleSuffix-1.2-more.qml b/tests/auto/qml/qmlcachegen/data/versionStyleSuffix-1.2-more.qml new file mode 100644 index 0000000000..0836808dc2 --- /dev/null +++ b/tests/auto/qml/qmlcachegen/data/versionStyleSuffix-1.2-more.qml @@ -0,0 +1,4 @@ +import QtQml 2.0 +QtObject { + property int success: 42 +} diff --git a/tests/auto/qml/qmlcachegen/data/versionchecks.qml b/tests/auto/qml/qmlcachegen/data/versionchecks.qml new file mode 100644 index 0000000000..77d67e7da4 --- /dev/null +++ b/tests/auto/qml/qmlcachegen/data/versionchecks.qml @@ -0,0 +1,4 @@ +import QtQml 2.0 +QtObject { + property bool ok: true +} diff --git a/tests/auto/qml/qmlcachegen/data/worker.js b/tests/auto/qml/qmlcachegen/data/worker.js new file mode 100644 index 0000000000..dd2d0b843d --- /dev/null +++ b/tests/auto/qml/qmlcachegen/data/worker.js @@ -0,0 +1,3 @@ +WorkerScript.onMessage = function(message) { + WorkerScript.sendMessage({ reply: message }); +} diff --git a/tests/auto/qml/qmlcachegen/data/worker.qml b/tests/auto/qml/qmlcachegen/data/worker.qml new file mode 100644 index 0000000000..1f1c9d1ac7 --- /dev/null +++ b/tests/auto/qml/qmlcachegen/data/worker.qml @@ -0,0 +1,12 @@ +import QtQml 2.0 +import QtQuick 2.0 +QtObject { + property bool success: false + property WorkerScript worker: WorkerScript { + source: "worker.js" + onMessage: { + success = true + } + } + Component.onCompleted: worker.sendMessage("Hello") +} diff --git a/tests/auto/qml/qmlcachegen/jsimport.qml b/tests/auto/qml/qmlcachegen/jsimport.qml deleted file mode 100644 index 9c40878e60..0000000000 --- a/tests/auto/qml/qmlcachegen/jsimport.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQml 2.0 -import "script.js" as Script - -QtObject { - property int value: Script.getter() -} diff --git a/tests/auto/qml/qmlcachegen/jsmoduleimport.qml b/tests/auto/qml/qmlcachegen/jsmoduleimport.qml deleted file mode 100644 index c1fad7fee2..0000000000 --- a/tests/auto/qml/qmlcachegen/jsmoduleimport.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQml 2.0 -import "script.mjs" as Script - -QtObject { - property bool ok: Script.ok() -} diff --git a/tests/auto/qml/qmlcachegen/library.js b/tests/auto/qml/qmlcachegen/library.js deleted file mode 100644 index 51fb41dc23..0000000000 --- a/tests/auto/qml/qmlcachegen/library.js +++ /dev/null @@ -1,4 +0,0 @@ - -function getter() { - return 42; -} diff --git a/tests/auto/qml/qmlcachegen/qmlcachegen.pro b/tests/auto/qml/qmlcachegen/qmlcachegen.pro index 7f7b3128cf..7f8e93d101 100644 --- a/tests/auto/qml/qmlcachegen/qmlcachegen.pro +++ b/tests/auto/qml/qmlcachegen/qmlcachegen.pro @@ -2,23 +2,31 @@ CONFIG += testcase qtquickcompiler TARGET = tst_qmlcachegen macos:CONFIG -= app_bundle +include (../../shared/util.pri) +TESTDATA = data/* + SOURCES += tst_qmlcachegen.cpp -workerscripts_test.files = worker.js worker.qml +RESOURCES += \ + data/versionchecks.qml \ + data/jsimport.qml \ + data/script.js \ + data/library.js \ + data/Enums.qml \ + data/componentInItem.qml \ + data/jsmoduleimport.qml \ + data/script.mjs + +workerscripts_test.files = \ + data/worker.js \ + data/worker.qml workerscripts_test.prefix = /workerscripts -RESOURCES += workerscripts_test - -RESOURCES += versionchecks.qml - -RESOURCES += trickypaths.qrc -RESOURCES += jsimport.qml script.js library.js - -RESOURCES += Enums.qml +RESOURCES += \ + workerscripts_test \ + trickypaths.qrc # QTBUG-46375 !win32: RESOURCES += trickypaths_umlaut.qrc -RESOURCES += jsmoduleimport.qml script.mjs - QT += core-private qml-private testlib diff --git a/tests/auto/qml/qmlcachegen/script.js b/tests/auto/qml/qmlcachegen/script.js deleted file mode 100644 index fa55f9069e..0000000000 --- a/tests/auto/qml/qmlcachegen/script.js +++ /dev/null @@ -1,6 +0,0 @@ - -.import "library.js" as Library - -function getter() { - return Library.getter() -} diff --git a/tests/auto/qml/qmlcachegen/script.mjs b/tests/auto/qml/qmlcachegen/script.mjs deleted file mode 100644 index 459c336125..0000000000 --- a/tests/auto/qml/qmlcachegen/script.mjs +++ /dev/null @@ -1,4 +0,0 @@ - -export function ok() { - return true -} diff --git a/tests/auto/qml/qmlcachegen/trickypaths.qml b/tests/auto/qml/qmlcachegen/trickypaths.qml deleted file mode 100644 index 0836808dc2..0000000000 --- a/tests/auto/qml/qmlcachegen/trickypaths.qml +++ /dev/null @@ -1,4 +0,0 @@ -import QtQml 2.0 -QtObject { - property int success: 42 -} diff --git a/tests/auto/qml/qmlcachegen/trickypaths.qrc b/tests/auto/qml/qmlcachegen/trickypaths.qrc index 57977ccf6d..b0c3bcf209 100644 --- a/tests/auto/qml/qmlcachegen/trickypaths.qrc +++ b/tests/auto/qml/qmlcachegen/trickypaths.qrc @@ -1,7 +1,7 @@ -trickypaths.qml -versionStyleSuffix-1.2-core-yc.qml -versionStyleSuffix-1.2-more.qml +data/trickypaths.qml +data/versionStyleSuffix-1.2-core-yc.qml +data/versionStyleSuffix-1.2-more.qml diff --git a/tests/auto/qml/qmlcachegen/trickypaths_umlaut.qrc b/tests/auto/qml/qmlcachegen/trickypaths_umlaut.qrc index 9ca889d692..17aa30473f 100644 --- a/tests/auto/qml/qmlcachegen/trickypaths_umlaut.qrc +++ b/tests/auto/qml/qmlcachegen/trickypaths_umlaut.qrc @@ -1,5 +1,5 @@ -umlaut.qml +data/umlaut.qml diff --git a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp index 97ac466e94..e290f21986 100644 --- a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp +++ b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp @@ -38,7 +38,9 @@ #include #include -class tst_qmlcachegen: public QObject +#include "../../shared/util.h" + +class tst_qmlcachegen: public QQmlDataTest { Q_OBJECT @@ -65,6 +67,9 @@ private slots: void enums(); void sourceFileIndices(); + + void reproducibleCache_data(); + void reproducibleCache(); }; // A wrapper around QQmlComponent to ensure the temporary reference counts @@ -352,12 +357,13 @@ static QQmlPrivate::CachedQmlUnit *temporaryModifiedCachedUnit = nullptr; void tst_qmlcachegen::versionChecksForAheadOfTimeUnits() { - QVERIFY(QFile::exists(":/versionchecks.qml")); - QCOMPARE(QFileInfo(":/versionchecks.qml").size(), 0); + QVERIFY(QFile::exists(":/data/versionchecks.qml")); + QCOMPARE(QFileInfo(":/data/versionchecks.qml").size(), 0); Q_ASSERT(!temporaryModifiedCachedUnit); QQmlMetaType::CachedUnitLookupError error = QQmlMetaType::CachedUnitLookupError::NoError; - const QV4::CompiledData::Unit *originalUnit = QQmlMetaType::findCachedCompilationUnit(QUrl("qrc:/versionchecks.qml"), &error); + const QV4::CompiledData::Unit *originalUnit = QQmlMetaType::findCachedCompilationUnit( + QUrl("qrc:/data/versionchecks.qml"), &error); QVERIFY(originalUnit); QV4::CompiledData::Unit *tweakedUnit = (QV4::CompiledData::Unit *)malloc(originalUnit->unitSize); memcpy(reinterpret_cast(tweakedUnit), reinterpret_cast(originalUnit), originalUnit->unitSize); @@ -365,7 +371,7 @@ void tst_qmlcachegen::versionChecksForAheadOfTimeUnits() temporaryModifiedCachedUnit = new QQmlPrivate::CachedQmlUnit{tweakedUnit, nullptr, nullptr}; auto testHandler = [](const QUrl &url) -> const QQmlPrivate::CachedQmlUnit * { - if (url == QUrl("qrc:/versionchecks.qml")) + if (url == QUrl("qrc:/data/versionchecks.qml")) return temporaryModifiedCachedUnit; return nullptr; }; @@ -373,15 +379,18 @@ void tst_qmlcachegen::versionChecksForAheadOfTimeUnits() { QQmlMetaType::CachedUnitLookupError error = QQmlMetaType::CachedUnitLookupError::NoError; - QVERIFY(!QQmlMetaType::findCachedCompilationUnit(QUrl("qrc:/versionchecks.qml"), &error)); + QVERIFY(!QQmlMetaType::findCachedCompilationUnit(QUrl("qrc:/data/versionchecks.qml"), &error)); QCOMPARE(error, QQmlMetaType::CachedUnitLookupError::VersionMismatch); } { QQmlEngine engine; - QQmlComponent component(&engine, QUrl("qrc:/versionchecks.qml")); + QQmlComponent component(&engine, QUrl("qrc:/data/versionchecks.qml")); QCOMPARE(component.status(), QQmlComponent::Error); - QCOMPARE(component.errorString(), QString("qrc:/versionchecks.qml:-1 File was compiled ahead of time with an incompatible version of Qt and the original file cannot be found. Please recompile\n")); + QCOMPARE(component.errorString(), + QString("qrc:/data/versionchecks.qml:-1 File was compiled ahead of time with an " + "incompatible version of Qt and the original file cannot be found. Please " + "recompile\n")); } Q_ASSERT(temporaryModifiedCachedUnit); @@ -394,12 +403,12 @@ void tst_qmlcachegen::versionChecksForAheadOfTimeUnits() void tst_qmlcachegen::workerScripts() { - QVERIFY(QFile::exists(":/workerscripts/worker.js")); - QVERIFY(QFile::exists(":/workerscripts/worker.qml")); - QCOMPARE(QFileInfo(":/workerscripts/worker.js").size(), 0); + QVERIFY(QFile::exists(":/workerscripts/data/worker.js")); + QVERIFY(QFile::exists(":/workerscripts/data/worker.qml")); + QCOMPARE(QFileInfo(":/workerscripts/data/worker.js").size(), 0); QQmlEngine engine; - CleanlyLoadingComponent component(&engine, QUrl("qrc:///workerscripts/worker.qml")); + CleanlyLoadingComponent component(&engine, QUrl("qrc:///workerscripts/data/worker.qml")); QScopedPointer obj(component.create()); QVERIFY(!obj.isNull()); QTRY_VERIFY(obj->property("success").toBool()); @@ -496,7 +505,7 @@ void tst_qmlcachegen::trickyPaths() void tst_qmlcachegen::qrcScriptImport() { QQmlEngine engine; - CleanlyLoadingComponent component(&engine, QUrl("qrc:///jsimport.qml")); + CleanlyLoadingComponent component(&engine, QUrl("qrc:///data/jsimport.qml")); QScopedPointer obj(component.create()); QVERIFY(!obj.isNull()); QTRY_COMPARE(obj->property("value").toInt(), 42); @@ -559,14 +568,14 @@ void tst_qmlcachegen::fsScriptImport() void tst_qmlcachegen::moduleScriptImport() { QQmlEngine engine; - CleanlyLoadingComponent component(&engine, QUrl("qrc:///jsmoduleimport.qml")); + CleanlyLoadingComponent component(&engine, QUrl("qrc:///data/jsmoduleimport.qml")); QVERIFY2(!component.isError(), qPrintable(component.errorString())); QScopedPointer obj(component.create()); QVERIFY(!obj.isNull()); QTRY_VERIFY(obj->property("ok").toBool()); - QVERIFY(QFile::exists(":/script.mjs")); - QCOMPARE(QFileInfo(":/script.mjs").size(), 0); + QVERIFY(QFile::exists(":/data/script.mjs")); + QCOMPARE(QFileInfo(":/data/script.mjs").size(), 0); { auto componentPrivate = QQmlComponentPrivate::get(&component); @@ -579,7 +588,8 @@ void tst_qmlcachegen::moduleScriptImport() QVERIFY(unitData->flags & QV4::CompiledData::Unit::IsESModule); QQmlMetaType::CachedUnitLookupError error = QQmlMetaType::CachedUnitLookupError::NoError; - const QV4::CompiledData::Unit *unitFromResources = QQmlMetaType::findCachedCompilationUnit(QUrl("qrc:/script.mjs"), &error); + const QV4::CompiledData::Unit *unitFromResources = QQmlMetaType::findCachedCompilationUnit( + QUrl("qrc:/data/script.mjs"), &error); QVERIFY(unitFromResources); QCOMPARE(unitFromResources, compilationUnit->unitData()); @@ -589,7 +599,7 @@ void tst_qmlcachegen::moduleScriptImport() void tst_qmlcachegen::enums() { QQmlEngine engine; - CleanlyLoadingComponent component(&engine, QUrl("qrc:///Enums.qml")); + CleanlyLoadingComponent component(&engine, QUrl("qrc:///data/Enums.qml")); QScopedPointer obj(component.create()); QVERIFY(!obj.isNull()); QTRY_COMPARE(obj->property("value").toInt(), 200); @@ -597,16 +607,50 @@ void tst_qmlcachegen::enums() void tst_qmlcachegen::sourceFileIndices() { - QVERIFY(QFile::exists(":/versionchecks.qml")); - QCOMPARE(QFileInfo(":/versionchecks.qml").size(), 0); + QVERIFY(QFile::exists(":/data/versionchecks.qml")); + QCOMPARE(QFileInfo(":/data/versionchecks.qml").size(), 0); QQmlMetaType::CachedUnitLookupError error = QQmlMetaType::CachedUnitLookupError::NoError; - const QV4::CompiledData::Unit *unitFromResources = QQmlMetaType::findCachedCompilationUnit(QUrl("qrc:/versionchecks.qml"), &error); + const QV4::CompiledData::Unit *unitFromResources = QQmlMetaType::findCachedCompilationUnit( + QUrl("qrc:/data/versionchecks.qml"), &error); QVERIFY(unitFromResources); QVERIFY(unitFromResources->flags & QV4::CompiledData::Unit::PendingTypeCompilation); QCOMPARE(uint(unitFromResources->sourceFileIndex), uint(0)); } +void tst_qmlcachegen::reproducibleCache_data() +{ + QTest::addColumn("filePath"); + + QDir dir(dataDirectory()); + for (const QString &entry : dir.entryList(QDir::Files)) { + QVERIFY(entry.endsWith(".qml") || entry.endsWith(".js") || entry.endsWith(".mjs")); + QTest::newRow(entry.toUtf8().constData()) << dir.filePath(entry); + } +} + +void tst_qmlcachegen::reproducibleCache() +{ + QFETCH(QString, filePath); + + QFile file(filePath); + QVERIFY(file.exists()); + + auto generate = [](const QString &path) { + if (!generateCache(path)) + return QByteArray(); + QFile generated(path + 'c'); + [&](){ QVERIFY(generated.open(QIODevice::ReadOnly)); }(); + const QByteArray result = generated.readAll(); + generated.remove(); + return result; + }; + + const QByteArray contents1 = generate(file.fileName()); + const QByteArray contents2 = generate(file.fileName()); + QCOMPARE(contents1, contents2); +} + QTEST_GUILESS_MAIN(tst_qmlcachegen) #include "tst_qmlcachegen.moc" diff --git a/tests/auto/qml/qmlcachegen/umlaut.qml b/tests/auto/qml/qmlcachegen/umlaut.qml deleted file mode 100644 index 0836808dc2..0000000000 --- a/tests/auto/qml/qmlcachegen/umlaut.qml +++ /dev/null @@ -1,4 +0,0 @@ -import QtQml 2.0 -QtObject { - property int success: 42 -} diff --git a/tests/auto/qml/qmlcachegen/versionStyleSuffix-1.2-core-yc.qml b/tests/auto/qml/qmlcachegen/versionStyleSuffix-1.2-core-yc.qml deleted file mode 100644 index 0836808dc2..0000000000 --- a/tests/auto/qml/qmlcachegen/versionStyleSuffix-1.2-core-yc.qml +++ /dev/null @@ -1,4 +0,0 @@ -import QtQml 2.0 -QtObject { - property int success: 42 -} diff --git a/tests/auto/qml/qmlcachegen/versionStyleSuffix-1.2-more.qml b/tests/auto/qml/qmlcachegen/versionStyleSuffix-1.2-more.qml deleted file mode 100644 index 0836808dc2..0000000000 --- a/tests/auto/qml/qmlcachegen/versionStyleSuffix-1.2-more.qml +++ /dev/null @@ -1,4 +0,0 @@ -import QtQml 2.0 -QtObject { - property int success: 42 -} diff --git a/tests/auto/qml/qmlcachegen/versionchecks.qml b/tests/auto/qml/qmlcachegen/versionchecks.qml deleted file mode 100644 index 77d67e7da4..0000000000 --- a/tests/auto/qml/qmlcachegen/versionchecks.qml +++ /dev/null @@ -1,4 +0,0 @@ -import QtQml 2.0 -QtObject { - property bool ok: true -} diff --git a/tests/auto/qml/qmlcachegen/worker.js b/tests/auto/qml/qmlcachegen/worker.js deleted file mode 100644 index dd2d0b843d..0000000000 --- a/tests/auto/qml/qmlcachegen/worker.js +++ /dev/null @@ -1,3 +0,0 @@ -WorkerScript.onMessage = function(message) { - WorkerScript.sendMessage({ reply: message }); -} diff --git a/tests/auto/qml/qmlcachegen/worker.qml b/tests/auto/qml/qmlcachegen/worker.qml deleted file mode 100644 index 1f1c9d1ac7..0000000000 --- a/tests/auto/qml/qmlcachegen/worker.qml +++ /dev/null @@ -1,12 +0,0 @@ -import QtQml 2.0 -import QtQuick 2.0 -QtObject { - property bool success: false - property WorkerScript worker: WorkerScript { - source: "worker.js" - onMessage: { - success = true - } - } - Component.onCompleted: worker.sendMessage("Hello") -} -- cgit v1.2.3 From 93ed9213f74dcd3806b0b2bfabc9900a545a5c69 Mon Sep 17 00:00:00 2001 From: Jani Heikkinen Date: Thu, 7 Feb 2019 15:04:24 +0200 Subject: Update tests/auto/qml/ecmascripttests/test262 Task-number: QTBUG-73454 Task-number: QTBUG-71209 Change-Id: I12925ce49cc18f4bb6908a5515fc476b32a222dc Reviewed-by: Simon Hausmann (cherry picked from commit 896d49a4e1113e3eb4832b83920b0dfd76987259) --- tests/auto/qml/ecmascripttests/test262 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/auto/qml') diff --git a/tests/auto/qml/ecmascripttests/test262 b/tests/auto/qml/ecmascripttests/test262 index 3c69133cc4..6b0c42c63c 160000 --- a/tests/auto/qml/ecmascripttests/test262 +++ b/tests/auto/qml/ecmascripttests/test262 @@ -1 +1 @@ -Subproject commit 3c69133cc419840c1be34638039cd8c48a7ef581 +Subproject commit 6b0c42c63c2492bd0a7a96d3179d122b5f71793f -- cgit v1.2.3 From 42ed40cf0abd0155d6e6d1ef01faf9bded065588 Mon Sep 17 00:00:00 2001 From: Tim Jenssen Date: Wed, 6 Feb 2019 15:27:54 +0100 Subject: Fix preview zoom problems on windows Apparently the window is moved to random places on multi-monitor setups on windows. Fixes: QDS-263 Change-Id: I21082c7031fefff3057074c147e82df7a88f4f78 Reviewed-by: Ulf Hermann Reviewed-by: Tim Jenssen --- tests/auto/qml/debugger/qqmlpreview/tst_qqmlpreview.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tests/auto/qml') diff --git a/tests/auto/qml/debugger/qqmlpreview/tst_qqmlpreview.cpp b/tests/auto/qml/debugger/qqmlpreview/tst_qqmlpreview.cpp index f713aa76c3..c7f8ec1118 100644 --- a/tests/auto/qml/debugger/qqmlpreview/tst_qqmlpreview.cpp +++ b/tests/auto/qml/debugger/qqmlpreview/tst_qqmlpreview.cpp @@ -319,12 +319,12 @@ void tst_QQmlPreview::zoom() QTRY_VERIFY(m_files.contains(testFile(file))); float baseZoomFactor = -1; QTRY_VERIFY_WITH_TIMEOUT((baseZoomFactor = parseZoomFactor(m_process->output())) > 0, 30000); - m_client->triggerZoom(2.0f); - verifyZoomFactor(m_process, baseZoomFactor * 2.0f); - m_client->triggerZoom(1.5f); - verifyZoomFactor(m_process, baseZoomFactor * 1.5f); - m_client->triggerZoom(0.5f); - verifyZoomFactor(m_process, baseZoomFactor * 0.5f); + + for (auto testZoomFactor : {2.0f, 1.5f, 0.5f}) { + m_client->triggerZoom(testZoomFactor); + verifyZoomFactor(m_process, baseZoomFactor * testZoomFactor); + } + m_client->triggerZoom(-1.0f); verifyZoomFactor(m_process, baseZoomFactor); m_process->stop(); -- cgit v1.2.3