diff options
Diffstat (limited to 'tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp')
-rw-r--r-- | tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp | 51 |
1 files changed, 14 insertions, 37 deletions
diff --git a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp index 92d9972b4e..bab2743513 100644 --- a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only // This file contains benchmarks for QNetworkReply functions. #include <QDebug> @@ -46,6 +21,8 @@ #include <QtNetwork/private/qhostinfo_p.h> #endif +using namespace std::chrono_literals; + Q_DECLARE_METATYPE(QSharedPointer<char>) class TimedSender: public QThread @@ -481,7 +458,7 @@ void tst_qnetworkreply::httpLatency() 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); + QTestEventLoop::instance().enterLoop(5s); QVERIFY(!QTestEventLoop::instance().timeout()); delete reply; } @@ -495,7 +472,7 @@ QPair<QNetworkReply *, qint64> tst_qnetworkreply::runGetRequest( QNetworkReply *reply = manager->get(request); connect(reply, SIGNAL(sslErrors(QList<QSslError>)), reply, SLOT(ignoreSslErrors())); connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection); - QTestEventLoop::instance().enterLoop(20); + QTestEventLoop::instance().enterLoop(20s); qint64 elapsed = timer.elapsed(); return qMakePair(reply, elapsed); } @@ -526,7 +503,7 @@ void tst_qnetworkreply::echoPerformance() QNetworkReply* reply = manager.post(request, data); connect(reply, SIGNAL(sslErrors(QList<QSslError>)), reply, SLOT(ignoreSslErrors())); connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection); - QTestEventLoop::instance().enterLoop(5); + QTestEventLoop::instance().enterLoop(5s); QVERIFY(!QTestEventLoop::instance().timeout()); QVERIFY(reply->error() == QNetworkReply::NoError); delete reply; @@ -535,7 +512,7 @@ void tst_qnetworkreply::echoPerformance() void tst_qnetworkreply::preConnectEncrypted() { - QFETCH(int, sleepTime); + QFETCH(std::chrono::milliseconds, sleepTime); QString hostName = QLatin1String("www.google.com"); QNetworkAccessManager manager; @@ -566,7 +543,7 @@ void tst_qnetworkreply::preConnectEncrypted() // now try to make the connection beforehand manager.connectToHostEncrypted(hostName); - QTestEventLoop::instance().enterLoopMSecs(sleepTime); + QTestEventLoop::instance().enterLoop(sleepTime); // now make another request and hopefully use the existing connection QPair<QNetworkReply *, qint64> preConnectResult = runGetRequest(&manager, request); @@ -584,12 +561,12 @@ void tst_qnetworkreply::preConnectEncrypted() void tst_qnetworkreply::preConnectEncrypted_data() { #ifndef QT_NO_OPENSSL - QTest::addColumn<int>("sleepTime"); + QTest::addColumn<std::chrono::milliseconds>("sleepTime"); // start a new normal request after preconnecting is done - QTest::newRow("HTTPS-2secs") << 2000; + QTest::newRow("HTTPS-2secs") << 2000ms; // start a new normal request while preconnecting is in-flight - QTest::newRow("HTTPS-100ms") << 100; + QTest::newRow("HTTPS-100ms") << 100ms; #endif // QT_NO_OPENSSL } @@ -940,9 +917,9 @@ void tst_qnetworkreply::preConnect() manager.clearAccessCache(); // now try to make the connection beforehand - QFETCH(int, sleepTime); + QFETCH(std::chrono::milliseconds, sleepTime); manager.connectToHost(hostName); - QTestEventLoop::instance().enterLoopMSecs(sleepTime); + QTestEventLoop::instance().enterLoop(sleepTime); // now make another request and hopefully use the existing connection QPair<QNetworkReply *, qint64> preConnectResult = runGetRequest(&manager, request); |