aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp')
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp56
1 files changed, 54 insertions, 2 deletions
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index 0f9e328bd9..5a924a901a 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -139,6 +139,8 @@ private slots:
void registrationOrder();
void readonly();
void receivers();
+ void registeredCompositeType();
+ void implicitImportsLast();
void basicRemote_data();
void basicRemote();
@@ -467,6 +469,9 @@ void tst_qqmllanguage::errors_data()
QTest::newRow("invalidTypeName.4") << "invalidTypeName.4.qml" << "invalidTypeName.4.errors.txt" << false;
QTest::newRow("Major version isolation") << "majorVersionIsolation.qml" << "majorVersionIsolation.errors.txt" << false;
+
+ QTest::newRow("badCompositeRegistration.1") << "badCompositeRegistration.1.qml" << "badCompositeRegistration.1.errors.txt" << false;
+ QTest::newRow("badCompositeRegistration.2") << "badCompositeRegistration.2.qml" << "badCompositeRegistration.2.errors.txt" << false;
}
@@ -2466,6 +2471,12 @@ void tst_qqmllanguage::importsOrder_data()
<< (!qmlCheckTypes()?"QQuickRectangle":"")// i.e. from org.qtproject.installedtest, not data/LocalLast.qml
<< (!qmlCheckTypes()?"":"LocalLast is ambiguous. Found in lib/org/qtproject/installedtest/ and in ")
<< false;
+ QTest::newRow("local last 3") << //Forces it to load the local qmldir to resolve types, but they shouldn't override anything
+ "import org.qtproject.installedtest 1.0\n"
+ "LocalLast {LocalLast2{}}"
+ << (!qmlCheckTypes()?"QQuickRectangle":"")// i.e. from org.qtproject.installedtest, not data/LocalLast.qml
+ << (!qmlCheckTypes()?"":"LocalLast is ambiguous. Found in lib/org/qtproject/installedtest/ and in ")
+ << false;
}
void tst_qqmllanguage::importsOrder()
@@ -2771,6 +2782,10 @@ void tst_qqmllanguage::initTestCase()
QQmlMetaType::registerCustomStringConverter(qMetaTypeId<MyCustomVariantType>(), myCustomVariantTypeConverter);
registerTypes();
+ // Registered here because it uses testFileUrl
+ qmlRegisterType(testFileUrl("CompositeType.qml"), "Test", 1, 0, "RegisteredCompositeType");
+ qmlRegisterType(testFileUrl("CompositeType.DoesNotExist.qml"), "Test", 1, 0, "RegisteredCompositeType2");
+ qmlRegisterType(testFileUrl("invalidRoot.1.qml"), "Test", 1, 0, "RegisteredCompositeType3");
// Registering the TestType class in other modules should have no adverse effects
qmlRegisterType<TestType>("org.qtproject.TestPre", 1, 0, "Test");
@@ -2915,6 +2930,17 @@ void tst_qqmllanguage::receivers()
delete o;
}
+void tst_qqmllanguage::registeredCompositeType()
+{
+ QQmlComponent component(&engine, testFileUrl("registeredCompositeType.qml"));
+
+ VERIFY_ERRORS(0);
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ delete o;
+}
+
// QTBUG-18268
void tst_qqmllanguage::remoteLoadCrash()
{
@@ -3053,6 +3079,8 @@ void tst_qqmllanguage::literals_data()
QTest::newRow("fp3") << "n5" << QVariant(3e-12);
QTest::newRow("fp4") << "n6" << QVariant(3e+12);
QTest::newRow("fp5") << "n7" << QVariant(0.1e9);
+ QTest::newRow("large-int1") << "n8" << QVariant((double) 1152921504606846976);
+ QTest::newRow("large-int2") << "n9" << QVariant(100000000000000000000.);
QTest::newRow("special1") << "c1" << QVariant(QString("\b"));
QTest::newRow("special2") << "c2" << QVariant(QString("\f"));
@@ -3064,8 +3092,8 @@ void tst_qqmllanguage::literals_data()
QTest::newRow("special8") << "c8" << QVariant(QString("\""));
QTest::newRow("special9") << "c9" << QVariant(QString("\\"));
// We don't handle octal escape sequences
- QTest::newRow("special11") << "c10" << QVariant(QString(1, QChar(0xa9)));
- QTest::newRow("special12") << "c11" << QVariant(QString(1, QChar(0x00A9)));
+ QTest::newRow("special10") << "c10" << QVariant(QString(1, QChar(0xa9)));
+ QTest::newRow("special11") << "c11" << QVariant(QString(1, QChar(0x00A9)));
}
void tst_qqmllanguage::literals()
@@ -3121,6 +3149,30 @@ void tst_qqmllanguage::scopedProperties()
QVERIFY(o->property("success").toBool());
}
+// Tests that the implicit import has lowest precedence, in the case where
+// there are conflicting types and types only found in the local import.
+// Tests that just check one (or the root) type are in ::importsOrder
+void tst_qqmllanguage::implicitImportsLast()
+{
+ if (qmlCheckTypes())
+ QSKIP("This test is about maintaining the same choice when type is ambiguous.");
+
+ if (engine.importPathList() == defaultImportPathList)
+ engine.addImportPath(testFile("lib"));
+
+ QQmlComponent component(&engine, testFile("localOrderTest.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = qobject_cast<QObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(QString(object->metaObject()->className()).startsWith(QLatin1String("QQuickMouseArea")));
+ QObject* object2 = object->property("item").value<QObject*>();
+ QVERIFY(object2 != 0);
+ QCOMPARE(QString(object2->metaObject()->className()), QLatin1String("QQuickRectangle"));
+
+ engine.setImportPathList(defaultImportPathList);
+}
+
+
QTEST_MAIN(tst_qqmllanguage)
#include "tst_qqmllanguage.moc"