diff options
Diffstat (limited to 'tests/auto/network-settings.h')
-rw-r--r-- | tests/auto/network-settings.h | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/auto/network-settings.h b/tests/auto/network-settings.h index d6b63c6100..16966ced4e 100644 --- a/tests/auto/network-settings.h +++ b/tests/auto/network-settings.h @@ -29,6 +29,8 @@ #include <QString> #ifdef QT_NETWORK_LIB #include <QtNetwork/QHostInfo> +#include <QtNetwork/QHostAddress> +#include <QtNetwork/QAbstractSocket> #endif #ifdef Q_OS_UNIX @@ -134,5 +136,21 @@ public: } return true; } -#endif + + // Helper function for usage with QVERIFY2 on sockets. + static QByteArray msgSocketError(const QAbstractSocket &s) + { + QString result; + QDebug debug(&result); + debug.nospace(); + debug.noquote(); + if (!s.localAddress().isNull()) + debug << "local=" << s.localAddress().toString() << ':' << s.localPort(); + if (!s.peerAddress().isNull()) + debug << ", peer=" << s.peerAddress().toString() << ':' << s.peerPort(); + debug << ", type=" << s.socketType() << ", state=" << s.state() + << ", error=" << s.error() << ": " << s.errorString(); + return result.toLocal8Bit(); + } +#endif // QT_NETWORK_LIB }; |