summaryrefslogtreecommitdiffstats
path: root/tests/auto/network-settings.h
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2016-04-07 14:18:21 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2016-05-02 19:20:33 +0000
commit22a7edd816b417daf43e3b4c4f0257fbc3ad7921 (patch)
tree1cbb22bbaac5d3b609fb3a473fbc8e3e0e0ab46d /tests/auto/network-settings.h
parent8f0bf2d3d258acfae91e7dda2d1e7ad29b950c9b (diff)
tst_QTcpSocket, tst_QUdpSocket: Improve diagnostics.
Add more error messages on failures. Task-number: QTBUG-25367 Task-number: QTBUG-25368 Change-Id: I064143a058b7b98d9d5eecab8b5da49f5307e1eb Reviewed-by: Edward Welbourne <edward.welbourne@theqtcompany.com> Reviewed-by: Richard J. Moore <rich@kde.org>
Diffstat (limited to 'tests/auto/network-settings.h')
-rw-r--r--tests/auto/network-settings.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/auto/network-settings.h b/tests/auto/network-settings.h
index a90ea62277..f4ec460709 100644
--- a/tests/auto/network-settings.h
+++ b/tests/auto/network-settings.h
@@ -34,6 +34,8 @@
#include <QString>
#ifdef QT_NETWORK_LIB
#include <QtNetwork/QHostInfo>
+#include <QtNetwork/QHostAddress>
+#include <QtNetwork/QAbstractSocket>
#endif
#ifdef Q_OS_UNIX
@@ -139,5 +141,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
};