From 898f7ea1ec106b5e24824d2819b53376b433c8c8 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 6 Mar 2014 15:50:27 +0100 Subject: [PATCH] Sanitize tst_qftp. - Replace SRCDIR define by QFINDTESTDATA - Replace QVERIFY by QCOMPARE where applicable - Introduce QVERIFY2 with message for comparisons Change-Id: Ib5a6b0f09428587281e1b9521e4d8a8117c1afdb Reviewed-by: Peter Hartmann --- tests/auto/network/access/qftp/qftp.pro | 3 - tests/auto/network/access/qftp/tst_qftp.cpp | 202 +++++++++++--------- 2 files changed, 113 insertions(+), 92 deletions(-) diff --git a/tests/auto/network/access/qftp/qftp.pro b/tests/auto/network/access/qftp/qftp.pro index c56dfa2b6e..44161f4e1e 100644 --- a/tests/auto/network/access/qftp/qftp.pro +++ b/tests/auto/network/access/qftp/qftp.pro @@ -9,9 +9,6 @@ wince*: { addFiles.files = rfc3252.txt addFiles.path = . DEPLOYMENT += addFiles - DEFINES += SRCDIR=\\\"\\\" -} else { - DEFINES += SRCDIR=\\\"$$PWD/\\\" } CONFIG+=insignificant_test # QTBUG-15111: uses live qt-test-server, inherently unstable diff --git a/tests/auto/network/access/qftp/tst_qftp.cpp b/tests/auto/network/access/qftp/tst_qftp.cpp index fffe663f0a..a322c7ab65 100644 --- a/tests/auto/network/access/qftp/tst_qftp.cpp +++ b/tests/auto/network/access/qftp/tst_qftp.cpp @@ -57,6 +57,14 @@ #include "../../../network-settings.h" +template +static QByteArray msgComparison(T1 lhs, const char *op, T2 rhs) +{ + QString result; + QTextStream(&result) << lhs << ' ' << op << ' ' << rhs; + return result.toLatin1(); +} + class tst_QFtp : public QObject { Q_OBJECT @@ -174,6 +182,7 @@ private: bool inFileDirExistsFunction; QString uniqueExtension; + QString rfc3252File; }; //#define DUMP_SIGNALS @@ -220,6 +229,8 @@ void tst_QFtp::initTestCase() networkSessionImplicit->open(); QVERIFY(networkSessionImplicit->waitForOpened(60000)); //there may be user prompt on 1st connect #endif + rfc3252File = QFINDTESTDATA("rfc3252.txt"); + QVERIFY(!rfc3252File.isEmpty()); } void tst_QFtp::cleanupTestCase() @@ -327,6 +338,16 @@ void tst_QFtp::connectToHost_data() QTest::newRow( "error02" ) << QString("foo.bar") << (uint)21 << (int)QFtp::Unconnected; } +static QByteArray msgTimedOut(const QString &host, quint16 port = 0) +{ + QByteArray result = "Network operation timed out on " + host.toLatin1(); + if (port) { + result += ':'; + result += QByteArray::number(port); + } + return result; +} + void tst_QFtp::connectToHost() { QFETCH( QString, host ); @@ -339,7 +360,7 @@ void tst_QFtp::connectToHost() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( "Network operation timed out" ); + QFAIL( msgTimedOut(host, port) ); QTEST( connectToHost_state, "state" ); @@ -347,9 +368,9 @@ void tst_QFtp::connectToHost() QVERIFY( it != resultMap.end() ); QFETCH( int, state ); if ( state == QFtp::Connected ) { - QVERIFY( it.value().success == 1 ); + QCOMPARE( it.value().success, 1 ); } else { - QVERIFY( it.value().success == 0 ); + QCOMPARE( it.value().success , 0 ); } } @@ -382,10 +403,10 @@ void tst_QFtp::connectToUnresponsiveHost() #endif QVERIFY2(! QTestEventLoop::instance().timeout(), "Network timeout longer than expected (should have been 60 seconds)"); - QVERIFY( ftp->state() == QFtp::Unconnected); + QCOMPARE( ftp->state(), QFtp::Unconnected); ResMapIt it = resultMap.find( QFtp::ConnectToHost ); QVERIFY( it != resultMap.end() ); - QVERIFY( it.value().success == 0 ); + QCOMPARE( it.value().success, 0 ); delete ftp; ftp = 0; @@ -423,16 +444,17 @@ void tst_QFtp::login() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( "Network operation timed out" ); + QFAIL( msgTimedOut(host, port) ); ResMapIt it = resultMap.find( QFtp::Login ); QVERIFY( it != resultMap.end() ); QTEST( it.value().success, "success" ); + const QFtp::State loginState = static_cast(login_state); if ( it.value().success ) { - QVERIFY( login_state == QFtp::LoggedIn ); + QCOMPARE( loginState, QFtp::LoggedIn ); } else { - QVERIFY( login_state != QFtp::LoggedIn ); + QVERIFY2( loginState != QFtp::LoggedIn, msgComparison(loginState, "!=", QFtp::LoggedIn)); } } @@ -470,13 +492,13 @@ void tst_QFtp::close() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( "Network operation timed out" ); + QFAIL( msgTimedOut(host, port) ); QCOMPARE( close_state, (int)QFtp::Unconnected ); ResMapIt it = resultMap.find( QFtp::Close ); QVERIFY( it != resultMap.end() ); - QVERIFY( it.value().success == 1 ); + QCOMPARE( it.value().success, 1 ); } void tst_QFtp::list_data() @@ -538,7 +560,7 @@ void tst_QFtp::list() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( "Network operation timed out" ); + QFAIL( msgTimedOut(host, port) ); ResMapIt it = resultMap.find( QFtp::List ); QVERIFY( it != resultMap.end() ); @@ -599,7 +621,7 @@ void tst_QFtp::cd() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) { - QFAIL( "Network operation timed out" ); + QFAIL( msgTimedOut(host, port) ); } ResMapIt it = resultMap.find( QFtp::Cd ); @@ -624,8 +646,8 @@ void tst_QFtp::get_data() QTest::addColumn("useIODevice"); // ### move this into external testdata - QFile file( SRCDIR "rfc3252.txt" ); - QVERIFY( file.open( QIODevice::ReadOnly ) ); + QFile file(rfc3252File); + QVERIFY2( file.open( QIODevice::ReadOnly ), qPrintable(file.errorString()) ); QByteArray rfc3252 = file.readAll(); // test the two get() overloads in one routine @@ -675,7 +697,7 @@ void tst_QFtp::get() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( "Network operation timed out" ); + QFAIL( msgTimedOut(host, port) ); ResMapIt it = resultMap.find( QFtp::Get ); QVERIFY( it != resultMap.end() ); @@ -685,17 +707,17 @@ void tst_QFtp::get() } else { QTEST( newData_ba, "res" ); } - QVERIFY( bytesTotal != bytesTotal_init ); + QVERIFY2( bytesTotal != bytesTotal_init, msgComparison(bytesTotal, "!=", bytesTotal_init) ); if ( bytesTotal != -1 ) { - QVERIFY( bytesDone == bytesTotal ); + QCOMPARE( bytesDone, bytesTotal ); } if ( useIODevice ) { if ( bytesDone != bytesDone_init ) { - QVERIFY( (int)buf_ba.size() == bytesDone ); + QCOMPARE( qlonglong(buf_ba.size()), bytesDone ); } } else { if ( bytesDone != bytesDone_init ) { - QVERIFY( (int)newData_ba.size() == bytesDone ); + QCOMPARE( qlonglong(newData_ba.size()), bytesDone ); } } } @@ -712,8 +734,8 @@ void tst_QFtp::put_data() QTest::addColumn("success"); // ### move this into external testdata - QFile file( SRCDIR "rfc3252.txt" ); - QVERIFY( file.open( QIODevice::ReadOnly ) ); + QFile file(rfc3252File); + QVERIFY2( file.open( QIODevice::ReadOnly ), qPrintable(file.errorString()) ); QByteArray rfc3252 = file.readAll(); QByteArray bigData( 10*1024*1024, 0 ); @@ -801,7 +823,7 @@ void tst_QFtp::put() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( "Network operation timed out" ); + QFAIL( msgTimedOut(host, port) ); it = resultMap.find( QFtp::Put ); QVERIFY( it != resultMap.end() ); @@ -810,8 +832,8 @@ void tst_QFtp::put() QVERIFY( !fileExists( host, port, user, password, file ) ); return; // the following tests are only meaningful if the file could be put } - QVERIFY( bytesTotal == (int)fileData.size() ); - QVERIFY( bytesDone == bytesTotal ); + QCOMPARE( bytesTotal, qlonglong(fileData.size()) ); + QCOMPARE( bytesDone, bytesTotal ); QVERIFY( fileExists( host, port, user, password, file ) ); @@ -834,9 +856,9 @@ void tst_QFtp::put() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( "Network operation timed out" ); + QFAIL( msgTimedOut(host, port) ); - QVERIFY( done_success == 1 ); + QCOMPARE( done_success, 1 ); QTEST( buf.buffer(), "fileData" ); ////////////////////////////////////////////////////////////////// @@ -852,7 +874,7 @@ void tst_QFtp::put() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( "Network operation timed out" ); + QFAIL( msgTimedOut(host, port) ); it = resultMap.find( QFtp::Remove ); QVERIFY( it != resultMap.end() ); @@ -916,7 +938,7 @@ void tst_QFtp::mkdir() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( "Network operation timed out" ); + QFAIL( msgTimedOut(host, port) ); ResMapIt it = resultMap.find( QFtp::Mkdir ); QVERIFY( it != resultMap.end() ); @@ -941,7 +963,7 @@ void tst_QFtp::mkdir() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( "Network operation timed out" ); + QFAIL( msgTimedOut(host, port) ); it = resultMap.find( QFtp::Mkdir ); QVERIFY( it != resultMap.end() ); @@ -961,7 +983,7 @@ void tst_QFtp::mkdir() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( "Network operation timed out" ); + QFAIL( msgTimedOut(host, port) ); it = resultMap.find( QFtp::Rmdir ); QVERIFY( it != resultMap.end() ); @@ -1074,11 +1096,11 @@ void tst_QFtp::renameInit( const QString &host, const QString &user, const QStri delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( "Network operation timed out" ); + QFAIL( msgTimedOut(host) ); ResMapIt it = resultMap.find( QFtp::Put ); QVERIFY( it != resultMap.end() ); - QVERIFY( it.value().success == 1 ); + QCOMPARE( it.value().success, 1 ); QVERIFY( fileExists( host, 21, user, password, createFile ) ); } @@ -1099,11 +1121,11 @@ void tst_QFtp::renameCleanup( const QString &host, const QString &user, const QS delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( "Network operation timed out" ); + QFAIL( msgTimedOut(host) ); ResMapIt it = resultMap.find( QFtp::Remove ); QVERIFY( it != resultMap.end() ); - QVERIFY( it.value().success == 1 ); + QCOMPARE( it.value().success, 1 ); QVERIFY( !fileExists( host, 21, user, password, fileToDelete ) ); } @@ -1144,7 +1166,7 @@ void tst_QFtp::rename() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( "Network operation timed out" ); + QFAIL( msgTimedOut(host) ); ResMapIt it = resultMap.find( QFtp::Rename ); QVERIFY( it != resultMap.end() ); @@ -1300,25 +1322,27 @@ void tst_QFtp::commandSequence() QFETCH( QList, cmds ); ftp = newFtp(); + QString host; + quint16 port = 0; QList::iterator it; for ( it = cmds.begin(); it != cmds.end(); ++it ) { switch ( (*it).cmd ) { case QFtp::ConnectToHost: { - QVERIFY( (*it).args.count() == 2 ); - uint port; + QCOMPARE( (*it).args.count(), 2 ); bool portOk; - port = (*it).args[1].toUInt( &portOk ); + port = (*it).args[1].toUShort( &portOk ); QVERIFY( portOk ); - ids << ftp->connectToHost( (*it).args[0], port ); + host = (*it).args[0]; + ids << ftp->connectToHost( host, port ); } break; case QFtp::Login: - QVERIFY( (*it).args.count() == 2 ); + QCOMPARE( (*it).args.count(), 2 ); ids << ftp->login( (*it).args[0], (*it).args[1] ); break; case QFtp::Close: - QVERIFY( (*it).args.count() == 0 ); + QCOMPARE( (*it).args.count(), 0 ); ids << ftp->close(); break; default: @@ -1331,7 +1355,7 @@ void tst_QFtp::commandSequence() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( "Network operation timed out" ); + QFAIL( msgTimedOut(host) ); QTEST( commandSequence_success, "success" ); } @@ -1389,7 +1413,7 @@ void tst_QFtp::abort() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( "Network operation timed out" ); + QFAIL( msgTimedOut(host, port) ); ResMapIt it = resultMap.find( cmd ); QVERIFY( it != resultMap.end() ); @@ -1399,18 +1423,18 @@ void tst_QFtp::abort() // the operation was aborted. So we have to use some heuristics. if ( host == QtNetworkSettings::serverName() ) { if ( cmd == QFtp::Get ) { - QVERIFY(bytesDone <= bytesTotal); + QVERIFY2(bytesDone <= bytesTotal, msgComparison(bytesDone, "<=", bytesTotal)); } else { // put commands should always be aborted, since we use really // big data - QVERIFY( bytesDone != bytesTotal ); + QVERIFY2( bytesDone != bytesTotal, msgComparison(bytesDone, "!=", bytesTotal) ); } } else { // this could be tested by verifying that no more progress signals are emitted - QVERIFY(bytesDone <= bytesTotal); + QVERIFY2(bytesDone <= bytesTotal, msgComparison(bytesDone, "<=", bytesTotal)); } } else { - QVERIFY( bytesDone != bytesTotal ); + QVERIFY2( bytesDone != bytesTotal, msgComparison(bytesDone, "!=", bytesTotal) ); } if ( cmd == QFtp::Put ) { @@ -1427,11 +1451,11 @@ void tst_QFtp::abort() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( "Network operation timed out" ); + QFAIL( msgTimedOut(host, port) ); it = resultMap.find( QFtp::Remove ); QVERIFY( it != resultMap.end() ); - QVERIFY( it.value().success == 1 ); + QCOMPARE( it.value().success, 1 ); } } @@ -1466,7 +1490,7 @@ void tst_QFtp::bytesAvailable() QTestEventLoop::instance().enterLoop( 40 ); if ( QTestEventLoop::instance().timeout() ) - QFAIL( "Network operation timed out" ); + QFAIL( msgTimedOut(host) ); ResMapIt it = resultMap.find( QFtp::Get ); QVERIFY( it != resultMap.end() ); @@ -1482,7 +1506,7 @@ void tst_QFtp::bytesAvailable() QCOMPARE(bytesAvailable_done, bytesAvailDone); ftp->readAll(); - QVERIFY( ftp->bytesAvailable() == 0 ); + QCOMPARE( ftp->bytesAvailable(), 0 ); delete ftp; ftp = 0; } @@ -1500,7 +1524,7 @@ void tst_QFtp::activeMode() connect(&ftp, SIGNAL(done(bool)), SLOT(activeModeDone(bool))); QTestEventLoop::instance().enterLoop(900); QFile::remove("tst_QFtp_activeMode_inittab"); - QVERIFY(done_success == 1); + QCOMPARE(done_success, 1); } @@ -1559,7 +1583,7 @@ void tst_QFtp::proxy() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) { - QFAIL( "Network operation timed out" ); + QFAIL( msgTimedOut(host, port) ); } ResMapIt it = resultMap.find( QFtp::Cd ); @@ -1594,7 +1618,7 @@ void tst_QFtp::binaryAscii() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( "Network operation timed out" ); + QFAIL( msgTimedOut(QtNetworkSettings::serverName()) ); ResMapIt it = resultMap.find(QFtp::Put); QVERIFY(it != resultMap.end()); @@ -1616,7 +1640,7 @@ void tst_QFtp::binaryAscii() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( "Network operation timed out" ); + QFAIL( msgTimedOut(QtNetworkSettings::serverName()) ); ResMapIt it2 = resultMap.find(QFtp::Get); QVERIFY(it2 != resultMap.end()); @@ -1624,7 +1648,7 @@ void tst_QFtp::binaryAscii() // most modern ftp servers leave the file as it is by default // (and do not remove the windows line ending), the -1 below could be // deleted in the future - QVERIFY(getData.size() == putData.size()-1); + QCOMPARE(getData.size(), putData.size() - 1); ////////////////////////////////////////////////////////////////// // cleanup (i.e. remove the file) -- this also tests the remove command init(); @@ -1639,7 +1663,7 @@ void tst_QFtp::binaryAscii() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( "Network operation timed out" ); + QFAIL( msgTimedOut(QtNetworkSettings::serverName()) ); it = resultMap.find( QFtp::Remove ); QVERIFY( it != resultMap.end() ); @@ -1666,11 +1690,11 @@ void tst_QFtp::commandStarted( int id ) qDebug( "%d:commandStarted( %d )", ftp->currentId(), id ); #endif // make sure that the commandStarted and commandFinished are nested correctly - QVERIFY( current_id == 0 ); + QCOMPARE( current_id, 0 ); current_id = id; QVERIFY( !ids.isEmpty() ); - QVERIFY( ids.first() == id ); + QCOMPARE( ids.first(), id ); if ( ids.count() > 1 ) { QVERIFY( ftp->hasPendingCommands() ); } else { @@ -1678,10 +1702,10 @@ void tst_QFtp::commandStarted( int id ) } QVERIFY( ftp->currentId() == id ); - QVERIFY( cur_state == ftp->state() ); + QCOMPARE( cur_state, int(ftp->state()) ); CURRENTCOMMAND_TEST; - QVERIFY( ftp->error() == QFtp::NoError ); + QCOMPARE( ftp->error(), QFtp::NoError ); } void tst_QFtp::commandFinished( int id, bool error ) @@ -1696,32 +1720,32 @@ void tst_QFtp::commandFinished( int id, bool error ) bytesAvailable_finished = ftp->bytesAvailable(); // make sure that the commandStarted and commandFinished are nested correctly - QVERIFY( current_id == id ); + QCOMPARE( current_id, id ); current_id = 0; QVERIFY( !ids.isEmpty() ); - QVERIFY( ids.first() == id ); + QCOMPARE( ids.first(), id ); if ( !error && ids.count() > 1) { QVERIFY( ftp->hasPendingCommands() ); } else { QVERIFY( !ftp->hasPendingCommands() ); } if ( error ) { - QVERIFY( ftp->error() != QFtp::NoError ); + QVERIFY2( ftp->error() != QFtp::NoError, msgComparison(ftp->error(), "!=", QFtp::NoError) ); ids.clear(); } else { - QVERIFY( ftp->error() == QFtp::NoError ); + QCOMPARE( ftp->error(), QFtp::NoError ); ids.pop_front(); } - QVERIFY( ftp->currentId() == id ); - QVERIFY( cur_state == ftp->state() ); + QCOMPARE( ftp->currentId(), id ); + QCOMPARE( cur_state, int(ftp->state()) ); CURRENTCOMMAND_TEST; if ( QTest::currentTestFunction() != QLatin1String("commandSequence") ) { ResMapIt it = resultMap.find( ftp->currentCommand() ); QVERIFY( it != resultMap.end() ); - QVERIFY( it.value().success == -1 ); + QCOMPARE( it.value().success, -1 ); if ( error ) it.value().success = 0; else @@ -1736,25 +1760,25 @@ void tst_QFtp::done( bool error ) #endif bytesAvailable_done = ftp->bytesAvailable(); - QVERIFY( ftp->currentId() == 0 ); + QCOMPARE( ftp->currentId(), 0 ); QVERIFY( current_id == 0 ); QVERIFY( ids.isEmpty() ); QVERIFY( cur_state == ftp->state() ); QVERIFY( !ftp->hasPendingCommands() ); if ( QTest::currentTestFunction() == QLatin1String("commandSequence") ) { - QVERIFY( commandSequence_success == -1 ); + QCOMPARE( commandSequence_success, -1 ); if ( error ) commandSequence_success = 0; else commandSequence_success = 1; } - QVERIFY( done_success == -1 ); + QCOMPARE( done_success, -1 ); if ( error ) { - QVERIFY( ftp->error() != QFtp::NoError ); + QVERIFY2( ftp->error() != QFtp::NoError, msgComparison(ftp->error(), "!=", QFtp::NoError) ); done_success = 0; } else { - QVERIFY( ftp->error() == QFtp::NoError ); + QCOMPARE( ftp->error(), QFtp::NoError ); done_success = 1; } QTestEventLoop::instance().exitLoop(); @@ -1768,13 +1792,13 @@ void tst_QFtp::stateChanged( int state ) QCOMPARE( ftp->currentId(), current_id ); CURRENTCOMMAND_TEST; - QVERIFY( state != cur_state ); + QVERIFY2( state != cur_state, msgComparison(state, "!=", cur_state) ); QCOMPARE( state, (int)ftp->state() ); if ( state != QFtp::Unconnected ) { // make sure that the states are always emitted in the right order (for // this, we assume an ordering on the enum values, which they have at // the moment) - QVERIFY( cur_state < state ); + QVERIFY2( cur_state < state, msgComparison(cur_state, "<", state) ); // make sure that state changes are only emitted in response to certain // commands @@ -1818,10 +1842,10 @@ void tst_QFtp::stateChanged( int state ) ResMapIt it = resultMap.find( QFtp::Close ); if ( it!=resultMap.end() && ftp->currentId()==it.value().id ) { if ( state == QFtp::Closing ) { - QVERIFY( close_state == -1 ); + QCOMPARE( close_state, -1 ); close_state = state; } else if ( state == QFtp::Unconnected ) { - QVERIFY( close_state == QFtp::Closing ); + QCOMPARE(close_state, int(QFtp::Closing) ); close_state = state; } } @@ -1829,7 +1853,7 @@ void tst_QFtp::stateChanged( int state ) ResMapIt it = resultMap.find( QFtp::Login ); if ( it!=resultMap.end() && ftp->currentId()==it.value().id ) { if ( state == QFtp::LoggedIn ) { - QVERIFY( login_state == -1 ); + QCOMPARE( login_state, -1 ); login_state = state; } } @@ -1847,13 +1871,13 @@ void tst_QFtp::listInfo( const QUrlInfo &i ) } else { QVERIFY( !ftp->hasPendingCommands() ); } - QVERIFY( cur_state == ftp->state() ); + QCOMPARE( cur_state, int(ftp->state()) ); CURRENTCOMMAND_TEST; if ( QTest::currentTestFunction()==QLatin1String("list") || QTest::currentTestFunction()==QLatin1String("cd") || QTest::currentTestFunction()==QLatin1String("proxy") || inFileDirExistsFunction ) { ResMapIt it = resultMap.find( QFtp::List ); QVERIFY( it != resultMap.end() ); - QVERIFY( ftp->currentId() == it.value().id ); + QCOMPARE( ftp->currentId(), it.value().id ); listInfo_i << i; } } @@ -1876,14 +1900,14 @@ void tst_QFtp::readyRead() int oldSize = newData_ba.size(); qlonglong bytesAvail = ftp->bytesAvailable(); QByteArray ba = ftp->readAll(); - QVERIFY( ba.size() == (int) bytesAvail ); + QCOMPARE( ba.size(), (int) bytesAvail ); newData_ba.resize( oldSize + ba.size() ); memcpy( newData_ba.data()+oldSize, ba.data(), ba.size() ); if ( bytesTotal != -1 ) { - QVERIFY( (int)newData_ba.size() <= bytesTotal ); + QVERIFY2( (int)newData_ba.size() <= bytesTotal, msgComparison(newData_ba.size(), "<=", bytesTotal) ); } - QVERIFY( (int)newData_ba.size() == bytesDone ); + QCOMPARE( qlonglong(newData_ba.size()), bytesDone ); } } @@ -1898,20 +1922,20 @@ void tst_QFtp::dataTransferProgress( qint64 done, qint64 total ) } else { QVERIFY( !ftp->hasPendingCommands() ); } - QVERIFY( cur_state == ftp->state() ); + QCOMPARE( cur_state, int(ftp->state()) ); CURRENTCOMMAND_TEST; if ( bytesTotal == bytesTotal_init ) { bytesTotal = total; } else { - QVERIFY( bytesTotal == total ); + QCOMPARE( bytesTotal, total ); } - QVERIFY( bytesTotal != bytesTotal_init ); - QVERIFY( bytesDone <= done ); + QVERIFY2( bytesTotal != bytesTotal_init, msgComparison(bytesTotal, "!=", bytesTotal_init) ); + QVERIFY2( bytesDone <= done, msgComparison(bytesDone, "<=", done) ); bytesDone = done; if ( bytesTotal != -1 ) { - QVERIFY( bytesDone <= bytesTotal ); + QVERIFY2( bytesDone <= bytesTotal, msgComparison(bytesDone, "<=", bytesTotal) ); } if ( QTest::currentTestFunction() == QLatin1String("abort") ) { @@ -2044,7 +2068,7 @@ bool tst_QFtp::dirExists( const QString &host, quint16 port, const QString &user ftp = 0; if ( QTestEventLoop::instance().timeout() ) { // ### make this test work - // QFAIL( "Network operation timed out" ); + // QFAIL( msgTimedOut(host, port) ); qWarning("tst_QFtp::dirExists: Network operation timed out"); return false; }