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;
|
static int ignoreLevel = 0;
|
||||||
enum { IndentSpacesCount = 4 };
|
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)
|
static void qSignalDumperCallback(QObject *caller, int method_index, void **argv)
|
||||||
{
|
{
|
||||||
Q_ASSERT(caller); Q_ASSERT(argv); Q_UNUSED(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 += QByteArray::number(quintptr(caller), 16);
|
||||||
|
|
||||||
str += ") ";
|
str += ") ";
|
||||||
str += QTest::memberName(member);
|
str += member.name();
|
||||||
str += " (";
|
str += " (";
|
||||||
|
|
||||||
QList<QByteArray> args = member.parameterTypes();
|
QList<QByteArray> args = member.parameterTypes();
|
||||||
|
@ -1095,20 +1095,16 @@ int Q_TESTLIB_EXPORT defaultKeyDelay()
|
|||||||
|
|
||||||
static bool isValidSlot(const QMetaMethod &sl)
|
static bool isValidSlot(const QMetaMethod &sl)
|
||||||
{
|
{
|
||||||
if (sl.access() != QMetaMethod::Private || !sl.parameterTypes().isEmpty()
|
if (sl.access() != QMetaMethod::Private || sl.parameterCount() != 0
|
||||||
|| qstrlen(sl.typeName()) || sl.methodType() != QMetaMethod::Slot)
|
|| sl.returnType() != QMetaType::Void || sl.methodType() != QMetaMethod::Slot)
|
||||||
return false;
|
return false;
|
||||||
QByteArray signature = sl.methodSignature();
|
QByteArray name = sl.name();
|
||||||
const char *sig = signature.constData();
|
if (name.isEmpty())
|
||||||
int len = qstrlen(sig);
|
|
||||||
if (len < 2)
|
|
||||||
return false;
|
return false;
|
||||||
if (sig[len - 2] != '(' || sig[len - 1] != ')')
|
if (name.endsWith("_data"))
|
||||||
return false;
|
return false;
|
||||||
if (len > 7 && strcmp(sig + (len - 7), "_data()") == 0)
|
if (name == "initTestCase" || name == "cleanupTestCase"
|
||||||
return false;
|
|| name == "cleanup" || name == "init")
|
||||||
if (strcmp(sig, "initTestCase()") == 0 || strcmp(sig, "cleanupTestCase()") == 0
|
|
||||||
|| strcmp(sig, "cleanup()") == 0 || strcmp(sig, "init()") == 0)
|
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user