/**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage ** This file may be used under the terms of the GNU Lesser General Public ** License version 2.1 as published by the Free Software Foundation and ** appearing in the file LICENSE.LGPL included in the packaging of this ** file. Please review the following information to ensure the GNU Lesser ** General Public License version 2.1 requirements will be met: ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain additional ** rights. These rights are described in the Nokia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU General ** Public License version 3.0 as published by the Free Software Foundation ** and appearing in the file LICENSE.GPL included in the packaging of this ** file. Please review the following information to ensure the GNU General ** Public License version 3.0 requirements will be met: ** http://www.gnu.org/copyleft/gpl.html. ** ** Other Usage ** Alternatively, this file may be used in accordance with the terms and ** conditions contained in a signed written agreement between you and Nokia. ** ** ** ** ** ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #include #include #include class tst_QMetaMethod : public QObject { Q_OBJECT private slots: void method_data(); void method(); void invalidMethod(); }; struct CustomType { }; Q_DECLARE_METATYPE(CustomType) struct CustomUnregisteredType { }; Q_DECLARE_METATYPE(QMetaMethod::Access) Q_DECLARE_METATYPE(QMetaMethod::MethodType) class MethodTestObject : public QObject { Q_OBJECT public: Q_INVOKABLE MethodTestObject(); Q_INVOKABLE MethodTestObject(int constructorIntArg); Q_INVOKABLE MethodTestObject(qreal constructorQRealArg); Q_INVOKABLE MethodTestObject(const QString &constructorQStringArg); Q_INVOKABLE MethodTestObject(CustomType constructorCustomTypeArg); Q_INVOKABLE MethodTestObject(CustomUnregisteredType constructorCustomUnregisteredTypeArg); Q_INVOKABLE MethodTestObject(bool boolArg, int intArg, uint uintArg, qlonglong longlongArg, qulonglong ulonglongArg, double doubleArg, long longArg, short shortArg, char charArg, ulong ulongArg, ushort ushortArg, uchar ucharArg, float floatArg); Q_INVOKABLE MethodTestObject(bool, int); Q_INVOKABLE void voidInvokable(); Q_INVOKABLE void voidInvokableInt(int voidInvokableIntArg); Q_INVOKABLE void voidInvokableQReal(qreal voidInvokableQRealArg); Q_INVOKABLE void voidInvokableQString(const QString &voidInvokableQStringArg); Q_INVOKABLE void voidInvokableCustomType(CustomType voidInvokableCustomTypeArg); Q_INVOKABLE void voidInvokableCustomUnregisteredType(CustomUnregisteredType voidInvokableCustomUnregisteredTypeArg); Q_INVOKABLE bool boolInvokable(); Q_INVOKABLE qreal qrealInvokable(); Q_INVOKABLE QString qstringInvokable(); Q_INVOKABLE CustomType customTypeInvokable(); Q_INVOKABLE CustomUnregisteredType customUnregisteredTypeInvokable(); Q_INVOKABLE QVariant qvariantInvokableBoolIntUIntLonglongULonglongDoubleLongShortCharUlongUshortUcharFloat( bool boolArg, int intArg, uint uintArg, qlonglong longlongArg, qulonglong ulonglongArg, double doubleArg, long longArg, short shortArg, char charArg, ulong ulongArg, ushort ushortArg, uchar ucharArg, float floatArg); Q_INVOKABLE void voidInvokableNoParameterNames(bool, int); public slots: void voidSlot(); void voidSlotInt(int voidSlotIntArg); void voidSlotQReal(qreal voidSlotQRealArg); void voidSlotQString(const QString &voidSlotQStringArg); void voidSlotCustomType(CustomType voidSlotCustomTypeArg); void voidSlotCustomUnregisteredType(CustomUnregisteredType voidSlotCustomUnregisteredTypeArg); bool boolSlot(); qreal qrealSlot(); QString qstringSlot(); CustomType customTypeSlot(); CustomUnregisteredType customUnregisteredTypeSlot(); QVariant qvariantSlotBoolIntUIntLonglongULonglongDoubleLongShortCharUlongUshortUcharFloat( bool boolArg, int intArg, uint uintArg, qlonglong longlongArg, qulonglong ulonglongArg, double doubleArg, long longArg, short shortArg, char charArg, ulong ulongArg, ushort ushortArg, uchar ucharArg, float floatArg); void voidSlotNoParameterNames(bool, int); signals: void voidSignal(); void voidSignalInt(int voidSignalIntArg); void voidSignalQReal(qreal voidSignalQRealArg); void voidSignalQString(const QString &voidSignalQStringArg); void voidSignalCustomType(CustomType voidSignalCustomTypeArg); void voidSignalCustomUnregisteredType(CustomUnregisteredType voidSignalCustomUnregisteredTypeArg); bool boolSignal(); qreal qrealSignal(); QString qstringSignal(); CustomType customTypeSignal(); CustomUnregisteredType customUnregisteredTypeSignal(); QVariant qvariantSignalBoolIntUIntLonglongULonglongDoubleLongShortCharUlongUshortUcharFloat( bool boolArg, int intArg, uint uintArg, qlonglong longlongArg, qulonglong ulonglongArg, double doubleArg, long longArg, short shortArg, char charArg, ulong ulongArg, ushort ushortArg, uchar ucharArg, float floatArg); void voidSignalNoParameterNames(bool, int); }; MethodTestObject::MethodTestObject() {} MethodTestObject::MethodTestObject(int) {} MethodTestObject::MethodTestObject(qreal) {} MethodTestObject::MethodTestObject(const QString &) {} MethodTestObject::MethodTestObject(CustomType) {} MethodTestObject::MethodTestObject(CustomUnregisteredType) {} MethodTestObject::MethodTestObject(bool, int, uint, qlonglong, qulonglong, double, long, short, char, ulong, ushort, uchar, float) {} MethodTestObject::MethodTestObject(bool, int) {} void MethodTestObject::voidInvokable() {} void MethodTestObject::voidInvokableInt(int) {} void MethodTestObject::voidInvokableQReal(qreal) {} void MethodTestObject::voidInvokableQString(const QString &) {} void MethodTestObject::voidInvokableCustomType(CustomType) {} void MethodTestObject::voidInvokableCustomUnregisteredType(CustomUnregisteredType) {} bool MethodTestObject::boolInvokable() { return true; } qreal MethodTestObject::qrealInvokable() { return 1.0; } QString MethodTestObject::qstringInvokable() { return QString(); } CustomType MethodTestObject::customTypeInvokable() { return CustomType(); } CustomUnregisteredType MethodTestObject::customUnregisteredTypeInvokable() { return CustomUnregisteredType(); } QVariant MethodTestObject::qvariantInvokableBoolIntUIntLonglongULonglongDoubleLongShortCharUlongUshortUcharFloat( bool, int, uint, qlonglong, qulonglong, double, long, short, char, ulong, ushort, uchar, float) { return QVariant(); } void MethodTestObject::voidInvokableNoParameterNames(bool, int) {} void MethodTestObject::voidSlot() {} void MethodTestObject::voidSlotInt(int) {} void MethodTestObject::voidSlotQReal(qreal) {} void MethodTestObject::voidSlotQString(const QString &) {} void MethodTestObject::voidSlotCustomType(CustomType) {} void MethodTestObject::voidSlotCustomUnregisteredType(CustomUnregisteredType) {} bool MethodTestObject::boolSlot() { return true; } qreal MethodTestObject::qrealSlot() { return 1.0; } QString MethodTestObject::qstringSlot() { return QString(); } CustomType MethodTestObject::customTypeSlot() { return CustomType(); } CustomUnregisteredType MethodTestObject::customUnregisteredTypeSlot() { return CustomUnregisteredType(); } QVariant MethodTestObject::qvariantSlotBoolIntUIntLonglongULonglongDoubleLongShortCharUlongUshortUcharFloat( bool, int, uint, qlonglong, qulonglong, double, long, short, char, ulong, ushort, uchar, float) { return QVariant(); } void MethodTestObject::voidSlotNoParameterNames(bool, int) {} void tst_QMetaMethod::method_data() { QTest::addColumn("signature"); QTest::addColumn("returnType"); QTest::addColumn("returnTypeName"); QTest::addColumn >("parameterTypes"); QTest::addColumn >("parameterTypeNames"); QTest::addColumn >("parameterNames"); QTest::addColumn("access"); QTest::addColumn("methodType"); QTest::newRow("voidSignal") << QByteArray("voidSignal()") << int(QMetaType::Void) << QByteArray("") << (QList()) << (QList()) << (QList()) << QMetaMethod::Protected << QMetaMethod::Signal; QTest::newRow("voidInvokable") << QByteArray("voidInvokable()") << int(QMetaType::Void) << QByteArray("") << (QList()) << (QList()) << (QList()) << QMetaMethod::Public << QMetaMethod::Method; QTest::newRow("voidSlot") << QByteArray("voidSlot()") << int(QMetaType::Void) << QByteArray("") << (QList()) << (QList()) << (QList()) << QMetaMethod::Public << QMetaMethod::Slot; QTest::newRow("MethodTestObject()") << QByteArray("MethodTestObject()") << int(QMetaType::Void) << QByteArray("") << (QList()) << (QList()) << (QList()) << QMetaMethod::Public << QMetaMethod::Constructor; QTest::newRow("voidSignalInt") << QByteArray("voidSignalInt(int)") << int(QMetaType::Void) << QByteArray("") << (QList() << int(QMetaType::Int)) << (QList() << QByteArray("int")) << (QList() << QByteArray("voidSignalIntArg")) << QMetaMethod::Protected << QMetaMethod::Signal; QTest::newRow("voidInvokableInt") << QByteArray("voidInvokableInt(int)") << int(QMetaType::Void) << QByteArray("") << (QList() << int(QMetaType::Int)) << (QList() << QByteArray("int")) << (QList() << QByteArray("voidInvokableIntArg")) << QMetaMethod::Public << QMetaMethod::Method; QTest::newRow("voidSlotInt") << QByteArray("voidSlotInt(int)") << int(QMetaType::Void) << QByteArray("") << (QList() << int(QMetaType::Int)) << (QList() << QByteArray("int")) << (QList() << QByteArray("voidSlotIntArg")) << QMetaMethod::Public << QMetaMethod::Slot; QTest::newRow("MethodTestObject(int)") << QByteArray("MethodTestObject(int)") << int(QMetaType::Void) << QByteArray("") << (QList() << int(QMetaType::Int)) << (QList() << QByteArray("int")) << (QList() << QByteArray("constructorIntArg")) << QMetaMethod::Public << QMetaMethod::Constructor; QTest::newRow("voidSignalQReal") << QByteArray("voidSignalQReal(qreal)") << int(QMetaType::Void) << QByteArray("") << (QList() << qMetaTypeId()) << (QList() << QByteArray("qreal")) << (QList() << QByteArray("voidSignalQRealArg")) << QMetaMethod::Protected << QMetaMethod::Signal; QTest::newRow("voidInvokableQReal") << QByteArray("voidInvokableQReal(qreal)") << int(QMetaType::Void) << QByteArray("") << (QList() << qMetaTypeId()) << (QList() << QByteArray("qreal")) << (QList() << QByteArray("voidInvokableQRealArg")) << QMetaMethod::Public << QMetaMethod::Method; QTest::newRow("voidSlotQReal") << QByteArray("voidSlotQReal(qreal)") << int(QMetaType::Void) << QByteArray("") << (QList() << qMetaTypeId()) << (QList() << QByteArray("qreal")) << (QList() << QByteArray("voidSlotQRealArg")) << QMetaMethod::Public << QMetaMethod::Slot; QTest::newRow("MethodTestObject(qreal)") << QByteArray("MethodTestObject(qreal)") << int(QMetaType::Void) << QByteArray("") << (QList() << qMetaTypeId()) << (QList() << QByteArray("qreal")) << (QList() << QByteArray("constructorQRealArg")) << QMetaMethod::Public << QMetaMethod::Constructor; QTest::newRow("voidSignalQString") << QByteArray("voidSignalQString(QString)") << int(QMetaType::Void) << QByteArray("") << (QList() << int(QMetaType::QString)) << (QList() << QByteArray("QString")) << (QList() << QByteArray("voidSignalQStringArg")) << QMetaMethod::Protected << QMetaMethod::Signal; QTest::newRow("voidInvokableQString") << QByteArray("voidInvokableQString(QString)") << int(QMetaType::Void) << QByteArray("") << (QList() << int(QMetaType::QString)) << (QList() << QByteArray("QString")) << (QList() << QByteArray("voidInvokableQStringArg")) << QMetaMethod::Public << QMetaMethod::Method; QTest::newRow("voidSlotQString") << QByteArray("voidSlotQString(QString)") << int(QMetaType::Void) << QByteArray("") << (QList() << int(QMetaType::QString)) << (QList() << QByteArray("QString")) << (QList() << QByteArray("voidSlotQStringArg")) << QMetaMethod::Public << QMetaMethod::Slot; QTest::newRow("MethodTestObject(QString)") << QByteArray("MethodTestObject(QString)") << int(QMetaType::Void) << QByteArray("") << (QList() << int(QMetaType::QString)) << (QList() << QByteArray("QString")) << (QList() << QByteArray("constructorQStringArg")) << QMetaMethod::Public << QMetaMethod::Constructor; QTest::newRow("voidSignalCustomType") << QByteArray("voidSignalCustomType(CustomType)") << int(QMetaType::Void) << QByteArray("") << (QList() << qMetaTypeId()) << (QList() << QByteArray("CustomType")) << (QList() << QByteArray("voidSignalCustomTypeArg")) << QMetaMethod::Protected << QMetaMethod::Signal; QTest::newRow("voidInvokableCustomType") << QByteArray("voidInvokableCustomType(CustomType)") << int(QMetaType::Void) << QByteArray("") << (QList() << qMetaTypeId()) << (QList() << QByteArray("CustomType")) << (QList() << QByteArray("voidInvokableCustomTypeArg")) << QMetaMethod::Public << QMetaMethod::Method; QTest::newRow("voidSlotCustomType") << QByteArray("voidSlotCustomType(CustomType)") << int(QMetaType::Void) << QByteArray("") << (QList() << qMetaTypeId()) << (QList() << QByteArray("CustomType")) << (QList() << QByteArray("voidSlotCustomTypeArg")) << QMetaMethod::Public << QMetaMethod::Slot; QTest::newRow("MethodTestObject(CustomType)") << QByteArray("MethodTestObject(CustomType)") << int(QMetaType::Void) << QByteArray("") << (QList() << qMetaTypeId()) << (QList() << QByteArray("CustomType")) << (QList() << QByteArray("constructorCustomTypeArg")) << QMetaMethod::Public << QMetaMethod::Constructor; QTest::newRow("voidSignalCustomUnregisteredType") << QByteArray("voidSignalCustomUnregisteredType(CustomUnregisteredType)") << int(QMetaType::Void) << QByteArray("") << (QList() << 0) << (QList() << QByteArray("CustomUnregisteredType")) << (QList() << QByteArray("voidSignalCustomUnregisteredTypeArg")) << QMetaMethod::Protected << QMetaMethod::Signal; QTest::newRow("voidInvokableCustomUnregisteredType") << QByteArray("voidInvokableCustomUnregisteredType(CustomUnregisteredType)") << int(QMetaType::Void) << QByteArray("") << (QList() << 0) << (QList() << QByteArray("CustomUnregisteredType")) << (QList() << QByteArray("voidInvokableCustomUnregisteredTypeArg")) << QMetaMethod::Public << QMetaMethod::Method; QTest::newRow("voidSlotCustomUnregisteredType") << QByteArray("voidSlotCustomUnregisteredType(CustomUnregisteredType)") << int(QMetaType::Void) << QByteArray("") << (QList() << 0) << (QList() << QByteArray("CustomUnregisteredType")) << (QList() << QByteArray("voidSlotCustomUnregisteredTypeArg")) << QMetaMethod::Public << QMetaMethod::Slot; QTest::newRow("MethodTestObject(CustomUnregisteredType)") << QByteArray("MethodTestObject(CustomUnregisteredType)") << int(QMetaType::Void) << QByteArray("") << (QList() << 0) << (QList() << QByteArray("CustomUnregisteredType")) << (QList() << QByteArray("constructorCustomUnregisteredTypeArg")) << QMetaMethod::Public << QMetaMethod::Constructor; QTest::newRow("boolSignal") << QByteArray("boolSignal()") << int(QMetaType::Bool) << QByteArray("bool") << (QList()) << (QList()) << (QList()) << QMetaMethod::Protected << QMetaMethod::Signal; QTest::newRow("boolInvokable") << QByteArray("boolInvokable()") << int(QMetaType::Bool) << QByteArray("bool") << (QList()) << (QList()) << (QList()) << QMetaMethod::Public << QMetaMethod::Method; QTest::newRow("boolSlot") << QByteArray("boolSlot()") << int(QMetaType::Bool) << QByteArray("bool") << (QList()) << (QList()) << (QList()) << QMetaMethod::Public << QMetaMethod::Slot; QTest::newRow("qrealSignal") << QByteArray("qrealSignal()") << int(QMetaType::QReal) << QByteArray("qreal") << (QList()) << (QList()) << (QList()) << QMetaMethod::Protected << QMetaMethod::Signal; QTest::newRow("qrealInvokable") << QByteArray("qrealInvokable()") << int(QMetaType::QReal) << QByteArray("qreal") << (QList()) << (QList()) << (QList()) << QMetaMethod::Public << QMetaMethod::Method; QTest::newRow("qrealSlot") << QByteArray("qrealSlot()") << int(QMetaType::QReal) << QByteArray("qreal") << (QList()) << (QList()) << (QList()) << QMetaMethod::Public << QMetaMethod::Slot; QTest::newRow("qstringSignal") << QByteArray("qstringSignal()") << int(QMetaType::QString) << QByteArray("QString") << (QList()) << (QList()) << (QList()) << QMetaMethod::Protected << QMetaMethod::Signal; QTest::newRow("qstringInvokable") << QByteArray("qstringInvokable()") << int(QMetaType::QString) << QByteArray("QString") << (QList()) << (QList()) << (QList()) << QMetaMethod::Public << QMetaMethod::Method; QTest::newRow("qstringSlot") << QByteArray("qstringSlot()") << int(QMetaType::QString) << QByteArray("QString") << (QList()) << (QList()) << (QList()) << QMetaMethod::Public << QMetaMethod::Slot; { QList parameterTypes = QList() << int(QMetaType::Bool) << int(QMetaType::Int) << int(QMetaType::UInt) << int(QMetaType::LongLong) << int(QMetaType::ULongLong) << int(QMetaType::Double) << int(QMetaType::Long) << int(QMetaType::Short) << int(QMetaType::Char) << int(QMetaType::ULong) << int(QMetaType::UShort) << int(QMetaType::UChar) << int(QMetaType::Float); QList parameterTypeNames = QList() << QByteArray("bool") << QByteArray("int") << QByteArray("uint") << QByteArray("qlonglong") << QByteArray("qulonglong") << QByteArray("double") << QByteArray("long") << QByteArray("short") << QByteArray("char") << QByteArray("ulong") << QByteArray("ushort") << QByteArray("uchar") << QByteArray("float"); QList parameterNames = QList() << QByteArray("boolArg") << QByteArray("intArg") << QByteArray("uintArg") << QByteArray("longlongArg") << QByteArray("ulonglongArg") << QByteArray("doubleArg") << QByteArray("longArg") << QByteArray("shortArg") << QByteArray("charArg") << QByteArray("ulongArg") << QByteArray("ushortArg") << QByteArray("ucharArg") << QByteArray("floatArg"); QTest::newRow("qvariantSignalBoolIntUIntLonglongULonglongDoubleLongShortCharUlongUshortUcharFloat") << QByteArray("qvariantSignalBoolIntUIntLonglongULonglongDoubleLongShortCharUlongUshortUcharFloat(" "bool,int,uint,qlonglong,qulonglong,double,long,short,char,ulong,ushort,uchar,float)") << int(QMetaType::QVariant) << QByteArray("QVariant") << parameterTypes << parameterTypeNames << parameterNames << QMetaMethod::Protected << QMetaMethod::Signal; QTest::newRow("qvariantInvokableBoolIntUIntLonglongULonglongDoubleLongShortCharUlongUshortUcharFloat") << QByteArray("qvariantInvokableBoolIntUIntLonglongULonglongDoubleLongShortCharUlongUshortUcharFloat(" "bool,int,uint,qlonglong,qulonglong,double,long,short,char,ulong,ushort,uchar,float)") << int(QMetaType::QVariant) << QByteArray("QVariant") << parameterTypes << parameterTypeNames << parameterNames << QMetaMethod::Public << QMetaMethod::Method; QTest::newRow("qvariantSlotBoolIntUIntLonglongULonglongDoubleLongShortCharUlongUshortUcharFloat") << QByteArray("qvariantSlotBoolIntUIntLonglongULonglongDoubleLongShortCharUlongUshortUcharFloat(" "bool,int,uint,qlonglong,qulonglong,double,long,short,char,ulong,ushort,uchar,float)") << int(QMetaType::QVariant) << QByteArray("QVariant") << parameterTypes << parameterTypeNames << parameterNames << QMetaMethod::Public << QMetaMethod::Slot; QTest::newRow("MethodTestObject(bool,int,uint,qlonglong,qulonglong,double,long,short,char,ulong,ushort,uchar,float)") << QByteArray("MethodTestObject(bool,int,uint,qlonglong,qulonglong,double,long,short,char,ulong,ushort,uchar,float)") << int(QMetaType::Void) << QByteArray("") << parameterTypes << parameterTypeNames << parameterNames << QMetaMethod::Public << QMetaMethod::Constructor; } QTest::newRow("voidSignalNoParameterNames") << QByteArray("voidSignalNoParameterNames(bool,int)") << int(QMetaType::Void) << QByteArray("") << (QList() << int(QMetaType::Bool) << int(QMetaType::Int)) << (QList() << QByteArray("bool") << QByteArray("int")) << (QList() << QByteArray("") << QByteArray("")) << QMetaMethod::Protected << QMetaMethod::Signal; QTest::newRow("voidInvokableNoParameterNames") << QByteArray("voidInvokableNoParameterNames(bool,int)") << int(QMetaType::Void) << QByteArray("") << (QList() << int(QMetaType::Bool) << int(QMetaType::Int)) << (QList() << QByteArray("bool") << QByteArray("int")) << (QList() << QByteArray("") << QByteArray("")) << QMetaMethod::Public << QMetaMethod::Method; QTest::newRow("voidSlotNoParameterNames") << QByteArray("voidSlotNoParameterNames(bool,int)") << int(QMetaType::Void) << QByteArray("") << (QList() << int(QMetaType::Bool) << int(QMetaType::Int)) << (QList() << QByteArray("bool") << QByteArray("int")) << (QList() << QByteArray("") << QByteArray("")) << QMetaMethod::Public << QMetaMethod::Slot; QTest::newRow("MethodTestObject(bool,int)") << QByteArray("MethodTestObject(bool,int)") << int(QMetaType::Void) << QByteArray("") << (QList() << int(QMetaType::Bool) << int(QMetaType::Int)) << (QList() << QByteArray("bool") << QByteArray("int")) << (QList() << QByteArray("") << QByteArray("")) << QMetaMethod::Public << QMetaMethod::Constructor; } void tst_QMetaMethod::method() { QFETCH(QByteArray, signature); QFETCH(int, returnType); QFETCH(QByteArray, returnTypeName); QFETCH(QList, parameterTypes); QFETCH(QList, parameterTypeNames); QFETCH(QList, parameterNames); QFETCH(QMetaMethod::MethodType, methodType); QFETCH(QMetaMethod::Access, access); QVERIFY(parameterTypes.size() == parameterTypeNames.size()); QVERIFY(parameterTypes.size() == parameterNames.size()); const QMetaObject *mo = &MethodTestObject::staticMetaObject; int index = (methodType == QMetaMethod::Constructor) ? mo->indexOfConstructor(signature) : mo->indexOfMethod(signature); QVERIFY(index != -1); QMetaMethod method = (methodType == QMetaMethod::Constructor) ? mo->constructor(index) : mo->method(index); QVERIFY(method.isValid()); QCOMPARE(method.methodType(), methodType); QCOMPARE(method.access(), access); QCOMPARE(method.signature(), signature.constData()); QCOMPARE(method.tag(), ""); QCOMPARE(method.typeName(), returnTypeName.constData()); QCOMPARE(QMetaType::type(method.typeName()), returnType); QCOMPARE(method.parameterTypes(), parameterTypeNames); QCOMPARE(method.parameterNames(), parameterNames); } void tst_QMetaMethod::invalidMethod() { QMetaMethod method; QVERIFY(!method.isValid()); QMetaMethod method2 = staticMetaObject.method(staticMetaObject.methodCount()); QVERIFY(!method2.isValid()); QMetaMethod method3 = staticMetaObject.method(-1); QVERIFY(!method3.isValid()); } QTEST_MAIN(tst_QMetaMethod) #include "tst_qmetamethod.moc"