aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmllanguage/data/compositeTypeByName_anon_qmldir.qml9
-rw-r--r--tests/auto/qml/qqmllanguage/data/compositeTypeByName_named_qmldir.qml9
-rw-r--r--tests/auto/qml/qqmllanguage/data/quickTypeByName_anon.qml8
-rw-r--r--tests/auto/qml/qqmllanguage/data/quickTypeByName_named.qml8
-rw-r--r--tests/auto/qml/qqmllanguage/data/simpleimportByName/SimpleType.qml4
-rw-r--r--tests/auto/qml/qqmllanguage/data/simpleimportByName/qmldir1
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp29
7 files changed, 68 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllanguage/data/compositeTypeByName_anon_qmldir.qml b/tests/auto/qml/qqmllanguage/data/compositeTypeByName_anon_qmldir.qml
new file mode 100644
index 0000000000..5ffdc26096
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/compositeTypeByName_anon_qmldir.qml
@@ -0,0 +1,9 @@
+import QtQuick 2.6
+import "simpleimportByName"
+
+Item {
+ Component.onCompleted: {
+ console.warn(SimpleType)
+ }
+}
+
diff --git a/tests/auto/qml/qqmllanguage/data/compositeTypeByName_named_qmldir.qml b/tests/auto/qml/qqmllanguage/data/compositeTypeByName_named_qmldir.qml
new file mode 100644
index 0000000000..c446eae84c
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/compositeTypeByName_named_qmldir.qml
@@ -0,0 +1,9 @@
+import QtQuick 2.6
+import "simpleimportByName" as ImportName
+
+Item {
+ Component.onCompleted: {
+ console.warn(ImportName.SimpleType)
+ }
+}
+
diff --git a/tests/auto/qml/qqmllanguage/data/quickTypeByName_anon.qml b/tests/auto/qml/qqmllanguage/data/quickTypeByName_anon.qml
new file mode 100644
index 0000000000..abe750db33
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/quickTypeByName_anon.qml
@@ -0,0 +1,8 @@
+import QtQuick 2.6
+
+Item {
+ Component.onCompleted: {
+ console.warn(Item)
+ }
+}
+
diff --git a/tests/auto/qml/qqmllanguage/data/quickTypeByName_named.qml b/tests/auto/qml/qqmllanguage/data/quickTypeByName_named.qml
new file mode 100644
index 0000000000..397d4f42f0
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/quickTypeByName_named.qml
@@ -0,0 +1,8 @@
+import QtQuick 2.6 as Quick
+
+Quick.Item {
+ Quick.Component.onCompleted: {
+ console.warn(Quick.Item)
+ }
+}
+
diff --git a/tests/auto/qml/qqmllanguage/data/simpleimportByName/SimpleType.qml b/tests/auto/qml/qqmllanguage/data/simpleimportByName/SimpleType.qml
new file mode 100644
index 0000000000..4772dde8f0
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/simpleimportByName/SimpleType.qml
@@ -0,0 +1,4 @@
+import QtQuick 2.6
+
+MouseArea {
+}
diff --git a/tests/auto/qml/qqmllanguage/data/simpleimportByName/qmldir b/tests/auto/qml/qqmllanguage/data/simpleimportByName/qmldir
new file mode 100644
index 0000000000..80df37d0e6
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/simpleimportByName/qmldir
@@ -0,0 +1 @@
+SimpleType 1.0 SimpleType.qml
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index f586f7d429..c0500afddd 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -257,6 +257,9 @@ private slots:
void defaultListProperty();
void namespacedPropertyTypes();
+ void qmlTypeCanBeResolvedByName_data();
+ void qmlTypeCanBeResolvedByName();
+
private:
QQmlEngine engine;
QStringList defaultImportPathList;
@@ -4250,6 +4253,32 @@ void tst_qqmllanguage::namespacedPropertyTypes()
QVERIFY(!o.isNull());
}
+void tst_qqmllanguage::qmlTypeCanBeResolvedByName_data()
+{
+ QTest::addColumn<QUrl>("componentUrl");
+
+ // Built-in C++ types
+ QTest::newRow("C++ - Anonymous") << testFileUrl("quickTypeByName_anon.qml");
+ QTest::newRow("C++ - Named") << testFileUrl("quickTypeByName_named.qml");
+
+ // Composite types with a qmldir
+ QTest::newRow("QML - Anonymous - qmldir") << testFileUrl("compositeTypeByName_anon_qmldir.qml");
+ QTest::newRow("QML - Named - qmldir") << testFileUrl("compositeTypeByName_named_qmldir.qml");
+}
+
+void tst_qqmllanguage::qmlTypeCanBeResolvedByName()
+{
+ QFETCH(QUrl, componentUrl);
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine, componentUrl);
+ VERIFY_ERRORS(0);
+ QTest::ignoreMessage(QtMsgType::QtWarningMsg, "[object Object]"); // a bit crude, but it will do
+
+ QScopedPointer<QObject> o(component.create());
+ QVERIFY(!o.isNull());
+}
+
QTEST_MAIN(tst_qqmllanguage)
#include "tst_qqmllanguage.moc"