diff options
author | Kurt Korbatits <kurt.korbatits@nokia.com> | 2009-10-22 00:51:04 (GMT) |
---|---|---|
committer | Kurt Korbatits <kurt.korbatits@nokia.com> | 2009-10-22 00:51:04 (GMT) |
commit | 61836f454fd49286bce038c386eb8921b88450da (patch) | |
tree | 781ad19d08c6aedc1bdc8beb988c38f86013f8cd /tests | |
parent | 493ce4c0aa1c7dc73206917b1a6874e77b7385d9 (diff) | |
parent | 26eda5fa33e401a1803b42e6eacf0921ddc6a14e (diff) | |
download | Qt-61836f454fd49286bce038c386eb8921b88450da.zip Qt-61836f454fd49286bce038c386eb8921b88450da.tar.gz Qt-61836f454fd49286bce038c386eb8921b88450da.tar.bz2 |
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt into 4.6
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qsslsocket/tst_qsslsocket.cpp | 45 | ||||
-rw-r--r-- | tests/auto/qwidget/tst_qwidget.cpp | 15 | ||||
-rw-r--r-- | tests/benchmarks/benchmarks.pro | 4 | ||||
-rw-r--r-- | tests/benchmarks/qnetworkreply/qnetworkreply.pro | 2 | ||||
-rw-r--r-- | tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp (renamed from tests/benchmarks/qnetworkreply/main.cpp) | 40 |
5 files changed, 102 insertions, 4 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) diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index a03f112..050d1c5 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -4391,12 +4391,27 @@ void tst_QWidget::winIdChangeEvent() { // Changing parent of a native widget + // Should cause winId of child to change, on all platforms QWidget parent1, parent2; WinIdChangeWidget child(&parent1); const WId winIdBefore = child.winId(); QCOMPARE(child.m_winIdChangeEventCount, 1); child.setParent(&parent2); const WId winIdAfter = child.internalWinId(); + QVERIFY(winIdBefore != winIdAfter); + QCOMPARE(child.m_winIdChangeEventCount, 2); + } + + { + // Changing grandparent of a native widget + // Should cause winId of grandchild to change only on Symbian + QWidget grandparent1, grandparent2; + QWidget parent(&grandparent1); + WinIdChangeWidget child(&parent); + const WId winIdBefore = child.winId(); + QCOMPARE(child.m_winIdChangeEventCount, 1); + parent.setParent(&grandparent2); + const WId winIdAfter = child.internalWinId(); #ifdef Q_OS_SYMBIAN QVERIFY(winIdBefore != winIdAfter); QCOMPARE(child.m_winIdChangeEventCount, 2); diff --git a/tests/benchmarks/benchmarks.pro b/tests/benchmarks/benchmarks.pro index ad1920b..a63fb41 100644 --- a/tests/benchmarks/benchmarks.pro +++ b/tests/benchmarks/benchmarks.pro @@ -9,8 +9,8 @@ SUBDIRS = containers-associative \ qiodevice \ qpixmap \ blendbench \ - qstring \ - qstringlist \ + qstring \ + qstringlist \ qmatrix4x4 \ qnetworkreply \ qobject \ diff --git a/tests/benchmarks/qnetworkreply/qnetworkreply.pro b/tests/benchmarks/qnetworkreply/qnetworkreply.pro index 060acf5..1e67d81 100644 --- a/tests/benchmarks/qnetworkreply/qnetworkreply.pro +++ b/tests/benchmarks/qnetworkreply/qnetworkreply.pro @@ -10,4 +10,4 @@ QT += network CONFIG += release # Input -SOURCES += main.cpp +SOURCES += tst_qnetworkreply.cpp diff --git a/tests/benchmarks/qnetworkreply/main.cpp b/tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp index 666e4f1..993db52 100644 --- a/tests/benchmarks/qnetworkreply/main.cpp +++ b/tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp @@ -54,6 +54,10 @@ class tst_qnetworkreply : public QObject private slots: void httpLatency(); +#ifndef QT_NO_OPENSSL + void echoPerformance_data(); + void echoPerformance(); +#endif }; void tst_qnetworkreply::httpLatency() @@ -69,6 +73,40 @@ void tst_qnetworkreply::httpLatency() } } +#ifndef QT_NO_OPENSSL +void tst_qnetworkreply::echoPerformance_data() +{ + QTest::addColumn<bool>("ssl"); + QTest::newRow("no_ssl") << false; + QTest::newRow("ssl") << true; +} + +void tst_qnetworkreply::echoPerformance() +{ + QFETCH(bool, ssl); + QNetworkAccessManager manager; + QNetworkRequest request(QUrl((ssl ? "https://" : "http://") + QtNetworkSettings::serverName() + "/qtest/cgi-bin/echo.cgi")); + + 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; + } + + QBENCHMARK{ + QNetworkReply* reply = manager.post(request, data); + connect(reply, SIGNAL(sslErrors( const QList<QSslError> &)), reply, SLOT(ignoreSslErrors())); + connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection); + QTestEventLoop::instance().enterLoop(5); + QVERIFY(!QTestEventLoop::instance().timeout()); + QVERIFY(reply->error() == QNetworkReply::NoError); + delete reply; + } +} +#endif + QTEST_MAIN(tst_qnetworkreply) -#include "main.moc" +#include "tst_qnetworkreply.moc" |