diff options
Diffstat (limited to 'tests/auto/quick/qquickstates/tst_qquickstates.cpp')
-rw-r--r-- | tests/auto/quick/qquickstates/tst_qquickstates.cpp | 63 |
1 files changed, 60 insertions, 3 deletions
diff --git a/tests/auto/quick/qquickstates/tst_qquickstates.cpp b/tests/auto/quick/qquickstates/tst_qquickstates.cpp index 44187d2b65..3bdbe29d1e 100644 --- a/tests/auto/quick/qquickstates/tst_qquickstates.cpp +++ b/tests/auto/quick/qquickstates/tst_qquickstates.cpp @@ -1,5 +1,5 @@ // 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> @@ -119,7 +119,12 @@ class tst_qquickstates : public QQmlDataTest { Q_OBJECT public: - tst_qquickstates() : QQmlDataTest(QT_QMLTEST_DATADIR) {} + tst_qquickstates() : QQmlDataTest(QT_QMLTEST_DATADIR) + { +#ifdef QML_DISABLE_INTERNAL_DEFERRED_PROPERTIES + qputenv("QML_DISABLE_INTERNAL_DEFERRED_PROPERTIES", "1"); +#endif + } private: QByteArray fullDataPath(const QString &path) const; @@ -184,7 +189,9 @@ private slots: void parentChangeInvolvingBindings(); void deferredProperties(); void rewindAnchorChange(); + void rewindAnchorChangeSize(); void bindingProperlyRemovedWithTransition(); + void doNotCrashOnBroken(); }; void tst_qquickstates::initTestCase() @@ -1650,7 +1657,7 @@ static int getRefCount(const QQmlAnyBinding &binding) } else { // this temporarily adds a refcount because we construc a new untypedpropertybinding // thus -1 - return QPropertyBindingPrivate::get(binding.asUntypedPropertyBinding())->ref - 1; + return QPropertyBindingPrivate::get(binding.asUntypedPropertyBinding())->refCount() - 1; } } @@ -1975,6 +1982,41 @@ void tst_qquickstates::rewindAnchorChange() QTRY_COMPARE(innerRect->height(), 200); } +void tst_qquickstates::rewindAnchorChangeSize() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("anchorRewindSize.qml")); + QVERIFY2(c.isReady(), qPrintable(c.errorString())); + std::unique_ptr<QObject> root(c.create()); + QVERIFY(root); + + QQmlContext *context = qmlContext(root.get()); + QVERIFY(context); + + QObject *inner = context->objectForName(QStringLiteral("inner")); + QVERIFY(inner); + + QQuickItem *innerRect = qobject_cast<QQuickItem *>(inner); + QVERIFY(innerRect); + + QCOMPARE(innerRect->x(), 0); + QCOMPARE(innerRect->y(), 0); + QCOMPARE(innerRect->width(), 100); + QCOMPARE(innerRect->height(), 100); + + root->setProperty("changeState", true); + QCOMPARE(innerRect->x(), 0); + QCOMPARE(innerRect->y(), 0); + QCOMPARE(innerRect->width(), 400); + QCOMPARE(innerRect->height(), 400); + + root->setProperty("changeState", false); + QCOMPARE(innerRect->x(), 0); + QCOMPARE(innerRect->y(), 0); + QCOMPARE(innerRect->width(), 100); + QCOMPARE(innerRect->height(), 100); +} + void tst_qquickstates::bindingProperlyRemovedWithTransition() { QQmlEngine engine; @@ -1995,6 +2037,21 @@ void tst_qquickstates::bindingProperlyRemovedWithTransition() QTRY_COMPARE(item->width(), 100); } +void tst_qquickstates::doNotCrashOnBroken() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("broken.qml")); + QVERIFY2(c.isReady(), qPrintable(c.errorString())); + QScopedPointer<QObject> root(c.create()); + QVERIFY(root); + QQuickItem *item = qobject_cast<QQuickItem *>(root.get()); + QVERIFY(item); + + QQmlListReference states(item, "states"); + QCOMPARE(states.size(), 1); + QCOMPARE(states.at(0), nullptr); +} + QTEST_MAIN(tst_qquickstates) #include "tst_qquickstates.moc" |