diff options
Diffstat (limited to 'tests/auto/quick/qquickdesignersupport/tst_qquickdesignersupport.cpp')
-rw-r--r-- | tests/auto/quick/qquickdesignersupport/tst_qquickdesignersupport.cpp | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/tests/auto/quick/qquickdesignersupport/tst_qquickdesignersupport.cpp b/tests/auto/quick/qquickdesignersupport/tst_qquickdesignersupport.cpp index c35f31b8f2..bdc8f97d3a 100644 --- a/tests/auto/quick/qquickdesignersupport/tst_qquickdesignersupport.cpp +++ b/tests/auto/quick/qquickdesignersupport/tst_qquickdesignersupport.cpp @@ -1,5 +1,6 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + #include <qtest.h> #include <QtQml/qqmlengine.h> #include <QtQml/qqmlcomponent.h> @@ -41,6 +42,7 @@ private slots: void testDotProperties(); void testItemReparenting(); void testPropertyNames(); + void regressionTestAllProperties(); }; @@ -557,14 +559,15 @@ void doComponentCompleteRecursive(QObject *object) QList<QObject*> childList = object->children(); if (item) { - foreach (QQuickItem *childItem, item->childItems()) { + const auto childItems = item->childItems(); + for (QQuickItem *childItem : childItems) { if (!childList.contains(childItem)) childList.append(childItem); } } - foreach (QObject *child, childList) - doComponentCompleteRecursive(child); + for (QObject *child : std::as_const(childList)) + doComponentCompleteRecursive(child); if (item) { static_cast<QQmlParserStatus*>(item)->componentComplete(); @@ -781,6 +784,37 @@ void tst_qquickdesignersupport::testPropertyNames() QVERIFY(!names.contains("testProperty")); } +void tst_qquickdesignersupport::regressionTestAllProperties() +{ + QScopedPointer<QQuickView> view(new QQuickView); + view->engine()->setOutputWarningsToStandardError(false); + view->setSource(testFileUrl("regTestProperties.qml")); + + QVERIFY(view->errors().isEmpty()); + QQuickItem *rootItem = view->rootObject(); + QVERIFY(rootItem); + + QObject *component = rootItem->findChild<QObject*>("testComponent"); + + QVERIFY(component); + QCOMPARE(component->objectName(), QLatin1String("testComponent")); + + QVERIFY(component); + + QQuickDesignerSupport::PropertyNameList names + = QQuickDesignerSupportProperties::allPropertyNames(component); + QVERIFY(!names.isEmpty()); + + const QByteArrayList expectedNames = QByteArrayList { + "objectName", "currentCategory", "materialsNames", "model" + }; + + QCOMPARE(names, expectedNames); + names = QQuickDesignerSupportProperties::propertyNameListForWritableProperties(component); + QVERIFY(!names.isEmpty()); + QCOMPARE(names, expectedNames); +} + QTEST_MAIN(tst_qquickdesignersupport) #include "tst_qquickdesignersupport.moc" |