You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test.h 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef TEST_H
  2. #define TEST_H
  3. #include <QObject>
  4. #include <QCoreApplication>
  5. #include <QPair>
  6. #include "ptserver.h"
  7. #include "ptsocket.h"
  8. #include <QDebug>
  9. #define ASSERT_LISTEN Q_ASSERT(m_serv->isListening())
  10. typedef QPair<int, PTSocket::State> TestState;
  11. class Test : public QObject
  12. {
  13. Q_OBJECT
  14. public:
  15. explicit Test(QObject *parent = 0);
  16. public slots:
  17. void testListen(quint16 p);
  18. void test0IntConvert();
  19. void test1Basic();
  20. void test2Ping();
  21. void test3Handshake();
  22. void test4HandshakeFake1();
  23. void test5HandshakeFake2();
  24. private slots:
  25. void timeout(int i = 15000);
  26. void stopTimeout();
  27. void timedout();
  28. void m_clientStateChangedTest(PTSocket::State s);
  29. void m_newClientTest(PTSocket* s);
  30. void preTest();
  31. void m_newClient1(PTSocket* s);
  32. void m_clientStateChanged1(PTSocket::State s);
  33. void m_newClient2(PTSocket* s);
  34. void m_clientStateChanged2(PTSocket::State s);
  35. void m_newClient3(PTSocket* s);
  36. void m_clientStateChanged3(PTSocket::State s);
  37. void m_newClient4(PTSocket* s);
  38. void m_clientStateChanged4(PTSocket::State s);
  39. void m_newClient5(PTSocket* s);
  40. void m_clientStateChanged5(PTSocket::State s);
  41. private:
  42. PTSocket* newSocket();
  43. QTimer m_timeoutTimer;
  44. PTServer* m_serv;
  45. QMap<PTSocket*, int> m_socketsIds;
  46. QList<QList<TestState> > m_testsStates;
  47. int m_currentTest;
  48. int m_currentState;
  49. };
  50. bool operator ==(TestState t1, TestState t2);
  51. bool operator !=(TestState t1, TestState t2);
  52. QDebug operator <<(QDebug dbg, TestState t);
  53. #endif // TEST_H