summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
index 2c2b551257..8b65c312bc 100644
--- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
+++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
@@ -201,6 +201,8 @@ private slots:
void qtbug14268_peek();
+ void setSocketOption();
+
protected slots:
void nonBlockingIMAP_hostFound();
@@ -2699,7 +2701,41 @@ void tst_QTcpSocket::qtbug14268_peek()
QVERIFY(incoming->read(128*1024) == QByteArray("abc\ndef\nghi\n"));
}
+void tst_QTcpSocket::setSocketOption()
+{
+ QFETCH_GLOBAL(bool, setProxy);
+ if (setProxy)
+ return;
+
+ SocketPair socketPair;
+ QVERIFY(socketPair.create());
+ QTcpSocket *outgoing = socketPair.endPoints[0];
+ QTcpSocket *incoming = socketPair.endPoints[1];
+
+ QVERIFY(incoming->state() == QTcpSocket::ConnectedState);
+ QVERIFY(outgoing->state() == QTcpSocket::ConnectedState);
+
+ outgoing->setSocketOption(QAbstractSocket::LowDelayOption, true);
+ QVariant v = outgoing->socketOption(QAbstractSocket::LowDelayOption);
+ QVERIFY(v.isValid() && v.toBool());
+ outgoing->setSocketOption(QAbstractSocket::KeepAliveOption, true);
+ v = outgoing->socketOption(QAbstractSocket::KeepAliveOption);
+ QVERIFY(v.isValid() && v.toBool());
+ outgoing->setSocketOption(QAbstractSocket::LowDelayOption, false);
+ v = outgoing->socketOption(QAbstractSocket::LowDelayOption);
+ QVERIFY(v.isValid() && !v.toBool());
+ outgoing->setSocketOption(QAbstractSocket::KeepAliveOption, false);
+ v = outgoing->socketOption(QAbstractSocket::KeepAliveOption);
+ QVERIFY(v.isValid() && !v.toBool());
+
+#ifdef Q_OS_WIN
+ QEXPECT_FAIL("", "QTBUG-23323", Abort);
+#endif
+ outgoing->setSocketOption(QAbstractSocket::TypeOfServiceOption, 32); //high priority
+ v = outgoing->socketOption(QAbstractSocket::TypeOfServiceOption);
+ QVERIFY(v.isValid() && v.toInt() == 32);
+}
QTEST_MAIN(tst_QTcpSocket)
#include "tst_qtcpsocket.moc"