12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- #ifndef TEST_H
- #define TEST_H
-
- #include <QObject>
- #include <QCoreApplication>
- #include <QPair>
- #include "ptserver.h"
- #include "ptsocket.h"
- #include <QDebug>
-
- #define ASSERT_LISTEN Q_ASSERT(m_serv->isListening())
-
- typedef QPair<int, PTSocket::State> TestState;
-
- class Test : public QObject
- {
- Q_OBJECT
- public:
- explicit Test(QObject *parent = 0);
-
- public slots:
- void testListen(quint16 p);
- void test0IntConvert();
- void test1Basic();
- void test2Ping();
- void test3Handshake();
- void test4HandshakeFake1();
- void test5HandshakeFake2();
-
- private slots:
- void timeout(int i = 15000);
- void stopTimeout();
- void timedout();
- void m_clientStateChangedTest(PTSocket::State s);
- void m_newClientTest(PTSocket* s);
-
- void preTest();
-
- void m_newClient1(PTSocket* s);
- void m_clientStateChanged1(PTSocket::State s);
-
- void m_newClient2(PTSocket* s);
- void m_clientStateChanged2(PTSocket::State s);
-
- void m_newClient3(PTSocket* s);
- void m_clientStateChanged3(PTSocket::State s);
-
- void m_newClient4(PTSocket* s);
- void m_clientStateChanged4(PTSocket::State s);
-
- void m_newClient5(PTSocket* s);
- void m_clientStateChanged5(PTSocket::State s);
-
-
- private:
- PTSocket* newSocket();
- QTimer m_timeoutTimer;
- PTServer* m_serv;
- QMap<PTSocket*, int> m_socketsIds;
- QList<QList<TestState> > m_testsStates;
- int m_currentTest;
- int m_currentState;
-
- };
-
- bool operator ==(TestState t1, TestState t2);
- bool operator !=(TestState t1, TestState t2);
- QDebug operator <<(QDebug dbg, TestState t);
-
- #endif // TEST_H
|