aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml')
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp4
-rw-r--r--tests/auto/qml/debugger/qqmlpreview/tst_qqmlpreview.cpp2
-rw-r--r--tests/auto/qml/ecmascripttests/TestExpectations2
-rw-r--r--tests/auto/qml/parserstress/dummy_imports.qml8
-rw-r--r--tests/auto/qml/parserstress/tst_parserstress.cpp3
-rw-r--r--tests/auto/qml/qjsengine/tst_qjsengine.cpp24
-rw-r--r--tests/auto/qml/qjsvalue/qjsvalue.pro2
-rw-r--r--tests/auto/qml/qjsvalue/tst_qjsvalue.cpp37
-rw-r--r--tests/auto/qml/qjsvalue/tst_qjsvalue.h4
-rw-r--r--tests/auto/qml/qmlmin/tst_qmlmin.cpp2
-rw-r--r--tests/auto/qml/qmlplugindump/data/dumper/CompositeWithEnum/Animal.qml15
-rw-r--r--tests/auto/qml/qmlplugindump/data/dumper/CompositeWithEnum/qmldir3
-rw-r--r--tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp16
-rw-r--r--tests/auto/qml/qqmlapplicationengine/data/i18n/qml.qmbin0 -> 102 bytes
-rw-r--r--tests/auto/qml/qqmlapplicationengine/data/i18n/qml.ts11
-rw-r--r--tests/auto/qml/qqmlapplicationengine/data/loadTranslation.qml5
-rw-r--r--tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp27
-rw-r--r--tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.pro3
-rw-r--r--tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.qrc6
-rw-r--r--tests/auto/qml/qqmlbinding/data/MyComponent.qml2
-rw-r--r--tests/auto/qml/qqmlbinding/data/bindToQMLComponent.qml12
-rw-r--r--tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp8
-rw-r--r--tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp2
-rw-r--r--tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp15
-rw-r--r--tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp16
-rw-r--r--tests/auto/qml/qqmlecmascript/data/SingletonLookupTest.qml14
-rw-r--r--tests/auto/qml/qqmlecmascript/data/getThis.qml60
-rw-r--r--tests/auto/qml/qqmlecmascript/data/preserveBindingWithUnresolvedNames.qml4
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp75
-rw-r--r--tests/auto/qml/qqmlengine/tst_qqmlengine.cpp23
-rw-r--r--tests/auto/qml/qqmlenginecleanup/CustomModuleImport/CustomModule.pro13
-rw-r--r--tests/auto/qml/qqmlenginecleanup/CustomModuleImport/ModuleType.qml41
-rw-r--r--tests/auto/qml/qqmlenginecleanup/CustomModuleImport/moduleplugin.cpp60
-rw-r--r--tests/auto/qml/qqmlenginecleanup/CustomModuleImport/moduleplugin.qrc5
-rw-r--r--tests/auto/qml/qqmlenginecleanup/CustomModuleImport/qmldir3
-rw-r--r--tests/auto/qml/qqmlenginecleanup/qqmlenginecleanup.pro11
-rw-r--r--tests/auto/qml/qqmlenginecleanup/tst_qqmlenginecleanup.cpp18
-rw-r--r--tests/auto/qml/qqmlenginecleanup/tst_qqmlenginecleanup.pro9
-rw-r--r--tests/auto/qml/qqmlextensionplugin/tst_qqmlextensionplugin.cpp26
-rw-r--r--tests/auto/qml/qqmllocale/data/localeAsCppProperty.qml6
-rw-r--r--tests/auto/qml/qqmllocale/tst_qqmllocale.cpp5
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/importsMixedQmlCppPlugin.2.qml1
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/importsMixedQmlCppPlugin.qml1
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp23
-rw-r--r--tests/auto/qml/qqmlparser/tst_qqmlparser.cpp45
-rw-r--r--tests/auto/qml/qqmlstatemachine/tst_qqmlstatemachine.cpp2
46 files changed, 626 insertions, 48 deletions
diff --git a/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp
index 1ac28c473b..255d679b1b 100644
--- a/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp
+++ b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp
@@ -38,7 +38,6 @@
#include <QtTest/qtest.h>
#include <QtTest/qtestsystem.h>
#include <QtCore/qprocess.h>
-#include <QtCore/qtimer.h>
#include <QtCore/qfileinfo.h>
#include <QtCore/qdir.h>
#include <QtCore/qmutex.h>
@@ -162,8 +161,6 @@ private:
void targetData();
bool waitForClientSignal(const char *signal, int timeout = 30000);
void checkVersionParameters();
-
- QTime t;
};
@@ -171,7 +168,6 @@ private:
void tst_QQmlDebugJS::initTestCase()
{
QQmlDebugTest::initTestCase();
- t.start();
}
QQmlDebugTest::ConnectResult tst_QQmlDebugJS::init(bool qmlscene, const QString &qmlFile,
diff --git a/tests/auto/qml/debugger/qqmlpreview/tst_qqmlpreview.cpp b/tests/auto/qml/debugger/qqmlpreview/tst_qqmlpreview.cpp
index c7f8ec1118..f08f3c1da7 100644
--- a/tests/auto/qml/debugger/qqmlpreview/tst_qqmlpreview.cpp
+++ b/tests/auto/qml/debugger/qqmlpreview/tst_qqmlpreview.cpp
@@ -322,7 +322,7 @@ void tst_QQmlPreview::zoom()
for (auto testZoomFactor : {2.0f, 1.5f, 0.5f}) {
m_client->triggerZoom(testZoomFactor);
- verifyZoomFactor(m_process, baseZoomFactor * testZoomFactor);
+ verifyZoomFactor(m_process, testZoomFactor);
}
m_client->triggerZoom(-1.0f);
diff --git a/tests/auto/qml/ecmascripttests/TestExpectations b/tests/auto/qml/ecmascripttests/TestExpectations
index 0e0d70845b..4c04afe886 100644
--- a/tests/auto/qml/ecmascripttests/TestExpectations
+++ b/tests/auto/qml/ecmascripttests/TestExpectations
@@ -712,8 +712,6 @@ language/statements/generators/yield-identifier-non-strict.js sloppyFails
language/statements/let/block-local-closure-set-before-initialization.js fails
language/statements/let/function-local-closure-set-before-initialization.js fails
language/statements/let/global-closure-set-before-initialization.js fails
-language/statements/throw/S12.13_A2_T6.js strictFails
-language/statements/try/S12.14_A18_T6.js strictFails
language/statements/try/scope-catch-block-lex-open.js fails
language/statements/variable/binding-resolution.js sloppyFails
language/statements/with/unscopables-inc-dec.js sloppyFails
diff --git a/tests/auto/qml/parserstress/dummy_imports.qml b/tests/auto/qml/parserstress/dummy_imports.qml
new file mode 100644
index 0000000000..b9a196e188
--- /dev/null
+++ b/tests/auto/qml/parserstress/dummy_imports.qml
@@ -0,0 +1,8 @@
+// This file exists for the sole purpose for qmlimportscanner to find
+// which modules it needs to extract for deployment.
+// Otherwise, it fails to find the imports that are expressed in C++
+// code in tst_parserstress.cpp
+
+import QtQuick 2.0
+
+QtObject { } // This is needed in order to keep importscanner happy
diff --git a/tests/auto/qml/parserstress/tst_parserstress.cpp b/tests/auto/qml/parserstress/tst_parserstress.cpp
index e32fcabaf3..11851de76e 100644
--- a/tests/auto/qml/parserstress/tst_parserstress.cpp
+++ b/tests/auto/qml/parserstress/tst_parserstress.cpp
@@ -130,8 +130,7 @@ void tst_parserstress::ecmascript()
QCOMPARE(component.errors().at(1).line(), 142);
} else {
-
- QVERIFY(!component.isError());
+ QVERIFY2(!component.isError(), qPrintable(component.errorString()));
}
}
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
index 6ca2663f30..e08a1cc37e 100644
--- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
@@ -244,6 +244,7 @@ private slots:
void equality();
void aggressiveGc();
+ void noAccumulatorInTemplateLiteral();
void interrupt_data();
void interrupt();
@@ -1443,12 +1444,10 @@ public:
Q_DECLARE_METATYPE(Foo)
Q_DECLARE_METATYPE(Foo*)
-Q_DECLARE_METATYPE(QLinkedList<QString>)
Q_DECLARE_METATYPE(QList<Foo>)
Q_DECLARE_METATYPE(QVector<QChar>)
Q_DECLARE_METATYPE(QStack<int>)
Q_DECLARE_METATYPE(QQueue<char>)
-Q_DECLARE_METATYPE(QLinkedList<QStack<int> >)
void tst_QJSEngine::valueConversion_basic()
{
@@ -4842,6 +4841,23 @@ void tst_QJSEngine::aggressiveGc()
qputenv("QV4_MM_AGGRESSIVE_GC", origAggressiveGc);
}
+void tst_QJSEngine::noAccumulatorInTemplateLiteral()
+{
+ const QByteArray origAggressiveGc = qgetenv("QV4_MM_AGGRESSIVE_GC");
+ qputenv("QV4_MM_AGGRESSIVE_GC", "true");
+ {
+ QJSEngine engine;
+
+ // getTemplateLiteral should not save the accumulator as it's garbage and trashes
+ // the next GC run. Instead, we want to see the stack overflow error.
+ QJSValue value = engine.evaluate("function a(){\nS=o=>s\nFunction``\na()}a()");
+
+ QVERIFY(value.isError());
+ QCOMPARE(value.toString(), "RangeError: Maximum call stack size exceeded.");
+ }
+ qputenv("QV4_MM_AGGRESSIVE_GC", origAggressiveGc);
+}
+
void tst_QJSEngine::interrupt_data()
{
QTest::addColumn<int>("jitThreshold");
@@ -4892,6 +4908,7 @@ private:
void tst_QJSEngine::interrupt()
{
+#if QT_CONFIG(cxx11_future)
QFETCH(int, jitThreshold);
QFETCH(QString, code);
@@ -4916,6 +4933,9 @@ void tst_QJSEngine::interrupt()
QVERIFY(worker->wait());
QVERIFY(!engineInThread);
+#else
+ QSKIP("This test requires C++11 futures");
+#endif
}
QTEST_MAIN(tst_QJSEngine)
diff --git a/tests/auto/qml/qjsvalue/qjsvalue.pro b/tests/auto/qml/qjsvalue/qjsvalue.pro
index 3bbbbd4787..a01cffa100 100644
--- a/tests/auto/qml/qjsvalue/qjsvalue.pro
+++ b/tests/auto/qml/qjsvalue/qjsvalue.pro
@@ -1,6 +1,6 @@
CONFIG += testcase
TARGET = tst_qjsvalue
macx:CONFIG -= app_bundle
-QT += qml widgets testlib gui-private
+QT += qml widgets testlib gui-private qml-private
SOURCES += tst_qjsvalue.cpp
HEADERS += tst_qjsvalue.h
diff --git a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp
index a57cd3113c..4de72ae7a1 100644
--- a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp
+++ b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp
@@ -27,7 +27,14 @@
****************************************************************************/
#include "tst_qjsvalue.h"
+
+#include <private/qv4engine_p.h>
+#include <private/qjsvalue_p.h>
+
#include <QtWidgets/QPushButton>
+#include <QtCore/qthread.h>
+
+#include <memory>
tst_QJSValue::tst_QJSValue()
: engine(nullptr)
@@ -2650,4 +2657,34 @@ void tst_QJSValue::nestedObjectToVariant()
QCOMPARE(o.toVariant(), expected);
}
+void tst_QJSValue::deleteFromDifferentThread()
+{
+#if !QT_CONFIG(thread)
+ QSKIP("Need thread support to destroy QJSValues from different threads");
+#else
+ QV4::PersistentValueStorage storage(engine->handle());
+ QCOMPARE(storage.firstPage, nullptr);
+ QJSValue jsval;
+ QJSValuePrivate::setRawValue(&jsval, storage.allocate());
+ QVERIFY(storage.firstPage != nullptr);
+
+ QMutex mutex;
+ QWaitCondition condition;
+
+ std::unique_ptr<QThread> thread(QThread::create([&]() {
+ QMutexLocker locker(&mutex);
+ QJSValuePrivate::free(&jsval);
+ QJSValuePrivate::setRawValue(&jsval, nullptr);
+ QVERIFY(storage.firstPage != nullptr);
+ condition.wakeOne();
+ }));
+
+ QMutexLocker locker(&mutex);
+ thread->start();
+ condition.wait(&mutex);
+ QTRY_VERIFY(thread->isFinished());
+ QTRY_COMPARE(storage.firstPage, nullptr);
+#endif
+}
+
QTEST_MAIN(tst_QJSValue)
diff --git a/tests/auto/qml/qjsvalue/tst_qjsvalue.h b/tests/auto/qml/qjsvalue/tst_qjsvalue.h
index 9532b1f10e..f704169d43 100644
--- a/tests/auto/qml/qjsvalue/tst_qjsvalue.h
+++ b/tests/auto/qml/qjsvalue/tst_qjsvalue.h
@@ -35,8 +35,6 @@
#include <qjsvalue.h>
#include <QtTest/QtTest>
-Q_DECLARE_METATYPE(QVariant)
-
class tst_QJSValue : public QObject
{
Q_OBJECT
@@ -144,6 +142,8 @@ private slots:
void nestedObjectToVariant_data();
void nestedObjectToVariant();
+ void deleteFromDifferentThread();
+
private:
void newEngine()
{
diff --git a/tests/auto/qml/qmlmin/tst_qmlmin.cpp b/tests/auto/qml/qmlmin/tst_qmlmin.cpp
index d1e74aecef..696ec66246 100644
--- a/tests/auto/qml/qmlmin/tst_qmlmin.cpp
+++ b/tests/auto/qml/qmlmin/tst_qmlmin.cpp
@@ -64,6 +64,7 @@ tst_qmlmin::tst_qmlmin()
void tst_qmlmin::initTestCase()
{
+#if QT_CONFIG(process) && !defined(QTEST_CROSS_COMPILED) // sources not available when cross compiled
qmlminPath = QLibraryInfo::location(QLibraryInfo::BinariesPath) + QLatin1String("/qmlmin");
#ifdef Q_OS_WIN
qmlminPath += QLatin1String(".exe");
@@ -129,6 +130,7 @@ void tst_qmlmin::initTestCase()
invalidFiles << "tests/auto/qml/qjsengine/script/com/trolltech/syntaxerror/__init__.js";
invalidFiles << "tests/auto/qml/debugger/qqmlpreview/data/broken.qml";
invalidFiles << "tests/auto/qml/qqmllanguage/data/fuzzed.2.qml";
+#endif
}
QStringList tst_qmlmin::findFiles(const QDir &d)
diff --git a/tests/auto/qml/qmlplugindump/data/dumper/CompositeWithEnum/Animal.qml b/tests/auto/qml/qmlplugindump/data/dumper/CompositeWithEnum/Animal.qml
new file mode 100644
index 0000000000..5bd7788a8c
--- /dev/null
+++ b/tests/auto/qml/qmlplugindump/data/dumper/CompositeWithEnum/Animal.qml
@@ -0,0 +1,15 @@
+pragma Singleton
+import QtQml 2.0
+
+QtObject {
+ property string name
+ property string category
+ property string sound
+ property int size: Animal.SizeSmall
+
+ enum SizeType {
+ SizeSmall,
+ SizeMedium,
+ SizeLarge
+ }
+}
diff --git a/tests/auto/qml/qmlplugindump/data/dumper/CompositeWithEnum/qmldir b/tests/auto/qml/qmlplugindump/data/dumper/CompositeWithEnum/qmldir
new file mode 100644
index 0000000000..f08b348efa
--- /dev/null
+++ b/tests/auto/qml/qmlplugindump/data/dumper/CompositeWithEnum/qmldir
@@ -0,0 +1,3 @@
+module dumper.CompositeWithEnum
+singleton Animal 1.0 Animal.qml
+depends QtQml 2.0
diff --git a/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp b/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp
index 17766a89b5..72356a4d84 100644
--- a/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp
+++ b/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp
@@ -46,6 +46,7 @@ private slots:
void builtins();
void singleton();
void compositeWithinSingleton();
+ void compositeWithEnum();
void plugin_data();
void plugin();
@@ -135,6 +136,21 @@ void tst_qmlplugindump::compositeWithinSingleton()
QVERIFY2(result.contains(QLatin1String("exportMetaObjectRevisions: [0]")), qPrintable(result));
}
+void tst_qmlplugindump::compositeWithEnum()
+{
+ QProcess dumper;
+ QStringList args;
+ args << QLatin1String("dumper.CompositeWithEnum") << QLatin1String("1.0")
+ << QLatin1String(QT_QMLTEST_DIR "/data");
+ dumper.start(qmlplugindumpPath, args);
+ QVERIFY2(dumper.waitForStarted(), qPrintable(dumper.errorString()));
+ QVERIFY2(dumper.waitForFinished(), qPrintable(dumper.errorString()));
+
+ const QString &result = dumper.readAllStandardOutput();
+ QVERIFY2(result.contains(QLatin1String("exports: [\"Animal 1.0\"]")), qPrintable(result));
+ QVERIFY2(result.contains(QLatin1String("Enum {")), qPrintable(result));
+}
+
void tst_qmlplugindump::plugin_data()
{
QTest::addColumn<QString>("import");
diff --git a/tests/auto/qml/qqmlapplicationengine/data/i18n/qml.qm b/tests/auto/qml/qqmlapplicationengine/data/i18n/qml.qm
new file mode 100644
index 0000000000..8e3c4967c2
--- /dev/null
+++ b/tests/auto/qml/qqmlapplicationengine/data/i18n/qml.qm
Binary files differ
diff --git a/tests/auto/qml/qqmlapplicationengine/data/i18n/qml.ts b/tests/auto/qml/qqmlapplicationengine/data/i18n/qml.ts
new file mode 100644
index 0000000000..51a204be3e
--- /dev/null
+++ b/tests/auto/qml/qqmlapplicationengine/data/i18n/qml.ts
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.1" language="" sourcelanguage="en">
+<context>
+ <name>loadTranslation</name>
+ <message>
+ <source>translate it</source>
+ <translation>translated</translation>
+ </message>
+</context>
+</TS>
diff --git a/tests/auto/qml/qqmlapplicationengine/data/loadTranslation.qml b/tests/auto/qml/qqmlapplicationengine/data/loadTranslation.qml
new file mode 100644
index 0000000000..bba4cab8d6
--- /dev/null
+++ b/tests/auto/qml/qqmlapplicationengine/data/loadTranslation.qml
@@ -0,0 +1,5 @@
+import QtQml 2.0
+
+QtObject {
+ property string translation: qsTr('translate it')
+}
diff --git a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp
index ce654dc45e..a9c28a0911 100644
--- a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp
+++ b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp
@@ -50,6 +50,9 @@ private slots:
void application();
void applicationProperties();
void removeObjectsWhenDestroyed();
+ void loadTranslation_data();
+ void loadTranslation();
+
private:
QString buildDir;
QString srcDir;
@@ -241,6 +244,30 @@ void tst_qqmlapplicationengine::removeObjectsWhenDestroyed()
QCOMPARE(test->rootObjects().size(), 0);
}
+void tst_qqmlapplicationengine::loadTranslation_data()
+{
+ QTest::addColumn<QUrl>("qmlUrl");
+ QTest::addColumn<QString>("translation");
+
+ QTest::newRow("local file") << testFileUrl("loadTranslation.qml")
+ << QStringLiteral("translated");
+ QTest::newRow("qrc") << QUrl(QLatin1String("qrc:///data/loadTranslation.qml"))
+ << QStringLiteral("translated");
+}
+
+void tst_qqmlapplicationengine::loadTranslation()
+{
+ QFETCH(QUrl, qmlUrl);
+ QFETCH(QString, translation);
+
+ QQmlApplicationEngine test(qmlUrl);
+ QVERIFY(!test.rootObjects().isEmpty());
+
+ QObject *rootObject = test.rootObjects().first();
+ QVERIFY(rootObject);
+
+ QCOMPARE(rootObject->property("translation").toString(), translation);
+}
QTEST_MAIN(tst_qqmlapplicationengine)
diff --git a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.pro b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.pro
index 18c38a80b6..88d07f2b62 100644
--- a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.pro
+++ b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.pro
@@ -5,6 +5,9 @@ macx:CONFIG -= app_bundle
SOURCES += tst_qqmlapplicationengine.cpp
TESTDATA += data/*
+RESOURCES += tst_qqmlapplicationengine.qrc
include (../../shared/util.pri)
QT += core-private gui-private qml-private network testlib
+
+TRANSLATIONS = data/i18n/qml_ja.ts
diff --git a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.qrc b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.qrc
new file mode 100644
index 0000000000..de79d665a3
--- /dev/null
+++ b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/">
+ <file>data/loadTranslation.qml</file>
+ <file>data/i18n/qml.qm</file>
+ </qresource>
+</RCC>
diff --git a/tests/auto/qml/qqmlbinding/data/MyComponent.qml b/tests/auto/qml/qqmlbinding/data/MyComponent.qml
new file mode 100644
index 0000000000..5892539a5d
--- /dev/null
+++ b/tests/auto/qml/qqmlbinding/data/MyComponent.qml
@@ -0,0 +1,2 @@
+import QtQuick 2.3
+QtObject { property real p: 0 }
diff --git a/tests/auto/qml/qqmlbinding/data/bindToQMLComponent.qml b/tests/auto/qml/qqmlbinding/data/bindToQMLComponent.qml
new file mode 100644
index 0000000000..471db9023b
--- /dev/null
+++ b/tests/auto/qml/qqmlbinding/data/bindToQMLComponent.qml
@@ -0,0 +1,12 @@
+import QtQuick 2.0
+
+Item {
+ id: root
+ property MyComponent myProperty
+ Binding {
+ target: root
+ property: "myProperty"
+ value: myObject
+ }
+ MyComponent { id: myObject }
+}
diff --git a/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp b/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp
index 717fd5dbd1..9b66cd828a 100644
--- a/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp
+++ b/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp
@@ -54,6 +54,7 @@ private slots:
void disabledOnReadonlyProperty();
void delayed();
void bindingOverwriting();
+ void bindToQmlComponent();
private:
QQmlEngine engine;
@@ -394,6 +395,13 @@ void tst_qqmlbinding::bindingOverwriting()
QCOMPARE(messageHandler.messages().count(), 2);
}
+void tst_qqmlbinding::bindToQmlComponent()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("bindToQMLComponent.qml"));
+ QVERIFY(c.create());
+}
+
QTEST_MAIN(tst_qqmlbinding)
#include "tst_qqmlbinding.moc"
diff --git a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
index 98ae86d248..6a3bf53a31 100644
--- a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
+++ b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
@@ -635,9 +635,11 @@ void tst_qqmlcomponent::relativeUrl_data()
{
QTest::addColumn<QUrl>("url");
+#if !defined(Q_OS_ANDROID)
QTest::addRow("fromLocalFile") << QUrl::fromLocalFile("data/QtObjectComponent.qml");
QTest::addRow("fromLocalFileHash") << QUrl::fromLocalFile("data/QtObjectComponent#2.qml");
QTest::addRow("constructor") << QUrl("data/QtObjectComponent.qml");
+#endif
QTest::addRow("absolute") << QUrl::fromLocalFile(QFINDTESTDATA("data/QtObjectComponent.qml"));
QTest::addRow("qrc") << QUrl("qrc:/data/QtObjectComponent.qml");
}
diff --git a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp
index cb4bee0d3a..d9cb6673df 100644
--- a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp
+++ b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp
@@ -71,6 +71,7 @@ private slots:
void outerContextObject();
void contextObjectHierarchy();
+ void destroyContextProperty();
private:
QQmlEngine engine;
@@ -892,6 +893,20 @@ void tst_qqmlcontext::contextObjectHierarchy()
});
}
+void tst_qqmlcontext::destroyContextProperty()
+{
+ QQmlEngine engine;
+ QQmlContext context(&engine);
+
+ {
+ QObject object;
+ context.setContextProperty(QLatin1String("a"), &object);
+ QCOMPARE(qvariant_cast<QObject *>(context.contextProperty(QLatin1String("a"))), &object);
+ }
+
+ QCOMPARE(qvariant_cast<QObject *>(context.contextProperty(QLatin1String("a"))), nullptr);
+}
+
QTEST_MAIN(tst_qqmlcontext)
#include "tst_qqmlcontext.moc"
diff --git a/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp b/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp
index 3643ca65c6..1e690e38dd 100644
--- a/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp
+++ b/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp
@@ -32,6 +32,7 @@
#include <QObject>
#include <QQmlEngine>
#include <QQmlComponent>
+#include <private/qqmljsdiagnosticmessage_p.h>
#include <private/qqmldirparser_p.h>
#include <QDebug>
@@ -56,12 +57,21 @@ tst_qqmldirparser::tst_qqmldirparser()
namespace {
- QStringList toStringList(const QList<QQmlError> &errors)
+ QStringList toStringList(const QList<QQmlJS::DiagnosticMessage> &errors)
{
QStringList rv;
- foreach (const QQmlError &e, errors)
- rv.append(e.toString());
+ for (const QQmlJS::DiagnosticMessage &e : errors) {
+ QString errorString = QLatin1String("qmldir");
+ if (e.line > 0) {
+ errorString += QLatin1Char(':') + QString::number(e.line);
+ if (e.column > 0)
+ errorString += QLatin1Char(':') + QString::number(e.column);
+ }
+
+ errorString += QLatin1String(": ") + e.message;
+ rv.append(errorString);
+ }
return rv;
}
diff --git a/tests/auto/qml/qqmlecmascript/data/SingletonLookupTest.qml b/tests/auto/qml/qqmlecmascript/data/SingletonLookupTest.qml
new file mode 100644
index 0000000000..3166ab647d
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/SingletonLookupTest.qml
@@ -0,0 +1,14 @@
+import QtQml 2.0
+import Test.Singletons 1.0
+
+QtObject {
+ property Component singletonAccessor : Component {
+ QtObject {
+ property var singletonHolder;
+ property int result: singletonHolder.testVar
+ }
+ }
+
+ property int firstLookup: singletonAccessor.createObject(this, { singletonHolder: CppSingleton1 }).result;
+ property int secondLookup: singletonAccessor.createObject(this, { singletonHolder: CppSingleton2 }).result;
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/getThis.qml b/tests/auto/qml/qqmlecmascript/data/getThis.qml
new file mode 100644
index 0000000000..cd617ee3c0
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/getThis.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQml 2.12
+
+QtObject {
+ id: root
+ property QtObject self;
+
+ property Timer timer: Timer {
+ running: true
+ interval: 1
+ onTriggered: {
+ root.assignThis();
+ root.self = null;
+ root.assignThis();
+ }
+ }
+
+ function getThis() {
+ return this;
+ }
+
+ function assignThis() {
+ self = getThis();
+ }
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/preserveBindingWithUnresolvedNames.qml b/tests/auto/qml/qqmlecmascript/data/preserveBindingWithUnresolvedNames.qml
new file mode 100644
index 0000000000..a57bafb07b
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/preserveBindingWithUnresolvedNames.qml
@@ -0,0 +1,4 @@
+import QtQml 2.0
+QtObject {
+ property string testTypeOf: typeof(contextProp)
+}
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 5ae9a6b038..b1a1ed4dec 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -356,6 +356,7 @@ private slots:
void callPropertyOnUndefined();
void jumpStrictNotEqualUndefined();
void removeBindingsWithNoDependencies();
+ void preserveBindingWithUnresolvedNames();
void temporaryDeadZone();
void importLexicalVariables_data();
void importLexicalVariables();
@@ -369,6 +370,8 @@ private slots:
void intMinDividedByMinusOne();
void undefinedPropertiesInObjectWrapper();
void hugeRegexpQuantifiers();
+ void singletonTypeWrapperLookup();
+ void getThisObject();
private:
// static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter);
@@ -8841,6 +8844,18 @@ void tst_qqmlecmascript::removeBindingsWithNoDependencies()
}
+void tst_qqmlecmascript::preserveBindingWithUnresolvedNames()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("preserveBindingWithUnresolvedNames.qml"));
+ QScopedPointer<QObject> object(component.create());
+ QVERIFY(!object.isNull());
+ QCOMPARE(object->property("testTypeOf").toString(), QString("undefined"));
+ QObject obj;
+ engine.rootContext()->setContextProperty("contextProp", &obj);
+ QCOMPARE(object->property("testTypeOf").toString(), QString("object"));
+}
+
void tst_qqmlecmascript::temporaryDeadZone()
{
QJSEngine engine;
@@ -9007,6 +9022,66 @@ void tst_qqmlecmascript::hugeRegexpQuantifiers()
QVERIFY(value.isRegExp());
}
+struct CppSingleton1 : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int testVar MEMBER testVar CONSTANT)
+public:
+ const int testVar = 0;
+};
+
+struct CppSingleton2 : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int testVar MEMBER testVar CONSTANT)
+public:
+ const int testVar = 1;
+};
+
+void tst_qqmlecmascript::singletonTypeWrapperLookup()
+{
+ QQmlEngine engine;
+
+ auto singletonTypeId1 = qmlRegisterSingletonType<CppSingleton1>("Test.Singletons", 1, 0, "CppSingleton1",
+ [](QQmlEngine *, QJSEngine *) -> QObject * {
+ return new CppSingleton1;
+ });
+
+ auto singletonTypeId2 = qmlRegisterSingletonType<CppSingleton2>("Test.Singletons", 1, 0, "CppSingleton2",
+ [](QQmlEngine *, QJSEngine *) -> QObject * {
+ return new CppSingleton2;
+ });
+
+ auto cleanup = qScopeGuard([&]() {
+ QQmlMetaType::unregisterType(singletonTypeId1);
+ QQmlMetaType::unregisterType(singletonTypeId2);
+ });
+
+ QQmlComponent component(&engine, testFileUrl("SingletonLookupTest.qml"));
+ QScopedPointer<QObject> test(component.create());
+ QVERIFY2(!test.isNull(), qPrintable(component.errorString()));
+
+ auto singleton1 = engine.singletonInstance<CppSingleton1*>(singletonTypeId1);
+ QVERIFY(singleton1);
+
+ auto singleton2 = engine.singletonInstance<CppSingleton2*>(singletonTypeId2);
+ QVERIFY(singleton2);
+
+ QCOMPARE(test->property("firstLookup").toInt(), singleton1->testVar);
+ QCOMPARE(test->property("secondLookup").toInt(), singleton2->testVar);
+}
+
+void tst_qqmlecmascript::getThisObject()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("getThis.qml"));
+ QVERIFY(component.isReady());
+ QScopedPointer<QObject> test(component.create());
+ QVERIFY(!test.isNull());
+
+ QTRY_COMPARE(qvariant_cast<QObject *>(test->property("self")), test.data());
+}
+
QTEST_MAIN(tst_qqmlecmascript)
#include "tst_qqmlecmascript.moc"
diff --git a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
index 0cb6753020..e55cd6f7a0 100644
--- a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
+++ b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
@@ -835,7 +835,7 @@ void tst_qqmlengine::urlInterceptor()
QFETCH(QString, expectedAbsoluteUrl);
QQmlEngine e;
- e.setImportPathList(QStringList() << testFileUrl("interception/imports").toLocalFile());
+ e.addImportPath(testFileUrl("interception/imports").toLocalFile());
CustomSelector cs(testFileUrl(""));
cs.m_interceptionPoints = interceptionPoint;
e.setUrlInterceptor(&cs);
@@ -935,7 +935,7 @@ void tst_qqmlengine::cppSignalAndEval()
{
ObjectCaller objectCaller;
QQmlEngine engine;
- engine.rootContext()->setContextProperty(QLatin1Literal("CallerCpp"), &objectCaller);
+ engine.rootContext()->setContextProperty(QLatin1String("CallerCpp"), &objectCaller);
QQmlComponent c(&engine);
c.setData("import QtQuick 2.9\n"
"Item {\n"
@@ -1015,6 +1015,25 @@ void tst_qqmlengine::singletonInstance()
}
{
+ int data = 30;
+ auto id = qmlRegisterSingletonType<CppSingleton>("Qt.test",1,0,"CapturingLambda",[data](QQmlEngine*, QJSEngine*){ // register qobject singleton with capturing lambda
+ auto o = new CppSingleton;
+ o->setProperty("data", data);
+ return o;
+ });
+ QJSValue value = engine.singletonInstance<QJSValue>(id);
+ QVERIFY(!value.isUndefined());
+ QVERIFY(value.isQObject());
+ QObject *instance = value.toQObject();
+ QVERIFY(instance);
+ QCOMPARE(instance->metaObject()->className(), "CppSingleton");
+ QCOMPARE(instance->property("data"), data);
+ }
+ {
+ qmlRegisterSingletonType<CppSingleton>("Qt.test",1,0,"NotAmbiguous", [](QQmlEngine* qeng, QJSEngine* jeng) -> QObject* {return CppSingleton::create(qeng, jeng);}); // test that overloads for qmlRegisterSingleton are not ambiguous
+ }
+
+ {
// Invalid types
QJSValue value;
value = engine.singletonInstance<QJSValue>(-4711);
diff --git a/tests/auto/qml/qqmlenginecleanup/CustomModuleImport/CustomModule.pro b/tests/auto/qml/qqmlenginecleanup/CustomModuleImport/CustomModule.pro
new file mode 100644
index 0000000000..3366ddc165
--- /dev/null
+++ b/tests/auto/qml/qqmlenginecleanup/CustomModuleImport/CustomModule.pro
@@ -0,0 +1,13 @@
+TEMPLATE = lib
+TARGET = CustomModule
+QT += quick qml
+
+CONFIG += qtquickcompiler
+SOURCES += moduleplugin.cpp
+RESOURCES += moduleplugin.qrc
+
+DESTDIR = ../CustomModule
+
+IMPORT_FILES = qmldir
+
+include (../../../shared/imports.pri)
diff --git a/tests/auto/qml/qqmlenginecleanup/CustomModuleImport/ModuleType.qml b/tests/auto/qml/qqmlenginecleanup/CustomModuleImport/ModuleType.qml
new file mode 100644
index 0000000000..ed154e3aa9
--- /dev/null
+++ b/tests/auto/qml/qqmlenginecleanup/CustomModuleImport/ModuleType.qml
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQml 2.12
+
+QtObject {
+ objectName: "moduleType"
+}
diff --git a/tests/auto/qml/qqmlenginecleanup/CustomModuleImport/moduleplugin.cpp b/tests/auto/qml/qqmlenginecleanup/CustomModuleImport/moduleplugin.cpp
new file mode 100644
index 0000000000..048250c730
--- /dev/null
+++ b/tests/auto/qml/qqmlenginecleanup/CustomModuleImport/moduleplugin.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtQml/qqmlextensionplugin.h>
+#include <QtQml/qqmlengine.h>
+
+QT_BEGIN_NAMESPACE
+
+class ModulePlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
+
+public:
+ ModulePlugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) {}
+ void registerTypes(const char *uri) override;
+};
+
+void ModulePlugin::registerTypes(const char *uri)
+{
+ qmlRegisterModule(uri, 1, 0);
+ qmlRegisterType(QUrl("qrc:/ModuleType.qml"), uri, 1, 0, "ModuleType");
+}
+
+QT_END_NAMESPACE
+
+#include "moduleplugin.moc"
diff --git a/tests/auto/qml/qqmlenginecleanup/CustomModuleImport/moduleplugin.qrc b/tests/auto/qml/qqmlenginecleanup/CustomModuleImport/moduleplugin.qrc
new file mode 100644
index 0000000000..c8f7dea691
--- /dev/null
+++ b/tests/auto/qml/qqmlenginecleanup/CustomModuleImport/moduleplugin.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>ModuleType.qml</file>
+ </qresource>
+</RCC>
diff --git a/tests/auto/qml/qqmlenginecleanup/CustomModuleImport/qmldir b/tests/auto/qml/qqmlenginecleanup/CustomModuleImport/qmldir
new file mode 100644
index 0000000000..f421ba44dc
--- /dev/null
+++ b/tests/auto/qml/qqmlenginecleanup/CustomModuleImport/qmldir
@@ -0,0 +1,3 @@
+module CustomModule
+plugin CustomModule
+classname ModulePlugin
diff --git a/tests/auto/qml/qqmlenginecleanup/qqmlenginecleanup.pro b/tests/auto/qml/qqmlenginecleanup/qqmlenginecleanup.pro
index 90508609a8..34c49a5c0e 100644
--- a/tests/auto/qml/qqmlenginecleanup/qqmlenginecleanup.pro
+++ b/tests/auto/qml/qqmlenginecleanup/qqmlenginecleanup.pro
@@ -1,9 +1,2 @@
-CONFIG += testcase
-TARGET = tst_qqmlenginecleanup
-macx:CONFIG -= app_bundle
-
-include (../../shared/util.pri)
-
-SOURCES += tst_qqmlenginecleanup.cpp
-
-QT += testlib qml qml-private
+TEMPLATE = subdirs
+SUBDIRS += tst_qqmlenginecleanup.pro CustomModuleImport/CustomModule.pro
diff --git a/tests/auto/qml/qqmlenginecleanup/tst_qqmlenginecleanup.cpp b/tests/auto/qml/qqmlenginecleanup/tst_qqmlenginecleanup.cpp
index b9cede6d13..690db30838 100644
--- a/tests/auto/qml/qqmlenginecleanup/tst_qqmlenginecleanup.cpp
+++ b/tests/auto/qml/qqmlenginecleanup/tst_qqmlenginecleanup.cpp
@@ -44,6 +44,7 @@ public:
private slots:
void test_qmlClearTypeRegistrations();
void test_valueTypeProviderModule(); // QTBUG-43004
+ void test_customModuleCleanup();
};
// A wrapper around QQmlComponent to ensure the temporary reference counts
@@ -168,6 +169,23 @@ void tst_qqmlenginecleanup::test_valueTypeProviderModule()
QVERIFY(noDangling);
}
+void tst_qqmlenginecleanup::test_customModuleCleanup()
+{
+ for (int i = 0; i < 5; ++i) {
+ qmlClearTypeRegistrations();
+
+ QQmlEngine engine;
+ engine.addImportPath(QT_TESTCASE_BUILDDIR);
+
+ QQmlComponent component(&engine);
+ component.setData("import CustomModule 1.0\nModuleType {}", QUrl());
+ QCOMPARE(component.status(), QQmlComponent::Ready);
+
+ QScopedPointer<QObject> object(component.create());
+ QVERIFY(!object.isNull());
+ }
+}
+
QTEST_MAIN(tst_qqmlenginecleanup)
#include "tst_qqmlenginecleanup.moc"
diff --git a/tests/auto/qml/qqmlenginecleanup/tst_qqmlenginecleanup.pro b/tests/auto/qml/qqmlenginecleanup/tst_qqmlenginecleanup.pro
new file mode 100644
index 0000000000..90508609a8
--- /dev/null
+++ b/tests/auto/qml/qqmlenginecleanup/tst_qqmlenginecleanup.pro
@@ -0,0 +1,9 @@
+CONFIG += testcase
+TARGET = tst_qqmlenginecleanup
+macx:CONFIG -= app_bundle
+
+include (../../shared/util.pri)
+
+SOURCES += tst_qqmlenginecleanup.cpp
+
+QT += testlib qml qml-private
diff --git a/tests/auto/qml/qqmlextensionplugin/tst_qqmlextensionplugin.cpp b/tests/auto/qml/qqmlextensionplugin/tst_qqmlextensionplugin.cpp
index 341a49bf09..16b8fe578d 100644
--- a/tests/auto/qml/qqmlextensionplugin/tst_qqmlextensionplugin.cpp
+++ b/tests/auto/qml/qqmlextensionplugin/tst_qqmlextensionplugin.cpp
@@ -47,18 +47,21 @@ class tst_qqmlextensionplugin : public QObject
{
Q_OBJECT
- bool isDuplicate(QString file, const QList<QString> & files) {
-#ifndef DEBUG_SUFFIX
- Q_UNUSED(file)
- Q_UNUSED(files)
- return false;
-#else
+ static QStringList removeDuplicates(QStringList files) {
+#ifdef DEBUG_SUFFIX
+ const auto isDuplicate = [files] (QString file) {
# ifdef QT_DEBUG
- return !file.endsWith(DEBUG_SUFFIX) && files.contains(file.replace(SUFFIX, DEBUG_SUFFIX));
+ return !file.endsWith(DEBUG_SUFFIX) && files.contains(file.replace(SUFFIX, DEBUG_SUFFIX));
# else
- return file.endsWith(DEBUG_SUFFIX) && files.contains(file.replace(DEBUG_SUFFIX, SUFFIX));
+ return file.endsWith(DEBUG_SUFFIX) && files.contains(file.replace(DEBUG_SUFFIX, SUFFIX));
# endif
+ };
+
+ files.erase(std::remove_if(files.begin(), files.end(), isDuplicate),
+ files.end());
+
#endif
+ return files;
}
public:
@@ -84,12 +87,7 @@ void tst_qqmlextensionplugin::iidCheck_data()
}
}
- for (QMutableListIterator<QString> it(files); it.hasNext(); ) {
- QString file = it.next();
- if (isDuplicate(file, files)) {
- it.remove();
- }
- }
+ files = removeDuplicates(std::move(files));
QTest::addColumn<QString>("filePath");
foreach (const QString &file, files) {
diff --git a/tests/auto/qml/qqmllocale/data/localeAsCppProperty.qml b/tests/auto/qml/qqmllocale/data/localeAsCppProperty.qml
new file mode 100644
index 0000000000..ff80f3cf85
--- /dev/null
+++ b/tests/auto/qml/qqmllocale/data/localeAsCppProperty.qml
@@ -0,0 +1,6 @@
+import QtQml 2.2
+import Test 1.0
+Calendar {
+ locale: Qt.locale('en_GB')
+ property var testLocale
+}
diff --git a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp
index eb6eb62648..cc13fb4b5f 100644
--- a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp
+++ b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp
@@ -1214,10 +1214,9 @@ private:
void tst_qqmllocale::localeAsCppProperty()
{
- QQmlComponent component(&engine);
qmlRegisterType<Calendar>("Test", 1, 0, "Calendar");
- component.setData("import QtQml 2.2\nimport Test 1.0\nCalendar { locale: Qt.locale('en_GB'); property var testLocale }", QUrl());
- QVERIFY(!component.isError());
+ QQmlComponent component(&engine, testFileUrl("localeAsCppProperty.qml"));
+ QVERIFY2(!component.isError(), qPrintable(component.errorString()));
QTRY_VERIFY(component.isReady());
Calendar *item = qobject_cast<Calendar*>(component.create());
diff --git a/tests/auto/qml/qqmlmoduleplugin/data/importsMixedQmlCppPlugin.2.qml b/tests/auto/qml/qqmlmoduleplugin/data/importsMixedQmlCppPlugin.2.qml
index b13b2004c2..ba6bb3d7ac 100644
--- a/tests/auto/qml/qqmlmoduleplugin/data/importsMixedQmlCppPlugin.2.qml
+++ b/tests/auto/qml/qqmlmoduleplugin/data/importsMixedQmlCppPlugin.2.qml
@@ -1,5 +1,6 @@
import org.qtproject.AutoTestQmlMixedPluginType 1.5
import QtQuick 2.0
+import QtQml 2.0
Item {
property bool test: false
diff --git a/tests/auto/qml/qqmlmoduleplugin/data/importsMixedQmlCppPlugin.qml b/tests/auto/qml/qqmlmoduleplugin/data/importsMixedQmlCppPlugin.qml
index 563c0b28e3..f1268075c1 100644
--- a/tests/auto/qml/qqmlmoduleplugin/data/importsMixedQmlCppPlugin.qml
+++ b/tests/auto/qml/qqmlmoduleplugin/data/importsMixedQmlCppPlugin.qml
@@ -1,5 +1,6 @@
import org.qtproject.AutoTestQmlMixedPluginType 1.0
import QtQuick 2.0
+import QtQml 2.0
Item {
property bool test: false
diff --git a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp
index 97ca3fa1de..3148ffb5a5 100644
--- a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp
+++ b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp
@@ -34,6 +34,10 @@
#include <QtCore/qjsondocument.h>
#include <QtCore/qjsonarray.h>
#include <QDebug>
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+#include <QCborMap>
+#include <QCborValue>
+#endif
#if defined(Q_OS_MAC)
// For _PC_CASE_SENSITIVE
@@ -130,8 +134,7 @@ QByteArray SecondStaticPlugin::metaData;
template <typename PluginType>
void registerStaticPlugin(const char *uri)
{
- QStaticPlugin plugin;
- plugin.instance = []() {
+ auto instanceFunctor = []() {
static PluginType plugin;
return static_cast<QObject*>(&plugin);
};
@@ -142,12 +145,28 @@ void registerStaticPlugin(const char *uri)
uris.append(uri);
md.insert(QStringLiteral("uri"), uris);
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ PluginType::metaData.append(QLatin1String("QTMETADATA !"));
+ PluginType::metaData.append(char(0)); // current version
+ PluginType::metaData.append(char(QT_VERSION_MAJOR));
+ PluginType::metaData.append(char(QT_VERSION_MINOR));
+ PluginType::metaData.append(char(qPluginArchRequirements()));
+ PluginType::metaData.append(QCborValue(QCborMap::fromJsonObject(md)).toCbor());
+
+ auto rawMetaDataFunctor = []() -> QPluginMetaData {
+ return {reinterpret_cast<const uchar *>(PluginType::metaData.constData()), size_t(PluginType::metaData.length())};
+ };
+ QStaticPlugin plugin(instanceFunctor, rawMetaDataFunctor);
+#else
PluginType::metaData.append(QLatin1String("QTMETADATA "));
PluginType::metaData.append(QJsonDocument(md).toBinaryData());
+ QStaticPlugin plugin;
+ plugin.instance = instanceFunctor;
plugin.rawMetaData = []() {
return PluginType::metaData.constData();
};
+#endif
qRegisterStaticPluginFunction(plugin);
};
diff --git a/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp
index fead8c4ebc..5f58df75d4 100644
--- a/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp
+++ b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp
@@ -54,6 +54,8 @@ private slots:
void noSubstitutionTemplateLiteral();
void templateLiteral();
void leadingSemicolonInClass();
+ void templatedReadonlyProperty();
+ void qmlImportInJSRequiresFullVersion();
private:
QStringList excludedDirs;
@@ -289,6 +291,49 @@ void tst_qqmlparser::leadingSemicolonInClass()
QVERIFY(parser.parseProgram());
}
+void tst_qqmlparser::templatedReadonlyProperty()
+{
+ QQmlJS::Engine engine;
+ QQmlJS::Lexer lexer(&engine);
+ lexer.setCode(QLatin1String("A { readonly property list<B> listfoo: [ C{} ] }"), 1);
+ QQmlJS::Parser parser(&engine);
+ QVERIFY(parser.parse());
+}
+
+void tst_qqmlparser::qmlImportInJSRequiresFullVersion()
+{
+ {
+ QQmlJS::Engine engine;
+ QQmlJS::Lexer lexer(&engine);
+ lexer.setCode(QLatin1String(".import Test 1.0 as T"), 0, false);
+ QQmlJS::Parser parser(&engine);
+ bool b = parser.parseProgram();
+ qDebug() << parser.errorMessage();
+ QVERIFY(b);
+ }
+ {
+ QQmlJS::Engine engine;
+ QQmlJS::Lexer lexer(&engine);
+ lexer.setCode(QLatin1String(".import Test 1 as T"), 0, false);
+ QQmlJS::Parser parser(&engine);
+ QVERIFY(!parser.parseProgram());
+ }
+ {
+ QQmlJS::Engine engine;
+ QQmlJS::Lexer lexer(&engine);
+ lexer.setCode(QLatin1String(".import Test 1 as T"), 0, false);
+ QQmlJS::Parser parser(&engine);
+ QVERIFY(!parser.parseProgram());
+ }
+ {
+ QQmlJS::Engine engine;
+ QQmlJS::Lexer lexer(&engine);
+ lexer.setCode(QLatin1String(".import Test as T"), 0, false);
+ QQmlJS::Parser parser(&engine);
+ QVERIFY(!parser.parseProgram());
+ }
+}
+
QTEST_MAIN(tst_qqmlparser)
#include "tst_qqmlparser.moc"
diff --git a/tests/auto/qml/qqmlstatemachine/tst_qqmlstatemachine.cpp b/tests/auto/qml/qqmlstatemachine/tst_qqmlstatemachine.cpp
index 68ed22c01c..a6f0d65453 100644
--- a/tests/auto/qml/qqmlstatemachine/tst_qqmlstatemachine.cpp
+++ b/tests/auto/qml/qqmlstatemachine/tst_qqmlstatemachine.cpp
@@ -78,7 +78,7 @@ void tst_qqmlstatemachine::tst_cppObjectSignal()
CppObject cppObject;
QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("cppsignal.qml"));
- QVERIFY(!component.isError());
+ QVERIFY2(!component.isError(), qPrintable(component.errorString()));
QQmlContext *ctxt = engine.rootContext();
ctxt->setContextProperty("_cppObject", &cppObject);