diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2016-03-13 18:39:03 +0000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2016-03-13 19:27:21 +0000 |
commit | 59a3ca679ede2cb9b6a162edf8eba5cf6d9af4a9 (patch) | |
tree | 0d0f76caa042db299cddaa84c14c28e4c80b2ffd /tests/auto/network | |
parent | 447a508d003ce487f2be69af9ab05aeec272e64d (diff) | |
parent | 50d0f57b77b8088875d7185c5906b5f57985d5fb (diff) |
Merge "Merge remote-tracking branch 'origin/5.6' into 5.7" into refs/staging/5.7
Diffstat (limited to 'tests/auto/network')
3 files changed, 76 insertions, 1 deletions
diff --git a/tests/auto/network/access/qhttpnetworkreply/tst_qhttpnetworkreply.cpp b/tests/auto/network/access/qhttpnetworkreply/tst_qhttpnetworkreply.cpp index 3373324c19..ec965a61b2 100644 --- a/tests/auto/network/access/qhttpnetworkreply/tst_qhttpnetworkreply.cpp +++ b/tests/auto/network/access/qhttpnetworkreply/tst_qhttpnetworkreply.cpp @@ -28,6 +28,9 @@ #include <QtTest/QtTest> +#include <QtCore/QBuffer> +#include <QtCore/QByteArray> + #include "private/qhttpnetworkconnection_p.h" class tst_QHttpNetworkReply: public QObject @@ -36,6 +39,9 @@ class tst_QHttpNetworkReply: public QObject private Q_SLOTS: void parseHeader_data(); void parseHeader(); + + void parseEndOfHeader_data(); + void parseEndOfHeader(); }; void tst_QHttpNetworkReply::parseHeader_data() @@ -95,5 +101,66 @@ void tst_QHttpNetworkReply::parseHeader() } } +class TestHeaderSocket : public QAbstractSocket +{ +public: + explicit TestHeaderSocket(const QByteArray &input) : QAbstractSocket(QAbstractSocket::TcpSocket, Q_NULLPTR) + { + inputBuffer.setData(input); + inputBuffer.open(QIODevice::ReadOnly | QIODevice::Unbuffered); + open(QIODevice::ReadOnly | QIODevice::Unbuffered); + } + + qint64 readData(char *data, qint64 maxlen) { return inputBuffer.read(data, maxlen); } + + QBuffer inputBuffer; +}; + +class TestHeaderReply : public QHttpNetworkReply +{ +public: + QHttpNetworkReplyPrivate *replyPrivate() { return static_cast<QHttpNetworkReplyPrivate *>(d_ptr.data()); } +}; + +void tst_QHttpNetworkReply::parseEndOfHeader_data() +{ + QTest::addColumn<QByteArray>("headers"); + QTest::addColumn<qint64>("lengths"); + + QTest::newRow("CRLFCRLF") << QByteArray("Content-Type: text/html; charset=utf-8\r\n" + "Content-Length:\r\n 1024\r\n" + "Content-Encoding: gzip\r\n\r\nHTTPBODY") + << qint64(90); + + QTest::newRow("CRLFLF") << QByteArray("Content-Type: text/html; charset=utf-8\r\n" + "Content-Length:\r\n 1024\r\n" + "Content-Encoding: gzip\r\n\nHTTPBODY") + << qint64(89); + + QTest::newRow("LFCRLF") << QByteArray("Content-Type: text/html; charset=utf-8\r\n" + "Content-Length:\r\n 1024\r\n" + "Content-Encoding: gzip\n\r\nHTTPBODY") + << qint64(89); + + QTest::newRow("LFLF") << QByteArray("Content-Type: text/html; charset=utf-8\r\n" + "Content-Length:\r\n 1024\r\n" + "Content-Encoding: gzip\n\nHTTPBODY") + << qint64(88); +} + +void tst_QHttpNetworkReply::parseEndOfHeader() +{ + QFETCH(QByteArray, headers); + QFETCH(qint64, lengths); + + TestHeaderSocket socket(headers); + + TestHeaderReply reply; + + QHttpNetworkReplyPrivate *replyPrivate = reply.replyPrivate(); + qint64 headerBytes = replyPrivate->readHeader(&socket); + QCOMPARE(headerBytes, lengths); +} + QTEST_MAIN(tst_QHttpNetworkReply) #include "tst_qhttpnetworkreply.moc" diff --git a/tests/auto/network/access/qnetworkreply/BLACKLIST b/tests/auto/network/access/qnetworkreply/BLACKLIST index 3ec580ddde..0605677e29 100644 --- a/tests/auto/network/access/qnetworkreply/BLACKLIST +++ b/tests/auto/network/access/qnetworkreply/BLACKLIST @@ -7,3 +7,7 @@ ubuntu-14.04 * [backgroundRequestInterruption:ftp, bg, nobg] * +[authenticationCacheAfterCancel:http+socksauth] +rhel-7.1 +[authenticationCacheAfterCancel:https+socksauth] +rhel-7.1 diff --git a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp index d037826410..ef47b45e9e 100644 --- a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp @@ -490,7 +490,11 @@ void tst_QLocalSocket::connectWithOldOpen() void tst_QLocalSocket::sendData_data() { - listenAndConnect_data(); + QTest::addColumn<QString>("name"); + QTest::addColumn<bool>("canListen"); + + QTest::newRow("null") << QString() << false; + QTest::newRow("tst_localsocket") << "tst_localsocket" << true; } void tst_QLocalSocket::sendData() |