summaryrefslogtreecommitdiffstats
path: root/tests/auto/tools/moc/tst_moc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/tools/moc/tst_moc.cpp')
-rw-r--r--tests/auto/tools/moc/tst_moc.cpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp
index 2bad8f2e63..a4ee6795c4 100644
--- a/tests/auto/tools/moc/tst_moc.cpp
+++ b/tests/auto/tools/moc/tst_moc.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Copyright (C) 2020 Olivier Goffart <ogoffart@woboq.com>
** Contact: https://www.qt.io/licensing/
**
@@ -721,6 +721,7 @@ private slots:
void cxxAttributes();
void mocJsonOutput();
void mocInclude();
+ void requiredProperties();
signals:
void sigWithUnsignedArg(unsigned foo);
@@ -4029,6 +4030,29 @@ void tst_Moc::mocInclude()
QCOMPARE(obj.prop1->x, 45);
}
+class RequiredTest :public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(int required MEMBER m_required REQUIRED)
+ Q_PROPERTY(int notRequired MEMBER m_notRequired)
+
+private:
+ int m_required;
+ int m_notRequired;
+};
+
+void tst_Moc::requiredProperties()
+{
+ QMetaObject mo = RequiredTest::staticMetaObject;
+ QMetaProperty required = mo.property(mo.indexOfProperty("required"));
+ QVERIFY(required.isValid());
+ QVERIFY(required.isRequired());
+ QMetaProperty notRequired = mo.property(mo.indexOfProperty("notRequired"));
+ QVERIFY(notRequired.isValid());
+ QVERIFY(!notRequired.isRequired());
+}
+
QTEST_MAIN(tst_Moc)
// the generated code must compile with QT_NO_KEYWORDS