@ -54,9 +54,8 @@ QList<DhtServer> MockNodeListGenerator::getBootstrapnodes() const {
@@ -54,9 +54,8 @@ QList<DhtServer> MockNodeListGenerator::getBootstrapnodes() const {
}
namespace {
const int bootstrap_timeout = 120000 ; // timeout for bootstrapping
const int local_timeout = 500 ; // timeout for operations happening offline
const int connected_message_timeout = 15000 ; // timeout for alice and bob messaging
const int very_long_timeout = 10 * 60 * 1000 ;
const int connected_message_wait = 15000 ; // timeout for alice and bob messaging
}
class TestCoreOnline : public QObject
@ -104,7 +103,7 @@ void TestCoreOnline::init()
@@ -104,7 +103,7 @@ void TestCoreOnline::init()
bob - > start ( ) ;
// Wait for both instances coming online
QTRY_VERIFY_WITH_TIMEOUT ( spyAliceOnline . count ( ) > = 1 & & spyBobOnline . count ( ) > = 1 , bootstrap _timeout) ;
QTRY_VERIFY_WITH_TIMEOUT ( spyAliceOnline . count ( ) > = 1 & & spyBobOnline . count ( ) > = 1 , very_long _timeout) ;
// Make a friend request from alice to bob
const QLatin1String friendMsg { " Test Invite Message " } ;
@ -114,7 +113,7 @@ void TestCoreOnline::init()
@@ -114,7 +113,7 @@ void TestCoreOnline::init()
alice - > requestFriendship ( bob - > getSelfId ( ) , friendMsg ) ;
// Wait for friend message to be received
QTRY_VERIFY_WITH_TIMEOUT ( spyBobFriendMsg . count ( ) = = 1 & & spyAliceFriendMsg . count ( ) = = 1 , bootstrap _timeout) ;
QTRY_VERIFY_WITH_TIMEOUT ( spyBobFriendMsg . count ( ) = = 1 & & spyAliceFriendMsg . count ( ) = = 1 , very_long _timeout) ;
// Check for expected signal content
QVERIFY ( qvariant_cast < ToxPk > ( spyBobFriendMsg [ 0 ] [ 0 ] ) = = alice - > getSelfPublicKey ( ) ) ;
@ -130,7 +129,7 @@ void TestCoreOnline::init()
@@ -130,7 +129,7 @@ void TestCoreOnline::init()
QSignalSpy spyAliceFriendOnline ( alice . get ( ) , & Core : : friendStatusChanged ) ;
QSignalSpy spyBobFriendOnline ( bob . get ( ) , & Core : : friendStatusChanged ) ;
QTRY_VERIFY_WITH_TIMEOUT ( spyAliceFriendOnline . count ( ) > = 1 & & spyBobFriendOnline . count ( ) > = 1 , bootstrap _timeout) ;
QTRY_VERIFY_WITH_TIMEOUT ( spyAliceFriendOnline . count ( ) > = 1 & & spyBobFriendOnline . count ( ) > = 1 , very_long _timeout) ;
// Check for expected signal content
QVERIFY ( spyAliceFriendOnline [ 0 ] [ 0 ] . toInt ( ) = = static_cast < int > ( Status : : Status : : Online ) ) ;
@ -154,20 +153,20 @@ void TestCoreOnline::change_name()
@@ -154,20 +153,20 @@ void TestCoreOnline::change_name()
alice - > setUsername ( aliceName ) ;
QTRY_VERIFY_WITH_TIMEOUT ( aliceSaveRequest . count ( ) = = 1 , local _timeout) ;
QTRY_VERIFY_WITH_TIMEOUT ( aliceSaveRequest . count ( ) = = 1 , very_long _timeout) ;
QTRY_VERIFY_WITH_TIMEOUT ( aliceUsernameChanged . count ( ) = = 1 & &
aliceUsernameChanged [ 0 ] [ 0 ] . toString ( ) = = aliceName ,
local _timeout) ;
very_long _timeout) ;
QTRY_VERIFY_WITH_TIMEOUT ( bobUsernameChangeReceived . count ( ) = = 1 & &
bobUsernameChangeReceived [ 0 ] [ 1 ] . toString ( ) = = aliceName , connected_message _timeout) ;
bobUsernameChangeReceived [ 0 ] [ 1 ] . toString ( ) = = aliceName , very_long _timeout) ;
// Setting the username again to the same value shoud NOT trigger any signals
alice - > setUsername ( aliceName ) ;
// Need to sleep here, because we're testing that these don't increase based on
// Alice re-setting her username, so QTRY_VERIFY_WITH_TIMEOUT would return immediately.
QTest : : qSleep ( connected_message_timeou t ) ;
QTest : : qSleep ( connected_message_wai t ) ;
QVERIFY ( aliceSaveRequest . count ( ) = = 1 ) ;
QVERIFY ( aliceUsernameChanged . count ( ) = = 1 ) ;
QVERIFY ( bobUsernameChangeReceived . count ( ) = = 1 ) ;
@ -184,20 +183,20 @@ void TestCoreOnline::change_status_message()
@@ -184,20 +183,20 @@ void TestCoreOnline::change_status_message()
alice - > setStatusMessage ( aliceStatusMsg ) ;
QTRY_VERIFY_WITH_TIMEOUT ( aliceSaveRequest . count ( ) = = 1 , local _timeout) ;
QTRY_VERIFY_WITH_TIMEOUT ( aliceSaveRequest . count ( ) = = 1 , very_long _timeout) ;
QTRY_VERIFY_WITH_TIMEOUT ( aliceStatusMsgChanged . count ( ) = = 1 & &
aliceStatusMsgChanged [ 0 ] [ 0 ] . toString ( ) = = aliceStatusMsg ,
local _timeout) ;
very_long _timeout) ;
QTRY_VERIFY_WITH_TIMEOUT ( bobStatusMsgChangeReceived . count ( ) = = 1 & &
bobStatusMsgChangeReceived [ 0 ] [ 1 ] . toString ( ) = = aliceStatusMsg , connected_message _timeout) ;
bobStatusMsgChangeReceived [ 0 ] [ 1 ] . toString ( ) = = aliceStatusMsg , very_long _timeout) ;
// Setting the status message again to the same value shoud NOT trigger any signals
alice - > setStatusMessage ( aliceStatusMsg ) ;
// Need to sleep here, because we're testing that these don't increase based on
// Alice re-setting her status message, so QTRY_VERIFY_WITH_TIMEOUT would return immediately.
QTest : : qSleep ( connected_message_timeou t ) ;
QTest : : qSleep ( connected_message_wai t ) ;
QVERIFY ( aliceSaveRequest . count ( ) = = 1 ) ;
QVERIFY ( aliceStatusMsgChanged . count ( ) = = 1 ) ;
QVERIFY ( bobStatusMsgChangeReceived . count ( ) = = 1 ) ;
@ -211,27 +210,27 @@ void TestCoreOnline::change_status()
@@ -211,27 +210,27 @@ void TestCoreOnline::change_status()
alice - > setStatus ( Status : : Status : : Away ) ;
QTRY_VERIFY_WITH_TIMEOUT ( aliceSaveRequest . count ( ) = = 1 , local _timeout) ;
QTRY_VERIFY_WITH_TIMEOUT ( aliceSaveRequest . count ( ) = = 1 , very_long _timeout) ;
QTRY_VERIFY_WITH_TIMEOUT ( aliceStatusChanged . count ( ) = = 1 & &
qvariant_cast < Status : : Status > ( aliceStatusChanged [ 0 ] [ 0 ] ) = = Status : : Status : : Away ,
local _timeout) ;
very_long _timeout) ;
QTRY_VERIFY_WITH_TIMEOUT ( bobStatusChangeReceived . count ( ) = = 1 & &
qvariant_cast < Status : : Status > ( bobStatusChangeReceived [ 0 ] [ 1 ] ) = = Status : : Status : : Away ,
connected_message _timeout) ;
very_long _timeout) ;
// Setting the status message again to the same value again triggers all signals
alice - > setStatus ( Status : : Status : : Away ) ;
// TODO(sudden6): Emitting these again odd and should probably be changed, lets codify it for now though
QTRY_VERIFY_WITH_TIMEOUT ( aliceSaveRequest . count ( ) = = 2 , local _timeout) ;
QTRY_VERIFY_WITH_TIMEOUT ( aliceSaveRequest . count ( ) = = 2 , very_long _timeout) ;
QTRY_VERIFY_WITH_TIMEOUT ( aliceStatusChanged . count ( ) = = 2 & &
qvariant_cast < Status : : Status > ( aliceStatusChanged [ 1 ] [ 0 ] ) = = Status : : Status : : Away ,
local _timeout) ;
very_long _timeout) ;
// Need to sleep here, because we're testing that we don't get a new signal for the re-set but
// unchanged status, so QTRY_VERIFY_WITH_TIMEOUT would return immediately.
QTest : : qSleep ( connected_message_timeou t ) ;
QTest : : qSleep ( connected_message_wai t ) ;
QVERIFY ( bobStatusChangeReceived . count ( ) = = 1 ) ;
}