aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlengine
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/qqmlengine')
-rw-r--r--tests/auto/qml/qqmlengine/data/qrcurls.js1
-rw-r--r--tests/auto/qml/qqmlengine/data/qrcurls.qml4
-rw-r--r--tests/auto/qml/qqmlengine/qqmlengine.pro4
-rw-r--r--tests/auto/qml/qqmlengine/tst_qqmlengine.cpp59
4 files changed, 68 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlengine/data/qrcurls.js b/tests/auto/qml/qqmlengine/data/qrcurls.js
new file mode 100644
index 0000000000..15a4d5a70c
--- /dev/null
+++ b/tests/auto/qml/qqmlengine/data/qrcurls.js
@@ -0,0 +1 @@
+function someFunction() {}
diff --git a/tests/auto/qml/qqmlengine/data/qrcurls.qml b/tests/auto/qml/qqmlengine/data/qrcurls.qml
new file mode 100644
index 0000000000..e879577e10
--- /dev/null
+++ b/tests/auto/qml/qqmlengine/data/qrcurls.qml
@@ -0,0 +1,4 @@
+import QtQml 2.0
+
+QtObject {
+}
diff --git a/tests/auto/qml/qqmlengine/qqmlengine.pro b/tests/auto/qml/qqmlengine/qqmlengine.pro
index 8d1e149d62..d2eb92bfd5 100644
--- a/tests/auto/qml/qqmlengine/qqmlengine.pro
+++ b/tests/auto/qml/qqmlengine/qqmlengine.pro
@@ -12,3 +12,7 @@ boot2qt: {
# GC corruption test is too heavy for qemu-arm
DEFINES += SKIP_GCCORRUPTION_TEST
}
+
+RESOURCES += \
+ data/qrcurls.qml \
+ data/qrcurls.js
diff --git a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
index 52e18011cb..95098648fa 100644
--- a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
+++ b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
@@ -77,6 +77,8 @@ private slots:
void testGCCorruption();
void testGroupedPropertyRevisions();
void componentFromEval();
+ void qrcUrls();
+ void cppSignalAndEval();
public slots:
QObject *createAQObjectForOwnershipTest ()
@@ -897,6 +899,63 @@ void tst_qqmlengine::componentFromEval()
QVERIFY(!item.isNull());
}
+void tst_qqmlengine::qrcUrls()
+{
+ QQmlEngine engine;
+ QQmlEnginePrivate *pEngine = QQmlEnginePrivate::get(&engine);
+
+ {
+ QQmlRefPointer<QQmlTypeData> oneQml(pEngine->typeLoader.getType(QUrl("qrc:/qrcurls.qml")),
+ QQmlRefPointer<QQmlTypeData>::Adopt);
+ QVERIFY(oneQml != nullptr);
+ QQmlRefPointer<QQmlTypeData> twoQml(pEngine->typeLoader.getType(QUrl("qrc:///qrcurls.qml")),
+ QQmlRefPointer<QQmlTypeData>::Adopt);
+ QVERIFY(twoQml != nullptr);
+ QCOMPARE(oneQml, twoQml);
+ }
+
+ {
+ QQmlRefPointer<QQmlTypeData> oneJS(pEngine->typeLoader.getType(QUrl("qrc:/qrcurls.js")),
+ QQmlRefPointer<QQmlTypeData>::Adopt);
+ QVERIFY(oneJS != nullptr);
+ QQmlRefPointer<QQmlTypeData> twoJS(pEngine->typeLoader.getType(QUrl("qrc:///qrcurls.js")),
+ QQmlRefPointer<QQmlTypeData>::Adopt);
+ QVERIFY(twoJS != nullptr);
+ QCOMPARE(oneJS, twoJS);
+ }
+}
+
+class ObjectCaller : public QObject
+{
+ Q_OBJECT
+signals:
+ void doubleReply(const double a);
+};
+
+void tst_qqmlengine::cppSignalAndEval()
+{
+ ObjectCaller objectCaller;
+ QQmlEngine engine;
+ engine.rootContext()->setContextProperty(QLatin1Literal("CallerCpp"), &objectCaller);
+ QQmlComponent c(&engine);
+ c.setData("import QtQuick 2.9\n"
+ "Item {\n"
+ " property var r: 0\n"
+ " Connections {\n"
+ " target: CallerCpp;\n"
+ " onDoubleReply: {\n"
+ " eval('var z = 1');\n"
+ " r = a;\n"
+ " }\n"
+ " }\n"
+ "}",
+ QUrl(QStringLiteral("qrc:/main.qml")));
+ QScopedPointer<QObject> object(c.create());
+ QVERIFY(!object.isNull());
+ emit objectCaller.doubleReply(1.1234);
+ QCOMPARE(object->property("r"), 1.1234);
+}
+
QTEST_MAIN(tst_qqmlengine)
#include "tst_qqmlengine.moc"