From 9d91a56ad5e39ddb237e10819a371e78defdf359 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 19 Oct 2009 16:23:47 +0200 Subject: Backport benchmarks/qnetworkreply to 4.5 Reviewed-by: TrustMe --- tests/benchmarks/benchmarks.pro | 1 + tests/benchmarks/qnetworkreply/qnetworkreply.pro | 13 ++++ .../benchmarks/qnetworkreply/tst_qnetworkreply.cpp | 74 ++++++++++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 tests/benchmarks/qnetworkreply/qnetworkreply.pro create mode 100644 tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp diff --git a/tests/benchmarks/benchmarks.pro b/tests/benchmarks/benchmarks.pro index 8e2c243..fb2b9ea 100644 --- a/tests/benchmarks/benchmarks.pro +++ b/tests/benchmarks/benchmarks.pro @@ -8,6 +8,7 @@ SUBDIRS = containers-associative \ qpixmap \ blendbench \ qstringlist \ + qnetworkreply \ qobject \ qrect \ qregexp \ diff --git a/tests/benchmarks/qnetworkreply/qnetworkreply.pro b/tests/benchmarks/qnetworkreply/qnetworkreply.pro new file mode 100644 index 0000000..1e67d81 --- /dev/null +++ b/tests/benchmarks/qnetworkreply/qnetworkreply.pro @@ -0,0 +1,13 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = tst_qnetworkreply +DEPENDPATH += . +INCLUDEPATH += . + +QT -= gui +QT += network + +CONFIG += release + +# Input +SOURCES += tst_qnetworkreply.cpp diff --git a/tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp b/tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp new file mode 100644 index 0000000..666e4f1 --- /dev/null +++ b/tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +// This file contains benchmarks for QNetworkReply functions. + +#include +#include +#include +#include +#include +#include +#include "../../auto/network-settings.h" + +class tst_qnetworkreply : public QObject +{ + Q_OBJECT +private slots: + void httpLatency(); + +}; + +void tst_qnetworkreply::httpLatency() +{ + QNetworkAccessManager manager; + QBENCHMARK{ + QNetworkRequest request(QUrl("http://" + QtNetworkSettings::serverName() + "/qtest/")); + QNetworkReply* reply = manager.get(request); + connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection); + QTestEventLoop::instance().enterLoop(5); + QVERIFY(!QTestEventLoop::instance().timeout()); + delete reply; + } +} + +QTEST_MAIN(tst_qnetworkreply) + +#include "main.moc" -- cgit v0.12 From 5fd8c58dde0c61a723ab124ac74c863f67288a14 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 19 Oct 2009 17:16:20 +0200 Subject: Add a up/down benchmark to benchmarks/qnetworkreply Reviewed-by: Peter Hartmann --- .../benchmarks/qnetworkreply/tst_qnetworkreply.cpp | 39 +++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp b/tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp index 666e4f1..e622d62 100644 --- a/tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp @@ -53,7 +53,10 @@ class tst_qnetworkreply : public QObject Q_OBJECT private slots: void httpLatency(); - +#ifndef QT_NO_OPENSSL + void echoPerformance_data(); + void echoPerformance(); +#endif }; void tst_qnetworkreply::httpLatency() @@ -69,6 +72,40 @@ void tst_qnetworkreply::httpLatency() } } +#ifndef QT_NO_OPENSSL +void tst_qnetworkreply::echoPerformance_data() +{ + QTest::addColumn("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 &)), 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" -- cgit v0.12 From 5651d2547261ccecbf50f8141c634f59c0adc00d Mon Sep 17 00:00:00 2001 From: Dean Dettman Date: Tue, 20 Oct 2009 11:13:02 +0200 Subject: Adds Key_Back and Key_Forward menu glyphs on mac(carbon) This change improves the behavior of QMenu when Key_Back and Key_Forward are used as shortcuts. A dotted arrow appears on carbon, and on Cocoa the image is blank, instead of undefined as it was before. Task-number: QTBUG-4873 Reviewed-by: msorvig --- src/gui/widgets/qmenu_mac.mm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm index 354161d..a7f6f0d 100644 --- a/src/gui/widgets/qmenu_mac.mm +++ b/src/gui/widgets/qmenu_mac.mm @@ -572,6 +572,10 @@ static void qt_mac_get_accel(quint32 accel_key, quint32 *modif, quint32 *key) { *key = kMenuNorthwestArrowGlyph; else if (accel_key == Qt::Key_End) *key = kMenuSoutheastArrowGlyph; + else if (accel_key == Qt::Key_Back) + *key = kMenuLeftArrowDashedGlyph; + else if (accel_key == Qt::Key_Forward) + *key = kMenuRightArrowDashedGlyph; } } #else // Cocoa @@ -1239,6 +1243,10 @@ NSString *keySequenceToKeyEqivalent(const QKeySequence &accel) keyEquiv[0] = NSHomeFunctionKey; else if (accel_key == Qt::Key_End) keyEquiv[0] = NSEndFunctionKey; + else if (accel_key == Qt::Key_Back) + keyEquiv[0] = kMenuLeftArrowDashedGlyph; // ### Cocoa has no equivalent - no icon is displayed + else if (accel_key == Qt::Key_Forward) + keyEquiv[0] = kMenuRightArrowDashedGlyph; // ### Cocoa has no equivalent - no icon is displayed else keyEquiv[0] = unichar(QChar(accel_key).toLower().unicode()); return [NSString stringWithCharacters:keyEquiv length:1]; -- cgit v0.12 From f779d9f7e317ff3e10f015a05d349e1fa3e7ab84 Mon Sep 17 00:00:00 2001 From: Dean Dettman Date: Tue, 20 Oct 2009 12:28:32 +0200 Subject: make missing Key_Back and Key_Forward menu glyphs return 0 on mac(cocoa) This is an addition to commit 5651d2547261ccecbf50f8141c634f59c0adc00d to make it obvious that in cocoa nothing is returned. Task-number: QTBUG-4873 Reviewed-by: MortenS --- src/gui/widgets/qmenu_mac.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm index 0f92ad9..ec9313f 100644 --- a/src/gui/widgets/qmenu_mac.mm +++ b/src/gui/widgets/qmenu_mac.mm @@ -1244,9 +1244,9 @@ NSString *keySequenceToKeyEqivalent(const QKeySequence &accel) else if (accel_key == Qt::Key_End) keyEquiv[0] = NSEndFunctionKey; else if (accel_key == Qt::Key_Back) - keyEquiv[0] = kMenuLeftArrowDashedGlyph; // ### Cocoa has no equivalent - no icon is displayed + keyEquiv[0] = 0 ; // ### could not find Cocoa equivalent to kMenuLeftArrowDashedGlyph else if (accel_key == Qt::Key_Forward) - keyEquiv[0] = kMenuRightArrowDashedGlyph; // ### Cocoa has no equivalent - no icon is displayed + keyEquiv[0] = 0 ; // ### could not find Cocoa equivalent to kMenuRightArrowDashedGlyph else keyEquiv[0] = unichar(QChar(accel_key).toLower().unicode()); return [NSString stringWithCharacters:keyEquiv length:1]; -- cgit v0.12 From 58574ea3590fbb28da5be73b983d83f0a8824d00 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Tue, 20 Oct 2009 15:03:56 +0200 Subject: tst_qsslsocket: new bigChunk testcase This new test is to find out if the BIO size of OpenSSL is limited or not. The test passes on my Linux, however the OpenSSL docu suggests that the BIO size is limited. From http://www.openssl.org/docs/crypto/BIO_s_bio.html "This is currently 17K". Reviewed-by: Peter Hartmann --- tests/auto/qsslsocket/tst_qsslsocket.cpp | 45 ++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp index 6b330e1..2f1c2e2 100644 --- a/tests/auto/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp @@ -173,6 +173,7 @@ private slots: void disconnectFromHostWhenConnected(); void resetProxy(); void readFromClosedSocket(); + void writeBigChunk(); static void exitLoop() { @@ -1537,6 +1538,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 &)), 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) -- cgit v0.12