aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2023-07-25 09:27:31 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2023-07-27 09:36:50 +0200
commite9c87ad1b2ca1c0b09aab0047f256116fbaafa42 (patch)
treef20feee2c7943165b24dc2f459661cd67697ff9e /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
parent81bab13560572ffd50153a9cab918063d3305cdd (diff)
tst_qmlcppcodegen: Split enum test
That makes it more clear which ignoreMessage belongs to which part. Change-Id: I4c2bcc16b80204c6bb55c18459b7e8b0b1b298be Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp')
-rw-r--r--tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp65
1 files changed, 34 insertions, 31 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
index 67d55015d2..674bfdef5d 100644
--- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
+++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
@@ -73,6 +73,7 @@ private slots:
void enumProblems();
void enumScope();
void enums();
+ void enumsInOtherObject();
void equalityQObjects();
void equalityQUrl();
void equalityVarAndNonStorable();
@@ -1343,43 +1344,45 @@ void tst_QmlCppCodegen::enumScope()
void tst_QmlCppCodegen::enums()
{
QQmlEngine engine;
- {
- QQmlComponent component(&engine, QUrl(u"qrc:/qt/qml/TestTypes/Enums.qml"_s));
- QVERIFY2(!component.isError(), component.errorString().toUtf8());
+ QQmlComponent component(&engine, QUrl(u"qrc:/qt/qml/TestTypes/Enums.qml"_s));
+ QVERIFY2(!component.isError(), component.errorString().toUtf8());
- QTest::ignoreMessage(QtWarningMsg, "qrc:/qt/qml/TestTypes/Enums.qml:4:1: "
- "QML Enums: Layout must be attached to Item elements");
- QScopedPointer<QObject> object(component.create());
+ QTest::ignoreMessage(QtWarningMsg, "qrc:/qt/qml/TestTypes/Enums.qml:4:1: "
+ "QML Enums: Layout must be attached to Item elements");
+ QScopedPointer<QObject> object(component.create());
- QVERIFY(!object.isNull());
- bool ok = false;
- QCOMPARE(object->property("appState").toInt(&ok), 2);
- QVERIFY(ok);
- QCOMPARE(object->property("color").toString(), u"blue"_s);
+ QVERIFY(!object.isNull());
+ bool ok = false;
+ QCOMPARE(object->property("appState").toInt(&ok), 2);
+ QVERIFY(ok);
+ QCOMPARE(object->property("color").toString(), u"blue"_s);
- QTRY_COMPARE(object->property("appState").toInt(&ok), 1);
- QVERIFY(ok);
- QCOMPARE(object->property("color").toString(), u"green"_s);
+ QTRY_COMPARE(object->property("appState").toInt(&ok), 1);
+ QVERIFY(ok);
+ QCOMPARE(object->property("color").toString(), u"green"_s);
+
+ const auto func = qmlAttachedPropertiesFunction(
+ object.data(), QMetaType::fromName("QQuickLayout*").metaObject());
- const auto func = qmlAttachedPropertiesFunction(
- object.data(), QMetaType::fromName("QQuickLayout*").metaObject());
+ QObject *attached = qmlAttachedPropertiesObject(object.data(), func);
- QTest::ignoreMessage(QtWarningMsg, "qrc:/qt/qml/TestTypes/enumsInOtherObject.qml:4:25: "
- "QML Enums: Layout must be attached to Item elements");
- QObject *attached = qmlAttachedPropertiesObject(object.data(), func);
+ const QVariant prop = attached->property("alignment");
+ QVERIFY(prop.isValid());
+ QCOMPARE(qvariant_cast<Qt::Alignment>(prop), Qt::AlignCenter);
- const QVariant prop = attached->property("alignment");
- QVERIFY(prop.isValid());
- QCOMPARE(qvariant_cast<Qt::Alignment>(prop), Qt::AlignCenter);
- }
- {
- QQmlComponent component(&engine, QUrl(u"qrc:/qt/qml/TestTypes/enumsInOtherObject.qml"_s));
- QVERIFY2(!component.isError(), component.errorString().toUtf8());
- QScopedPointer<QObject> object(component.create());
- QVERIFY(!object.isNull());
- QCOMPARE(object->property("color").toString(), u"blue"_s);
- QTRY_COMPARE(object->property("color").toString(), u"green"_s);
- }
+}
+
+void tst_QmlCppCodegen::enumsInOtherObject()
+{
+ QQmlEngine engine;
+ QTest::ignoreMessage(QtWarningMsg, "qrc:/qt/qml/TestTypes/enumsInOtherObject.qml:4:25: "
+ "QML Enums: Layout must be attached to Item elements");
+ QQmlComponent component(&engine, QUrl(u"qrc:/qt/qml/TestTypes/enumsInOtherObject.qml"_s));
+ QVERIFY2(!component.isError(), component.errorString().toUtf8());
+ QScopedPointer<QObject> object(component.create());
+ QVERIFY(!object.isNull());
+ QCOMPARE(object->property("color").toString(), u"blue"_s);
+ QTRY_COMPARE(object->property("color").toString(), u"green"_s);
}
void tst_QmlCppCodegen::equalityQObjects()