Use the new QMetaMethod API in testlib
Use QMetaMethod::name() instead of parsing the signature. Use QMetaMethod::returnType() instead of checking the length of typeName(). Use QMetaMethod::parameterCount() instead of checking the size of parameterTypes(). Change-Id: I424370b19b5b150865377666dca0fba5f29ad30f Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com> Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>
This commit is contained in:
parent
d4258bc238
commit
e2502e1a06
@ -64,12 +64,6 @@ static int iLevel = 0;
|
||||
static int ignoreLevel = 0;
|
||||
enum { IndentSpacesCount = 4 };
|
||||
|
||||
static QByteArray memberName(const QMetaMethod &member)
|
||||
{
|
||||
QByteArray ba = member.methodSignature();
|
||||
return ba.left(ba.indexOf('('));
|
||||
}
|
||||
|
||||
static void qSignalDumperCallback(QObject *caller, int method_index, void **argv)
|
||||
{
|
||||
Q_ASSERT(caller); Q_ASSERT(argv); Q_UNUSED(argv);
|
||||
@ -96,7 +90,7 @@ static void qSignalDumperCallback(QObject *caller, int method_index, void **argv
|
||||
str += QByteArray::number(quintptr(caller), 16);
|
||||
|
||||
str += ") ";
|
||||
str += QTest::memberName(member);
|
||||
str += member.name();
|
||||
str += " (";
|
||||
|
||||
QList<QByteArray> args = member.parameterTypes();
|
||||
|
@ -1095,20 +1095,16 @@ int Q_TESTLIB_EXPORT defaultKeyDelay()
|
||||
|
||||
static bool isValidSlot(const QMetaMethod &sl)
|
||||
{
|
||||
if (sl.access() != QMetaMethod::Private || !sl.parameterTypes().isEmpty()
|
||||
|| qstrlen(sl.typeName()) || sl.methodType() != QMetaMethod::Slot)
|
||||
if (sl.access() != QMetaMethod::Private || sl.parameterCount() != 0
|
||||
|| sl.returnType() != QMetaType::Void || sl.methodType() != QMetaMethod::Slot)
|
||||
return false;
|
||||
QByteArray signature = sl.methodSignature();
|
||||
const char *sig = signature.constData();
|
||||
int len = qstrlen(sig);
|
||||
if (len < 2)
|
||||
QByteArray name = sl.name();
|
||||
if (name.isEmpty())
|
||||
return false;
|
||||
if (sig[len - 2] != '(' || sig[len - 1] != ')')
|
||||
if (name.endsWith("_data"))
|
||||
return false;
|
||||
if (len > 7 && strcmp(sig + (len - 7), "_data()") == 0)
|
||||
return false;
|
||||
if (strcmp(sig, "initTestCase()") == 0 || strcmp(sig, "cleanupTestCase()") == 0
|
||||
|| strcmp(sig, "cleanup()") == 0 || strcmp(sig, "init()") == 0)
|
||||
if (name == "initTestCase" || name == "cleanupTestCase"
|
||||
|| name == "cleanup" || name == "init")
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user