diff options
Diffstat (limited to 'tests')
9 files changed, 75 insertions, 143 deletions
diff --git a/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp b/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp index d1c0c8e965..4b38d46317 100644 --- a/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp +++ b/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp @@ -364,7 +364,7 @@ void tst_QRandomGenerator::bounded() QCOMPARE(ivalue, int(expected)); // confirm only the bound now - setRNGControl(control & (SkipHWRNG|SkipSystemRNG|SkipMemfill)); + setRNGControl(control & (SkipHWRNG|SkipSystemRNG)); value = QRandomGenerator::bounded(sup); QVERIFY(value < sup); @@ -536,7 +536,6 @@ void tst_QRandomGenerator::stdUniformIntDistribution_data() auto newRow = [](quint32 max) { QTest::addRow("default:%u", max) << 0U << max; - QTest::addRow("direct:%u", max) << uint(SkipMemfill) << max; QTest::addRow("system:%u", max) << uint(SkipHWRNG) << max; #ifdef HAVE_FALLBACK_ENGINE QTest::addRow("fallback:%u", max) << uint(SkipHWRNG | SkipSystemRNG) << max; @@ -555,7 +554,7 @@ void tst_QRandomGenerator::stdUniformIntDistribution() { QFETCH(uint, control); QFETCH(quint32, max); - setRNGControl(control & (SkipHWRNG|SkipSystemRNG|SkipMemfill)); + setRNGControl(control & (SkipHWRNG|SkipSystemRNG)); { QRandomGenerator rd; @@ -653,7 +652,6 @@ void tst_QRandomGenerator::stdUniformRealDistribution_data() auto newRow = [](double min, double sup) { QTest::addRow("default:%g-%g", min, sup) << 0U << min << sup; - QTest::addRow("direct:%g-%g", min, sup) << uint(SkipMemfill) << min << sup; QTest::addRow("system:%g-%g", min, sup) << uint(SkipHWRNG) << min << sup; #ifdef HAVE_FALLBACK_ENGINE QTest::addRow("fallback:%g-%g", min, sup) << uint(SkipHWRNG | SkipSystemRNG) << min << sup; @@ -673,7 +671,7 @@ void tst_QRandomGenerator::stdUniformRealDistribution() QFETCH(uint, control); QFETCH(double, min); QFETCH(double, sup); - setRNGControl(control & (SkipHWRNG|SkipSystemRNG|SkipMemfill)); + setRNGControl(control & (SkipHWRNG|SkipSystemRNG)); { QRandomGenerator rd; diff --git a/tests/auto/corelib/tools/qstringapisymmetry/tst_qstringapisymmetry.cpp b/tests/auto/corelib/tools/qstringapisymmetry/tst_qstringapisymmetry.cpp index e482b409a5..61d1f86f00 100644 --- a/tests/auto/corelib/tools/qstringapisymmetry/tst_qstringapisymmetry.cpp +++ b/tests/auto/corelib/tools/qstringapisymmetry/tst_qstringapisymmetry.cpp @@ -483,32 +483,6 @@ struct has_qCompareStrings { }; template <typename LHS, typename RHS> -using if_has_qCompareStrings = typename std::enable_if<has_qCompareStrings<LHS, RHS>::value, bool>::type; - -template <typename LHS, typename RHS> -using if_lacks_qCompareStrings = typename std::enable_if<!has_qCompareStrings<LHS, RHS>::value, bool>::type; - -static inline Q_DECL_CONSTEXPR int sign(int x) Q_DECL_NOTHROW -{ - return x < 0 ? -1 : - x > 0 ? +1 : - /*else*/ 0 ; -} - -template <typename LHS, typename RHS, if_has_qCompareStrings<LHS, RHS> = true> -int qCompareStringsWrapper(const LHS &lhs, const RHS &rhs, Qt::CaseSensitivity cs, int) - Q_DECL_NOEXCEPT_EXPR(noexcept(qCompareStrings(lhs, rhs, cs))) -{ - return qCompareStrings(lhs, rhs, cs); -} - -template <typename LHS, typename RHS, if_lacks_qCompareStrings<LHS, RHS> = true> -int qCompareStringsWrapper(const LHS &, const RHS &, Qt::CaseSensitivity, int result) -{ - return result; -} - -template <typename LHS, typename RHS> void tst_QStringApiSymmetry::compare_impl() const { QFETCH(QStringRef, lhsUnicode); @@ -517,6 +491,7 @@ void tst_QStringApiSymmetry::compare_impl() const QFETCH(QLatin1String, rhsLatin1); QFETCH(int, caseSensitiveCompareResult); QFETCH(const int, caseInsensitiveCompareResult); + Q_UNUSED(caseInsensitiveCompareResult); const auto lhsU8 = lhsUnicode.toUtf8(); const auto rhsU8 = rhsUnicode.toUtf8(); @@ -533,10 +508,6 @@ void tst_QStringApiSymmetry::compare_impl() const # define QVERIFY_NOEXCEPT(expr) #endif - QCOMPARE(sign(qCompareStringsWrapper(lhs, rhs, Qt::CaseSensitive, caseSensitiveCompareResult)), - sign(caseSensitiveCompareResult)); - QCOMPARE(sign(qCompareStringsWrapper(lhs, rhs, Qt::CaseInsensitive, caseInsensitiveCompareResult)), - sign(caseInsensitiveCompareResult)); #define CHECK(op) \ QVERIFY_NOEXCEPT(lhs op rhs); \ do { if (caseSensitiveCompareResult op 0) { \ diff --git a/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp b/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp index 37d97cd3db..4fca9a07fc 100644 --- a/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp +++ b/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp @@ -64,7 +64,7 @@ public: m_received.clear(); } - bool event(QEvent *event) + bool event(QEvent *event) override { m_received[event->type()]++; return QWindow::event(event); diff --git a/tests/auto/network/access/http2/http2srv.cpp b/tests/auto/network/access/http2/http2srv.cpp index 663f40cbae..69e480b164 100644 --- a/tests/auto/network/access/http2/http2srv.cpp +++ b/tests/auto/network/access/http2/http2srv.cpp @@ -76,13 +76,11 @@ void fill_push_header(const HttpHeader &originalRequest, HttpHeader &promisedReq } -Http2Server::Http2Server(bool h2c, const Http2Settings &ss, const Http2Settings &cs) +Http2Server::Http2Server(bool h2c, const Http2::RawSettings &ss, const Http2::RawSettings &cs) : serverSettings(ss), + expectedClientSettings(cs), clearTextHTTP2(h2c) { - for (const auto &s : cs) - expectedClientSettings[quint16(s.identifier)] = s.value; - responseBody = "<html>\n" "<head>\n" "<title>Sample \"Hello, World\" Application</title>\n" @@ -159,11 +157,11 @@ void Http2Server::sendServerSettings() return; writer.start(FrameType::SETTINGS, FrameFlag::EMPTY, connectionStreamID); - for (const auto &s : serverSettings) { - writer.append(s.identifier); - writer.append(s.value); - if (s.identifier == Settings::INITIAL_WINDOW_SIZE_ID) - streamRecvWindowSize = s.value; + for (auto it = serverSettings.cbegin(); it != serverSettings.cend(); ++it) { + writer.append(it.key()); + writer.append(it.value()); + if (it.key() == Settings::INITIAL_WINDOW_SIZE_ID) + streamRecvWindowSize = it.value(); } writer.write(*socket); // Now, let's update our peer on a session recv window size: @@ -285,9 +283,9 @@ void Http2Server::incomingConnection(qintptr socketDescriptor) quint32 Http2Server::clientSetting(Http2::Settings identifier, quint32 defaultValue) { - const auto it = expectedClientSettings.find(quint16(identifier)); + const auto it = expectedClientSettings.find(identifier); if (it != expectedClientSettings.end()) - return it->second; + return it.value(); return defaultValue; } @@ -623,7 +621,7 @@ void Http2Server::handleSETTINGS() const auto notFound = expectedClientSettings.end(); while (src != end) { - const auto id = qFromBigEndian<quint16>(src); + const auto id = Http2::Settings(qFromBigEndian<quint16>(src)); const auto value = qFromBigEndian<quint32>(src + 2); if (expectedClientSettings.find(id) == notFound || expectedClientSettings[id] != value) { diff --git a/tests/auto/network/access/http2/http2srv.h b/tests/auto/network/access/http2/http2srv.h index f89e04cc0d..76c5a0ee36 100644 --- a/tests/auto/network/access/http2/http2srv.h +++ b/tests/auto/network/access/http2/http2srv.h @@ -48,19 +48,6 @@ QT_BEGIN_NAMESPACE -struct Http2Setting -{ - Http2::Settings identifier; - quint32 value = 0; - - Http2Setting(Http2::Settings ident, quint32 v) - : identifier(ident), - value(v) - {} -}; - -using Http2Settings = std::vector<Http2Setting>; - // At the moment we do not have any public API parsing HTTP headers. Even worse - // the code that can do this exists only in QHttpNetworkReplyPrivate class. // To be able to access reply's d_func() we have these classes: @@ -78,8 +65,8 @@ class Http2Server : public QTcpServer { Q_OBJECT public: - Http2Server(bool clearText, const Http2Settings &serverSettings, - const Http2Settings &clientSettings); + Http2Server(bool clearText, const Http2::RawSettings &serverSettings, + const Http2::RawSettings &clientSettings); ~Http2Server(); @@ -144,8 +131,8 @@ private: bool settingsSent = false; bool waitingClientAck = false; - Http2Settings serverSettings; - std::map<quint16, quint32> expectedClientSettings; + Http2::RawSettings serverSettings; + Http2::RawSettings expectedClientSettings; bool connectionError = false; diff --git a/tests/auto/network/access/http2/tst_http2.cpp b/tests/auto/network/access/http2/tst_http2.cpp index 9befb7276e..7b453ca635 100644 --- a/tests/auto/network/access/http2/tst_http2.cpp +++ b/tests/auto/network/access/http2/tst_http2.cpp @@ -30,6 +30,7 @@ #include "http2srv.h" +#include <QtNetwork/private/http2protocol_p.h> #include <QtNetwork/qnetworkaccessmanager.h> #include <QtNetwork/qnetworkrequest.h> #include <QtNetwork/qnetworkreply.h> @@ -96,8 +97,8 @@ private: // small payload. void runEventLoop(int ms = 5000); void stopEventLoop(); - Http2Server *newServer(const Http2Settings &serverSettings, - const Http2Settings &clientSettings = defaultClientSettings); + Http2Server *newServer(const Http2::RawSettings &serverSettings, + const Http2::ProtocolParameters &clientSettings = {}); // Send a get or post request, depending on a payload (empty or not). void sendRequest(int streamNumber, QNetworkRequest::Priority priority = QNetworkRequest::NormalPriority, @@ -118,14 +119,10 @@ private: bool prefaceOK = false; bool serverGotSettingsACK = false; - static const Http2Settings defaultServerSettings; - static const Http2Settings defaultClientSettings; + static const Http2::RawSettings defaultServerSettings; }; -const Http2Settings tst_Http2::defaultServerSettings{{Http2::Settings::MAX_CONCURRENT_STREAMS_ID, 100}}; -const Http2Settings tst_Http2::defaultClientSettings{{Http2::Settings::MAX_FRAME_SIZE_ID, quint32(Http2::maxFrameSize)}, - {Http2::Settings::INITIAL_WINDOW_SIZE_ID, quint32(Http2::initialStreamReceiveWindowSize)}, - {Http2::Settings::ENABLE_PUSH_ID, quint32(0)}}; +const Http2::RawSettings tst_Http2::defaultServerSettings{{Http2::Settings::MAX_CONCURRENT_STREAMS_ID, 100}}; namespace { @@ -142,27 +139,6 @@ struct ServerDeleter using ServerPtr = QScopedPointer<Http2Server, ServerDeleter>; -struct EnvVarGuard -{ - EnvVarGuard(const char *name, const QByteArray &value) - : varName(name), - prevValue(qgetenv(name)) - { - Q_ASSERT(name); - qputenv(name, value); - } - ~EnvVarGuard() - { - if (prevValue.size()) - qputenv(varName.c_str(), prevValue); - else - qunsetenv(varName.c_str()); - } - - const std::string varName; - const QByteArray prevValue; -}; - } // unnamed namespace tst_Http2::tst_Http2() @@ -241,9 +217,11 @@ void tst_Http2::multipleRequests() // Just to make the order a bit more interesting // we'll index this randomly: - QNetworkRequest::Priority priorities[] = {QNetworkRequest::HighPriority, - QNetworkRequest::NormalPriority, - QNetworkRequest::LowPriority}; + const QNetworkRequest::Priority priorities[] = { + QNetworkRequest::HighPriority, + QNetworkRequest::NormalPriority, + QNetworkRequest::LowPriority + }; for (int i = 0; i < nRequests; ++i) sendRequest(i, priorities[std::rand() % 3]); @@ -258,11 +236,11 @@ void tst_Http2::multipleRequests() void tst_Http2::flowControlClientSide() { // Create a server but impose limits: - // 1. Small MAX frame size, so we test CONTINUATION frames. - // 2. Small client windows so server responses cause client streams - // to suspend and server sends WINDOW_UPDATE frames. - // 3. Few concurrent streams, to test protocol handler can resume - // suspended requests. + // 1. Small client receive windows so server's responses cause client + // streams to suspend and protocol handler has to send WINDOW_UPDATE + // frames. + // 2. Few concurrent streams supported by the server, to test protocol + // handler in the client can suspend and then resume streams. using namespace Http2; clearHTTP2State(); @@ -271,11 +249,20 @@ void tst_Http2::flowControlClientSide() nRequests = 10; windowUpdates = 0; - const Http2Settings serverSettings = {{Settings::MAX_CONCURRENT_STREAMS_ID, 3}}; + Http2::ProtocolParameters params; + // A small window size for a session, and even a smaller one per stream - + // this will result in WINDOW_UPDATE frames both on connection stream and + // per stream. + params.maxSessionReceiveWindowSize = Http2::defaultSessionWindowSize * 5; + params.settingsFrameData[Settings::INITIAL_WINDOW_SIZE_ID] = Http2::defaultSessionWindowSize; + // Inform our manager about non-default settings: + manager.setProperty(Http2::http2ParametersPropertyName, QVariant::fromValue(params)); - ServerPtr srv(newServer(serverSettings)); + const Http2::RawSettings serverSettings = {{Settings::MAX_CONCURRENT_STREAMS_ID, quint32(3)}}; + ServerPtr srv(newServer(serverSettings, params)); - const QByteArray respond(int(Http2::initialStreamReceiveWindowSize * 5), 'x'); + + const QByteArray respond(int(Http2::defaultSessionWindowSize * 10), 'x'); srv->setResponseBody(respond); QMetaObject::invokeMethod(srv.data(), "startServer", Qt::QueuedConnection); @@ -309,7 +296,7 @@ void tst_Http2::flowControlServerSide() serverPort = 0; nRequests = 30; - const Http2Settings serverSettings = {{Settings::MAX_CONCURRENT_STREAMS_ID, 7}}; + const Http2::RawSettings serverSettings = {{Settings::MAX_CONCURRENT_STREAMS_ID, 7}}; ServerPtr srv(newServer(serverSettings)); @@ -341,12 +328,12 @@ void tst_Http2::pushPromise() serverPort = 0; nRequests = 1; - const EnvVarGuard env("QT_HTTP2_ENABLE_PUSH_PROMISE", "1"); - const Http2Settings clientSettings{{Settings::MAX_FRAME_SIZE_ID, quint32(Http2::maxFrameSize)}, - {Http2::Settings::INITIAL_WINDOW_SIZE_ID, quint32(Http2::initialStreamReceiveWindowSize)}, - {Settings::ENABLE_PUSH_ID, quint32(1)}}; + Http2::ProtocolParameters params; + // Defaults are good, except ENABLE_PUSH: + params.settingsFrameData[Settings::ENABLE_PUSH_ID] = 1; + manager.setProperty(Http2::http2ParametersPropertyName, QVariant::fromValue(params)); - ServerPtr srv(newServer(defaultServerSettings, clientSettings)); + ServerPtr srv(newServer(defaultServerSettings, params)); srv->enablePushPromise(true, QByteArray("/script.js")); QMetaObject::invokeMethod(srv.data(), "startServer", Qt::QueuedConnection); @@ -420,7 +407,7 @@ void tst_Http2::goaway() serverPort = 0; nRequests = 3; - ServerPtr srv(newServer(defaultServerSettings, defaultClientSettings)); + ServerPtr srv(newServer(defaultServerSettings)); srv->emulateGOAWAY(responseTimeoutMS); QMetaObject::invokeMethod(srv.data(), "startServer", Qt::QueuedConnection); runEventLoop(); @@ -463,6 +450,7 @@ void tst_Http2::clearHTTP2State() windowUpdates = 0; prefaceOK = false; serverGotSettingsACK = false; + manager.setProperty(Http2::http2ParametersPropertyName, QVariant()); } void tst_Http2::runEventLoop(int ms) @@ -478,11 +466,12 @@ void tst_Http2::stopEventLoop() eventLoop.quit(); } -Http2Server *tst_Http2::newServer(const Http2Settings &serverSettings, - const Http2Settings &clientSettings) +Http2Server *tst_Http2::newServer(const Http2::RawSettings &serverSettings, + const Http2::ProtocolParameters &clientSettings) { using namespace Http2; - auto srv = new Http2Server(clearTextHTTP2, serverSettings, clientSettings); + auto srv = new Http2Server(clearTextHTTP2, serverSettings, + clientSettings.settingsFrameData); using Srv = Http2Server; using Cl = tst_Http2; diff --git a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp index caf8145c19..f5f5146eb5 100644 --- a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp +++ b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp @@ -187,7 +187,7 @@ void tst_QHostInfo::initTestCase() networkSession.reset(new QNetworkSession(networkConfiguration)); if (!networkSession->isOpen()) { networkSession->open(); - QVERIFY(networkSession->waitForOpened(30000)); + networkSession->waitForOpened(30000); } #endif diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp index e9a29d444a..3a676f1275 100644 --- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp @@ -224,15 +224,12 @@ public: return index.isValid() ? qint32(index.internalId()) : qint32(-1); } - bool canFetchMore(const QModelIndex &) const { - return !fetched; - } + bool canFetchMore(const QModelIndex &) const override { return !fetched; } - void fetchMore(const QModelIndex &) { - fetched = true; - } + void fetchMore(const QModelIndex &) override { fetched = true; } - bool hasChildren(const QModelIndex &parent = QModelIndex()) const { + bool hasChildren(const QModelIndex &parent = QModelIndex()) const override + { bool hasFetched = fetched; fetched = true; bool r = QAbstractItemModel::hasChildren(parent); @@ -240,14 +237,16 @@ public: return r; } - int rowCount(const QModelIndex& parent = QModelIndex()) const { + int rowCount(const QModelIndex& parent = QModelIndex()) const override + { if (!fetched) qFatal("%s: rowCount should not be called before fetching", Q_FUNC_INFO); if ((parent.column() > 0) || (level(parent) > levels)) return 0; return rows; } - int columnCount(const QModelIndex& parent = QModelIndex()) const { + int columnCount(const QModelIndex& parent = QModelIndex()) const override + { if ((parent.column() > 0) || (level(parent) > levels)) return 0; return cols; @@ -259,7 +258,7 @@ public: return false; } - QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const + QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override { if (row < 0 || column < 0 || (level(parent) > levels) || column >= cols || row >= rows) { return QModelIndex(); @@ -269,14 +268,14 @@ public: return i; } - QModelIndex parent(const QModelIndex &index) const + QModelIndex parent(const QModelIndex &index) const override { if (!parentHash.contains(index)) return QModelIndex(); return parentHash[index]; } - QVariant data(const QModelIndex &idx, int role) const + QVariant data(const QModelIndex &idx, int role) const override { if (!idx.isValid()) return QVariant(); diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp index 53511ed7e2..f383d430d6 100644 --- a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp +++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp @@ -2604,30 +2604,20 @@ namespace { class MyPaintEngine : public QPaintEngine { public: - bool begin(QPaintDevice *) - { - return true; - } + bool begin(QPaintDevice *) override { return true; } - bool end() - { - return true; - } + bool end() override { return true; } - void updateState(const QPaintEngineState &) - { - } + void updateState(const QPaintEngineState &) override { } - void drawPixmap(const QRectF &, const QPixmap &, const QRectF &) - { - } + void drawPixmap(const QRectF &, const QPixmap &, const QRectF &) override { } void drawTextItem(const QPointF &, const QTextItem &textItem) override { itemFonts.append(qMakePair(textItem.text(), textItem.font())); } - Type type() const { return User; } + Type type() const override { return User; } QList<QPair<QString, QFont> > itemFonts; |