diff options
Diffstat (limited to 'tests')
23 files changed, 268 insertions, 53 deletions
diff --git a/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp b/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp index e3f45df27d..8ba3505d8b 100644 --- a/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp +++ b/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp @@ -53,6 +53,7 @@ # undef min #endif // Q_CC_MSVC + class tst_QSocketNotifier : public QObject { Q_OBJECT @@ -63,6 +64,9 @@ private slots: void posixSockets(); #endif void asyncMultipleDatagram(); + void activationReason_data(); + void activationReason(); + void legacyConnect(); protected slots: void async_readDatagramSlot(); @@ -97,10 +101,10 @@ public: { QSocketNotifier *notifier1 = new QSocketNotifier(readEnd1->socketDescriptor(), QSocketNotifier::Read, this); - connect(notifier1, SIGNAL(activated(int)), SLOT(handleActivated())); + connect(notifier1, SIGNAL(activated(QSocketDescriptor)), SLOT(handleActivated())); QSocketNotifier *notifier2 = new QSocketNotifier(readEnd2->socketDescriptor(), QSocketNotifier::Read, this); - connect(notifier2, SIGNAL(activated(int)), SLOT(handleActivated())); + connect(notifier2, SIGNAL(activated(QSocketDescriptor)), SLOT(handleActivated())); } public slots: @@ -284,12 +288,12 @@ void tst_QSocketNotifier::posixSockets() { QSocketNotifier rn(posixSocket, QSocketNotifier::Read); - connect(&rn, SIGNAL(activated(int)), &QTestEventLoop::instance(), SLOT(exitLoop())); + connect(&rn, SIGNAL(activated(QSocketDescriptor)), &QTestEventLoop::instance(), SLOT(exitLoop())); QSignalSpy readSpy(&rn, &QSocketNotifier::activated); QVERIFY(readSpy.isValid()); // No write notifier, some systems trigger write notification on socket creation, but not all QSocketNotifier en(posixSocket, QSocketNotifier::Exception); - connect(&en, SIGNAL(activated(int)), &QTestEventLoop::instance(), SLOT(exitLoop())); + connect(&en, SIGNAL(activated(QSocketDescriptor)), &QTestEventLoop::instance(), SLOT(exitLoop())); QSignalSpy errorSpy(&en, &QSocketNotifier::activated); QVERIFY(errorSpy.isValid()); @@ -306,7 +310,7 @@ void tst_QSocketNotifier::posixSockets() QCOMPARE(buffer, "hello"); QSocketNotifier wn(posixSocket, QSocketNotifier::Write); - connect(&wn, SIGNAL(activated(int)), &QTestEventLoop::instance(), SLOT(exitLoop())); + connect(&wn, SIGNAL(activated(QSocketDescriptor)), &QTestEventLoop::instance(), SLOT(exitLoop())); QSignalSpy writeSpy(&wn, &QSocketNotifier::activated); QVERIFY(writeSpy.isValid()); qt_safe_write(posixSocket, "goodbye", 8); @@ -385,5 +389,61 @@ void tst_QSocketNotifier::asyncMultipleDatagram() #endif // !Q_OS_WINRT } +void tst_QSocketNotifier::activationReason_data() +{ + QTest::addColumn<QSocketNotifier::Type>("type"); + QTest::addRow("read") << QSocketNotifier::Read; + QTest::addRow("write") << QSocketNotifier::Write; + QTest::addRow("exception") << QSocketNotifier::Exception; +} +void tst_QSocketNotifier::activationReason() +{ + QSocketDescriptor fd = 15; + + QFETCH(QSocketNotifier::Type, type); + + QSocketNotifier notifier(fd, type); + auto activation = new QEvent(QEvent::SockAct); + QCoreApplication::postEvent(¬ifier, activation); + + QSocketNotifier::Type notifierType; + connect(¬ifier, &QSocketNotifier::activated, this, + [¬ifierType, fd](QSocketDescriptor sockfd, QSocketNotifier::Type sntype) { + if (sockfd == fd) + notifierType = sntype; + else + qWarning() << "Got an unexpected socket file descriptor:" << qintptr(sockfd); + }); + + QCoreApplication::processEvents(); + QCOMPARE(notifierType, type); +} + +// This test ensures that we can connect QSocketNotifier::activated to a slot taking an integer +// or qintptr. +void tst_QSocketNotifier::legacyConnect() +{ + qintptr fd = 15; + QSocketNotifier notifier(fd, QSocketNotifier::Read); + auto activation = new QEvent(QEvent::SockAct); + QCoreApplication::postEvent(¬ifier, activation); + + bool receivedQIntPtr = false; + connect(¬ifier, &QSocketNotifier::activated, this, [&receivedQIntPtr, fd](qintptr q){ + if (q == fd) + receivedQIntPtr = true; + }); + bool receivedInt = false; + connect(¬ifier, &QSocketNotifier::activated, this, [&receivedInt, fd](int q){ + if (q == fd) + receivedInt = true; + }); + + QCoreApplication::processEvents(); + QVERIFY(receivedQIntPtr); + QVERIFY(receivedInt); +} + + QTEST_MAIN(tst_QSocketNotifier) #include <tst_qsocketnotifier.moc> diff --git a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp index 05cf199abe..64321c11fa 100644 --- a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp +++ b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp @@ -385,9 +385,21 @@ void tst_QCborValue::copyCompare() { QFETCH(QCborValue, v); QCborValue other = v; + + // self-moving + v = std::move(v); + QCOMPARE(v, other); // make sure it's still valid + + // moving + v = std::move(other); + other = std::move(v); + + // normal copying + other = v; other = v; v = other; + QCOMPARE(v.compare(other), 0); QCOMPARE(v, other); QVERIFY(!(v != other)); diff --git a/tests/auto/gui/text/qtextmarkdownwriter/data/blockquotes.md b/tests/auto/gui/text/qtextmarkdownwriter/data/blockquotes.md index 6336d0219f..702ccef134 100644 --- a/tests/auto/gui/text/qtextmarkdownwriter/data/blockquotes.md +++ b/tests/auto/gui/text/qtextmarkdownwriter/data/blockquotes.md @@ -20,7 +20,7 @@ MacFarlane writes: > equivalent sample of Markdown. Here is a sample of AsciiDoc from the AsciiDoc > manual: -> ``` AsciiDoc +> ```AsciiDoc > 1. List item one. > + > List item one continued with a second paragraph followed by an @@ -50,7 +50,7 @@ Now let's have an indented code block: } and end with a fenced code block: -~~~ pseudocode +~~~pseudocode #include <something.h> #include <else.h> diff --git a/tests/auto/gui/text/qtextmarkdownwriter/data/listsAndCodeBlocks.md b/tests/auto/gui/text/qtextmarkdownwriter/data/listsAndCodeBlocks.md new file mode 100644 index 0000000000..54e3f25afa --- /dev/null +++ b/tests/auto/gui/text/qtextmarkdownwriter/data/listsAndCodeBlocks.md @@ -0,0 +1,24 @@ +- something happens in the debugger like this: + + ``` + 1 QQuickEventPoint::setGrabberItem qquickevents.cpp 869 0x7ffff7a963f2 + 2 QQuickItem::grabMouse qquickitem.cpp 7599 0x7ffff7abea29 + 3 QQuickWindowPrivate::deliverMatchingPointsToItem qquickwindow.cpp 2738 0x7ffff7aea34c + 4 QQuickWindowPrivate::deliverPressOrReleaseEvent qquickwindow.cpp 2692 0x7ffff7ae9e57 + 5 QQuickWindowPrivate::deliverMouseEvent qquickwindow.cpp 1911 0x7ffff7ae561b + 6 QQuickWindowPrivate::deliverPointerEvent qquickwindow.cpp 2454 0x7ffff7ae888c + 7 QQuickWindowPrivate::handleMouseEvent qquickwindow.cpp 2282 0x7ffff7ae7f1a + 8 QQuickWindow::mousePressEvent qquickwindow.cpp 2249 0x7ffff7ae7bf5 + 9 QQuickView::mousePressEvent qquickview.cpp 626 0x7ffff7bd6bad + 10 QWindow::event qwindow.cpp 2258 0x7ffff70b2c54 + ``` + and then I want to explain something about it. + +- something I tried to fix it: + + ```c++ + item->ungrab(); + ``` +- still didn't fix it, expecting a breakthrough any day now +- some sort of miracle +- profit! diff --git a/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp b/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp index 31592c7f0f..13449299cb 100644 --- a/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp +++ b/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp @@ -369,6 +369,7 @@ void tst_QTextMarkdownWriter::rewriteDocument_data() QTest::newRow("list items after headings") << "headingsAndLists.md"; QTest::newRow("word wrap") << "wordWrap.md"; QTest::newRow("links") << "links.md"; + QTest::newRow("lists and code blocks") << "listsAndCodeBlocks.md"; } void tst_QTextMarkdownWriter::rewriteDocument() @@ -431,7 +432,7 @@ void tst_QTextMarkdownWriter::fromHtml_data() "![foo](/url \"title\")\n\n"; QTest::newRow("code") << "<pre class=\"language-pseudocode\">\n#include \"foo.h\"\n\nblock {\n statement();\n}\n\n</pre>" << - "``` pseudocode\n#include \"foo.h\"\n\nblock {\n statement();\n}\n```\n\n"; + "```pseudocode\n#include \"foo.h\"\n\nblock {\n statement();\n}\n```\n\n"; // TODO // QTest::newRow("escaped number and paren after double newline") << // "<p>(The first sentence of this paragraph is a line, the next paragraph has a number</p>13) but that's not part of an ordered list" << diff --git a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog_mac_helpers.mm b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog_mac_helpers.mm index 44b6423f1c..00cc6a879f 100644 --- a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog_mac_helpers.mm +++ b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog_mac_helpers.mm @@ -26,7 +26,6 @@ ** ****************************************************************************/ -#include <private/qt_mac_p.h> #include <AppKit/AppKit.h> void click_cocoa_button() diff --git a/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp b/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp index e4f927750e..dd8a3e5839 100644 --- a/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp +++ b/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** 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. @@ -365,43 +365,67 @@ void tst_QButtonGroup::testSignals() qRegisterMetaType<QAbstractButton *>("QAbstractButton *"); QSignalSpy clickedSpy(&buttons, SIGNAL(buttonClicked(QAbstractButton*))); + QSignalSpy clickedIdSpy(&buttons, SIGNAL(idClicked(int))); QSignalSpy pressedSpy(&buttons, SIGNAL(buttonPressed(QAbstractButton*))); + QSignalSpy pressedIdSpy(&buttons, SIGNAL(idPressed(int))); QSignalSpy releasedSpy(&buttons, SIGNAL(buttonReleased(QAbstractButton*))); + QSignalSpy releasedIdSpy(&buttons, SIGNAL(idReleased(int))); pb1.animateClick(); QTestEventLoop::instance().enterLoop(1); QCOMPARE(clickedSpy.count(), 1); + QCOMPARE(clickedIdSpy.count(), 1); + int expectedId = -2; + + QCOMPARE(clickedIdSpy.takeFirst().at(0).toInt(), expectedId); QCOMPARE(pressedSpy.count(), 1); + QCOMPARE(pressedIdSpy.count(), 1); + QCOMPARE(pressedIdSpy.takeFirst().at(0).toInt(), expectedId); QCOMPARE(releasedSpy.count(), 1); + QCOMPARE(releasedIdSpy.count(), 1); + QCOMPARE(releasedIdSpy.takeFirst().at(0).toInt(), expectedId); clickedSpy.clear(); + clickedIdSpy.clear(); pressedSpy.clear(); + pressedIdSpy.clear(); releasedSpy.clear(); + releasedIdSpy.clear(); pb2.animateClick(); QTestEventLoop::instance().enterLoop(1); QCOMPARE(clickedSpy.count(), 1); + QCOMPARE(clickedIdSpy.count(), 1); + QCOMPARE(clickedIdSpy.takeFirst().at(0).toInt(), 23); QCOMPARE(pressedSpy.count(), 1); + QCOMPARE(pressedIdSpy.count(), 1); + QCOMPARE(pressedIdSpy.takeFirst().at(0).toInt(), 23); QCOMPARE(releasedSpy.count(), 1); + QCOMPARE(releasedIdSpy.count(), 1); + QCOMPARE(releasedIdSpy.takeFirst().at(0).toInt(), 23); QSignalSpy toggledSpy(&buttons, SIGNAL(buttonToggled(QAbstractButton*, bool))); + QSignalSpy toggledIdSpy(&buttons, SIGNAL(idToggled(int, bool))); pb1.setCheckable(true); pb2.setCheckable(true); pb1.toggle(); QCOMPARE(toggledSpy.count(), 1); + QCOMPARE(toggledIdSpy.count(), 1); pb2.toggle(); QCOMPARE(toggledSpy.count(), 3); // equals 3 since pb1 and pb2 are both toggled + QCOMPARE(toggledIdSpy.count(), 3); pb1.setCheckable(false); pb2.setCheckable(false); pb1.toggle(); QCOMPARE(toggledSpy.count(), 3); + QCOMPARE(toggledIdSpy.count(), 3); } void tst_QButtonGroup::task106609() diff --git a/tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp b/tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp index 5bd4bc5520..1fd3b9d5da 100644 --- a/tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp +++ b/tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** 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. @@ -28,6 +28,7 @@ #include <QtTest/QtTest> #include <QtCore/QProcess> +#include <QtCore/QElapsedTimer> class tst_QProcess : public QObject { @@ -50,7 +51,7 @@ void tst_QProcess::echoTest_performance() QVERIFY(process.waitForStarted()); - QTime stopWatch; + QElapsedTimer stopWatch; stopWatch.start(); qint64 totalBytes = 0; diff --git a/tests/benchmarks/gui/painting/qtbench/tst_qtbench.cpp b/tests/benchmarks/gui/painting/qtbench/tst_qtbench.cpp index c2ce15f720..fb5b2cdc91 100644 --- a/tests/benchmarks/gui/painting/qtbench/tst_qtbench.cpp +++ b/tests/benchmarks/gui/painting/qtbench/tst_qtbench.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** 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. @@ -29,6 +29,7 @@ #include <qtest.h> #include <QtCore/qmath.h> +#include <QtCore/QElapsedTimer> #include <QtWidgets/QWidget> #include "benchmarktests.h" @@ -44,7 +45,7 @@ public: qreal result() const { return m_result; } public: - QTime timer; + QElapsedTimer timer; Benchmark *m_benchmark; @@ -77,7 +78,7 @@ void BenchWidget::paintEvent(QPaintEvent *) ++m_iteration; - uint currentElapsed = timer.isNull() ? 0 : timer.elapsed(); + uint currentElapsed = timer.isValid() ? timer.elapsed() : 0; timer.restart(); m_total += currentElapsed; diff --git a/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/main.cpp b/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/main.cpp index 1f3f38eaaf..7f0f0190ec 100644 --- a/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/main.cpp +++ b/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/main.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** 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. @@ -32,6 +32,7 @@ #include <QtNetwork/qnetworkrequest.h> #include <QtNetwork/qnetworkaccessmanager.h> #include <QtCore/QTemporaryFile> +#include <QtCore/QElapsedTimer> #include <QtCore/QFile> class qfile_vs_qnetworkaccessmanager : public QObject @@ -88,7 +89,7 @@ void qfile_vs_qnetworkaccessmanager::qnamFileRead_iteration(QNetworkAccessManage void qfile_vs_qnetworkaccessmanager::qnamFileRead() { QNetworkAccessManager manager; - QTime t; + QElapsedTimer t; QNetworkRequest request(QUrl::fromLocalFile(testFile.fileName())); // do 3 dry runs for cache warmup @@ -121,7 +122,7 @@ void qfile_vs_qnetworkaccessmanager::qnamImmediateFileRead_iteration(QNetworkAcc void qfile_vs_qnetworkaccessmanager::qnamImmediateFileRead() { QNetworkAccessManager manager; - QTime t; + QElapsedTimer t; QNetworkRequest request(QUrl::fromLocalFile(testFile.fileName())); // do 3 dry runs for cache warmup @@ -151,7 +152,7 @@ void qfile_vs_qnetworkaccessmanager::qfileFileRead_iteration() void qfile_vs_qnetworkaccessmanager::qfileFileRead() { - QTime t; + QElapsedTimer t; // do 3 dry runs for cache warmup qfileFileRead_iteration(); diff --git a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp index 95ee094f00..559ed82834 100644 --- a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** 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. @@ -31,6 +31,7 @@ #include <qtest.h> #include <QtTest/QtTest> #include <QtCore/qrandom.h> +#include <QtCore/QElapsedTimer> #include <QtNetwork/qnetworkreply.h> #include <QtNetwork/qnetworkrequest.h> #include <QtNetwork/qnetworkaccessmanager.h> @@ -93,7 +94,7 @@ protected: QEventLoop eventLoop; QTimer::singleShot(timeout, &eventLoop, SLOT(quit())); - QTime timer; + QElapsedTimer timer; timer.start(); eventLoop.exec(); disconnect(client, SIGNAL(bytesWritten(qint64)), this, 0); @@ -187,7 +188,7 @@ protected: DataReader reader(client, false); QObject::connect(client, SIGNAL(disconnected()), &eventLoop, SLOT(quit())); - QTime timer; + QElapsedTimer timer; timer.start(); eventLoop.exec(); qint64 elapsed = timer.elapsed(); @@ -280,7 +281,7 @@ protected: DataReader reader(client, false); QObject::connect(client, SIGNAL(disconnected()), &eventLoop, SLOT(quit())); - QTime timer; + QElapsedTimer timer; timer.start(); eventLoop.exec(); qint64 elapsed = timer.elapsed(); @@ -611,7 +612,7 @@ void tst_qnetworkreply::downloadPerformance() QNetworkReplyPtr reply(manager.get(request)); DataReader reader(reply, false); - QTime loopTime; + QElapsedTimer loopTime; connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); loopTime.start(); QTestEventLoop::instance().enterLoop(40); @@ -654,7 +655,7 @@ void tst_qnetworkreply::httpUploadPerformance() connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); - QTime time; + QElapsedTimer time; generator.start(); time.start(); QTestEventLoop::instance().enterLoop(40); @@ -682,7 +683,7 @@ void tst_qnetworkreply::performanceControlRate() sink.connectToHost("127.0.0.1", sender.serverPort()); DataReader reader(&sink, false); - QTime loopTime; + QElapsedTimer loopTime; connect(&sink, SIGNAL(disconnected()), &QTestEventLoop::instance(), SLOT(exitLoop())); loopTime.start(); QTestEventLoop::instance().enterLoop(40); @@ -720,7 +721,7 @@ void tst_qnetworkreply::httpDownloadPerformance() connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection); HttpDownloadPerformanceClient client(reply.data()); - QTime time; + QElapsedTimer time; time.start(); QTestEventLoop::instance().enterLoop(40); QCOMPARE(reply->error(), QNetworkReply::NoError); diff --git a/tests/benchmarks/network/socket/qtcpserver/tst_qtcpserver.cpp b/tests/benchmarks/network/socket/qtcpserver/tst_qtcpserver.cpp index a9f8634129..f35e5cd3db 100644 --- a/tests/benchmarks/network/socket/qtcpserver/tst_qtcpserver.cpp +++ b/tests/benchmarks/network/socket/qtcpserver/tst_qtcpserver.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** 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. @@ -27,6 +27,7 @@ ****************************************************************************/ #include <QtTest/QtTest> +#include <QtCore/QElapsedTimer> #include <qglobal.h> #include <qcoreapplication.h> #include <qtcpsocket.h> @@ -129,7 +130,7 @@ void tst_QTcpServer::ipv4LoopbackPerformanceTest() QVERIFY(clientB); QByteArray buffer(16384, '@'); - QTime stopWatch; + QElapsedTimer stopWatch; stopWatch.start(); qlonglong totalWritten = 0; while (stopWatch.elapsed() < 5000) { @@ -180,7 +181,7 @@ void tst_QTcpServer::ipv6LoopbackPerformanceTest() QVERIFY(clientB); QByteArray buffer(16384, '@'); - QTime stopWatch; + QElapsedTimer stopWatch; stopWatch.start(); qlonglong totalWritten = 0; while (stopWatch.elapsed() < 5000) { @@ -230,7 +231,7 @@ void tst_QTcpServer::ipv4PerformanceTest() QVERIFY(clientB); QByteArray buffer(16384, '@'); - QTime stopWatch; + QElapsedTimer stopWatch; stopWatch.start(); qlonglong totalWritten = 0; while (stopWatch.elapsed() < 5000) { diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglist.cpp b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglist.cpp index eabe3671e5..0aa73b9e26 100644 --- a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglist.cpp +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglist.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -27,7 +27,7 @@ ****************************************************************************/ #include <QDebug> -#include <QTime> +#include <QElapsedTimer> #include "itemrecyclinglist.h" #include "listitemcontainer.h" @@ -160,10 +160,10 @@ void ItemRecyclingList::themeChange() void ItemRecyclingList::keyPressEvent(QKeyEvent *event) { - static QTime keyPressInterval = QTime::currentTime(); + static QElapsedTimer keyPressInterval; static qreal step = 0.0; static bool repeat = false; - int interval = keyPressInterval.elapsed(); + int interval = keyPressInterval.isValid() ? keyPressInterval.elapsed() : 0; ScrollBar* sb = verticalScrollBar(); qreal currentValue = sb->sliderPosition(); diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/mainview.cpp b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/mainview.cpp index 8f5782b0b8..d8e778f151 100644 --- a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/mainview.cpp +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/mainview.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -132,7 +132,7 @@ qreal MainView::fps() void MainView::fpsReset() { m_frameCount = 0; - m_fpsFirstTs.start(); + m_fpsFirstTs = QTime::currentTime(); m_fpsLatestTs = m_fpsFirstTs; m_fpsUpdated.start(); } @@ -201,7 +201,7 @@ void MainView::paintEvent (QPaintEvent *event) emit repainted(); m_frameCount++; - m_fpsLatestTs.start(); + m_fpsLatestTs = QTime::currentTime(); if(m_fpsUpdated.elapsed() > 2000) { updateFps(); m_fpsUpdated.start(); diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/mainview.h b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/mainview.h index d7fe404023..8237ff7469 100644 --- a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/mainview.h +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/mainview.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -31,6 +31,7 @@ #include <QGraphicsView> #include <QTime> +#include <QElapsedTimer> #include <QTimer> #include "settings.h" @@ -100,7 +101,7 @@ private: QTime m_fpsFirstTs; QTime m_fpsLatestTs; bool m_OutputFps; - QTime m_fpsUpdated; + QElapsedTimer m_fpsUpdated; QList<qreal> m_Fpss; int m_angle; diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/scroller_p.h b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/scroller_p.h index cf11c7fa02..c8769f59b2 100644 --- a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/scroller_p.h +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/scroller_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -42,7 +42,7 @@ #include <QPoint> #include <QTimer> -#include <QTime> +#include <QElapsedTimer> #include "scroller.h" @@ -70,8 +70,8 @@ public: QPoint m_cursorPos; QPointF m_speed; State m_state; - QTime m_lastCursorTime; - QTime m_lastFrameTime; + QElapsedTimer m_lastCursorTime; + QElapsedTimer m_lastFrameTime; QTimer m_scrollTimer; int m_scrollSlowAccum; diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/simplelist.cpp b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/simplelist.cpp index 941cab8c21..d64f3ac38d 100644 --- a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/simplelist.cpp +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/simplelist.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -29,7 +29,7 @@ #include <QDebug> #include <QGraphicsLinearLayout> #include <QFont> -#include <QTime> +#include <QElapsedTimer> #include "simplelist.h" static const int MinItemWidth = 276; @@ -99,10 +99,10 @@ void SimpleList::setListItemCaching(bool enable) void SimpleList::keyPressEvent(QKeyEvent *event) { - static QTime keyPressInterval = QTime::currentTime(); + static QElapsedTimer keyPressInterval; static qreal step = 0.0; static bool repeat = false; - int interval = keyPressInterval.elapsed(); + int interval = keyPressInterval.isValid() ? keyPressInterval.elapsed() : 0; ScrollBar* sb = verticalScrollBar(); qreal currentValue = sb->sliderPosition(); diff --git a/tests/benchmarks/widgets/graphicsview/qgraphicsview/chiptester/chiptester.cpp b/tests/benchmarks/widgets/graphicsview/qgraphicsview/chiptester/chiptester.cpp index 1eaa5f6578..6b108f7be9 100644 --- a/tests/benchmarks/widgets/graphicsview/qgraphicsview/chiptester/chiptester.cpp +++ b/tests/benchmarks/widgets/graphicsview/qgraphicsview/chiptester/chiptester.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** 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. @@ -65,7 +65,6 @@ void ChipTester::runBenchmark() { npaints = 0; timerId = startTimer(0); - stopWatch.start(); eventLoop.exec(); killTimer(timerId); } diff --git a/tests/benchmarks/widgets/graphicsview/qgraphicsview/chiptester/chiptester.h b/tests/benchmarks/widgets/graphicsview/qgraphicsview/chiptester/chiptester.h index e4c9197142..467c3fb293 100644 --- a/tests/benchmarks/widgets/graphicsview/qgraphicsview/chiptester/chiptester.h +++ b/tests/benchmarks/widgets/graphicsview/qgraphicsview/chiptester/chiptester.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** 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. @@ -31,7 +31,6 @@ #include <QtWidgets/QGraphicsView> #include <QtCore/QEventLoop> -#include <QtCore/QTime> QT_FORWARD_DECLARE_CLASS(QGraphicsScene) QT_FORWARD_DECLARE_CLASS(QGraphicsView) @@ -66,7 +65,6 @@ private: int npaints; int timerId; QEventLoop eventLoop; - QTime stopWatch; Operation operation; }; diff --git a/tests/libfuzzer/corelib/serialization/qcborstreamreader/next/main.cpp b/tests/libfuzzer/corelib/serialization/qcborstreamreader/next/main.cpp new file mode 100644 index 0000000000..118f402a15 --- /dev/null +++ b/tests/libfuzzer/corelib/serialization/qcborstreamreader/next/main.cpp @@ -0,0 +1,36 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#include <QCborStreamReader> + +extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size) { + QCborStreamReader reader(QByteArray::fromRawData(Data, Size)); + while (reader.isValid()) + reader.next(1024); + return 0; +} diff --git a/tests/libfuzzer/corelib/serialization/qcborstreamreader/next/next.pro b/tests/libfuzzer/corelib/serialization/qcborstreamreader/next/next.pro new file mode 100644 index 0000000000..6c988c2434 --- /dev/null +++ b/tests/libfuzzer/corelib/serialization/qcborstreamreader/next/next.pro @@ -0,0 +1,10 @@ +QT -= gui +CONFIG += console +CONFIG -= app_bundle +SOURCES += main.cpp +FUZZ_ENGINE = $$(LIB_FUZZING_ENGINE) +isEmpty(FUZZ_ENGINE) { + QMAKE_LFLAGS += -fsanitize=fuzzer +} else { + LIBS += $$FUZZ_ENGINE +} diff --git a/tests/libfuzzer/corelib/serialization/qtextstream/extractionoperator-float/extractionoperator-float.pro b/tests/libfuzzer/corelib/serialization/qtextstream/extractionoperator-float/extractionoperator-float.pro new file mode 100644 index 0000000000..6c988c2434 --- /dev/null +++ b/tests/libfuzzer/corelib/serialization/qtextstream/extractionoperator-float/extractionoperator-float.pro @@ -0,0 +1,10 @@ +QT -= gui +CONFIG += console +CONFIG -= app_bundle +SOURCES += main.cpp +FUZZ_ENGINE = $$(LIB_FUZZING_ENGINE) +isEmpty(FUZZ_ENGINE) { + QMAKE_LFLAGS += -fsanitize=fuzzer +} else { + LIBS += $$FUZZ_ENGINE +} diff --git a/tests/libfuzzer/corelib/serialization/qtextstream/extractionoperator-float/main.cpp b/tests/libfuzzer/corelib/serialization/qtextstream/extractionoperator-float/main.cpp new file mode 100644 index 0000000000..10d5c3222e --- /dev/null +++ b/tests/libfuzzer/corelib/serialization/qtextstream/extractionoperator-float/main.cpp @@ -0,0 +1,36 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#include <QTextStream> + +extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size) { + QTextStream qts(QByteArray::fromRawData(Data, Size)); + float f; + qts >> f; + return 0; +} |