From 5f6c75eee2a333095b2a3c8939b6fe34946fdca1 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Mon, 23 May 2022 00:09:32 +0300 Subject: [PATCH] libs: attach the signal spy after D-Bus initialization stuff happens in favicon test Signed-off-by: Ivailo Monev --- libs/konq/tests/favicontest.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/libs/konq/tests/favicontest.cpp b/libs/konq/tests/favicontest.cpp index 3d75cf15..363d35c1 100644 --- a/libs/konq/tests/favicontest.cpp +++ b/libs/konq/tests/favicontest.cpp @@ -83,15 +83,15 @@ void FavIconTest::testSetIconForURL() if ( !checkNetworkAccess() ) QSKIP( "no network access", SkipAll ); - QSignalSpy spy( &m_favIconModule, SIGNAL(iconChanged(bool,QString,QString)) ); - QVERIFY( spy.isValid() ); - QCOMPARE( spy.count(), 0 ); - { QEventLoop eventLoop; // The call to connect() triggers qdbus initialization stuff, while QSignalSpy doesn't... connect(&m_favIconModule, SIGNAL(iconChanged(bool,QString,QString)), &eventLoop, SLOT(quit())); + QSignalSpy spy( &m_favIconModule, SIGNAL(iconChanged(bool,QString,QString)) ); + QVERIFY( spy.isValid() ); + QCOMPARE( spy.count(), 0 ); + m_favIconModule.setIconForUrl( QString( s_hostUrl ), QString( s_altIconUrl ) ); qDebug( "called first setIconForUrl, waiting" ); @@ -110,18 +110,23 @@ void FavIconTest::testSetIconForURL() QEventLoop eventLoop; // The call to connect() triggers qdbus initialization stuff, while QSignalSpy doesn't... connect(&m_favIconModule, SIGNAL(iconChanged(bool,QString,QString)), &eventLoop, SLOT(quit())); + + QSignalSpy spy( &m_favIconModule, SIGNAL(iconChanged(bool,QString,QString)) ); + QVERIFY( spy.isValid() ); + QCOMPARE( spy.count(), 0 ); + m_favIconModule.setIconForUrl( QString( s_hostUrl ), QString( s_iconUrl ) ); qDebug( "called setIconForUrl again, waiting" ); - if ( spy.count() < 2 ) { + if ( spy.count() < 1 ) { QTimer::singleShot(10000, &eventLoop, SLOT(quit())); eventLoop.exec( QEventLoop::ExcludeUserInputEvents ); } - QCOMPARE( spy.count(), 2 ); - QCOMPARE( spy[1][0].toBool(), false ); - QCOMPARE( spy[1][1].toString(), QString( s_hostUrl ) ); - QCOMPARE( spy[1][2].toString(), QString( "favicons/www.google.com" ) ); + QCOMPARE( spy.count(), 1 ); + QCOMPARE( spy[0][0].toBool(), false ); + QCOMPARE( spy[0][1].toString(), QString( s_hostUrl ) ); + QCOMPARE( spy[0][2].toString(), QString( "favicons/www.google.com" ) ); } }