From 28ed215281bb4ee687d2a2bfb7d6fdc1001c082b Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 22 Jun 2016 09:30:10 +0200 Subject: Added two unit tests for alias nesting The first test covers a use-case currently only otherwise see in QtQuickControls, and so having it here allows for catching regressions in that area before hitting the next qt5 build. Having an alias refer to another alias property within the same file only works if the second alias is resolved/processed before the first one. This works by chance when relying on the order of processing reverse to the declaration, but that's a bug. It should work regardless of the order. That is what the second test-case demonstrates and that is why it is marked as failure. Change-Id: Iba386437d21efa868d9814221092df5f7ef6f1f6 Reviewed-by: Lars Knoll --- tests/auto/qml/qqmllanguage/data/alias.12.qml | 15 ++++++++++++ tests/auto/qml/qqmllanguage/data/alias.13.qml | 16 +++++++++++++ tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 30 ++++++++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 tests/auto/qml/qqmllanguage/data/alias.12.qml create mode 100644 tests/auto/qml/qqmllanguage/data/alias.13.qml (limited to 'tests/auto/qml/qqmllanguage') diff --git a/tests/auto/qml/qqmllanguage/data/alias.12.qml b/tests/auto/qml/qqmllanguage/data/alias.12.qml new file mode 100644 index 0000000000..cc17318092 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/alias.12.qml @@ -0,0 +1,15 @@ +import QtQml 2.0 + +QtObject { + id: root + property alias topLevelAlias: subObject.targetProperty + + property QtObject referencingSubObject: QtObject { + property alias success: root.topLevelAlias + } + + property QtObject foo: QtObject { + id: subObject + property bool targetProperty: true + } +} diff --git a/tests/auto/qml/qqmllanguage/data/alias.13.qml b/tests/auto/qml/qqmllanguage/data/alias.13.qml new file mode 100644 index 0000000000..cff8a72d9a --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/alias.13.qml @@ -0,0 +1,16 @@ +import QtQml 2.0 + +QtObject { + id: root + property bool targetProperty: true + + property QtObject foo: QtObject { + id: otherSubObject + property alias theAlias: root.targetProperty + } + + property QtObject referencingSubObject: QtObject { + property alias success: otherSubObject.theAlias + } + +} diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 70db9aecd4..1e8e92217c 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -1803,6 +1803,36 @@ void tst_qqmllanguage::aliasProperties() delete object; } + + // Nested aliases with a qml file + { + QQmlComponent component(&engine, testFileUrl("alias.12.qml")); + VERIFY_ERRORS(0); + QScopedPointer object(component.create()); + QVERIFY(!object.isNull()); + + QPointer subObject = qvariant_cast(object->property("referencingSubObject")); + QVERIFY(!subObject.isNull()); + + QVERIFY(subObject->property("success").toBool()); + } + + // Nested aliases with a qml file with reverse ordering + { + // This is known to fail at the moment. + QQmlComponent component(&engine, testFileUrl("alias.13.qml")); + QVERIFY(!component.errors().isEmpty()); +#if 0 + VERIFY_ERRORS(0); + QScopedPointer object(component.create()); + QVERIFY(!object.isNull()); + + QPointer subObject = qvariant_cast(object->property("referencingSubObject")); + QVERIFY(!subObject.isNull()); + + QVERIFY(subObject->property("success").toBool()); +#endif + } } // QTBUG-13374 Test that alias properties and signals can coexist -- cgit v1.2.3