File indexing completed on 2024-06-23 10:37:24

0001 /*
0002     This file is part of the KDE libraries
0003     SPDX-FileCopyrightText: 2007 Andreas Hartmetz <ahartmetz@gmail.com>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef KTCPSOCKETTEST_H
0009 #define KTCPSOCKETTEST_H
0010 
0011 #include <QTest>
0012 
0013 class Server;
0014 
0015 class KTcpSocketTest : public QObject
0016 {
0017     Q_OBJECT
0018 public:
0019     Server *server;
0020     KTcpSocketTest();
0021     ~KTcpSocketTest() override;
0022 
0023 private:
0024     void invokeOnServer(const char *);
0025 private Q_SLOTS:
0026     void initTestCase();
0027     void cleanupTestCase();
0028     void connectDisconnect();
0029     void read();
0030     void write();
0031     void statesIana();
0032     void statesLocalHost();
0033     void statesManyHosts();
0034     void errors();
0035 public Q_SLOTS: // auxiliary slots to check signal emission from the socket
0036     void states_hostFound();
0037 
0038 private:
0039     QThread *m_thread;
0040 };
0041 
0042 class QTcpServer;
0043 class QTcpSocket;
0044 
0045 class Server : public QObject
0046 {
0047     Q_OBJECT
0048 public:
0049     QTcpServer *listener;
0050     QTcpSocket *socket;
0051     quint16 port;
0052     explicit Server(quint16 _port);
0053     ~Server() override;
0054 
0055 private:
0056     void cleanupSocket();
0057 
0058 public Q_SLOTS:
0059     void connectDisconnect();
0060     void read();
0061     void write();
0062     void states();
0063     void errors();
0064 };
0065 
0066 #endif