diff options
| author | Markus Mittendrein <git@maxmitti.tk> | 2015-10-14 14:50:58 +0200 |
|---|---|---|
| committer | Markus Mittendrein <git@maxmitti.tk> | 2015-10-14 14:50:58 +0200 |
| commit | 1a5fb5eca8d151034b5e54c505932d1add97a775 (patch) | |
| tree | 38b54edd03012972c6fe7bf1b8fa8365c1df42a8 /src/libcommuni/tests/auto/irclagtimer/tst_irclagtimer.cpp | |
| parent | e7485b051ef4fe01330d5f51759177027d2678b6 (diff) | |
| download | manager-1a5fb5eca8d151034b5e54c505932d1add97a775.tar.gz manager-1a5fb5eca8d151034b5e54c505932d1add97a775.zip | |
Include libcommuni through git-submodules
Diffstat (limited to 'src/libcommuni/tests/auto/irclagtimer/tst_irclagtimer.cpp')
| -rw-r--r-- | src/libcommuni/tests/auto/irclagtimer/tst_irclagtimer.cpp | 109 |
1 files changed, 0 insertions, 109 deletions
diff --git a/src/libcommuni/tests/auto/irclagtimer/tst_irclagtimer.cpp b/src/libcommuni/tests/auto/irclagtimer/tst_irclagtimer.cpp deleted file mode 100644 index 3a69042..0000000 --- a/src/libcommuni/tests/auto/irclagtimer/tst_irclagtimer.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (C) 2008-2014 The Communi Project - * - * This test is free, and not covered by the BSD license. There is no - * restriction applied to their modification, redistribution, using and so on. - * You can study them, modify them, use them in your own program - either - * completely or partially. - */ - -#include "irclagtimer.h" -#include "ircconnection.h" -#include "tst_ircclientserver.h" -#include "tst_ircdata.h" -#include <QtTest/QtTest> - -class tst_IrcLagTimer : public tst_IrcClientServer -{ - Q_OBJECT - -private slots: - void testDefaults(); - void testInterval(); - void testConnection(); - void testLag(); -}; - -void tst_IrcLagTimer::testDefaults() -{ - IrcLagTimer timer; - QCOMPARE(timer.lag(), qint64(-1)); - QVERIFY(!timer.connection()); - QCOMPARE(timer.interval(), 60); -} - -void tst_IrcLagTimer::testInterval() -{ - IrcLagTimer timer; - timer.setInterval(INT_MIN); - QCOMPARE(timer.interval(), INT_MIN); - timer.setInterval(0); - QCOMPARE(timer.interval(), 0); - timer.setInterval(INT_MAX); - QCOMPARE(timer.interval(), INT_MAX); -} - -void tst_IrcLagTimer::testConnection() -{ - IrcLagTimer timer(connection); - QCOMPARE(timer.connection(), connection.data()); - timer.setConnection(0); - QVERIFY(!timer.connection()); - timer.setConnection(connection); - QCOMPARE(timer.connection(), connection.data()); -} - -void tst_IrcLagTimer::testLag() -{ -#if QT_VERSION >= 0x040700 - IrcLagTimer timer(connection); - - QSignalSpy lagSpy(&timer, SIGNAL(lagChanged(qint64))); - QVERIFY(lagSpy.isValid()); - int lagCount = 0; - - connection->open(); - QVERIFY(waitForOpened()); - - QCOMPARE(timer.lag(), -1ll); - - QVERIFY(waitForWritten(tst_IrcData::welcome())); - - // cheat a bit to avoid waiting a 1s interval at minimum... - QMetaObject::invokeMethod(&timer, "_irc_pingServer"); - QVERIFY(clientSocket->waitForBytesWritten(1000)); - QVERIFY(serverSocket->waitForReadyRead(1000)); - - QRegExp rx("PING communi/(\\d+)"); - QString written = QString::fromUtf8(serverSocket->readAll()); - QVERIFY(rx.indexIn(written) != -1); - - waitForWritten(QString(":irc.ser.ver PONG communi communi/%1").arg(QDateTime::currentMSecsSinceEpoch() - 1234ll).toUtf8()); - QVERIFY(timer.lag() >= 1234ll); - QCOMPARE(lagSpy.count(), ++lagCount); - QVERIFY(lagSpy.last().at(0).toLongLong() >= 1234ll); - - timer.setConnection(0); - QCOMPARE(timer.lag(), -1ll); - QCOMPARE(lagSpy.count(), ++lagCount); - QCOMPARE(lagSpy.last().at(0).toLongLong(), -1ll); - - timer.setConnection(connection); - QCOMPARE(timer.lag(), -1ll); - QCOMPARE(lagSpy.count(), lagCount); - - waitForWritten(QString(":irc.ser.ver PONG communi communi/%1").arg(QDateTime::currentMSecsSinceEpoch() - 4321ll).toUtf8()); - QVERIFY(timer.lag() >= 4321ll); - QCOMPARE(lagSpy.count(), ++lagCount); - QVERIFY(lagSpy.last().at(0).toLongLong() >= 4321ll); - - connection->close(); - QCOMPARE(timer.lag(), -1ll); - QCOMPARE(lagSpy.count(), ++lagCount); - QCOMPARE(lagSpy.last().at(0).toLongLong(), -1ll); -#endif // QT_VERSION >= 0x040700 -} - -QTEST_MAIN(tst_IrcLagTimer) - -#include "tst_irclagtimer.moc" |
