aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmllanguage
diff options
context:
space:
mode:
authorMatthew Vogt <matthew.vogt@nokia.com>2012-03-26 16:39:00 +1000
committerQt by Nokia <qt-info@nokia.com>2012-03-29 00:36:49 +0200
commite4baefacff3e04ea3b599c5279e883d75d2ad489 (patch)
treedc78ce14db08c0aa771ddff9df8c23da8b8919ba /tests/auto/qml/qqmllanguage
parent5de103291d8159a236cabcc689caade265de1bd5 (diff)
Re-order imports statements to import nested imports later
Re-order the imports for a script by increasing order of URI length. This ensures that an import of the type 'import X.Y' is processed after the import of 'import X' which contains the type definitions for the namespace X.Y. Task-number: QTBUG-24369 Change-Id: I1b06e9d114a97c9f47279f8f33383a27e0efb4bb Reviewed-by: Chris Adams <christopher.adams@nokia.com> Reviewed-by: Michael Brasser <michael.brasser@nokia.com> Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests/auto/qml/qqmllanguage')
-rw-r--r--tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/InstalledTest3.qml2
-rw-r--r--tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/qmldir1
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp58
3 files changed, 39 insertions, 22 deletions
diff --git a/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/InstalledTest3.qml b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/InstalledTest3.qml
new file mode 100644
index 0000000000..26a5d6bba9
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/InstalledTest3.qml
@@ -0,0 +1,2 @@
+import QtQuick 2.0
+Rectangle {}
diff --git a/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/qmldir b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/qmldir
index b301226099..ce51ecae1a 100644
--- a/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/qmldir
+++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/qmldir
@@ -1,2 +1,3 @@
InstalledTest 1.4 InstalledTest2.qml
InstalledTestTP 0.0 InstalledTest.qml
+Rectangle 1.5 InstalledTest3.qml
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index 837a9d2604..f70b212231 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -181,7 +181,7 @@ private slots:
private:
QQmlEngine engine;
- void testType(const QString& qml, const QString& type, const QString& error);
+ void testType(const QString& qml, const QString& type, const QString& error, bool partialMatch = false);
};
#define DETERMINE_ERRORS(errorfile,expected,actual)\
@@ -1480,7 +1480,7 @@ void tst_qqmllanguage::reservedWords()
}
// Check that first child of qml is of given type. Empty type insists on error.
-void tst_qqmllanguage::testType(const QString& qml, const QString& type, const QString& expectederror)
+void tst_qqmllanguage::testType(const QString& qml, const QString& type, const QString& expectederror, bool partialMatch)
{
QQmlComponent component(&engine);
component.setData(qml.toUtf8(), TEST_FILE("empty.qml")); // just a file for relative local imports
@@ -1495,7 +1495,7 @@ void tst_qqmllanguage::testType(const QString& qml, const QString& type, const Q
actualerror.append("; ");
actualerror.append(e.description());
}
- QCOMPARE(actualerror,expectederror);
+ QCOMPARE(actualerror.left(partialMatch ? expectederror.length(): -1),expectederror);
} else {
VERIFY_ERRORS(0);
QObject *object = component.create();
@@ -1616,13 +1616,13 @@ void tst_qqmllanguage::importsBuiltin_data()
"import com.nokia.Test 1.12\n"
"Test {}"
<< (!qmlCheckTypes()?"TestType2":"")
- << (!qmlCheckTypes()?"":"Test is ambiguous. Found in com/nokia/Test in version 1.12 and 1.11");
+ << (!qmlCheckTypes()?"":"Test is ambiguous. Found in com/nokia/Test/ in version 1.12 and 1.11");
QTest::newRow("multiversion 2")
<< "import com.nokia.Test 1.11\n"
"import com.nokia.Test 1.12\n"
"OldTest {}"
<< (!qmlCheckTypes()?"TestType":"")
- << (!qmlCheckTypes()?"":"OldTest is ambiguous. Found in com/nokia/Test in version 1.12 and 1.11");
+ << (!qmlCheckTypes()?"":"OldTest is ambiguous. Found in com/nokia/Test/ in version 1.12 and 1.11");
QTest::newRow("qualified multiversion 3")
<< "import com.nokia.Test 1.0 as T0\n"
"import com.nokia.Test 1.8 as T8\n"
@@ -1691,7 +1691,7 @@ void tst_qqmllanguage::importsLocal_data()
"import com.nokia.Test 1.0\n"
"Test {}"
<< (!qmlCheckTypes()?"TestType":"")
- << (!qmlCheckTypes()?"":"Test is ambiguous. Found in com/nokia/Test and in subdir");
+ << (!qmlCheckTypes()?"":"Test is ambiguous. Found in com/nokia/Test/ and in subdir/");
}
void tst_qqmllanguage::importsLocal()
@@ -1841,32 +1841,37 @@ void tst_qqmllanguage::importsOrder_data()
QTest::addColumn<QString>("qml");
QTest::addColumn<QString>("type");
QTest::addColumn<QString>("error");
+ QTest::addColumn<bool>("partialMatch");
QTest::newRow("double import") <<
"import com.nokia.installedtest 1.4\n"
"import com.nokia.installedtest 1.4\n"
"InstalledTest {}"
<< (!qmlCheckTypes()?"QQuickText":"")
- << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.4 and 1.4");
+ << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest/ in version 1.4 and 1.4")
+ << false;
QTest::newRow("installed import overrides 1") <<
"import com.nokia.installedtest 1.0\n"
"import com.nokia.installedtest 1.4\n"
"InstalledTest {}"
<< (!qmlCheckTypes()?"QQuickText":"")
- << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.4 and 1.0");
+ << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest/ in version 1.4 and 1.0")
+ << false;
QTest::newRow("installed import overrides 2") <<
"import com.nokia.installedtest 1.4\n"
"import com.nokia.installedtest 1.0\n"
"InstalledTest {}"
<< (!qmlCheckTypes()?"QQuickRectangle":"")
- << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.0 and 1.4");
+ << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest/ in version 1.0 and 1.4")
+ << false;
QTest::newRow("installed import re-overrides 1") <<
"import com.nokia.installedtest 1.4\n"
"import com.nokia.installedtest 1.0\n"
"import com.nokia.installedtest 1.4\n"
"InstalledTest {}"
<< (!qmlCheckTypes()?"QQuickText":"")
- << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.4 and 1.0");
+ << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest/ in version 1.4 and 1.0")
+ << false;
QTest::newRow("installed import re-overrides 2") <<
"import com.nokia.installedtest 1.4\n"
"import com.nokia.installedtest 1.0\n"
@@ -1874,41 +1879,49 @@ void tst_qqmllanguage::importsOrder_data()
"import com.nokia.installedtest 1.0\n"
"InstalledTest {}"
<< (!qmlCheckTypes()?"QQuickRectangle":"")
- << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.0 and 1.4");
+ << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest/ in version 1.0 and 1.4")
+ << false;
+ // Note: imports are now reordered by increasing order of URI length
QTest::newRow("installed import versus builtin 1") <<
+ "import com.nokia.installedtest0 1.5\n"
"import com.nokia.installedtest 1.5\n"
- "import QtQuick 2.0\n"
"Rectangle {}"
<< (!qmlCheckTypes()?"QQuickRectangle":"")
- << (!qmlCheckTypes()?"":"Rectangle is ambiguous. Found in Qt and in lib/com/nokia/installedtest");
+ << (!qmlCheckTypes()?"":"Rectangle is ambiguous. Found in lib/com/nokia/installedtest0/ and in ")
+ << true;
QTest::newRow("installed import versus builtin 2") <<
"import QtQuick 2.0\n"
"import com.nokia.installedtest 1.5\n"
"Rectangle {}"
<< (!qmlCheckTypes()?"QQuickText":"")
- << (!qmlCheckTypes()?"":"Rectangle is ambiguous. Found in lib/com/nokia/installedtest and in Qt");
+ << (!qmlCheckTypes()?"":"Rectangle is ambiguous. Found in lib/com/nokia/installedtest/ and in ")
+ << true;
QTest::newRow("namespaces cannot be overridden by types 1") <<
"import QtQuick 2.0 as Rectangle\n"
"import com.nokia.installedtest 1.5\n"
"Rectangle {}"
- << ""
- << "Namespace Rectangle cannot be used as a type";
+ << ""
+ << "Namespace Rectangle cannot be used as a type"
+ << false;
QTest::newRow("namespaces cannot be overridden by types 2") <<
"import QtQuick 2.0 as Rectangle\n"
"import com.nokia.installedtest 1.5\n"
"Rectangle.Image {}"
- << "QQuickImage"
- << "";
+ << "QQuickImage"
+ << ""
+ << false;
QTest::newRow("local last 1") <<
"LocalLast {}"
- << "QQuickText"
- << "";
+ << "QQuickText"
+ << ""
+ << false;
QTest::newRow("local last 2") <<
"import com.nokia.installedtest 1.0\n"
"LocalLast {}"
<< (!qmlCheckTypes()?"QQuickRectangle":"")// i.e. from com.nokia.installedtest, not data/LocalLast.qml
- << (!qmlCheckTypes()?"":"LocalLast is ambiguous. Found in lib/com/nokia/installedtest and in local directory");
+ << (!qmlCheckTypes()?"":"LocalLast is ambiguous. Found in lib/com/nokia/installedtest/ and in ")
+ << false;
}
void tst_qqmllanguage::importsOrder()
@@ -1916,7 +1929,8 @@ void tst_qqmllanguage::importsOrder()
QFETCH(QString, qml);
QFETCH(QString, type);
QFETCH(QString, error);
- testType(qml,type,error);
+ QFETCH(bool, partialMatch);
+ testType(qml,type,error,partialMatch);
}
void tst_qqmllanguage::importIncorrectCase()