tst_QMetaObject: make sure we don't mix references with non-refs

We should fail to even find the method. `QString' and `QString&` are not
compatible.

Change-Id: I36b24183fbd041179f2ffffd170259bcf07fd459
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
bb10
Thiago Macieira 2022-07-16 08:44:40 -07:00
parent 48ce496c50
commit b01051dda7
1 changed files with 10 additions and 0 deletions

View File

@ -778,6 +778,9 @@ void tst_QMetaObject::invokeMetaMember()
QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::sl1(QString,QString,QString)\n"
"Candidates are:\n sl1(QString)");
QVERIFY(!QMetaObject::invokeMethod(&obj, "sl1", Q_ARG(QString, "arg"), Q_ARG(QString, "arg"), Q_ARG(QString, "arg")));
QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::testReference(QString)\n"
"Candidates are:\n testReference(QString&)");
QVERIFY(!QMetaObject::invokeMethod(&obj, "testReference", Q_ARG(QString, exp)));
//should not have changed since last test.
QCOMPARE(exp, QString("yessir"));
@ -908,6 +911,10 @@ void tst_QMetaObject::invokeQueuedMetaMember()
qApp->processEvents(QEventLoop::AllEvents);
QCOMPARE(obj.slotResult, QString("testLongLong:-1,0"));
QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::testReference(QString)\n"
"Candidates are:\n testReference(QString&)");
QVERIFY(!QMetaObject::invokeMethod(&obj, "testReference", Qt::QueuedConnection, Q_ARG(QString, exp)));
obj.slotResult.clear();
{
const MyForwardDeclaredType &t = getForwardDeclaredType();
@ -1131,6 +1138,9 @@ void tst_QMetaObject::invokeBlockingQueuedMetaMember()
QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::sl1(QString,QString,QString)\n"
"Candidates are:\n sl1(QString)");
QVERIFY(!QMetaObject::invokeMethod(&obj, "sl1", Qt::BlockingQueuedConnection, Q_ARG(QString, "arg"), Q_ARG(QString, "arg"), Q_ARG(QString, "arg")));
QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::testReference(QString)\n"
"Candidates are:\n testReference(QString&)");
QVERIFY(!QMetaObject::invokeMethod(&obj, "testReference", Qt::BlockingQueuedConnection, Q_ARG(QString, exp)));
//should not have changed since last test.
QCOMPARE(exp, QString("yessir"));