[Interest] QTest::qWait Error
Robin Burchell
robin+qt at viroteck.net
Mon Mar 26 14:48:42 CEST 2012
On Mon, Mar 26, 2012 at 2:37 PM, <Lucas.Betschart at crypto.ch> wrote:
> I've got some test slots which should only trigger when the signal arrived.
> How can I test this? I want to use them like they're normal test cases but
> that they don't get called automatically.
Don't put it on the test at all. Create another QObject subclass for
it, something like this:
class SomeOtherObject : public QObject
{
Q_OBJECT
slots:
void signalReceivedTest()
{
qDebug("Called");
}
};
MFE_Protocol_Unit_Tests::MFE_Protocol_Unit_Tests()
{
SomeOtherObj obj;
QObject::connect(&connection, SIGNAL(click()),
&obj,SLOT(signalReceivedTest()));
// wouldn't work since there is no connection & obj would be
deleted when it goes out of scope, but you get the idea
}
More information about the Interest
mailing list