aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickdesignersupport/tst_qquickdesignersupport.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quick/qquickdesignersupport/tst_qquickdesignersupport.cpp')
-rw-r--r--tests/auto/quick/qquickdesignersupport/tst_qquickdesignersupport.cpp150
1 files changed, 97 insertions, 53 deletions
diff --git a/tests/auto/quick/qquickdesignersupport/tst_qquickdesignersupport.cpp b/tests/auto/quick/qquickdesignersupport/tst_qquickdesignersupport.cpp
index 6165e0ee93..bdc8f97d3a 100644
--- a/tests/auto/quick/qquickdesignersupport/tst_qquickdesignersupport.cpp
+++ b/tests/auto/quick/qquickdesignersupport/tst_qquickdesignersupport.cpp
@@ -1,30 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
#include <qtest.h>
#include <QtQml/qqmlengine.h>
#include <QtQml/qqmlcomponent.h>
@@ -40,17 +16,16 @@
#include <private/qquickstategroup_p.h>
#include <private/qquickpropertychanges_p.h>
#include <private/qquickrectangle_p.h>
-#include "../../shared/util.h"
-#include "../shared/visualtestutil.h"
-#include <QtTest/private/qemulationdetector_p.h>
+#include <QtQuickTestUtils/private/qmlutils_p.h>
+#include <QtQuickTestUtils/private/visualtestutils_p.h>
-using namespace QQuickVisualTestUtil;
+using namespace QQuickVisualTestUtils;
class tst_qquickdesignersupport : public QQmlDataTest
{
Q_OBJECT
public:
- tst_qquickdesignersupport() {}
+ tst_qquickdesignersupport() : QQmlDataTest(QT_QMLTEST_DATADIR) {}
private slots:
void customData();
@@ -66,6 +41,8 @@ private slots:
void testSimpleBindings();
void testDotProperties();
void testItemReparenting();
+ void testPropertyNames();
+ void regressionTestAllProperties();
};
@@ -106,9 +83,9 @@ void addToNewProperty(QObject *object, QObject *newParent, const QByteArray &new
Q_ASSERT(objectToVariant(object).isValid());
}
-static void removeObjectFromList(const QQmlProperty &property, QObject *objectToBeRemoved, QQmlEngine * engine)
+static void removeObjectFromList(const QQmlProperty &property, QObject *objectToBeRemoved)
{
- QQmlListReference listReference(property.object(), property.name().toUtf8(), engine);
+ QQmlListReference listReference(property.object(), property.name().toUtf8());
int count = listReference.count();
@@ -312,7 +289,7 @@ void tst_qquickdesignersupport::dynamicProperty()
QVERIFY(simpleItem);
QQuickDesignerSupportProperties::registerNodeInstanceMetaObject(simpleItem, view->engine());
- QQuickDesignerSupportProperties::getPropertyCache(simpleItem, view->engine());
+ QQuickDesignerSupportProperties::getPropertyCache(simpleItem);
QQuickDesignerSupportProperties::createNewDynamicProperty(simpleItem, view->engine(), QLatin1String("dynamicProperty"));
@@ -344,10 +321,13 @@ void tst_qquickdesignersupport::createComponent()
QVERIFY(rootItem);
- QObject *testComponentObject = QQuickDesignerSupportItems::createComponent(testFileUrl("TestComponent.qml"), view->rootContext());
+ QScopedPointer<QObject> testComponentObject(
+ QQuickDesignerSupportItems::createComponent(
+ testFileUrl("TestComponent.qml"), view->rootContext()));
QVERIFY(testComponentObject);
- QVERIFY(QQuickDesignerSupportMetaInfo::isSubclassOf(testComponentObject, "QtQuick/Item"));
+ QVERIFY(QQuickDesignerSupportMetaInfo::isSubclassOf(
+ testComponentObject.data(), "QtQuick/Item"));
}
void tst_qquickdesignersupport::basicStates()
@@ -366,7 +346,7 @@ void tst_qquickdesignersupport::basicStates()
QVERIFY(stateGroup);
- QCOMPARE(stateGroup->states().count(), 2 );
+ QCOMPARE(stateGroup->states().size(), 2 );
QQuickState *state01 = stateGroup->states().first();
QQuickState *state02 = stateGroup->states().last();
@@ -412,7 +392,7 @@ void tst_qquickdesignersupport::statesPropertyChanges()
QVERIFY(stateGroup);
- QCOMPARE(stateGroup->states().count(), 2 );
+ QCOMPARE(stateGroup->states().size(), 2 );
QQuickState *state01 = stateGroup->states().first();
QQuickState *state02 = stateGroup->states().last();
@@ -431,7 +411,7 @@ void tst_qquickdesignersupport::statesPropertyChanges()
QCOMPARE(state01->operationCount(), 1);
- QCOMPARE(statePrivate01->operations.count(), 1);
+ QCOMPARE(statePrivate01->operations.size(), 1);
QQuickStateOperation *propertyChange = statePrivate01->operations.at(0).data();
@@ -466,7 +446,7 @@ void tst_qquickdesignersupport::statesPropertyChanges()
QCOMPARE(rootItem, QQuickDesignerSupportPropertyChanges::targetObject(newPropertyChange));
QCOMPARE(state01->operationCount(), 2);
- QCOMPARE(statePrivate01->operations.count(), 2);
+ QCOMPARE(statePrivate01->operations.size(), 2);
QCOMPARE(QQuickDesignerSupportPropertyChanges::stateObject(newPropertyChange), state01);
@@ -579,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();
@@ -664,9 +645,6 @@ void tst_qquickdesignersupport::testComponentOnCompleteSignal()
void tst_qquickdesignersupport::testSimpleBindings()
{
- if (QTestPrivate::isRunningArmOnX86())
- QSKIP("Crashes in QEMU. (QTBUG-90869)");
-
QScopedPointer<QQuickView> view(new QQuickView);
view->engine()->setOutputWarningsToStandardError(false);
view->setSource(testFileUrl("bindingTest.qml"));
@@ -708,9 +686,6 @@ void tst_qquickdesignersupport::testSimpleBindings()
void tst_qquickdesignersupport::testDotProperties()
{
- if (QTestPrivate::isRunningArmOnX86())
- QSKIP("Crashes in QEMU. (QTBUG-90869)");
-
QScopedPointer<QQuickView> view(new QQuickView);
view->engine()->setOutputWarningsToStandardError(false);
view->setSource(testFileUrl("bindingTest.qml"));
@@ -740,8 +715,6 @@ void tst_qquickdesignersupport::testDotProperties()
void tst_qquickdesignersupport::testItemReparenting()
{
- if (QTestPrivate::isRunningArmOnX86())
- QSKIP("Crashes in QEMU. (QTBUG-90869)");
QScopedPointer<QQuickView> view(new QQuickView);
view->engine()->setOutputWarningsToStandardError(false);
@@ -766,11 +739,82 @@ void tst_qquickdesignersupport::testItemReparenting()
QCOMPARE(text->parentItem(), rootItem);
QQmlProperty childrenProperty(rootItem, "children");
- removeObjectFromList(childrenProperty, text, view->engine());
+ removeObjectFromList(childrenProperty, text);
addToNewProperty(text, item, "children");
QCOMPARE(text->parentItem(), item);
}
+void tst_qquickdesignersupport::testPropertyNames()
+{
+ QScopedPointer<QQuickView> view(new QQuickView);
+ view->engine()->setOutputWarningsToStandardError(false);
+ view->setSource(testFileUrl("propertyNameTest.qml"));
+
+ QVERIFY(view->errors().isEmpty());
+ QQuickItem *rootItem = view->rootObject();
+ QVERIFY(rootItem);
+
+ QQuickDesignerSupport::PropertyNameList names = QQuickDesignerSupportProperties::allPropertyNames(rootItem);
+ QVERIFY(!names.isEmpty());
+ QVERIFY(names.contains("width"));
+ QVERIFY(names.contains("height"));
+ QVERIFY(names.contains("clip"));
+ QVERIFY(names.contains("childrenRect"));
+ QVERIFY(names.contains("activeFocus"));
+ QVERIFY(names.contains("border.width"));
+ names = QQuickDesignerSupportProperties::propertyNameListForWritableProperties(rootItem);
+ QVERIFY(!names.isEmpty());
+ QVERIFY(names.contains("width"));
+ QVERIFY(names.contains("height"));
+ QVERIFY(names.contains("opacity"));
+ QVERIFY(!names.contains("childrenRect"));
+ QVERIFY(!names.contains("childrenRect"));
+ QVERIFY(!names.contains("activeFocus"));
+ QVERIFY(names.contains("border.width"));
+
+ QQuickItem *recursiveProperty = findItem<QQuickItem>(rootItem, QLatin1String("recursiveProperty"));
+ QVERIFY(recursiveProperty);
+ names = QQuickDesignerSupportProperties::allPropertyNames(recursiveProperty);
+ QVERIFY(!names.isEmpty());
+ QVERIFY(names.contains("testProperty"));
+ QVERIFY(names.contains("myproperty.testProperty"));
+
+ names = QQuickDesignerSupportProperties::propertyNameListForWritableProperties(recursiveProperty);
+ QVERIFY(!names.isEmpty());
+ 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"