diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2009-10-21 20:07:26 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2009-10-21 20:07:26 (GMT) |
commit | 26eda5fa33e401a1803b42e6eacf0921ddc6a14e (patch) | |
tree | 510cff78e0dcdd8a3b0d70dea9c270b37d8ac57d /tests/auto/qsslsocket | |
parent | fad27a3b6f018a0bc3cb261c81aaefc540589585 (diff) | |
parent | 58574ea3590fbb28da5be73b983d83f0a8824d00 (diff) | |
download | Qt-26eda5fa33e401a1803b42e6eacf0921ddc6a14e.zip Qt-26eda5fa33e401a1803b42e6eacf0921ddc6a14e.tar.gz Qt-26eda5fa33e401a1803b42e6eacf0921ddc6a14e.tar.bz2 |
Merge branch '4.5' into 4.6
Conflicts:
src/gui/widgets/qmenu_mac.mm
tests/benchmarks/benchmarks.pro
tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp
Diffstat (limited to 'tests/auto/qsslsocket')
-rw-r--r-- | tests/auto/qsslsocket/tst_qsslsocket.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp index 6efe440..d576201 100644 --- a/tests/auto/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp @@ -182,6 +182,7 @@ private slots: void ignoreSslErrorsListWithSlot_data(); void ignoreSslErrorsListWithSlot(); void readFromClosedSocket(); + void writeBigChunk(); static void exitLoop() { @@ -1698,6 +1699,50 @@ void tst_QSslSocket::readFromClosedSocket() QVERIFY(!socket->bytesToWrite()); } +void tst_QSslSocket::writeBigChunk() +{ + if (!QSslSocket::supportsSsl()) + return; + + QSslSocketPtr socket = newSocket(); + this->socket = socket; + + connect(socket, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(ignoreErrorSlot())); + socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + + QByteArray data; + data.resize(1024*1024*10); // 10 MB + // init with garbage. needed so ssl cannot compress it in an efficient way. + for (int i = 0; i < data.size() / sizeof(int); i++) { + int r = qrand(); + data.data()[i*sizeof(int)] = r; + } + + QVERIFY(socket->waitForEncrypted(10000)); + QString errorBefore = socket->errorString(); + + int ret = socket->write(data.constData(), data.size()); + QVERIFY(data.size() == ret); + + // spin the event loop once so QSslSocket::transmit() gets called + QCoreApplication::processEvents(); + QString errorAfter = socket->errorString(); + + // no better way to do this right now since the error is the same as the default error. + if (socket->errorString().startsWith(QLatin1String("Unable to write data"))) + { + qWarning() << socket->error() << socket->errorString(); + QFAIL("Error while writing! Check if the OpenSSL BIO size is limited?!"); + } + // also check the error string. If another error (than UnknownError) occured, it should be different than before + QVERIFY(errorBefore == errorAfter); + + // check that everything has been written to OpenSSL + QVERIFY(socket->bytesToWrite() == 0); + + socket->close(); +} + #endif // QT_NO_OPENSSL QTEST_MAIN(tst_QSslSocket) |