diff options
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp')
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index b8ea5477fb..0ea7346746 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -12,6 +12,7 @@ #include <data/resettable.h> #include <data/weathermoduleurl.h> #include <data/withlength.h> +#include <data/qmlusing.h> #include <QtQml/private/qqmlengine_p.h> #include <QtQml/private/qqmlpropertycachecreator_p.h> @@ -202,6 +203,7 @@ private slots: void popContextAfterRet(); void prefixedType(); void propertyOfParent(); + void qmlUsing(); void qtfont(); void reduceWithNullThis(); void readEnumFromInstance(); @@ -4221,6 +4223,38 @@ void tst_QmlCppCodegen::propertyOfParent() } } +void tst_QmlCppCodegen::qmlUsing() +{ + QQmlEngine engine; + QQmlComponent component(&engine, QUrl(u"qrc:/qt/qml/TestTypes/qmlUsing.qml"_s)); + QVERIFY2(component.isReady(), component.errorString().toUtf8()); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); + + UsingUserObject *u = qobject_cast<UsingUserObject *>(object.data()); + QVERIFY(u); + + QCOMPARE(u->a(), 7); + QCOMPARE(u->val().a(), 24); + QCOMPARE(u->property("valA").toInt(), 24); + QCOMPARE(u->property("myA").toInt(), 7); + QCOMPARE(u->property("myA2").toInt(), 7); + + QList<int> as; + QObject::connect(u, &UsingUserObject::aChanged, this, [&]() { as.append(u->a()); }); + + QMetaObject::invokeMethod(object.data(), "twiddle"); + + const QList<int> expected = { 57, 59 }; + QCOMPARE(as, expected); + + QCOMPARE(u->a(), 59); + QCOMPARE(u->val().a(), 55); + QCOMPARE(u->property("valA").toInt(), 55); + QCOMPARE(u->property("myA").toInt(), 59); + QCOMPARE(u->property("myA2").toInt(), 59); +} + void tst_QmlCppCodegen::qtfont() { QQmlEngine engine; |
