summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp
index 870e65f0cc..3afc2bc574 100644
--- a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp
+++ b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp
@@ -155,6 +155,7 @@ private slots:
void invokeCustomTypes();
void invokeMetaConstructor();
void invokeTypedefTypes();
+ void invokeException();
void qtMetaObjectInheritance();
void normalizedSignature_data();
void normalizedSignature();
@@ -301,6 +302,19 @@ void tst_QMetaObject::connectSlotsByName()
struct MyUnregisteredType { };
+static int countedStructObjectsCount = 0;
+struct CountedStruct
+{
+ CountedStruct() { ++countedStructObjectsCount; }
+ CountedStruct(const CountedStruct &) { ++countedStructObjectsCount; }
+ CountedStruct &operator=(const CountedStruct &) { return *this; }
+ ~CountedStruct() { --countedStructObjectsCount; }
+};
+
+#ifndef QT_NO_EXCEPTIONS
+class ObjectException : public std::exception { };
+#endif
+
class QtTestObject: public QObject
{
friend class tst_QMetaObject;
@@ -340,6 +354,13 @@ public slots:
void slotWithUnregisteredParameterType(MyUnregisteredType);
+ CountedStruct throwingSlot(const CountedStruct &, CountedStruct s2) {
+#ifndef QT_NO_EXCEPTIONS
+ throw ObjectException();
+#endif
+ return s2;
+ }
+
signals:
void sig0();
QString sig1(QString s1);
@@ -847,6 +868,23 @@ void tst_QMetaObject::invokeTypedefTypes()
QCOMPARE(spy.at(0).at(0), QVariant(arg));
}
+void tst_QMetaObject::invokeException()
+{
+#ifndef QT_NO_EXCEPTIONS
+ QtTestObject obj;
+ QCOMPARE(countedStructObjectsCount, 0);
+ try {
+ CountedStruct s;
+ QVERIFY(QMetaObject::invokeMethod(&obj, "throwingSlot", Q_RETURN_ARG(CountedStruct, s),
+ Q_ARG(CountedStruct, s), Q_ARG(CountedStruct, s)));
+ QFAIL("Did not throw");
+ } catch(ObjectException &) {}
+ QCOMPARE(countedStructObjectsCount, 0);
+#else
+ QSKIP("Needs exceptions");
+#endif
+}
+
void tst_QMetaObject::normalizedSignature_data()
{
QTest::addColumn<QString>("signature");