From c668fd940d0c610324254d5aa5aab6e0769f78a6 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Wed, 11 Mar 2020 10:38:20 +0100 Subject: Fix 'out of process' autotests We are, arguably, not testing QProcess and its ability to start or finish, we test QUdpSocket. If, for some reason (as we discovered on some specific machines recently) the process does not start or does not produce any output (canReadLine), we QSKIP instead of failing. Also, all those QCOMPARE will bypass the part there we stop processes - so must be RAII-protected. Fixes: QTBUG-82717 Change-Id: Idfb0d4a483d753f336b3827875eeaf51c79270e2 Reviewed-by: Volker Hilsheimer --- .../network/socket/qudpsocket/tst_qudpsocket.cpp | 82 ++++++++++++++-------- 1 file changed, 54 insertions(+), 28 deletions(-) (limited to 'tests') diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp index 0f419e9de4..bed8a8b129 100644 --- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp @@ -1090,12 +1090,21 @@ void tst_QUdpSocket::outOfProcessConnectedClientServerTest() QProcess serverProcess; serverProcess.start(QLatin1String("clientserver/clientserver server 1 1"), QIODevice::ReadWrite | QIODevice::Text); - QVERIFY2(serverProcess.waitForStarted(3000), - qPrintable("Failed to start subprocess: " + serverProcess.errorString())); + + const auto serverProcessCleaner = qScopeGuard([&serverProcess] { + serverProcess.kill(); + serverProcess.waitForFinished(); + }); + + if (!serverProcess.waitForStarted(3000)) + QSKIP("Failed to start server as a subprocess"); // Wait until the server has started and reports success. - while (!serverProcess.canReadLine()) - QVERIFY(serverProcess.waitForReadyRead(3000)); + while (!serverProcess.canReadLine()) { + if (!serverProcess.waitForReadyRead(3000)) + QSKIP("No output from the server process, bailing out"); + } + QByteArray serverGreeting = serverProcess.readLine(); QVERIFY(serverGreeting != QByteArray("XXX\n")); int serverPort = serverGreeting.trimmed().toInt(); @@ -1105,12 +1114,21 @@ void tst_QUdpSocket::outOfProcessConnectedClientServerTest() clientProcess.start(QString::fromLatin1("clientserver/clientserver connectedclient %1 %2") .arg(QLatin1String("127.0.0.1")).arg(serverPort), QIODevice::ReadWrite | QIODevice::Text); - QVERIFY2(clientProcess.waitForStarted(3000), - qPrintable("Failed to start subprocess: " + clientProcess.errorString())); - // Wait until the server has started and reports success. - while (!clientProcess.canReadLine()) - QVERIFY(clientProcess.waitForReadyRead(3000)); + const auto clientProcessCleaner = qScopeGuard([&clientProcess] { + clientProcess.kill(); + clientProcess.waitForFinished(); + }); + + if (!clientProcess.waitForStarted(3000)) + QSKIP("Client process did not start"); + + // Wait until the client has started and reports success. + while (!clientProcess.canReadLine()) { + if (!clientProcess.waitForReadyRead(3000)) + QSKIP("No output from the client process, bailing out"); + } + QByteArray clientGreeting = clientProcess.readLine(); QCOMPARE(clientGreeting, QByteArray("ok\n")); @@ -1135,11 +1153,6 @@ void tst_QUdpSocket::outOfProcessConnectedClientServerTest() QCOMPARE(serverData.at(i * 3 + 2).trimmed().mid(8).toInt(), sdata.mid(4).trimmed().toInt() * 2); } - - clientProcess.kill(); - QVERIFY(clientProcess.waitForFinished()); - serverProcess.kill(); - QVERIFY(serverProcess.waitForFinished()); #endif } @@ -1151,12 +1164,21 @@ void tst_QUdpSocket::outOfProcessUnconnectedClientServerTest() QProcess serverProcess; serverProcess.start(QLatin1String("clientserver/clientserver server 1 1"), QIODevice::ReadWrite | QIODevice::Text); - QVERIFY2(serverProcess.waitForStarted(3000), - qPrintable("Failed to start subprocess: " + serverProcess.errorString())); + + const auto serverProcessCleaner = qScopeGuard([&serverProcess] { + serverProcess.kill(); + serverProcess.waitForFinished(); + }); + + if (!serverProcess.waitForStarted(3000)) + QSKIP("Failed to start the server subprocess"); // Wait until the server has started and reports success. - while (!serverProcess.canReadLine()) - QVERIFY(serverProcess.waitForReadyRead(3000)); + while (!serverProcess.canReadLine()) { + if (!serverProcess.waitForReadyRead(3000)) + QSKIP("No output from the server, probably, it is not running"); + } + QByteArray serverGreeting = serverProcess.readLine(); QVERIFY(serverGreeting != QByteArray("XXX\n")); int serverPort = serverGreeting.trimmed().toInt(); @@ -1166,12 +1188,21 @@ void tst_QUdpSocket::outOfProcessUnconnectedClientServerTest() clientProcess.start(QString::fromLatin1("clientserver/clientserver unconnectedclient %1 %2") .arg(QLatin1String("127.0.0.1")).arg(serverPort), QIODevice::ReadWrite | QIODevice::Text); - QVERIFY2(clientProcess.waitForStarted(3000), - qPrintable("Failed to start subprocess: " + clientProcess.errorString())); - // Wait until the server has started and reports success. - while (!clientProcess.canReadLine()) - QVERIFY(clientProcess.waitForReadyRead(3000)); + const auto clientProcessCleaner = qScopeGuard([&clientProcess] { + clientProcess.kill(); + clientProcess.waitForFinished(); + }); + + if (!clientProcess.waitForStarted(3000)) + QSKIP("Failed to start the client's subprocess"); + + // Wait until the client has started and reports success. + while (!clientProcess.canReadLine()) { + if (!clientProcess.waitForReadyRead(3000)) + QSKIP("The client subprocess produced not output, exiting."); + } + QByteArray clientGreeting = clientProcess.readLine(); QCOMPARE(clientGreeting, QByteArray("ok\n")); @@ -1197,11 +1228,6 @@ void tst_QUdpSocket::outOfProcessUnconnectedClientServerTest() QCOMPARE(serverData.at(i * 3 + 2).trimmed().mid(8).toInt(), sdata.mid(4).trimmed().toInt() * 2); } - - clientProcess.kill(); - QVERIFY(clientProcess.waitForFinished()); - serverProcess.kill(); - QVERIFY(serverProcess.waitForFinished()); #endif } -- cgit v1.2.3 From 7d20f86958522bf1bdbaeaf8c0e395453c463058 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 11 Mar 2020 21:02:03 +0100 Subject: Stabilize and rename tst_qmessagebox::expandDetails_QTBUG_32473 This has been flaky on OpenSuSE; if the stored geom.topLeft() is 0,0 it apparently means the window manager (probably kwin) didn't get around to decorating and repositioning the dialog by the time qWaitForWindowExposed() returns. Because we check later to see whether it moved, we need to be certain of its initial position. Waiting for the extra "fleece" widget to be shown was based on the theory that by the time the X server has processed messages related to that new window, the WM should be done processing the consequences of the resized dialog window. But there's no such guarantee, so let's try removing that. On the other hand, removing the delay does open us up to miss a regression (maybe the dialog gets moved after we have checked that it didn't move). Rename because we don't name autotests after bugs. Amends 26ddb586acd49834c7cffac781ce504ec78635cc Task-number: QTBUG-32473 Change-Id: I6bbfe2b4baaee389db0d4112f0fec3b7cb9da554 Reviewed-by: Qt CI Bot Reviewed-by: Liang Qi --- .../auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp index 76314564f1..543128915e 100644 --- a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp +++ b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp @@ -51,7 +51,7 @@ private slots: void about(); void detailsText(); void detailsButtonText(); - void expandDetails_QTBUG_32473(); + void expandDetailsWithoutMoving(); #ifndef Q_OS_MAC void shortcut(); @@ -499,7 +499,7 @@ void tst_QMessageBox::detailsButtonText() } } -void tst_QMessageBox::expandDetails_QTBUG_32473() +void tst_QMessageBox::expandDetailsWithoutMoving() // QTBUG-32473 { tst_ResizingMessageBox box; box.setDetailedText("bla"); @@ -516,18 +516,14 @@ void tst_QMessageBox::expandDetails_QTBUG_32473() auto moreButton = *it; QVERIFY(QTest::qWaitForWindowExposed(&box)); + QTRY_VERIFY2(!box.geometry().topLeft().isNull(), "window manager is expected to decorate and position the dialog"); QRect geom = box.geometry(); box.resized = false; + // now click the "more" button, and verify that the dialog resizes but does not move moreButton->click(); QTRY_VERIFY(box.resized); - // After we receive the expose event for a second widget, it's likely - // that the window manager is also done manipulating the first QMessageBox. - QWidget fleece; - fleece.show(); - QVERIFY(QTest::qWaitForWindowExposed(&fleece)); - if (geom.topLeft() == box.geometry().topLeft()) - QTest::qWait(500); - QCOMPARE(geom.topLeft(), box.geometry().topLeft()); + QVERIFY(box.geometry().height() > geom.height()); + QCOMPARE(box.geometry().topLeft(), geom.topLeft()); } void tst_QMessageBox::incorrectDefaultButton() -- cgit v1.2.3 From 97422abcfcdf2c5c5b81b9de05ceb7bef6edcf13 Mon Sep 17 00:00:00 2001 From: David Faure Date: Thu, 5 Mar 2020 17:56:32 +0100 Subject: QTreeView: don't call model.index(-1, 0) when using spanning items drawTree() does QPoint hoverPos = d->viewport->mapFromGlobal(QCursor::pos()); d->hoverBranch = d->itemDecorationAt(hoverPos); and itemDecorationAt does const QModelIndex index = q->indexAt(pos); which might very well be an invalid index. Change-Id: I7db98871543bd7e1c57fcc475d2646757bf2bb42 Reviewed-by: Christian Ehrlicher --- tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp index 0580c466cf..b26516ee6b 100644 --- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp @@ -270,6 +270,12 @@ public: QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override { + if (onlyValidCalls) { + Q_ASSERT(row >= 0); + Q_ASSERT(column >= 0); + Q_ASSERT(row < rows); + Q_ASSERT(column < cols); + } if (row < 0 || column < 0 || (level(parent) > levels) || column >= cols || row >= rows) { return QModelIndex(); } @@ -378,6 +384,7 @@ public: mutable bool fetched = false; bool decorationsEnabled = false; bool statusTipsEnabled = false; + bool onlyValidCalls = false; }; // Testing get/set functions @@ -2420,6 +2427,7 @@ void tst_QTreeView::hiddenItems() void tst_QTreeView::spanningItems() { QtTestModel model(10, 10); + model.onlyValidCalls = true; QTreeView view; view.setModel(&model); view.show(); @@ -2459,6 +2467,8 @@ void tst_QTreeView::spanningItems() } } QCOMPARE(view.sizeHintForColumn(0), w); + + view.repaint(); // to check that this doesn't hit any assert } void tst_QTreeView::selectionOrderTest() -- cgit v1.2.3 From 6db55e3451e8ba244e9f2555713d44d988977871 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Thu, 12 Mar 2020 16:25:31 +0100 Subject: QSequentialIterable: Treat sets as appendable QSet and std::(unordered_)set were so far not treated as appendable, as they lack a push_back method. We do however need support for this in declarative to enable converting back from QJSValue arrays to sets. We achieve this by testing for and using the insert method. While vector has also such a method, it doesn't take a single value, but rather a position or iterator + value, so the template specialization is not ambiguous. Task-number: QTBUG-82743 Change-Id: I74fc7b1b856d9bcd38100b274ba2b69578ea8bbb Reviewed-by: Ulf Hermann --- .../auto/corelib/kernel/qvariant/tst_qvariant.cpp | 30 ++++++++++++++++------ 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index 70bda1a0ef..86c61cba12 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -5161,14 +5161,28 @@ void tst_QVariant::sequentialIterableEndianessSanityCheck() void tst_QVariant::sequentialIterableAppend() { - QVector container {1, 2}; - auto variant = QVariant::fromValue(container); - QVERIFY(variant.canConvert()); - auto asIterable = variant.value(); - const int i = 3, j = 4; - asIterable.append(&i); - asIterable.append(&j); - QCOMPARE(variant.value>(), QVector ({1, 2, 3, 4})); + { + QVector container {1, 2}; + auto variant = QVariant::fromValue(container); + QVERIFY(variant.canConvert()); + auto asIterable = variant.value(); + const int i = 3, j = 4; + asIterable.append(&i); + asIterable.append(&j); + QCOMPARE(variant.value>(), QVector ({1, 2, 3, 4})); + } + { + QSet container { QByteArray{"hello"}, QByteArray{"world"} }; + auto variant = QVariant::fromValue(std::move(container)); + QVERIFY(variant.canConvert()); + auto asIterable = variant.value(); + QByteArray qba1 {"goodbye"}; + QByteArray qba2 { "moon" }; + asIterable.append( &qba1 ); + asIterable.append( &qba2); + QSet reference { "hello", "world", "goodbye", "moon" }; + QCOMPARE(variant.value>(), reference); + } } void tst_QVariant::preferDirectConversionOverInterfaces() -- cgit v1.2.3 From 05dd80871c870a564a46e388d7fd124a58fc970d Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Wed, 18 Mar 2020 10:34:37 +0100 Subject: tst_QMenu: make QSKIP message truthful MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since the test was refactored and QCursor::setPosition() replaced with QTest::mouseMove(), the test is completely crippled on macOS, since it relies on the parts in widget's code, ifdefed with condition !Q_OS_OSX and commented as "Cocoa tracks popups". Yes it does, but not for "fake" events generated by QTest. The original test was introduced when fixing different problems on non-Apple platform(s) anyway. Let's make QSKIP message saying the truth. Task-number: QTBUG-63031 Change-Id: If54f195ccc0d4409cc2e7f4ae0b0fbf43989b286 Reviewed-by: Tor Arne Vestbø --- tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp index 727d1c2a16..1fc1c65be0 100644 --- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp +++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp @@ -1264,7 +1264,7 @@ void tst_QMenu::QTBUG47515_widgetActionEnterLeave() if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) QSKIP("Window activation is not supported"); if (QGuiApplication::platformName() == QLatin1String("cocoa")) - QSKIP("See QTBUG-63031"); + QSKIP("This test is meaningless on macOS, for additional info see QTBUG-63031"); const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry(); QRect geometry(QPoint(), availableGeometry.size() / 3); -- cgit v1.2.3 From b77e239c5e7d3befbd48200aa51c5ff9b51d07f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Wed, 18 Mar 2020 09:39:36 +0100 Subject: Fix perl script warning The apache logs are filled with warnings about this when it's used. https://blog.gerv.net/2014/10/new-class-of-vulnerability-in-perl-web-applications/ Change-Id: I977d2b022d706d9587c033fd8e80f129e60c439c Reviewed-by: Timur Pocheptsov Reviewed-by: Edward Welbourne --- tests/testserver/apache2/testdata/www/cgi-bin/multipart.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/testserver/apache2/testdata/www/cgi-bin/multipart.cgi b/tests/testserver/apache2/testdata/www/cgi-bin/multipart.cgi index 6973875cc9..60c0c0e8ad 100755 --- a/tests/testserver/apache2/testdata/www/cgi-bin/multipart.cgi +++ b/tests/testserver/apache2/testdata/www/cgi-bin/multipart.cgi @@ -11,7 +11,7 @@ print "content type: $contentType\n"; if ($contentType =~ /^multipart\/form-data/) { foreach my $key ($q->param) { - foreach my $value ($q->param($key)) { + foreach my $value (scalar $q->param($key)) { if ($key =~ /text/) { $retValue = $value; } else { -- cgit v1.2.3 From 40f4b3de1a7dc8fdce26893880f2d4ca962cf966 Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Fri, 20 Mar 2020 02:29:14 +0100 Subject: qeasingcurve/tst_qeasingcurve: Fix for MinGW 8.1 x86 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test fails on MinGW 8.1 x86, but not on MinGW 8.1 x86_64. Task-number: QTQAINFRA-3304 Task-number: QTBUG-69947 Change-Id: Ie9a35bd6d5a8481028cd0ea426d1cf00bd7cf093 Reviewed-by: Tony Sarajärvi Reviewed-by: Friedemann Kleint --- tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp index 2a9c1e1e41..898ac86874 100644 --- a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp +++ b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp @@ -428,9 +428,9 @@ void tst_QEasingCurve::setCustomType() QCOMPARE(curve.valueForProgress(0.15), 0.1); QCOMPARE(curve.valueForProgress(0.20), 0.2); QCOMPARE(curve.valueForProgress(0.25), 0.2); - // QTBUG-69947, MinGW 7.3 returns 0.2 + // QTBUG-69947, MinGW 7.3, 8.1 x86 returns 0.2 #if defined(Q_CC_MINGW) -#if !defined(__GNUC__) || __GNUC__ != 7 || __GNUC_MINOR__ < 3 +#if !defined(__GNUC__) || defined(__MINGW64__) QCOMPARE(curve.valueForProgress(0.30), 0.3); #endif #endif -- cgit v1.2.3 From e7cff5bca7aefaea63e80598babf6bd7917aa1c3 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 10 Mar 2020 14:37:15 +0100 Subject: Fix keypad navigation within a button group for push buttons Keypad navigation within a group should work for auto-exclusive buttons, or for checkable buttons that are in a button group. Since the code already tests whether the button should be treated like an exclusive (which implies checkable) button, use the result of that test when finding the candidate button to move focus to, and not only when actually changing the checked button and the focus. Change-Id: I4dc41a90d51a8304483046252ceff0ebfe2a2e52 Fixes: QTBUG-27151 Done-with: david.faure@kdab.com Reviewed-by: Volker Hilsheimer --- .../widgets/qbuttongroup/tst_qbuttongroup.cpp | 68 ++++++++++++++++++++++ 1 file changed, 68 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp b/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp index 279fe49e3a..3b8bcf98c3 100644 --- a/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp +++ b/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp @@ -83,6 +83,7 @@ Q_OBJECT private slots: void arrowKeyNavigation(); + void keyNavigationPushButtons(); void exclusive(); void exclusiveWithActions(); void testSignals(); @@ -185,6 +186,73 @@ void tst_QButtonGroup::arrowKeyNavigation() QVERIFY(bt3.hasFocus()); } +/* + Test that tab and arrow key navigation through buttons + in an invisible button group works as expected. Tabbing + into the group should give focus to the checked button, + and arrow navigation should change the checked button and + move focus. +*/ +void tst_QButtonGroup::keyNavigationPushButtons() +{ + if (!qt_tab_all_widgets()) + QSKIP("This test requires full keyboard control to be enabled."); + + QDialog dlg(nullptr); + QLineEdit *le1 = new QLineEdit; + le1->setObjectName("le1"); + QPushButton *pb1 = new QPushButton("Exclusive 1"); + pb1->setObjectName("pb1"); + pb1->setCheckable(true); + pb1->setChecked(true); + QPushButton *pb2 = new QPushButton("Exclusive 2"); + pb2->setObjectName("pb2"); + pb2->setCheckable(true); + QPushButton *pb3 = new QPushButton("Exclusive 3"); + pb3->setObjectName("pb3"); + pb3->setCheckable(true); + QLineEdit *le2 = new QLineEdit; + le2->setObjectName("le2"); + + QVBoxLayout* layout = new QVBoxLayout(&dlg); + layout->addWidget(le1); + layout->addWidget(pb1); + layout->addWidget(pb2); + layout->addWidget(pb3); + layout->addWidget(le2); + + QButtonGroup *buttonGroup = new QButtonGroup; + buttonGroup->addButton(pb1); + buttonGroup->addButton(pb2); + buttonGroup->addButton(pb3); + + dlg.show(); + qApp->setActiveWindow(&dlg); + if (!QTest::qWaitForWindowActive(&dlg)) + QSKIP("Window activation failed, skipping test"); + + QVERIFY2(le1->hasFocus(), qPrintable(qApp->focusWidget()->objectName())); + QTest::keyClick(qApp->focusWidget(), Qt::Key_Tab); + QVERIFY2(pb1->hasFocus(), qPrintable(qApp->focusWidget()->objectName())); + QVERIFY2(pb1->isChecked(), qPrintable(buttonGroup->checkedButton()->objectName())); + QTest::keyClick(qApp->focusWidget(), Qt::Key_Down); + QVERIFY2(pb2->hasFocus(), qPrintable(qApp->focusWidget()->objectName())); + QVERIFY2(pb2->isChecked(), qPrintable(buttonGroup->checkedButton()->objectName())); + QTest::keyClick(qApp->focusWidget(), Qt::Key_Down); + QVERIFY2(pb3->hasFocus(), qPrintable(qApp->focusWidget()->objectName())); + QVERIFY2(pb3->isChecked(), qPrintable(buttonGroup->checkedButton()->objectName())); + QTest::keyClick(qApp->focusWidget(), Qt::Key_Up); + QVERIFY2(pb2->hasFocus(), qPrintable(qApp->focusWidget()->objectName())); + QVERIFY2(pb2->isChecked(), qPrintable(buttonGroup->checkedButton()->objectName())); + QTest::keyClick(qApp->focusWidget(), Qt::Key_Tab); + QVERIFY2(le2->hasFocus(), qPrintable(qApp->focusWidget()->objectName())); + QTest::keyClick(qApp->focusWidget(), Qt::Key_Backtab); + QVERIFY2(pb2->hasFocus(), qPrintable(qApp->focusWidget()->objectName())); + QVERIFY2(pb2->isChecked(), qPrintable(buttonGroup->checkedButton()->objectName())); + QTest::keyClick(qApp->focusWidget(), Qt::Key_Backtab); + QVERIFY2(le1->hasFocus(), qPrintable(qApp->focusWidget()->objectName())); +} + void tst_QButtonGroup::exclusiveWithActions() { QDialog dlg(0); -- cgit v1.2.3 From 2af04860f6536bbbf82ee21d6aa95ca33a60fbf5 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Fri, 3 May 2019 20:02:10 +0200 Subject: qtimezoneprivate_tz: Apply a cache over the top of timezone data Constantly re-reading the timezone information only to be told the exact same thing is wildly expensive, which can hurt in operations that cause a lot of QTimeZone creation, for example, V4's DateObject - which creates them a lot (in DaylightSavingTA). This performance problem was identified when I noticed that a QDateTime binding updated once per frame was causing >100% CPU usage (on a desktop!) thanks to a QtQuickControls 1 Calendar (which has a number of bindings to the date's properties like getMonth() and so on). The newly added tst_QTimeZone::systemTimeZone benchmark gets a ~90% decrease in instruction count: --- before +++ after PASS : tst_QTimeZone::systemTimeZone() RESULT : tst_QTimeZone::systemTimeZone(): - 0.024 msecs per iteration (total: 51, iterations: 2048) + 0.0036 msecs per iteration (total: 59, iterations: 16384) Also impacted (over in QDateTime) is tst_QDateTime::setMSecsSinceEpochTz(). The results here are - on the surface - less impressive (~0.17% drop), however, it isn't even creating QTimeZone on a hot path to begin with, so a large drop would have been a surprise. Added several further benchmarks to cover non-system zones and traverse transitions. Done-With: Edward Welbourne Task-number: QTBUG-75585 Change-Id: I044a84fc2d3a2dc965f63cd3a3299fc509750bf7 Reviewed-by: Ulf Hermann Reviewed-by: Simon Hausmann --- tests/benchmarks/corelib/time/qtimezone/main.cpp | 122 +++++++++++++++++++++++ 1 file changed, 122 insertions(+) (limited to 'tests') diff --git a/tests/benchmarks/corelib/time/qtimezone/main.cpp b/tests/benchmarks/corelib/time/qtimezone/main.cpp index 65455a7261..133e6451bc 100644 --- a/tests/benchmarks/corelib/time/qtimezone/main.cpp +++ b/tests/benchmarks/corelib/time/qtimezone/main.cpp @@ -1,5 +1,6 @@ /**************************************************************************** ** +** Copyright (C) 2019 Crimson AS ** Copyright (C) 2018 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author David Faure ** Contact: https://www.qt.io/licensing/ ** @@ -30,14 +31,57 @@ #include #include +// Enable to test *every* zone, rather than a hand-picked few, in some _data() sets: +// #define EXHAUSTIVE + class tst_QTimeZone : public QObject { Q_OBJECT private Q_SLOTS: void isTimeZoneIdAvailable(); + void systemTimeZone(); + void zoneByName_data(); + void zoneByName(); + void transitionList_data(); + void transitionList(); + void transitionsForward_data() { transitionList_data(); } + void transitionsForward(); + void transitionsReverse_data() { transitionList_data(); } + void transitionsReverse(); }; +static QVector enoughZones() +{ +#ifdef EXHAUSTIVE + auto available = QTimeZone::availableTimeZoneIds(); + QVector result; + result.reserve(available.size() + 1); + for (conat auto &name : available) + result << name; +#else + QVector result{ + QByteArray("UTC"), + // Those named overtly in tst_QDateTime: + QByteArray("Europe/Oslo"), + QByteArray("America/Vancouver"), + QByteArray("Europe/Berlin"), + QByteArray("America/Sao_Paulo"), + QByteArray("Pacific/Auckland"), + QByteArray("Australia/Eucla"), + QByteArray("Asia/Kathmandu"), + QByteArray("Pacific/Kiritimati"), + QByteArray("Pacific/Apia"), + QByteArray("UTC+12:00"), + QByteArray("Australia/Sydney"), + QByteArray("Asia/Singapore"), + QByteArray("Australia/Brisbane") + }; +#endif + result << QByteArray("Vulcan/ShiKahr"); // invalid: also worth testing + return result; +} + void tst_QTimeZone::isTimeZoneIdAvailable() { const QList available = QTimeZone::availableTimeZoneIds(); @@ -47,6 +91,84 @@ void tst_QTimeZone::isTimeZoneIdAvailable() } } +void tst_QTimeZone::systemTimeZone() +{ + QBENCHMARK { + QTimeZone::systemTimeZone(); + } +} + +void tst_QTimeZone::zoneByName_data() +{ + QTest::addColumn("name"); + + const auto names = enoughZones(); + for (const auto &name : names) + QTest::newRow(name.constData()) << name; +} + +void tst_QTimeZone::zoneByName() +{ + QFETCH(QByteArray, name); + QTimeZone zone; + QBENCHMARK { + zone = QTimeZone(name); + } + Q_UNUSED(zone); +} + +void tst_QTimeZone::transitionList_data() +{ + QTest::addColumn("name"); + QTest::newRow("system") << QByteArray(); // Handled specially in the test. + + const auto names = enoughZones(); + for (const auto &name : names) { + QTimeZone zone(name); + if (zone.isValid() && zone.hasTransitions()) + QTest::newRow(name.constData()) << name; + } +} + +void tst_QTimeZone::transitionList() +{ + QFETCH(QByteArray, name); + const QTimeZone zone = name.isEmpty() ? QTimeZone::systemTimeZone() : QTimeZone(name); + const QDateTime early = QDate(1625, 6, 8).startOfDay(Qt::UTC); // Cassini's birth date + const QDateTime late // End of 32-bit signed time_t + = QDateTime::fromSecsSinceEpoch(std::numeric_limits::max(), Qt::UTC); + QTimeZone::OffsetDataList seq; + QBENCHMARK { + seq = zone.transitions(early, late); + } + Q_UNUSED(seq); +} + +void tst_QTimeZone::transitionsForward() +{ + QFETCH(QByteArray, name); + const QTimeZone zone = name.isEmpty() ? QTimeZone::systemTimeZone() : QTimeZone(name); + const QDateTime early = QDate(1625, 6, 8).startOfDay(Qt::UTC); // Cassini's birth date + QBENCHMARK { + QTimeZone::OffsetData tran = zone.nextTransition(early); + while (tran.atUtc.isValid()) + tran = zone.nextTransition(tran.atUtc); + } +} + +void tst_QTimeZone::transitionsReverse() +{ + QFETCH(QByteArray, name); + const QTimeZone zone = name.isEmpty() ? QTimeZone::systemTimeZone() : QTimeZone(name); + const QDateTime late // End of 32-bit signed time_t + = QDateTime::fromSecsSinceEpoch(std::numeric_limits::max(), Qt::UTC); + QBENCHMARK { + QTimeZone::OffsetData tran = zone.previousTransition(late); + while (tran.atUtc.isValid()) + tran = zone.previousTransition(tran.atUtc); + } +} + QTEST_MAIN(tst_QTimeZone) #include "main.moc" -- cgit v1.2.3 From 580e9eedf783ccbdcb67baa3d1a9dcdd53922f86 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 17 Mar 2020 18:07:15 +0100 Subject: QDateTimeEdit: with keyboardTracking off, allow values outside the range QDateTimeEdit very aggressively prevents user input that would result in values that are outside the dateTimeRange. While keyboardTracking is on this makes sense, as otherwise the dateTimeChanged signal would be emitted after each section, with a value that is outside the range. However, this prevented users from entering a date that is allowed, but where sections of the date are above or below the respective section in the maximum or minimum value. If keyboardTracking is off, QDateTimeEdit only emits the dateTimeChanged signal at the end of editing, when focus is lost or the return key is pressed, and then it enforces that the value is within the range anyway. This change makes the parser ignore the range during editing if keyboardTracking is off, thus allowing the user to enter a date where temporary values are outside the range. The test makes sure that we don't get signals emitted with out-of-range values, testing both with and without keyboard tracking. Change-Id: I00fb9f1b328a3477163f890c4618b40878657816 Fixes: QTBUG-65 Reviewed-by: Andy Shaw Reviewed-by: Lars Knoll --- .../widgets/qdatetimeedit/tst_qdatetimeedit.cpp | 116 +++++++++++++++++++++ 1 file changed, 116 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp index 4c6cf3588a..6345d238e1 100644 --- a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp +++ b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp @@ -195,6 +195,8 @@ private slots: void specialValueText(); void setRange_data(); void setRange(); + void editingRanged_data(); + void editingRanged(); void selectAndScrollWithKeys(); void backspaceKey(); @@ -1310,6 +1312,120 @@ void tst_QDateTimeEdit::setRange() } } +/* + Test that a user can input a date into a ranged QDateTimeEdit or QDateEdit + where a part of date is larger than the respective part of the maximum, or + smaller than the respective part of the minimum of the range. + + This test is expected to fail unless keyboard tracking of the edit is set + to off. Otherwise the changed-signal would be emitted with values outside + of the allowed range as the user types. +*/ +void tst_QDateTimeEdit::editingRanged_data() +{ + QTest::addColumn("minDate"); + QTest::addColumn("minTime"); + QTest::addColumn("maxDate"); + QTest::addColumn("maxTime"); + QTest::addColumn("userInput"); + QTest::addColumn("expected"); + + QTest::addRow("trivial") + << QDate(2010, 1, 1) << QTime(9, 0) + << QDate(2011, 12, 31) << QTime(16, 0) + << QString::fromLatin1("311220101600") + << QDateTime(QDate(2010, 12, 31), QTime(16, 0)); + + QTest::addRow("data0") + << QDate(2010, 12, 30) << QTime(16, 0) + << QDate(2011, 1, 2) << QTime(9, 0) + << QString::fromLatin1("311220102359") + << QDateTime(QDate(2010, 12, 31), QTime(23, 59)); + + QTest::addRow("data1") + << QDate(2010, 12, 30) << QTime(16, 0) + << QDate(2011, 1, 2) << QTime(9, 0) + << QString::fromLatin1("010120111823") + << QDateTime(QDate(2011, 1, 1), QTime(18, 23)); + + QTest::addRow("Out of range") + << QDate(2010, 12, 30) << QTime(16, 0) + << QDate(2011, 1, 2) << QTime(9, 0) + << QString::fromLatin1("090920111823") + << QDateTime(QDate(2011, 1, 2), QTime(9, 0)); + + QTest::addRow("only date") + << QDate(2010, 12, 30) << QTime() + << QDate(2011, 1, 2) << QTime() + << QString::fromLatin1("01012011") + << QDateTime(QDate(2011, 1, 1), QTime()); +} + +void tst_QDateTimeEdit::editingRanged() +{ + QFETCH(QDate, minDate); + QFETCH(QTime, minTime); + QFETCH(QDate, maxDate); + QFETCH(QTime, maxTime); + QFETCH(QString, userInput); + QFETCH(QDateTime, expected); + + QDateTimeEdit *edit; + if (minTime.isValid()) { + edit = new QDateTimeEdit; + edit->setDisplayFormat("dd.MM.yyyy hh:mm"); + edit->setDateTimeRange(QDateTime(minDate, minTime), QDateTime(maxDate, maxTime)); + } else { + edit = new QDateEdit; + edit->setDisplayFormat("dd.MM.yyyy"); + edit->setDateRange(minDate, maxDate); + } + + int callCount = 0; + connect(edit, &QDateTimeEdit::dateTimeChanged, [&](const QDateTime &dateTime) { + ++callCount; + if (minTime.isValid()) { + QVERIFY(dateTime >= QDateTime(minDate, minTime)); + QVERIFY(dateTime <= QDateTime(maxDate, maxTime)); + } else { + QVERIFY(dateTime.date() >= minDate); + QVERIFY(dateTime.date() <= maxDate); + } + }); + + edit->show(); + QApplication::setActiveWindow(edit); + if (!QTest::qWaitForWindowActive(edit)) + QSKIP("Failed to make window active, aborting"); + edit->setFocus(); + + // with keyboard tracking, never get a signal with an out-of-range value + edit->setKeyboardTracking(true); + QTest::keyClicks(edit, userInput); + QTest::keyClick(edit, Qt::Key_Return); + QVERIFY(callCount > 0); + + // QDateTimeEdit blocks these dates from being entered - see QTBUG-65 + QEXPECT_FAIL("data0", "Can't enter this date", Continue); + QEXPECT_FAIL("data1", "Can't enter this date", Continue); + QEXPECT_FAIL("Out of range", "Can't enter this date", Continue); + QEXPECT_FAIL("only date", "Can't enter this date", Continue); + QCOMPARE(edit->dateTime(), expected); + + // reset + edit->clearFocus(); + edit->setFocus(); + callCount = 0; + + edit->setKeyboardTracking(false); + QTest::keyClicks(edit, userInput); + QTest::keyClick(edit, Qt::Key_Return); + QCOMPARE(edit->dateTime(), expected); + QCOMPARE(callCount, 1); + + delete edit; +} + void tst_QDateTimeEdit::wrappingTime_data() { QTest::addColumn("startWithMin"); -- cgit v1.2.3 From 456137066113ac2a85cce8b4e7bcd76193675674 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Tue, 24 Mar 2020 10:33:01 +0100 Subject: More qOverload cleanups in qtbase MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-82605 Change-Id: I1c3c14ed82911ed5483258c11e76f5dd7744fa12 Reviewed-by: Mårten Nordheim --- tests/auto/network/access/http2/tst_http2.cpp | 4 +--- tests/auto/network/ssl/qocsp/tst_qocsp.cpp | 3 +-- tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp | 3 +-- 3 files changed, 3 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/auto/network/access/http2/tst_http2.cpp b/tests/auto/network/access/http2/tst_http2.cpp index 6a07ae78fb..6702f25b16 100644 --- a/tests/auto/network/access/http2/tst_http2.cpp +++ b/tests/auto/network/access/http2/tst_http2.cpp @@ -512,9 +512,7 @@ void tst_Http2::goaway() request.setAttribute(QNetworkRequest::Http2AllowedAttribute, QVariant(true)); replies[i] = manager->get(request); QCOMPARE(replies[i]->error(), QNetworkReply::NoError); - void (QNetworkReply::*errorSignal)(QNetworkReply::NetworkError) = - &QNetworkReply::errorOccurred; - connect(replies[i], errorSignal, this, &tst_Http2::replyFinishedWithError); + connect(replies[i], &QNetworkReply::errorOccurred, this, &tst_Http2::replyFinishedWithError); // Since we're using self-signed certificates, ignore SSL errors: replies[i]->ignoreSslErrors(); } diff --git a/tests/auto/network/ssl/qocsp/tst_qocsp.cpp b/tests/auto/network/ssl/qocsp/tst_qocsp.cpp index edd1c24547..f877dcab2d 100644 --- a/tests/auto/network/ssl/qocsp/tst_qocsp.cpp +++ b/tests/auto/network/ssl/qocsp/tst_qocsp.cpp @@ -410,7 +410,6 @@ private: static QString certDirPath; - void (QSslSocket::*socketErrorSignal)(QAbstractSocket::SocketError) = &QAbstractSocket::errorOccurred; void (QSslSocket::*tlsErrorsSignal)(const QList &) = &QSslSocket::sslErrors; void (QTestEventLoop::*exitLoopSlot)() = &QTestEventLoop::exitLoop; @@ -764,7 +763,7 @@ void tst_QOcsp::setupOcspClient(QSslSocket &clientSocket, const CertificateChain clientSocket.setSslConfiguration(clientConfig); clientSocket.setPeerVerifyName(name); - connect(&clientSocket, socketErrorSignal, &loop, exitLoopSlot); + connect(&clientSocket, &QAbstractSocket::errorOccurred, &loop, exitLoopSlot); connect(&clientSocket, tlsErrorsSignal, &loop, exitLoopSlot); connect(&clientSocket, &QSslSocket::encrypted, &loop, exitLoopSlot); } diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index 23495436eb..2d71bdfc26 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -2552,8 +2552,7 @@ void tst_QSslSocket::closeWhileEmittingSocketError() clientSocket.setSslConfiguration(clientConfig); QSignalSpy socketErrorSpy(&clientSocket, SIGNAL(errorOccurred(QAbstractSocket::SocketError))); - void (QSslSocket::*errorSignal)(QAbstractSocket::SocketError) = &QSslSocket::errorOccurred; - connect(&clientSocket, errorSignal, &handshake, &BrokenPskHandshake::socketError); + connect(&clientSocket, &QSslSocket::errorOccurred, &handshake, &BrokenPskHandshake::socketError); clientSocket.connectToHostEncrypted(QStringLiteral("127.0.0.1"), handshake.serverPort()); // Make sure we have some data buffered so that close will try to flush: -- cgit v1.2.3 From 46ebd11e66f6f3180043a7258b46a1aff79a69f8 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 25 Mar 2020 11:20:28 +0100 Subject: Fix deprecation of QComboBox:::currentIndexChanged(const QString&) Don't introduce another overload with two parameters. Users want a simple signal to connect to, not another overload. Deprecate the currentIndexChanged(QString) overload, usage of that can/should get replaced by currentTextChanged(). This partially reverts commit 11dc7b35c8c3957bd19087a5e3ae7cfc4f1a3343. Change-Id: I5e7d16413f3d62b1a5a7a197f510af2c45cdfa55 Reviewed-by: Vitaly Fanaskov --- .../auto/widgets/widgets/qcombobox/tst_qcombobox.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index c5be8a3f16..c934f8e27b 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -1208,7 +1208,8 @@ void tst_QComboBox::currentIndex() QVERIFY(testWidget->currentText().isEmpty()); // spy on currentIndexChanged - QSignalSpy indexChangedSpy(testWidget, SIGNAL(currentIndexChanged(int, QString))); + QSignalSpy indexChangedInt(testWidget, SIGNAL(currentIndexChanged(int))); + QSignalSpy indexChangedString(testWidget, SIGNAL(currentIndexChanged(QString))); // stuff items into it foreach(QString text, initialItems) { @@ -1232,12 +1233,16 @@ void tst_QComboBox::currentIndex() QCOMPARE(testWidget->currentText(), expectedCurrentText); // check that signal count is correct - QCOMPARE(indexChangedSpy.count(), expectedSignalCount); + QCOMPARE(indexChangedInt.count(), expectedSignalCount); + QCOMPARE(indexChangedString.count(), expectedSignalCount); // compare with last sent signal values - if (indexChangedSpy.count()) - QCOMPARE(indexChangedSpy.at(indexChangedSpy.count() - 1).at(0).toInt(), - testWidget->currentIndex()); + if (indexChangedInt.count()) + QCOMPARE(indexChangedInt.at(indexChangedInt.count() - 1).at(0).toInt(), + testWidget->currentIndex()); + if (indexChangedString.count()) + QCOMPARE(indexChangedString.at(indexChangedString.count() - 1).at(0).toString(), + testWidget->currentText()); if (edit) { testWidget->setCurrentIndex(-1); @@ -2336,8 +2341,7 @@ public: { QStringList list; list << "one" << "two"; - connect(this, SIGNAL(currentIndexChanged(int, QString)), - this, SLOT(onCurrentIndexChanged(int))); + connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(onCurrentIndexChanged(int))); addItems(list); } public slots: @@ -2763,7 +2767,7 @@ void tst_QComboBox::resetModel() }; QComboBox cb; StringListModel model({"1", "2"}); - QSignalSpy spy(&cb, QOverload::of(&QComboBox::currentIndexChanged)); + QSignalSpy spy(&cb, QOverload::of(&QComboBox::currentIndexChanged)); QCOMPARE(spy.count(), 0); QCOMPARE(cb.currentIndex(), -1); //no selection -- cgit v1.2.3 From cc333f5faf2fa892ca0e321915263cab5d793191 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 28 Jan 2020 11:46:16 +0100 Subject: Diaglib: Fix build Use range-based for and fix deprecation warnings. Change-Id: I54152b2598e9e4a7a3cc9db9b7072bbabcef7fcf Reviewed-by: Shawn Rutledge --- tests/manual/diaglib/debugproxystyle.cpp | 2 +- tests/manual/diaglib/nativewindowdump_win.cpp | 10 +++++----- tests/manual/diaglib/qwidgetdump.cpp | 10 +++++----- tests/manual/diaglib/qwindowdump.cpp | 10 +++++----- tests/manual/diaglib/textdump.cpp | 6 +++--- 5 files changed, 19 insertions(+), 19 deletions(-) (limited to 'tests') diff --git a/tests/manual/diaglib/debugproxystyle.cpp b/tests/manual/diaglib/debugproxystyle.cpp index ed35af5962..73e9e7ce54 100644 --- a/tests/manual/diaglib/debugproxystyle.cpp +++ b/tests/manual/diaglib/debugproxystyle.cpp @@ -69,7 +69,7 @@ QDebug operator<<(QDebug debug, const QStyleOption *option) debug << "QStyleOption("; } debug << "rect=" << option->rect.width() << 'x' << option->rect.height() - << forcesign << option->rect.x() << option->rect.y() << noforcesign; + << Qt::forcesign << option->rect.x() << option->rect.y() << Qt::noforcesign; if (option->state != QStyle::State_None) debug << ", state=" << option->state; #if QT_VERSION >= 0x050000 diff --git a/tests/manual/diaglib/nativewindowdump_win.cpp b/tests/manual/diaglib/nativewindowdump_win.cpp index d91e673d1c..256142462f 100644 --- a/tests/manual/diaglib/nativewindowdump_win.cpp +++ b/tests/manual/diaglib/nativewindowdump_win.cpp @@ -69,7 +69,7 @@ static QTextStream &operator<<(QTextStream &str, const QSize &s) static QTextStream &operator<<(QTextStream &str, const QRect &rect) { - str << rect.size() << forcesign << rect.x() << rect.y() << noforcesign; + str << rect.size() << Qt::forcesign << rect.x() << rect.y() << Qt::noforcesign; return str; } @@ -110,7 +110,7 @@ static bool isTopLevel(HWND hwnd) static void formatNativeWindow(HWND hwnd, QTextStream &str) { - str << hex << showbase << quintptr(hwnd) << noshowbase << dec; + str << Qt::hex << Qt::showbase << quintptr(hwnd) << Qt::noshowbase << Qt::dec; const bool topLevel = isTopLevel(hwnd); if (topLevel) @@ -136,7 +136,7 @@ static void formatNativeWindow(HWND hwnd, QTextStream &str) if (GetClassName(hwnd, buf, sizeof(buf)/sizeof(buf[0]))) str << '"' << QString::fromWCharArray(buf) << '"'; - str << hex << showbase; + str << Qt::hex << Qt::showbase; if (const LONG_PTR style = GetWindowLongPtr(hwnd, GWL_STYLE)) { str << " style=" << style; debugWinStyle(str, style, WS_OVERLAPPED) @@ -208,7 +208,7 @@ static void formatNativeWindow(HWND hwnd, QTextStream &str) if (const ULONG_PTR wndProc = GetClassLongPtr(hwnd, GCLP_WNDPROC)) str << " wndProc=" << wndProc; - str << noshowbase << dec; + str << Qt::noshowbase << Qt::dec; if (GetWindowModuleFileName(hwnd, buf, sizeof(buf)/sizeof(buf[0]))) str << " module=\"" << QString::fromWCharArray(buf) << '"'; @@ -258,7 +258,7 @@ static void dumpNativeWindows(const WIdVector& wins) DumpContext dc; QString s; dc.stream = QSharedPointer(new QTextStream(&s)); - foreach (WId win, wins) + for (WId win : wins) dumpNativeWindowRecursion(reinterpret_cast(win), &dc); #if QT_VERSION >= 0x050400 qDebug().noquote() << s; diff --git a/tests/manual/diaglib/qwidgetdump.cpp b/tests/manual/diaglib/qwidgetdump.cpp index 5a2966021b..9e175cd3cf 100644 --- a/tests/manual/diaglib/qwidgetdump.cpp +++ b/tests/manual/diaglib/qwidgetdump.cpp @@ -86,14 +86,14 @@ static void dumpWidgetRecursion(QTextStream &str, const QWidget *w, formatWidgetClass(str, w); str << ' ' << (w->isVisible() ? "[visible] " : "[hidden] "); if (const WId nativeWinId = w->internalWinId()) - str << "[native: " << hex << showbase << nativeWinId << dec << noshowbase << "] "; + str << "[native: " << Qt::hex << Qt::showbase << nativeWinId << Qt::dec << Qt::noshowbase << "] "; if (w->isWindow()) str << "[top] "; str << (w->testAttribute(Qt::WA_Mapped) ? "[mapped] " : "[not mapped] "); if (w->testAttribute(Qt::WA_DontCreateNativeAncestors)) str << "[NoNativeAncestors] "; if (const int states = w->windowState()) - str << "windowState=" << hex << showbase << states << dec << noshowbase << ' '; + str << "windowState=" << Qt::hex << Qt::showbase << states << Qt::dec << Qt::noshowbase << ' '; formatRect(str, w->geometry()); if (w->isWindow()) { str << ' ' << w->logicalDpiX() << "DPI"; @@ -135,7 +135,7 @@ static void dumpWidgetRecursion(QTextStream &str, const QWidget *w, str << '\n'; } #endif // Qt 5 - foreach (const QObject *co, w->children()) { + for (const QObject *co : w->children()) { if (co->isWidgetType()) dumpWidgetRecursion(str, static_cast(co), options, depth + 1); } @@ -151,11 +151,11 @@ void dumpAllWidgets(FormatWindowOptions options, const QWidget *root) topLevels.append(const_cast(root)); else topLevels = QApplication::topLevelWidgets(); - foreach (QWidget *tw, topLevels) + for (QWidget *tw : qAsConst(topLevels)) dumpWidgetRecursion(str, tw, options); #if QT_VERSION >= 0x050400 { - foreach (const QString &line, d.split(QLatin1Char('\n'))) + for (const QString &line : d.split(QLatin1Char('\n'))) qDebug().noquote() << line; } #else diff --git a/tests/manual/diaglib/qwindowdump.cpp b/tests/manual/diaglib/qwindowdump.cpp index 381b683359..83e29fc183 100644 --- a/tests/manual/diaglib/qwindowdump.cpp +++ b/tests/manual/diaglib/qwindowdump.cpp @@ -62,7 +62,7 @@ void formatObject(QTextStream &str, const QObject *o) void formatRect(QTextStream &str, const QRect &geom) { str << geom.width() << 'x' << geom.height() - << forcesign << geom.x() << geom.y() << noforcesign; + << Qt::forcesign << geom.x() << geom.y() << Qt::noforcesign; } #define debugType(s, type, typeConstant) \ @@ -75,7 +75,7 @@ if (flags & flagConstant) \ void formatWindowFlags(QTextStream &str, Qt::WindowFlags flags) { - str << showbase << hex << unsigned(flags) << dec << noshowbase; + str << Qt::showbase << Qt::hex << unsigned(flags) << Qt::dec << Qt::noshowbase; const Qt::WindowFlags windowType = flags & Qt::WindowType_Mask; debugFlag(str, flags, Qt::Window) debugType(str, windowType, Qt::Dialog) @@ -123,7 +123,7 @@ void formatWindow(QTextStream &str, const QWindow *w, FormatWindowOptions option formatObject(str, w); str << ' ' << (w->isVisible() ? "[visible] " : "[hidden] "); if (const WId nativeWinId = pw ? pw->winId() : WId(0)) - str << "[native: " << hex << showbase << nativeWinId << dec << noshowbase << "] "; + str << "[native: " << Qt::hex << Qt::showbase << nativeWinId << Qt::dec << Qt::noshowbase << "] "; if (w->isTopLevel()) str << "[top] "; if (w->isExposed()) @@ -162,7 +162,7 @@ static void dumpWindowRecursion(QTextStream &str, const QWindow *w, { indentStream(str, 2 * depth); formatWindow(str, w, options); - foreach (const QObject *co, w->children()) { + for (const QObject *co : w->children()) { if (co->isWindowType()) dumpWindowRecursion(str, static_cast(co), options, depth + 1); } @@ -173,7 +173,7 @@ void dumpAllWindows(FormatWindowOptions options) QString d; QTextStream str(&d); str << "### QWindows:\n"; - foreach (QWindow *w, QGuiApplication::topLevelWindows()) + for (QWindow *w : QGuiApplication::topLevelWindows()) dumpWindowRecursion(str, w, options); #if QT_VERSION >= 0x050400 qDebug().noquote() << d; diff --git a/tests/manual/diaglib/textdump.cpp b/tests/manual/diaglib/textdump.cpp index 383ec4edb0..61fb494785 100644 --- a/tests/manual/diaglib/textdump.cpp +++ b/tests/manual/diaglib/textdump.cpp @@ -408,8 +408,8 @@ struct FormattingContext static void formatCharacter(QTextStream &str, const QChar &qc, FormattingContext &context) { const ushort unicode = qc.unicode(); - str << "U+" << qSetFieldWidth(4) << qSetPadChar('0') << uppercasedigits << hex << unicode - << dec << qSetFieldWidth(0) << ' '; + str << "U+" << qSetFieldWidth(4) << qSetPadChar('0') << Qt::uppercasedigits + << Qt::hex << unicode << Qt::dec << qSetFieldWidth(0) << ' '; const EnumLookup *specialChar = enumLookup(unicode, specialCharactersEnumLookup, sizeof(specialCharactersEnumLookup) / sizeof(EnumLookup)); if (specialChar) @@ -477,7 +477,7 @@ QString dumpTextAsCode(const QString &text) { QString result; QTextStream str(&result); - str << " QString result;\n" << hex << showbase; + str << " QString result;\n" << Qt::hex << Qt::showbase; for (QChar c : text) str << " result += QChar(" << c.unicode() << ");\n"; str << '\n'; -- cgit v1.2.3 From b1e3f33a28aad1d9386ff2ef569db90341a8d68a Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Thu, 12 Mar 2020 17:07:08 +0100 Subject: Call post routines from ~QGuiApplication MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently depending if user uses QApplication or QGuiApplication we end up in different behavior when running post routines. For example QApplication destructor calls post routines before stopping event dispatcher, In case of QGuiApplication post routines are called from QCoreApplication destructor, so no more event dispatcher. This behavior is not consistent and creates troubles when releasing resources of web engine. Attached test will hang on windows with QGuiApplication, however works fine with QApplication. Task-number: QTBUG-79864 Change-Id: Ice05e66a467feaf3ad6addfbc14973649da8065e Reviewed-by: Tor Arne Vestbø --- tests/auto/gui/kernel/kernel.pro | 3 +- .../gui/kernel/qaddpostroutine/qaddpostroutine.pro | 7 +++ .../kernel/qaddpostroutine/tst_qaddpostroutine.cpp | 66 ++++++++++++++++++++++ 3 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 tests/auto/gui/kernel/qaddpostroutine/qaddpostroutine.pro create mode 100644 tests/auto/gui/kernel/qaddpostroutine/tst_qaddpostroutine.cpp (limited to 'tests') diff --git a/tests/auto/gui/kernel/kernel.pro b/tests/auto/gui/kernel/kernel.pro index 42135dae24..3187ea3720 100644 --- a/tests/auto/gui/kernel/kernel.pro +++ b/tests/auto/gui/kernel/kernel.pro @@ -25,7 +25,8 @@ SUBDIRS=\ qguiapplication \ qpixelformat \ qopenglwindow \ - qrasterwindow + qrasterwindow \ + qaddpostroutine win32:!winrt:qtHaveModule(network): SUBDIRS += noqteventloop diff --git a/tests/auto/gui/kernel/qaddpostroutine/qaddpostroutine.pro b/tests/auto/gui/kernel/qaddpostroutine/qaddpostroutine.pro new file mode 100644 index 0000000000..e67720b5d5 --- /dev/null +++ b/tests/auto/gui/kernel/qaddpostroutine/qaddpostroutine.pro @@ -0,0 +1,7 @@ +CONFIG += testcase +TARGET = tst_qaddpostroutine + +QT += testlib + +SOURCES += tst_qaddpostroutine.cpp + diff --git a/tests/auto/gui/kernel/qaddpostroutine/tst_qaddpostroutine.cpp b/tests/auto/gui/kernel/qaddpostroutine/tst_qaddpostroutine.cpp new file mode 100644 index 0000000000..500543d2e1 --- /dev/null +++ b/tests/auto/gui/kernel/qaddpostroutine/tst_qaddpostroutine.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** 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 +#include + +static bool done = false; + +static void cleanup() +{ + done = true; + QEventLoop loop; + QTimer::singleShot(100,&loop, &QEventLoop::quit); + loop.exec(); +} + +struct tst_qAddPostRoutine : public QObject +{ +public: + tst_qAddPostRoutine(); + ~tst_qAddPostRoutine(); +}; + +tst_qAddPostRoutine::tst_qAddPostRoutine() +{ + qAddPostRoutine(cleanup); +} + +tst_qAddPostRoutine::~tst_qAddPostRoutine() +{ + Q_ASSERT(done); +} +int main(int argc, char *argv[]) +{ + tst_qAddPostRoutine tc; + QGuiApplication app(argc, argv); + app.setAttribute(Qt::AA_Use96Dpi, true); + QTEST_SET_MAIN_SOURCE_PATH + return QTest::qExec(&tc, argc, argv); +} -- cgit v1.2.3 From 2b9137426182fb0e0c3ef37cfa8dec0762ad52b4 Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Wed, 25 Mar 2020 10:04:55 +0100 Subject: Fuzzing: Add fuzz target for QRegularExpression::optimize Change-Id: I693af83caed60cdffc83af368a15567d72524844 Reviewed-by: Albert Astals Cid Reviewed-by: Shawn Rutledge --- .../text/qregularexpression/optimize/main.cpp | 35 ++++++++++++++++++++++ .../text/qregularexpression/optimize/optimize.pro | 8 +++++ 2 files changed, 43 insertions(+) create mode 100644 tests/libfuzzer/corelib/text/qregularexpression/optimize/main.cpp create mode 100644 tests/libfuzzer/corelib/text/qregularexpression/optimize/optimize.pro (limited to 'tests') diff --git a/tests/libfuzzer/corelib/text/qregularexpression/optimize/main.cpp b/tests/libfuzzer/corelib/text/qregularexpression/optimize/main.cpp new file mode 100644 index 0000000000..30a714c250 --- /dev/null +++ b/tests/libfuzzer/corelib/text/qregularexpression/optimize/main.cpp @@ -0,0 +1,35 @@ +/**************************************************************************** +** +** 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 + +extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size) { + QRegularExpression qre(QByteArray::fromRawData(Data, Size)); + qre.optimize(); + return 0; +} diff --git a/tests/libfuzzer/corelib/text/qregularexpression/optimize/optimize.pro b/tests/libfuzzer/corelib/text/qregularexpression/optimize/optimize.pro new file mode 100644 index 0000000000..196aca42eb --- /dev/null +++ b/tests/libfuzzer/corelib/text/qregularexpression/optimize/optimize.pro @@ -0,0 +1,8 @@ +QT -= gui +SOURCES += main.cpp +FUZZ_ENGINE = $$(LIB_FUZZING_ENGINE) +isEmpty(FUZZ_ENGINE) { + QMAKE_LFLAGS += -fsanitize=fuzzer +} else { + LIBS += $$FUZZ_ENGINE +} -- cgit v1.2.3 From ba5e2ce49a43c7d68e2ffa57b9e7f8d5d7fafe2f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 21 Feb 2020 20:40:35 -0800 Subject: forkfd: fix forkfd_wait when FFD_USE_FORK was active If we detected that the OS supports a version of system forkfd (Linux pidfd, FreeBSD procdesc), the forkfd_wait() function was using only the system waiting implementation, which of course can't work for file descriptors created with FFD_USE_FORK. So just detect EBADF and attempt again. If the file descriptor is neither one of our pipes nor a system forkfd, bad things will happen... Fixes: QTBUG-82351 Change-Id: I4e559af2a9a1455ab770fffd15f59fb3160b22eb Reviewed-by: Edward Welbourne Reviewed-by: Oswald Buddenhagen --- tests/auto/corelib/io/qprocess/tst_qprocess.cpp | 56 ++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index 3de1bef789..9495631c23 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2016 Intel Corporation. +** Copyright (C) 2020 The Qt Company Ltd. +** Copyright (C) 2020 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -40,6 +40,12 @@ #include #include #include + +#include +#ifdef Q_OS_UNIX +# include +#endif + #include typedef void (QProcess::*QProcessFinishedSignal1)(int); @@ -59,6 +65,7 @@ private slots: void getSetCheck(); void constructing(); void simpleStart(); + void setupChildProcess(); void startWithOpen(); void startWithOldOpen(); void execute(); @@ -277,6 +284,51 @@ void tst_QProcess::simpleStart() QCOMPARE(qvariant_cast(spy.at(2).at(0)), QProcess::NotRunning); } +void tst_QProcess::setupChildProcess() +{ + /* This test exists because in Qt 5.15, the Unix version of QProcess has + * some code that depends on whether it's an actual QProcess or a + * derived class */ + static const char setupChildMessage[] = "Called from setupChildProcess()"; + class DerivedProcessClass : public QProcess { + public: + int fd; + DerivedProcessClass(int fd) : fd(fd) + { + } + + protected: + void setupChildProcess() override + { + QT_WRITE(fd, setupChildMessage, sizeof(setupChildMessage) - 1); + QT_CLOSE(fd); + } + }; + + int pipes[2] = { -1 , -1 }; +#ifdef Q_OS_UNIX + QVERIFY(qt_safe_pipe(pipes) == 0); +#endif + + DerivedProcessClass process(pipes[1]); + process.start("testProcessNormal/testProcessNormal"); + if (process.state() != QProcess::Starting) + QCOMPARE(process.state(), QProcess::Running); + QVERIFY2(process.waitForStarted(5000), qPrintable(process.errorString())); + +#ifdef Q_OS_UNIX + char buf[sizeof setupChildMessage] = {}; + qt_safe_close(pipes[1]); + QCOMPARE(qt_safe_read(pipes[0], buf, sizeof(buf)), qint64(sizeof(setupChildMessage) - 1)); + QCOMPARE(buf, setupChildMessage); + qt_safe_close(pipes[0]); +#endif + + QVERIFY2(process.waitForFinished(5000), qPrintable(process.errorString())); + QCOMPARE(process.exitStatus(), QProcess::NormalExit); + QCOMPARE(process.exitCode(), 0); +} + void tst_QProcess::startWithOpen() { QProcess p; -- cgit v1.2.3 From 02d595946faa7a21f6aa4109227f7e90db20ae7a Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 7 Mar 2020 07:38:51 -0800 Subject: QCborValue::fromCbor: Apply a recursion limit to decoding A simple 16k file can produce deep enough recursion in Qt to cause stack overflow. So prevent that. I tested 4096 recursions just fine on my Linux system (8 MB stack), but decided 1024 was sufficient, as this code will also be run on embedded systems that could have smaller stacks. [ChangeLog][QtCore][QCborValue] fromCbor() now limits decoding to at most 1024 nested maps, arrays, and tags to prevent stack overflows. This should be sufficient for most uses of CBOR. An API to limit further or to relax the limit will be provided in 5.15. Meanwhile, if decoding more is required, QCborStreamReader can be used (note that each level of map and array allocates memory). Change-Id: Iaa63461109844e978376fffd15fa0fbefbf607a2 Reviewed-by: Lars Knoll --- .../serialization/qcborvalue/tst_qcborvalue.cpp | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp index d5a9012f9f..49bb9cc144 100644 --- a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp +++ b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp @@ -102,6 +102,8 @@ private slots: void fromCborStreamReaderIODevice(); void validation_data(); void validation(); + void recursionLimit_data(); + void recursionLimit(); void toDiagnosticNotation_data(); void toDiagnosticNotation(); @@ -1720,6 +1722,58 @@ void tst_QCborValue::validation() } } +void tst_QCborValue::recursionLimit_data() +{ + constexpr int RecursionAttempts = 4096; + QTest::addColumn("data"); + QByteArray arrays(RecursionAttempts, char(0x81)); + QByteArray _arrays(RecursionAttempts, char(0x9f)); + QByteArray maps(RecursionAttempts, char(0xa1)); + QByteArray _maps(RecursionAttempts, char(0xbf)); + QByteArray tags(RecursionAttempts, char(0xc0)); + + QTest::newRow("array-nesting-too-deep") << arrays; + QTest::newRow("_array-nesting-too-deep") << _arrays; + QTest::newRow("map-nesting-too-deep") << maps; + QTest::newRow("_map-nesting-too-deep") << _maps; + QTest::newRow("tag-nesting-too-deep") << tags; + + QByteArray mixed(5 * RecursionAttempts, Qt::Uninitialized); + char *ptr = mixed.data(); + for (int i = 0; i < RecursionAttempts; ++i) { + quint8 type = qBound(quint8(QCborStreamReader::Array), quint8(i & 0x80), quint8(QCborStreamReader::Tag)); + quint8 additional_info = i & 0x1f; + if (additional_info == 0x1f) + (void)additional_info; // leave it + else if (additional_info > 0x1a) + additional_info = 0x1a; + else if (additional_info < 1) + additional_info = 1; + + *ptr++ = type | additional_info; + if (additional_info == 0x18) { + *ptr++ = uchar(i); + } else if (additional_info == 0x19) { + qToBigEndian(ushort(i), ptr); + ptr += 2; + } else if (additional_info == 0x1a) { + qToBigEndian(uint(i), ptr); + ptr += 4; + } + } + + QTest::newRow("mixed-nesting-too-deep") << mixed; +} + +void tst_QCborValue::recursionLimit() +{ + QFETCH(QByteArray, data); + + QCborParserError error; + QCborValue decoded = QCborValue::fromCbor(data, &error); + QCOMPARE(error.error, QCborError::NestingTooDeep); +} + void tst_QCborValue::toDiagnosticNotation_data() { QTest::addColumn("v"); -- cgit v1.2.3 From f22c929c8a1e9575ba9f99acdbb061e12d4da4a2 Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Tue, 17 Mar 2020 16:40:34 +0100 Subject: Make tst_QRandomGenerator::qualityReal() test more stable Increasing the sample size of randomly generated test samples reduces the probability of small deviations from the expected uniform distribution. On my machine with the new values the test fails approximately once per 3000 consecutive runs, instead of failing once per 300. Change-Id: I4d1815504c353290a2fb350b3fd1cbb802f8d559 Reviewed-by: Lars Knoll Reviewed-by: Thiago Macieira --- tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp b/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp index 6f9dcc08f9..5bbde1ef09 100644 --- a/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp +++ b/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp @@ -671,7 +671,7 @@ void tst_QRandomGenerator::qualityReal() RandomGenerator rng(control); enum { - SampleSize = 160, + SampleSize = 16000, // Expected value: sample size times proportion of the range: PerfectOctile = SampleSize / 8, @@ -679,8 +679,8 @@ void tst_QRandomGenerator::qualityReal() // Variance is (1 - proportion of range) * expected; sqrt() for standard deviations. // Should usually be within twice that and almost never outside four times: - RangeHalf = 25, // floor(4 * sqrt((1 - 0.5) * PerfectHalf)) - RangeOctile = 16 // floor(4 * sqrt((1 - 0.125) * PerfectOctile)) + RangeHalf = 252, // floor(4 * sqrt((1 - 0.5) * PerfectHalf)) + RangeOctile = 167 // floor(4 * sqrt((1 - 0.125) * PerfectOctile)) }; double data[SampleSize]; -- cgit v1.2.3 From 533f7d7ca328e81804c8f52818f9d39172694f94 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Fri, 27 Mar 2020 09:41:03 +0100 Subject: Raster painting: fix dashing for separate lines When drawing multiple distinct (unconnected) lines (e.g. from QPainter::drawLines() or a QPainterPath with alternating movetos/linetos), the dash pattern should not continue from one to the next, as it should when drawing a connected line (e.g. polyline). Both the cosmetic stroker and the full stroker does it right, but the fast rasterizing codepath got it wrong. Fixes: QTBUG-83048 Change-Id: I3d090f7121726755a0e53cb66b99a5563ac0e1c0 Reviewed-by: Allan Sandfeld Jensen --- tests/auto/other/lancelot/scripts/linedashes.qps | 40 +++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/other/lancelot/scripts/linedashes.qps b/tests/auto/other/lancelot/scripts/linedashes.qps index ee7d18b156..78c791e68b 100644 --- a/tests/auto/other/lancelot/scripts/linedashes.qps +++ b/tests/auto/other/lancelot/scripts/linedashes.qps @@ -91,4 +91,42 @@ translate 100 0 repeat_block draw_lines setPen 0xffff0000 0 dashline squarecap translate 100 0 -repeat_block draw_lines \ No newline at end of file +repeat_block draw_lines + +path_moveTo mypath 10 10 +path_lineTo mypath 87 10 +path_moveTo mypath 10 30 +path_lineTo mypath 87 30 +path_moveTo mypath 10 50 +path_lineTo mypath 87 50 + +resetMatrix +translate 0 150 + +begin_block distinctLines + +setPen black 0 SolidLine SquareCap +pen_setDashPattern [ 3 3 ] +drawPath mypath + +translate 100 0 +setPen black 5 SolidLine SquareCap +pen_setDashPattern [ 3 3 ] +drawPath mypath + +translate 100 0 +setPen black 0 SolidLine RoundCap +pen_setDashPattern [ 3 3 ] +drawPath mypath + +translate 100 0 +setPen black 5 SolidLine RoundCap +pen_setDashPattern [ 3 3 ] +drawPath mypath + +end_block distinctLines + +resetMatrix +translate 0 220 +setRenderHint Antialiasing true +repeat_block distinctLines -- cgit v1.2.3 From 783d574b932288b61f915b28d5b7b9c5a979f58e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 6 Mar 2020 13:38:17 -0800 Subject: CBOR support: prevent overflowing QByteArray's max allocation QByteArray doesn't like it. Apply the same protection to QString, which we know uses the same backend but uses elements twice as big. That means it can contain slightly more than half as many elements, but exact half will suffice for our needs. Change-Id: Iaa63461109844e978376fffd15f9d4c7a9137856 Reviewed-by: Edward Welbourne --- .../serialization/cborlargedatavalidation.cpp | 134 +++++++++++++++++++++ .../qcborstreamreader/qcborstreamreader.pro | 2 +- .../qcborstreamreader/tst_qcborstreamreader.cpp | 49 +++++++- .../serialization/qcborvalue/qcborvalue.pro | 2 +- .../serialization/qcborvalue/tst_qcborvalue.cpp | 52 ++++++-- 5 files changed, 223 insertions(+), 16 deletions(-) create mode 100644 tests/auto/corelib/serialization/cborlargedatavalidation.cpp (limited to 'tests') diff --git a/tests/auto/corelib/serialization/cborlargedatavalidation.cpp b/tests/auto/corelib/serialization/cborlargedatavalidation.cpp new file mode 100644 index 0000000000..9abfe0f575 --- /dev/null +++ b/tests/auto/corelib/serialization/cborlargedatavalidation.cpp @@ -0,0 +1,134 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Intel Corporation. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** 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-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +namespace { +// A QIODevice that supplies a fixed header followed by a large sequence of +// null bytes up until a pre-determined size. +class LargeIODevice final : public QIODevice +{ +public: + qint64 realSize; + QByteArray start; + + LargeIODevice(const QByteArray &start, qint64 size, QObject *parent = nullptr) + : QIODevice(parent), realSize(size), start(start) + {} + + qint64 size() const override { return realSize; } + bool isSequential() const override { return false; } + +protected: + qint64 readData(char *data, qint64 maxlen) override; + qint64 writeData(const char *, qint64) override { return -1; } +}; +}; + +qint64 LargeIODevice::readData(char *data, qint64 maxlen) +{ + qint64 p = pos(); + if (maxlen > realSize - p) + maxlen = realSize - p; + memset(data, '\0', maxlen); + + qint64 fromstart = start.size() - p; + if (fromstart > maxlen) + fromstart = maxlen; + else if (fromstart < 0) + fromstart = 0; + if (fromstart) + memcpy(data, start.constData() + p, fromstart); + return maxlen; +} + +void addValidationLargeData(qsizetype minInvalid, qsizetype maxInvalid) +{ + char toolong[2 + sizeof(qsizetype)] = { char(0x81) }; + for (qsizetype v = maxInvalid; v >= minInvalid; --v) { + // 0x5a for 32-bit, 0x5b for 64-bit + toolong[1] = sizeof(v) > 4 ? 0x5b : 0x5a; + qToBigEndian(v, toolong + 2); + + QTest::addRow("bytearray-too-big-for-qbytearray-%llx", v) + << QByteArray(toolong, sizeof(toolong)) << 0 << CborErrorDataTooLarge; + toolong[1] |= 0x20; + + // QCborStreamReader::readString copies to a QByteArray first + QTest::addRow("string-too-big-for-qbytearray-%llx", v) + << QByteArray(toolong, sizeof(toolong)) << 0 << CborErrorDataTooLarge; + } +} + +void addValidationHugeDevice(qsizetype byteArrayInvalid, qsizetype stringInvalid) +{ + qRegisterMetaType>(); + QTest::addColumn>("device"); + QTest::addColumn("expectedError"); + + char buf[1 + sizeof(quint64)]; + auto device = [&buf](QCborStreamReader::Type t, quint64 size) { + buf[0] = quint8(t) | 0x1b; + qToBigEndian(size, buf + 1); + size += sizeof(buf); + QSharedPointer p = + QSharedPointer::create(QByteArray(buf, sizeof(buf)), size); + return p; + }; + + // do the exact limits + QTest::newRow("bytearray-just-too-big") + << device(QCborStreamReader::ByteArray, byteArrayInvalid) << CborErrorDataTooLarge; + QTest::newRow("string-just-too-big") + << device(QCborStreamReader::String, stringInvalid) << CborErrorDataTooLarge; + + auto addSize = [=](const char *sizename, qint64 size) { + if (byteArrayInvalid < size) + QTest::addRow("bytearray-%s", sizename) + << device(QCborStreamReader::ByteArray, size) << CborErrorDataTooLarge; + if (stringInvalid < size) + QTest::addRow("string-%s", sizename) + << device(QCborStreamReader::String, size) << CborErrorDataTooLarge; + }; + addSize("1GB", quint64(1) << 30); + addSize("2GB", quint64(1) << 31); + addSize("4GB", quint64(1) << 32); + addSize("max", std::numeric_limits::max() - sizeof(buf)); +} diff --git a/tests/auto/corelib/serialization/qcborstreamreader/qcborstreamreader.pro b/tests/auto/corelib/serialization/qcborstreamreader/qcborstreamreader.pro index 5df331314a..b758de1a9e 100644 --- a/tests/auto/corelib/serialization/qcborstreamreader/qcborstreamreader.pro +++ b/tests/auto/corelib/serialization/qcborstreamreader/qcborstreamreader.pro @@ -1,4 +1,4 @@ -QT = core testlib +QT = core-private testlib TARGET = tst_qcborstreamreader CONFIG += testcase SOURCES += \ diff --git a/tests/auto/corelib/serialization/qcborstreamreader/tst_qcborstreamreader.cpp b/tests/auto/corelib/serialization/qcborstreamreader/tst_qcborstreamreader.cpp index 28d29168fb..f969bb9074 100644 --- a/tests/auto/corelib/serialization/qcborstreamreader/tst_qcborstreamreader.cpp +++ b/tests/auto/corelib/serialization/qcborstreamreader/tst_qcborstreamreader.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2018 Intel Corporation. +** Copyright (C) 2020 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -40,6 +40,8 @@ #include #include +#include + class tst_QCborStreamReader : public QObject { Q_OBJECT @@ -73,6 +75,8 @@ private Q_SLOTS: void next(); void validation_data(); void validation(); + void hugeDeviceValidation_data(); + void hugeDeviceValidation(); void recursionLimit_data(); void recursionLimit(); @@ -902,16 +906,26 @@ void tst_QCborStreamReader::next() QVERIFY(doit("\xbf\x9f\1\xff\x9f" + data + "\xff\xff")); } +#include "../cborlargedatavalidation.cpp" + void tst_QCborStreamReader::validation_data() { + // Add QCborStreamReader-specific limitations due to use of QByteArray and + // QString, which are allocated by QArrayData::allocate(). + const qsizetype MaxInvalid = std::numeric_limits::max(); + const qsizetype MinInvalid = MaxByteArraySize + 1; + addValidationColumns(); - addValidationData(); + addValidationData(MinInvalid); + addValidationLargeData(MinInvalid, MaxInvalid); } void tst_QCborStreamReader::validation() { QFETCH_GLOBAL(bool, useDevice); QFETCH(QByteArray, data); + QFETCH(CborError, expectedError); + QCborError error = { QCborError::Code(expectedError) }; QBuffer buffer(&data); QCborStreamReader reader(data); @@ -920,12 +934,39 @@ void tst_QCborStreamReader::validation() reader.setDevice(&buffer); } parse(reader, data); - QVERIFY(reader.lastError() != QCborError::NoError); + QCOMPARE(reader.lastError(), error); + + // next() should fail + reader.reset(); + QVERIFY(!reader.next()); + QCOMPARE(reader.lastError(), error); +} + +void tst_QCborStreamReader::hugeDeviceValidation_data() +{ + addValidationHugeDevice(MaxByteArraySize + 1, MaxStringSize + 1); +} + +void tst_QCborStreamReader::hugeDeviceValidation() +{ + QFETCH_GLOBAL(bool, useDevice); + if (!useDevice) + return; + + QFETCH(QSharedPointer, device); + QFETCH(CborError, expectedError); + QCborError error = { QCborError::Code(expectedError) }; + + device->open(QIODevice::ReadOnly | QIODevice::Unbuffered); + QCborStreamReader reader(device.data()); + + QVERIFY(parseOne(reader).isEmpty()); + QCOMPARE(reader.lastError(), error); // next() should fail reader.reset(); QVERIFY(!reader.next()); - QVERIFY(reader.lastError() != QCborError::NoError); + QCOMPARE(reader.lastError(), error); } static const int Recursions = 3; diff --git a/tests/auto/corelib/serialization/qcborvalue/qcborvalue.pro b/tests/auto/corelib/serialization/qcborvalue/qcborvalue.pro index 9dd67da1f0..4d01b290f5 100644 --- a/tests/auto/corelib/serialization/qcborvalue/qcborvalue.pro +++ b/tests/auto/corelib/serialization/qcborvalue/qcborvalue.pro @@ -1,4 +1,4 @@ -QT = core testlib +QT = core-private testlib TARGET = tst_qcborvalue CONFIG += testcase SOURCES += \ diff --git a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp index 49bb9cc144..488771d059 100644 --- a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp +++ b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2018 Intel Corporation. +** Copyright (C) 2020 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -40,6 +40,8 @@ #include #include +#include + Q_DECLARE_METATYPE(QCborKnownTags) Q_DECLARE_METATYPE(QCborValue) Q_DECLARE_METATYPE(QCborValue::EncodingOptions) @@ -102,6 +104,8 @@ private slots: void fromCborStreamReaderIODevice(); void validation_data(); void validation(); + void hugeDeviceValidation_data(); + void hugeDeviceValidation(); void recursionLimit_data(); void recursionLimit(); void toDiagnosticNotation_data(); @@ -1689,10 +1693,17 @@ void tst_QCborValue::fromCborStreamReaderIODevice() fromCbor_common(doCheck); } +#include "../cborlargedatavalidation.cpp" + void tst_QCborValue::validation_data() { + // Add QCborStreamReader-specific limitations due to use of QByteArray and + // QString, which are allocated by QArrayData::allocate(). + const qsizetype MaxInvalid = std::numeric_limits::max(); + const qsizetype MinInvalid = MaxByteArraySize + 1; addValidationColumns(); - addValidationData(); + addValidationData(MinInvalid); + addValidationLargeData(MinInvalid, MaxInvalid); // These tests say we have arrays and maps with very large item counts. // They are meant to ensure we don't pre-allocate a lot of memory @@ -1700,28 +1711,49 @@ void tst_QCborValue::validation_data() // elements in the stream is only 2, so we should get an unexpected EOF // error. QCborValue internally uses 16 bytes per element, so we get to // 2 GB at 2^27 elements. - QTest::addRow("very-large-array-no-overflow") << raw("\x9a\x07\xff\xff\xff" "\0\0"); - QTest::addRow("very-large-array-overflow1") << raw("\x9a\x40\0\0\0" "\0\0"); + QTest::addRow("very-large-array-no-overflow") << raw("\x9a\x07\xff\xff\xff" "\0\0") << 0 << CborErrorUnexpectedEOF; + QTest::addRow("very-large-array-overflow1") << raw("\x9a\x40\0\0\0" "\0\0") << 0 << CborErrorUnexpectedEOF; // this makes sure we don't accidentally clip to 32-bit: sending 2^32+2 elements - QTest::addRow("very-large-array-overflow2") << raw("\x9b\0\0\0\1""\0\0\0\2" "\0\0"); + QTest::addRow("very-large-array-overflow2") << raw("\x9b\0\0\0\1""\0\0\0\2" "\0\0") << 0 << CborErrorDataTooLarge; } void tst_QCborValue::validation() { QFETCH(QByteArray, data); + QFETCH(CborError, expectedError); + QCborError error = { QCborError::Code(expectedError) }; - QCborParserError error; - QCborValue decoded = QCborValue::fromCbor(data, &error); - QVERIFY(error.error != QCborError{}); + QCborParserError parserError; + QCborValue decoded = QCborValue::fromCbor(data, &parserError); + QCOMPARE(parserError.error, error); if (data.startsWith('\x81')) { // decode without the array prefix - decoded = QCborValue::fromCbor(data.mid(1), &error); - QVERIFY(error.error != QCborError{}); + char *ptr = const_cast(data.constData()); + QByteArray mid = QByteArray::fromRawData(ptr + 1, data.size() - 1); + decoded = QCborValue::fromCbor(mid, &parserError); + QCOMPARE(parserError.error, error); } } +void tst_QCborValue::hugeDeviceValidation_data() +{ + addValidationHugeDevice(MaxByteArraySize + 1, MaxStringSize + 1); +} + +void tst_QCborValue::hugeDeviceValidation() +{ + QFETCH(QSharedPointer, device); + QFETCH(CborError, expectedError); + QCborError error = { QCborError::Code(expectedError) }; + + device->open(QIODevice::ReadOnly | QIODevice::Unbuffered); + QCborStreamReader reader(device.data()); + QCborValue decoded = QCborValue::fromCbor(reader); + QCOMPARE(reader.lastError(), error); +} + void tst_QCborValue::recursionLimit_data() { constexpr int RecursionAttempts = 4096; -- cgit v1.2.3 From bff56f953adc8ce743aa774d6ad09725d8b9bc45 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 20 Mar 2020 17:55:31 -0300 Subject: tst_QCborValue: Prepare for 64-bit QVectors in Qt 6 Change-Id: Ief61acdfbe4d4b5ba1f0fffd15fe1e921aab0a72 Reviewed-by: Lars Knoll --- .../serialization/qcborvalue/tst_qcborvalue.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp index 488771d059..6d8161c1f9 100644 --- a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp +++ b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp @@ -1709,13 +1709,21 @@ void tst_QCborValue::validation_data() // They are meant to ensure we don't pre-allocate a lot of memory // unnecessarily and possibly crash the application. The actual number of // elements in the stream is only 2, so we should get an unexpected EOF - // error. QCborValue internally uses 16 bytes per element, so we get to - // 2 GB at 2^27 elements. - QTest::addRow("very-large-array-no-overflow") << raw("\x9a\x07\xff\xff\xff" "\0\0") << 0 << CborErrorUnexpectedEOF; - QTest::addRow("very-large-array-overflow1") << raw("\x9a\x40\0\0\0" "\0\0") << 0 << CborErrorUnexpectedEOF; - - // this makes sure we don't accidentally clip to 32-bit: sending 2^32+2 elements - QTest::addRow("very-large-array-overflow2") << raw("\x9b\0\0\0\1""\0\0\0\2" "\0\0") << 0 << CborErrorDataTooLarge; + // error. QCborValue internally uses 16 bytes per element, so we get to 2 + // GB at 2^27 elements (32-bit) or, theoretically, 2^63 bytes at 2^59 + // elements (64-bit). + if (sizeof(QVector::size_type) == sizeof(int)) { + // 32-bit sizes (Qt 5 and 32-bit platforms) + QTest::addRow("very-large-array-no-overflow") << raw("\x9a\x07\xff\xff\xff" "\0\0") << 0 << CborErrorUnexpectedEOF; + QTest::addRow("very-large-array-overflow1") << raw("\x9a\x40\0\0\0" "\0\0") << 0 << CborErrorUnexpectedEOF; + + // this makes sure we don't accidentally clip to 32-bit: sending 2^32+2 elements + QTest::addRow("very-large-array-overflow2") << raw("\x9b\0\0\0\1""\0\0\0\2" "\0\0") << 0 << CborErrorDataTooLarge; + } else { + // 64-bit Qt 6 + QTest::addRow("very-large-array-no-overflow") << raw("\x9b\x07\xff\xff\xff" "\xff\xff\xff\xff" "\0\0"); + QTest::addRow("very-large-array-overflow") << raw("\x9b\x40\0\0\0" "\0\0\0\0" "\0\0"); + } } void tst_QCborValue::validation() -- cgit v1.2.3 From 2e0c29a4bbe2b3ae427137e65f179b0550dcf169 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 11 Feb 2020 13:58:04 +0100 Subject: itemviews: Use the start of the current selection when getting the range When doing a shift-select while moving the mouse then the start point should be based on the start of the current selection and not the pressed position. If there is no current selection start index, then we can safely depend on pressed position as this will be the previous index pressed on. This resolves an issue introduced by e02293a76d21e7077f1952d4ed8af6c6d1970190 when fixing QTBUG-78797 Fixes: QTBUG-81542 Change-Id: Ia66c42b220452fdcbc8cfccc05dbc8a3911c3f5e Reviewed-by: Richard Moe Gustavsen --- .../qabstractitemview/tst_qabstractitemview.cpp | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp index bcfc477733..5828b099d6 100644 --- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp +++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp @@ -151,6 +151,7 @@ private slots: void currentFollowsIndexWidget(); void checkFocusAfterActivationChanges_data(); void checkFocusAfterActivationChanges(); + void dragSelectAfterNewPress(); }; class MyAbstractItemDelegate : public QAbstractItemDelegate @@ -2514,5 +2515,62 @@ void tst_QAbstractItemView::checkFocusAfterActivationChanges() QVERIFY(view->hasFocus()); } +void tst_QAbstractItemView::dragSelectAfterNewPress() +{ + QStandardItemModel model; + for (int i = 0; i < 10; ++i) { + QStandardItem *item = new QStandardItem(QString::number(i)); + model.setItem(i, 0, item); + } + + QListView view; + view.setFixedSize(160, 650); // Minimum width for windows with frame on Windows 8 + view.setSelectionMode(QListView::ExtendedSelection); + view.setModel(&model); + centerOnScreen(&view); + moveCursorAway(&view); + view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + + QModelIndex index0 = model.index(0, 0); + QModelIndex index2 = model.index(2, 0); + + view.setCurrentIndex(index0); + QCOMPARE(view.currentIndex(), index0); + + // Select item 0 using a single click + QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::NoModifier, + view.visualRect(index0).center()); + QCOMPARE(view.currentIndex(), index0); + + // Press to select item 2 + QTest::mousePress(view.viewport(), Qt::LeftButton, Qt::ShiftModifier, + view.visualRect(index2).center()); + QCOMPARE(view.currentIndex(), index2); + + // Verify that the selection worked OK + QModelIndexList selected = view.selectionModel()->selectedIndexes(); + QCOMPARE(selected.count(), 3); + for (int i = 0; i < 2; ++i) + QVERIFY(selected.contains(model.index(i, 0))); + + QModelIndex index5 = model.index(5, 0); + const QPoint releasePos = view.visualRect(index5).center(); + // The mouse move event has to be created manually because the QTest framework does not + // contain a function for mouse moves with buttons pressed + QMouseEvent moveEvent2(QEvent::MouseMove, releasePos, Qt::NoButton, Qt::LeftButton, + Qt::ShiftModifier); + const bool moveEventReceived = qApp->notify(view.viewport(), &moveEvent2); + QVERIFY(moveEventReceived); + QTest::mouseRelease(view.viewport(), Qt::LeftButton, Qt::ShiftModifier, releasePos); + QCOMPARE(view.currentIndex(), index5); + + // Verify that the selection worked OK + selected = view.selectionModel()->selectedIndexes(); + QCOMPARE(selected.count(), 6); + for (int i = 0; i < 5; ++i) + QVERIFY(selected.contains(model.index(i, 0))); +} + QTEST_MAIN(tst_QAbstractItemView) #include "tst_qabstractitemview.moc" -- cgit v1.2.3 From cd57dae62ff80ad371ebcb3fe63731ebbf7ef808 Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Fri, 20 Mar 2020 11:54:14 +0100 Subject: Fuzzing: Add QGuiApplication to gui fuzz targets Change-Id: I3713701f63d9d8938fbb42ad1ae2f0c4ae813e94 Reviewed-by: Shawn Rutledge --- .../gui/painting/qcolorspace/fromiccprofile/fromiccprofile.pro | 1 + .../libfuzzer/gui/painting/qcolorspace/fromiccprofile/main.cpp | 8 ++++++-- tests/libfuzzer/gui/text/qtextdocument/sethtml/main.cpp | 10 +++++++--- tests/libfuzzer/gui/text/qtextdocument/sethtml/sethtml.pro | 3 ++- tests/libfuzzer/gui/text/qtextdocument/setmarkdown/main.cpp | 7 +++++++ .../gui/text/qtextdocument/setmarkdown/setmarkdown.pro | 4 ++-- .../libfuzzer/gui/text/qtextlayout/beginlayout/beginlayout.pro | 3 ++- tests/libfuzzer/gui/text/qtextlayout/beginlayout/main.cpp | 7 +++++++ 8 files changed, 34 insertions(+), 9 deletions(-) (limited to 'tests') diff --git a/tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/fromiccprofile.pro b/tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/fromiccprofile.pro index 934ff81077..bed2198e0d 100644 --- a/tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/fromiccprofile.pro +++ b/tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/fromiccprofile.pro @@ -1,4 +1,5 @@ QT += gui +QTPLUGIN *= qminimal SOURCES += main.cpp FUZZ_ENGINE = $$(LIB_FUZZING_ENGINE) isEmpty(FUZZ_ENGINE) { diff --git a/tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/main.cpp b/tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/main.cpp index 7681c1468e..f663727d1a 100644 --- a/tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/main.cpp +++ b/tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/main.cpp @@ -34,8 +34,12 @@ // to reduce noise and increase speed. extern "C" int LLVMFuzzerTestOneInput(const char *data, size_t size) { - static int c = 0; - static QGuiApplication a(c, nullptr); + static int argc = 3; + static char arg1[] = "fuzzer"; + static char arg2[] = "-platform"; + static char arg3[] = "minimal"; + static char *argv[] = {arg1, arg2, arg3, nullptr}; + static QGuiApplication qga(argc, argv); QColorSpace cs = QColorSpace::fromIccProfile(QByteArray::fromRawData(data, size)); return 0; } diff --git a/tests/libfuzzer/gui/text/qtextdocument/sethtml/main.cpp b/tests/libfuzzer/gui/text/qtextdocument/sethtml/main.cpp index 51fa3c9e0f..ed2a5c4e37 100644 --- a/tests/libfuzzer/gui/text/qtextdocument/sethtml/main.cpp +++ b/tests/libfuzzer/gui/text/qtextdocument/sethtml/main.cpp @@ -26,12 +26,16 @@ ** ****************************************************************************/ -#include +#include #include extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size) { - static int c = 0; - static QApplication a(c, nullptr); + static int argc = 3; + static char arg1[] = "fuzzer"; + static char arg2[] = "-platform"; + static char arg3[] = "minimal"; + static char *argv[] = {arg1, arg2, arg3, nullptr}; + static QGuiApplication qga(argc, argv); QTextDocument().setHtml(QByteArray::fromRawData(Data, Size)); return 0; } diff --git a/tests/libfuzzer/gui/text/qtextdocument/sethtml/sethtml.pro b/tests/libfuzzer/gui/text/qtextdocument/sethtml/sethtml.pro index af5ef9e940..bed2198e0d 100644 --- a/tests/libfuzzer/gui/text/qtextdocument/sethtml/sethtml.pro +++ b/tests/libfuzzer/gui/text/qtextdocument/sethtml/sethtml.pro @@ -1,4 +1,5 @@ -QT += widgets +QT += gui +QTPLUGIN *= qminimal SOURCES += main.cpp FUZZ_ENGINE = $$(LIB_FUZZING_ENGINE) isEmpty(FUZZ_ENGINE) { diff --git a/tests/libfuzzer/gui/text/qtextdocument/setmarkdown/main.cpp b/tests/libfuzzer/gui/text/qtextdocument/setmarkdown/main.cpp index 66ddf738f2..6093da9827 100644 --- a/tests/libfuzzer/gui/text/qtextdocument/setmarkdown/main.cpp +++ b/tests/libfuzzer/gui/text/qtextdocument/setmarkdown/main.cpp @@ -26,9 +26,16 @@ ** ****************************************************************************/ +#include #include extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size) { + static int argc = 3; + static char arg1[] = "fuzzer"; + static char arg2[] = "-platform"; + static char arg3[] = "minimal"; + static char *argv[] = {arg1, arg2, arg3, nullptr}; + static QGuiApplication qga(argc, argv); QTextDocument().setMarkdown(QByteArray::fromRawData(Data, Size)); return 0; } diff --git a/tests/libfuzzer/gui/text/qtextdocument/setmarkdown/setmarkdown.pro b/tests/libfuzzer/gui/text/qtextdocument/setmarkdown/setmarkdown.pro index 758622e1af..bed2198e0d 100644 --- a/tests/libfuzzer/gui/text/qtextdocument/setmarkdown/setmarkdown.pro +++ b/tests/libfuzzer/gui/text/qtextdocument/setmarkdown/setmarkdown.pro @@ -1,5 +1,5 @@ -CONFIG += console -CONFIG -= app_bundle +QT += gui +QTPLUGIN *= qminimal SOURCES += main.cpp FUZZ_ENGINE = $$(LIB_FUZZING_ENGINE) isEmpty(FUZZ_ENGINE) { diff --git a/tests/libfuzzer/gui/text/qtextlayout/beginlayout/beginlayout.pro b/tests/libfuzzer/gui/text/qtextlayout/beginlayout/beginlayout.pro index af5ef9e940..bed2198e0d 100644 --- a/tests/libfuzzer/gui/text/qtextlayout/beginlayout/beginlayout.pro +++ b/tests/libfuzzer/gui/text/qtextlayout/beginlayout/beginlayout.pro @@ -1,4 +1,5 @@ -QT += widgets +QT += gui +QTPLUGIN *= qminimal SOURCES += main.cpp FUZZ_ENGINE = $$(LIB_FUZZING_ENGINE) isEmpty(FUZZ_ENGINE) { diff --git a/tests/libfuzzer/gui/text/qtextlayout/beginlayout/main.cpp b/tests/libfuzzer/gui/text/qtextlayout/beginlayout/main.cpp index dfb9559241..27e0566c2c 100644 --- a/tests/libfuzzer/gui/text/qtextlayout/beginlayout/main.cpp +++ b/tests/libfuzzer/gui/text/qtextlayout/beginlayout/main.cpp @@ -26,9 +26,16 @@ ** ****************************************************************************/ +#include #include extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size) { + static int argc = 3; + static char arg1[] = "fuzzer"; + static char arg2[] = "-platform"; + static char arg3[] = "minimal"; + static char *argv[] = {arg1, arg2, arg3, nullptr}; + static QGuiApplication qga(argc, argv); QTextLayout tl(QByteArray::fromRawData(Data, Size)); tl.beginLayout(); tl.endLayout(); -- cgit v1.2.3 From f5a58cccc2dad567ddda2fe621f21352781852f0 Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Mon, 23 Mar 2020 22:05:02 +0100 Subject: Fuzzing: ignore logging output from QColorSpace Change-Id: Ica549be24c8873854934f4ba24f2b3f7cb077e25 Reviewed-by: Allan Sandfeld Jensen --- .../libfuzzer/gui/painting/qcolorspace/fromiccprofile/main.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/main.cpp b/tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/main.cpp index f663727d1a..8a588c6e21 100644 --- a/tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/main.cpp +++ b/tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/main.cpp @@ -26,14 +26,16 @@ ** ****************************************************************************/ +#include + #include #include -// Run this with -// QT_LOGGING_RULES="qt.gui.icc=false" -// to reduce noise and increase speed. - extern "C" int LLVMFuzzerTestOneInput(const char *data, size_t size) { + // to reduce noise and increase speed + static char quiet[] = "QT_LOGGING_RULES=qt.gui.icc=false"; + static int pe = putenv(quiet); + Q_UNUSED(pe) static int argc = 3; static char arg1[] = "fuzzer"; static char arg2[] = "-platform"; -- cgit v1.2.3 From ae653fc08b3dd670f8f9a7c49f861107ed61266f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 31 Mar 2020 11:52:19 +0200 Subject: tst_QApplication::testDeleteLaterProcessEvents(): Split the test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test can trigger timeouts in COIN, split into subtests. Change-Id: I1fa5d52422275f89b2858d90c5979632aa7058e2 Reviewed-by: Mårten Nordheim --- .../kernel/qapplication/tst_qapplication.cpp | 149 +++++++++++---------- 1 file changed, 80 insertions(+), 69 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp index 367a5767c4..a7a000a01e 100644 --- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp +++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp @@ -93,7 +93,11 @@ private slots: void quitOnLastWindowClosed(); void closeAllWindows(); void testDeleteLater(); - void testDeleteLaterProcessEvents(); + void testDeleteLaterProcessEvents1(); + void testDeleteLaterProcessEvents2(); + void testDeleteLaterProcessEvents3(); + void testDeleteLaterProcessEvents4(); + void testDeleteLaterProcessEvents5(); #if QT_CONFIG(library) void libraryPaths(); @@ -1333,10 +1337,8 @@ public slots: } }; -void tst_QApplication::testDeleteLaterProcessEvents() +void tst_QApplication::testDeleteLaterProcessEvents1() { - int argc = 0; - // Calling processEvents() with no event dispatcher does nothing. QObject *object = new QObject; QPointer p(object); @@ -1344,75 +1346,84 @@ void tst_QApplication::testDeleteLaterProcessEvents() QApplication::processEvents(); QVERIFY(p); delete object; +} - { - QApplication app(argc, nullptr); - // If you call processEvents() with an event dispatcher present, but - // outside any event loops, deferred deletes are not processed unless - // sendPostedEvents(0, DeferredDelete) is called. - object = new QObject; - p = object; - object->deleteLater(); - QCoreApplication::processEvents(); - QVERIFY(p); - QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete); - QVERIFY(!p); - - // If you call deleteLater() on an object when there is no parent - // event loop, and then enter an event loop, the object will get - // deleted. - object = new QObject; - p = object; - object->deleteLater(); - QEventLoop loop; - QTimer::singleShot(1000, &loop, &QEventLoop::quit); - loop.exec(); - QVERIFY(!p); - } - { - // When an object is in an event loop, then calls deleteLater() and enters - // an event loop recursively, it should not die until the parent event - // loop continues. - QApplication app(argc, nullptr); - QEventLoop loop; - EventLoopNester *nester = new EventLoopNester; - p = nester; - QTimer::singleShot(3000, &loop, &QEventLoop::quit); - QTimer::singleShot(0, nester, &EventLoopNester::deleteLaterAndEnterLoop); - - loop.exec(); - QVERIFY(!p); - } - - { - // When the event loop that calls deleteLater() is exited - // immediately, the object should die when returning to the - // parent event loop - QApplication app(argc, nullptr); - QEventLoop loop; - EventLoopNester *nester = new EventLoopNester; - p = nester; - QTimer::singleShot(3000, &loop, &QEventLoop::quit); - QTimer::singleShot(0, nester, &EventLoopNester::deleteLaterAndExitLoop); +void tst_QApplication::testDeleteLaterProcessEvents2() +{ + int argc = 0; + QApplication app(argc, nullptr); + // If you call processEvents() with an event dispatcher present, but + // outside any event loops, deferred deletes are not processed unless + // sendPostedEvents(0, DeferredDelete) is called. + auto object = new QObject; + QPointer p(object); + object->deleteLater(); + QCoreApplication::processEvents(); + QVERIFY(p); + QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete); + QVERIFY(!p); + + // If you call deleteLater() on an object when there is no parent + // event loop, and then enter an event loop, the object will get + // deleted. + object = new QObject; + p = object; + object->deleteLater(); + QEventLoop loop; + QTimer::singleShot(1000, &loop, &QEventLoop::quit); + loop.exec(); + QVERIFY(!p); +} - loop.exec(); - QVERIFY(!p); - } +void tst_QApplication::testDeleteLaterProcessEvents3() +{ + int argc = 0; + // When an object is in an event loop, then calls deleteLater() and enters + // an event loop recursively, it should not die until the parent event + // loop continues. + QApplication app(argc, nullptr); + QEventLoop loop; + EventLoopNester *nester = new EventLoopNester; + QPointer p(nester); + QTimer::singleShot(3000, &loop, &QEventLoop::quit); + QTimer::singleShot(0, nester, &EventLoopNester::deleteLaterAndEnterLoop); + + loop.exec(); + QVERIFY(!p); +} - { - // when the event loop that calls deleteLater() also calls - // processEvents() immediately afterwards, the object should - // not die until the parent loop continues - QApplication app(argc, nullptr); - QEventLoop loop; - EventLoopNester *nester = new EventLoopNester(); - p = nester; - QTimer::singleShot(3000, &loop, &QEventLoop::quit); - QTimer::singleShot(0, nester, &EventLoopNester::deleteLaterAndProcessEvents); +void tst_QApplication::testDeleteLaterProcessEvents4() +{ + int argc = 0; + // When the event loop that calls deleteLater() is exited + // immediately, the object should die when returning to the + // parent event loop + QApplication app(argc, nullptr); + QEventLoop loop; + EventLoopNester *nester = new EventLoopNester; + QPointer p(nester); + QTimer::singleShot(3000, &loop, &QEventLoop::quit); + QTimer::singleShot(0, nester, &EventLoopNester::deleteLaterAndExitLoop); + + loop.exec(); + QVERIFY(!p); +} - loop.exec(); - QVERIFY(!p); - } +void tst_QApplication::testDeleteLaterProcessEvents5() +{ + // when the event loop that calls deleteLater() also calls + // processEvents() immediately afterwards, the object should + // not die until the parent loop continues + int argc = 0; + QApplication app(argc, nullptr); + QEventLoop loop; + EventLoopNester *nester = new EventLoopNester(); + QPointer p(nester); + QTimer::singleShot(3000, &loop, &QEventLoop::quit); + QTimer::singleShot(0, nester, &EventLoopNester::deleteLaterAndProcessEvents); + + loop.exec(); + QVERIFY(!p); } /* -- cgit v1.2.3 From 00d9f68c411a336e451065ae71b8d0fb0d44da60 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 31 Mar 2020 11:56:53 +0200 Subject: Speed up tst_QApplication::testDeleteLaterProcessEvents2() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Quit the event loop once the object is destroyed. Change-Id: I6df1cfe867daacb6af56eb84646be91d98a2f545 Reviewed-by: Alex Trotsenko Reviewed-by: Mårten Nordheim --- tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp index a7a000a01e..3debfd4231 100644 --- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp +++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp @@ -1366,10 +1366,11 @@ void tst_QApplication::testDeleteLaterProcessEvents2() // If you call deleteLater() on an object when there is no parent // event loop, and then enter an event loop, the object will get // deleted. + QEventLoop loop; object = new QObject; + connect(object, &QObject::destroyed, &loop, &QEventLoop::quit); p = object; object->deleteLater(); - QEventLoop loop; QTimer::singleShot(1000, &loop, &QEventLoop::quit); loop.exec(); QVERIFY(!p); -- cgit v1.2.3 From f515ca5dcd02cc7490c3113bdff739aa2b2fd77f Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 1 Apr 2020 10:03:24 +0200 Subject: Fix QTabletEvent manual tests - QPainterPath needs an explicit include now - QTabletEvent::device() is deprecated Change-Id: I2d1086847ee2cf5ed63e345c7c2d6eb43897f0e4 Reviewed-by: Friedemann Kleint --- tests/manual/qtabletevent/device_information/tabletwidget.cpp | 2 +- tests/manual/qtabletevent/regular_widgets/main.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/manual/qtabletevent/device_information/tabletwidget.cpp b/tests/manual/qtabletevent/device_information/tabletwidget.cpp index 14d059abc1..e146175109 100644 --- a/tests/manual/qtabletevent/device_information/tabletwidget.cpp +++ b/tests/manual/qtabletevent/device_information/tabletwidget.cpp @@ -58,7 +58,7 @@ bool TabletWidget::eventFilter(QObject *, QEvent *ev) mPos = event->pos(); mGPos = event->globalPos(); mHiResGlobalPos = event->posF(); - mDev = event->device(); + mDev = event->deviceType(); mPointerType = event->pointerType(); mUnique = event->uniqueId(); mXT = event->xTilt(); diff --git a/tests/manual/qtabletevent/regular_widgets/main.cpp b/tests/manual/qtabletevent/regular_widgets/main.cpp index 4816e2f3b9..1d0af4559b 100644 --- a/tests/manual/qtabletevent/regular_widgets/main.cpp +++ b/tests/manual/qtabletevent/regular_widgets/main.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include enum TabletPointType { -- cgit v1.2.3 From 53ed635dbb5d1ab8103eb1161f81c7e4102d1df2 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 30 Mar 2020 16:15:44 +0200 Subject: Set CONFIG += benchmark in corelib's various benchmarks This leads to "make benchmark" actually running the benchmark, which would be nice, I think. Purged various CONFIG += release or -= debug lines from the same configurations; those surely only configure how the test code is compiled, which is more or less pointless; it's the code under test whose debug/release state matters, and I don't suppose that's affected by the build config of the test code. In the process, reduce diversity of the ordering of lines within these *.pro files and purge some dangling space. Change-Id: Ia9f9f0ca4c096262de928806bdfa6ea3b9e7b9ba Reviewed-by: Joerg Bornemann --- tests/benchmarks/corelib/codecs/qtextcodec/qtextcodec.pro | 5 +++-- tests/benchmarks/corelib/io/qdir/10000/10000.pro | 6 +++--- tests/benchmarks/corelib/io/qdir/tree/tree.pro | 6 +++--- tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro | 6 ++---- tests/benchmarks/corelib/io/qfile/qfile.pro | 3 ++- tests/benchmarks/corelib/io/qfileinfo/qfileinfo.pro | 6 ++---- tests/benchmarks/corelib/io/qiodevice/qiodevice.pro | 6 ++---- tests/benchmarks/corelib/io/qprocess/test/test.pro | 5 +++-- .../io/qprocess/testProcessLoopback/testProcessLoopback.pro | 4 +++- tests/benchmarks/corelib/io/qtemporaryfile/qtemporaryfile.pro | 6 ++---- tests/benchmarks/corelib/io/qtextstream/qtextstream.pro | 6 ++---- tests/benchmarks/corelib/io/qurl/qurl.pro | 3 ++- tests/benchmarks/corelib/json/json.pro | 3 ++- tests/benchmarks/corelib/kernel/events/events.pro | 4 ++-- .../corelib/kernel/qcoreapplication/qcoreapplication.pro | 4 ++-- tests/benchmarks/corelib/kernel/qmetaobject/qmetaobject.pro | 3 ++- tests/benchmarks/corelib/kernel/qmetatype/qmetatype.pro | 6 +++--- tests/benchmarks/corelib/kernel/qobject/qobject.pro | 4 ++-- .../kernel/qtimer_vs_qmetaobject/qtimer_vs_qmetaobject.pro | 11 ++++------- tests/benchmarks/corelib/kernel/qvariant/qvariant.pro | 7 ++----- .../corelib/mimetypes/qmimedatabase/qmimedatabase.pro | 2 +- tests/benchmarks/corelib/plugin/quuid/quuid.pro | 5 +++-- tests/benchmarks/corelib/text/qbytearray/qbytearray.pro | 6 +++--- tests/benchmarks/corelib/text/qchar/qchar.pro | 4 +++- tests/benchmarks/corelib/text/qlocale/qlocale.pro | 3 ++- tests/benchmarks/corelib/text/qregexp/qregexp.pro | 6 +++--- tests/benchmarks/corelib/text/qstring/qstring.pro | 5 +++-- .../benchmarks/corelib/text/qstringbuilder/qstringbuilder.pro | 10 ++++------ tests/benchmarks/corelib/text/qstringlist/qstringlist.pro | 6 +++--- tests/benchmarks/corelib/thread/qmutex/qmutex.pro | 5 +++-- .../corelib/thread/qreadwritelock/qreadwritelock.pro | 7 ++++--- tests/benchmarks/corelib/thread/qthreadpool/qthreadpool.pro | 5 +++-- .../corelib/thread/qthreadstorage/qthreadstorage.pro | 5 +++-- .../corelib/thread/qwaitcondition/qwaitcondition.pro | 4 +++- tests/benchmarks/corelib/time/qdate/qdate.pro | 3 ++- tests/benchmarks/corelib/time/qdatetime/qdatetime.pro | 3 ++- tests/benchmarks/corelib/time/qtimezone/qtimezone.pro | 3 ++- .../tools/containers-associative/containers-associative.pro | 4 ++-- .../tools/containers-sequential/containers-sequential.pro | 4 ++-- tests/benchmarks/corelib/tools/qalgorithms/qalgorithms.pro | 4 +++- .../corelib/tools/qcontiguouscache/qcontiguouscache.pro | 9 ++++----- .../corelib/tools/qcryptographichash/qcryptographichash.pro | 7 ++++--- tests/benchmarks/corelib/tools/qhash/qhash.pro | 5 +++-- tests/benchmarks/corelib/tools/qlist/qlist.pro | 3 ++- tests/benchmarks/corelib/tools/qmap/qmap.pro | 5 +++-- tests/benchmarks/corelib/tools/qrect/qrect.pro | 5 ++--- tests/benchmarks/corelib/tools/qringbuffer/qringbuffer.pro | 5 ++--- tests/benchmarks/corelib/tools/qset/qset.pro | 5 +++-- tests/benchmarks/corelib/tools/qstack/qstack.pro | 5 +++-- tests/benchmarks/corelib/tools/qvector/qvector.pro | 7 ++++--- 50 files changed, 132 insertions(+), 122 deletions(-) (limited to 'tests') diff --git a/tests/benchmarks/corelib/codecs/qtextcodec/qtextcodec.pro b/tests/benchmarks/corelib/codecs/qtextcodec/qtextcodec.pro index 5ee577c256..7d29c6bfdd 100644 --- a/tests/benchmarks/corelib/codecs/qtextcodec/qtextcodec.pro +++ b/tests/benchmarks/corelib/codecs/qtextcodec/qtextcodec.pro @@ -1,6 +1,7 @@ -TARGET = tst_bench_qtextcodec +CONFIG += benchmark QT = core testlib + +TARGET = tst_bench_qtextcodec SOURCES += main.cpp TESTDATA = utf-8.txt - diff --git a/tests/benchmarks/corelib/io/qdir/10000/10000.pro b/tests/benchmarks/corelib/io/qdir/10000/10000.pro index 2e83dad071..52325f314f 100644 --- a/tests/benchmarks/corelib/io/qdir/10000/10000.pro +++ b/tests/benchmarks/corelib/io/qdir/10000/10000.pro @@ -1,6 +1,6 @@ TEMPLATE = app -TARGET = tst_bench_qdir_10000 +CONFIG += benchmark +QT = core testlib +TARGET = tst_bench_qdir_10000 SOURCES += bench_qdir_10000.cpp - -QT = core testlib diff --git a/tests/benchmarks/corelib/io/qdir/tree/tree.pro b/tests/benchmarks/corelib/io/qdir/tree/tree.pro index 2998a13b57..90ddd23345 100644 --- a/tests/benchmarks/corelib/io/qdir/tree/tree.pro +++ b/tests/benchmarks/corelib/io/qdir/tree/tree.pro @@ -1,7 +1,7 @@ TEMPLATE = app -TARGET = bench_qdir_tree +CONFIG += benchmark +QT = core testlib +TARGET = bench_qdir_tree SOURCES += bench_qdir_tree.cpp RESOURCES += bench_qdir_tree.qrc - -QT = core testlib diff --git a/tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro b/tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro index 061b22a5d1..b332cda84b 100644 --- a/tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro +++ b/tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro @@ -1,8 +1,6 @@ -TARGET = tst_bench_qdiriterator - +CONFIG += benchmark QT = core testlib -CONFIG += release - +TARGET = tst_bench_qdiriterator SOURCES += main.cpp qfilesystemiterator.cpp HEADERS += qfilesystemiterator.h diff --git a/tests/benchmarks/corelib/io/qfile/qfile.pro b/tests/benchmarks/corelib/io/qfile/qfile.pro index 5f7b9af73f..a882c4ea61 100644 --- a/tests/benchmarks/corelib/io/qfile/qfile.pro +++ b/tests/benchmarks/corelib/io/qfile/qfile.pro @@ -1,6 +1,7 @@ TEMPLATE = app -TARGET = tst_bench_qfile +CONFIG += benchmark QT = core core-private testlib win32: DEFINES+= _CRT_SECURE_NO_WARNINGS +TARGET = tst_bench_qfile SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/io/qfileinfo/qfileinfo.pro b/tests/benchmarks/corelib/io/qfileinfo/qfileinfo.pro index 42e8708b02..9c97bfc84a 100644 --- a/tests/benchmarks/corelib/io/qfileinfo/qfileinfo.pro +++ b/tests/benchmarks/corelib/io/qfileinfo/qfileinfo.pro @@ -1,9 +1,7 @@ TEMPLATE = app -TARGET = tst_bench_qfileinfo - +CONFIG += benchmark QT -= gui QT += core-private testlib -CONFIG += release - +TARGET = tst_bench_qfileinfo SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/io/qiodevice/qiodevice.pro b/tests/benchmarks/corelib/io/qiodevice/qiodevice.pro index 7937436e13..febe6e87f9 100644 --- a/tests/benchmarks/corelib/io/qiodevice/qiodevice.pro +++ b/tests/benchmarks/corelib/io/qiodevice/qiodevice.pro @@ -1,8 +1,6 @@ TEMPLATE = app -TARGET = tst_bench_qiodevice - +CONFIG += benchmark QT = core testlib -CONFIG += release - +TARGET = tst_bench_qiodevice SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/io/qprocess/test/test.pro b/tests/benchmarks/corelib/io/qprocess/test/test.pro index b665525b17..e7e8e01aef 100644 --- a/tests/benchmarks/corelib/io/qprocess/test/test.pro +++ b/tests/benchmarks/corelib/io/qprocess/test/test.pro @@ -1,4 +1,5 @@ +CONFIG += benchmark +QT = core core-private testlib + TARGET = ../tst_bench_qprocess SOURCES += ../tst_bench_qprocess.cpp - -QT = core core-private testlib diff --git a/tests/benchmarks/corelib/io/qprocess/testProcessLoopback/testProcessLoopback.pro b/tests/benchmarks/corelib/io/qprocess/testProcessLoopback/testProcessLoopback.pro index a0230e1cb8..1f56ad6ee6 100644 --- a/tests/benchmarks/corelib/io/qprocess/testProcessLoopback/testProcessLoopback.pro +++ b/tests/benchmarks/corelib/io/qprocess/testProcessLoopback/testProcessLoopback.pro @@ -1,5 +1,7 @@ -SOURCES = main.cpp +CONFIG += benchmark CONFIG -= qt CONFIG += cmdline winrt: QMAKE_LFLAGS += /ENTRY:mainCRTStartup + +SOURCES = main.cpp DESTDIR = ./ diff --git a/tests/benchmarks/corelib/io/qtemporaryfile/qtemporaryfile.pro b/tests/benchmarks/corelib/io/qtemporaryfile/qtemporaryfile.pro index 758930c139..b6064e1f91 100644 --- a/tests/benchmarks/corelib/io/qtemporaryfile/qtemporaryfile.pro +++ b/tests/benchmarks/corelib/io/qtemporaryfile/qtemporaryfile.pro @@ -1,8 +1,6 @@ TEMPLATE = app -TARGET = tst_bench_qtemporaryfile - +CONFIG += benchmark QT = core testlib -CONFIG += release - +TARGET = tst_bench_qtemporaryfile SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/io/qtextstream/qtextstream.pro b/tests/benchmarks/corelib/io/qtextstream/qtextstream.pro index e8170319f2..fb45d05bc9 100644 --- a/tests/benchmarks/corelib/io/qtextstream/qtextstream.pro +++ b/tests/benchmarks/corelib/io/qtextstream/qtextstream.pro @@ -1,8 +1,6 @@ TEMPLATE = app -TARGET = tst_bench_qtextstream - +CONFIG += benchmark QT = core testlib -CONFIG += release - +TARGET = tst_bench_qtextstream SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/io/qurl/qurl.pro b/tests/benchmarks/corelib/io/qurl/qurl.pro index 52f7bdc8b6..0e10e32a22 100644 --- a/tests/benchmarks/corelib/io/qurl/qurl.pro +++ b/tests/benchmarks/corelib/io/qurl/qurl.pro @@ -1,6 +1,7 @@ TEMPLATE = app -TARGET = tst_qurl +CONFIG += benchmark QT = core testlib win32: DEFINES+= _CRT_SECURE_NO_WARNINGS +TARGET = tst_qurl SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/json/json.pro b/tests/benchmarks/corelib/json/json.pro index 004f4b123e..8f9e515cb9 100644 --- a/tests/benchmarks/corelib/json/json.pro +++ b/tests/benchmarks/corelib/json/json.pro @@ -1,7 +1,8 @@ -TARGET = tst_bench_qtbinaryjson QT = core testlib +CONFIG += benchmark CONFIG -= app_bundle +TARGET = tst_bench_qtbinaryjson SOURCES += tst_bench_qtbinaryjson.cpp TESTDATA = numbers.json test.json diff --git a/tests/benchmarks/corelib/kernel/events/events.pro b/tests/benchmarks/corelib/kernel/events/events.pro index 798a880e5b..1381bb001e 100644 --- a/tests/benchmarks/corelib/kernel/events/events.pro +++ b/tests/benchmarks/corelib/kernel/events/events.pro @@ -1,6 +1,6 @@ TEMPLATE = app -TARGET = tst_bench_events - +CONFIG += benchmark QT = core testlib +TARGET = tst_bench_events SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/kernel/qcoreapplication/qcoreapplication.pro b/tests/benchmarks/corelib/kernel/qcoreapplication/qcoreapplication.pro index 8bf8487a5f..5572f06924 100644 --- a/tests/benchmarks/corelib/kernel/qcoreapplication/qcoreapplication.pro +++ b/tests/benchmarks/corelib/kernel/qcoreapplication/qcoreapplication.pro @@ -1,6 +1,6 @@ +TEMPLATE = app +CONFIG += benchmark QT = core testlib -TEMPLATE = app TARGET = tst_bench_qcoreapplication - SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/kernel/qmetaobject/qmetaobject.pro b/tests/benchmarks/corelib/kernel/qmetaobject/qmetaobject.pro index 47d2acb9b1..0d595ed4da 100644 --- a/tests/benchmarks/corelib/kernel/qmetaobject/qmetaobject.pro +++ b/tests/benchmarks/corelib/kernel/qmetaobject/qmetaobject.pro @@ -1,5 +1,6 @@ TEMPLATE = app +CONFIG += benchmark QT += widgets testlib -TARGET = tst_bench_qmetaobject +TARGET = tst_bench_qmetaobject SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/kernel/qmetatype/qmetatype.pro b/tests/benchmarks/corelib/kernel/qmetatype/qmetatype.pro index 83d0708b60..ffd36ad202 100644 --- a/tests/benchmarks/corelib/kernel/qmetatype/qmetatype.pro +++ b/tests/benchmarks/corelib/kernel/qmetatype/qmetatype.pro @@ -1,6 +1,6 @@ -QT = core testlib TEMPLATE = app -TARGET = tst_bench_qmetatype +CONFIG += benchmark +QT = core testlib +TARGET = tst_bench_qmetatype SOURCES += tst_qmetatype.cpp - diff --git a/tests/benchmarks/corelib/kernel/qobject/qobject.pro b/tests/benchmarks/corelib/kernel/qobject/qobject.pro index e611eff0a2..eb1d8a2daa 100644 --- a/tests/benchmarks/corelib/kernel/qobject/qobject.pro +++ b/tests/benchmarks/corelib/kernel/qobject/qobject.pro @@ -1,7 +1,7 @@ +TEMPLATE = app +CONFIG += benchmark QT += widgets testlib -TEMPLATE = app TARGET = tst_bench_qobject - HEADERS += object.h SOURCES += main.cpp object.cpp diff --git a/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/qtimer_vs_qmetaobject.pro b/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/qtimer_vs_qmetaobject.pro index e127ba1934..3d4e48e76c 100644 --- a/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/qtimer_vs_qmetaobject.pro +++ b/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/qtimer_vs_qmetaobject.pro @@ -1,10 +1,7 @@ TEMPLATE = app -TARGET = qtimer_vs_qmetaobject -INCLUDEPATH += . - -CONFIG += release -#CONFIG += debug - +CONFIG += benchmark +QT = core testlib +INCLUDEPATH += . +TARGET = qtimer_vs_qmetaobject SOURCES += tst_qtimer_vs_qmetaobject.cpp -QT = core testlib diff --git a/tests/benchmarks/corelib/kernel/qvariant/qvariant.pro b/tests/benchmarks/corelib/kernel/qvariant/qvariant.pro index 8a8e9f25d3..2616ae78ea 100644 --- a/tests/benchmarks/corelib/kernel/qvariant/qvariant.pro +++ b/tests/benchmarks/corelib/kernel/qvariant/qvariant.pro @@ -1,9 +1,6 @@ -TARGET = tst_bench_qvariant +CONFIG += benchmark QT += testlib !qtHaveModule(gui): QT -= gui -CONFIG += release -#CONFIG += debug - - +TARGET = tst_bench_qvariant SOURCES += tst_qvariant.cpp diff --git a/tests/benchmarks/corelib/mimetypes/qmimedatabase/qmimedatabase.pro b/tests/benchmarks/corelib/mimetypes/qmimedatabase/qmimedatabase.pro index fe55b98e54..3d218554d3 100644 --- a/tests/benchmarks/corelib/mimetypes/qmimedatabase/qmimedatabase.pro +++ b/tests/benchmarks/corelib/mimetypes/qmimedatabase/qmimedatabase.pro @@ -1,5 +1,5 @@ +CONFIG += benchmark QT = core testlib TARGET = tst_bench_qmimedatabase SOURCES = main.cpp - diff --git a/tests/benchmarks/corelib/plugin/quuid/quuid.pro b/tests/benchmarks/corelib/plugin/quuid/quuid.pro index 8f88bb85b4..5179c0cc40 100644 --- a/tests/benchmarks/corelib/plugin/quuid/quuid.pro +++ b/tests/benchmarks/corelib/plugin/quuid/quuid.pro @@ -1,5 +1,6 @@ TEMPLATE = app -TARGET = tst_bench_quuid +CONFIG += benchmark +QT = core testlib +TARGET = tst_bench_quuid SOURCES += tst_quuid.cpp -QT = core testlib diff --git a/tests/benchmarks/corelib/text/qbytearray/qbytearray.pro b/tests/benchmarks/corelib/text/qbytearray/qbytearray.pro index cf28b0247f..25af9512d4 100644 --- a/tests/benchmarks/corelib/text/qbytearray/qbytearray.pro +++ b/tests/benchmarks/corelib/text/qbytearray/qbytearray.pro @@ -1,7 +1,7 @@ TEMPLATE = app -TARGET = tst_bench_qbytearray - +CONFIG += benchmark QT = core testlib -TESTDATA += main.cpp +TARGET = tst_bench_qbytearray SOURCES += main.cpp +TESTDATA += main.cpp diff --git a/tests/benchmarks/corelib/text/qchar/qchar.pro b/tests/benchmarks/corelib/text/qchar/qchar.pro index 80a9861f48..902acbb831 100644 --- a/tests/benchmarks/corelib/text/qchar/qchar.pro +++ b/tests/benchmarks/corelib/text/qchar/qchar.pro @@ -1,3 +1,5 @@ -TARGET = tst_bench_qchar +CONFIG += benchmark QT = core testlib + +TARGET = tst_bench_qchar SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/text/qlocale/qlocale.pro b/tests/benchmarks/corelib/text/qlocale/qlocale.pro index e56bbe0341..a39a20a677 100644 --- a/tests/benchmarks/corelib/text/qlocale/qlocale.pro +++ b/tests/benchmarks/corelib/text/qlocale/qlocale.pro @@ -1,4 +1,5 @@ -TARGET = tst_bench_qlocale +CONFIG += benchmark QT = core testlib +TARGET = tst_bench_qlocale SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/text/qregexp/qregexp.pro b/tests/benchmarks/corelib/text/qregexp/qregexp.pro index f64ae781a2..c04c13060b 100644 --- a/tests/benchmarks/corelib/text/qregexp/qregexp.pro +++ b/tests/benchmarks/corelib/text/qregexp/qregexp.pro @@ -1,8 +1,9 @@ TEMPLATE = app -TARGET = tst_bench_qregexp +CONFIG += benchmark +CONFIG += exceptions QT = core testlib -CONFIG += release exceptions +TARGET = tst_bench_qregexp SOURCES += main.cpp RESOURCES += qregexp.qrc @@ -17,4 +18,3 @@ qtHaveModule(script):!pcre { LIBS += -lboost_regex } } - diff --git a/tests/benchmarks/corelib/text/qstring/qstring.pro b/tests/benchmarks/corelib/text/qstring/qstring.pro index 9f5e34b915..e25431b983 100644 --- a/tests/benchmarks/corelib/text/qstring/qstring.pro +++ b/tests/benchmarks/corelib/text/qstring/qstring.pro @@ -1,5 +1,6 @@ -TARGET = tst_bench_qstring +CONFIG += benchmark QT -= gui QT += core testlib -SOURCES += main.cpp +TARGET = tst_bench_qstring +SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/text/qstringbuilder/qstringbuilder.pro b/tests/benchmarks/corelib/text/qstringbuilder/qstringbuilder.pro index fa4cbe3c13..91421b3b2c 100644 --- a/tests/benchmarks/corelib/text/qstringbuilder/qstringbuilder.pro +++ b/tests/benchmarks/corelib/text/qstringbuilder/qstringbuilder.pro @@ -1,11 +1,9 @@ TEMPLATE = app -TARGET = tst_bench_qstringbuilder +CONFIG += benchmark +QT = core testlib QMAKE_CXXFLAGS += -g QMAKE_CFLAGS += -g -QT = core testlib - -CONFIG += release - -SOURCES += main.cpp +TARGET = tst_bench_qstringbuilder +SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/text/qstringlist/qstringlist.pro b/tests/benchmarks/corelib/text/qstringlist/qstringlist.pro index 5803e7da0e..a27bf0a6ab 100644 --- a/tests/benchmarks/corelib/text/qstringlist/qstringlist.pro +++ b/tests/benchmarks/corelib/text/qstringlist/qstringlist.pro @@ -1,5 +1,5 @@ -TARGET = tst_bench_qstringlist -CONFIG -= debug -CONFIG += release +CONFIG += benchmark QT = core testlib + +TARGET = tst_bench_qstringlist SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/thread/qmutex/qmutex.pro b/tests/benchmarks/corelib/thread/qmutex/qmutex.pro index ec87f60919..a0b2ddeaa9 100644 --- a/tests/benchmarks/corelib/thread/qmutex/qmutex.pro +++ b/tests/benchmarks/corelib/thread/qmutex/qmutex.pro @@ -1,5 +1,6 @@ TEMPLATE = app -TARGET = tst_bench_qmutex +CONFIG += benchmark QT = core testlib -SOURCES += tst_qmutex.cpp +TARGET = tst_bench_qmutex +SOURCES += tst_qmutex.cpp diff --git a/tests/benchmarks/corelib/thread/qreadwritelock/qreadwritelock.pro b/tests/benchmarks/corelib/thread/qreadwritelock/qreadwritelock.pro index a1827d0276..7c36067cb7 100644 --- a/tests/benchmarks/corelib/thread/qreadwritelock/qreadwritelock.pro +++ b/tests/benchmarks/corelib/thread/qreadwritelock/qreadwritelock.pro @@ -1,7 +1,8 @@ TEMPLATE = app -TARGET = tst_bench_qreadwritelock -QT = core-private testlib -SOURCES += tst_qreadwritelock.cpp +CONFIG += benchmark CONFIG += c++14 # for std::shared_timed_mutex CONFIG += c++1z # for std::shared_mutex +QT = core-private testlib +TARGET = tst_bench_qreadwritelock +SOURCES += tst_qreadwritelock.cpp diff --git a/tests/benchmarks/corelib/thread/qthreadpool/qthreadpool.pro b/tests/benchmarks/corelib/thread/qthreadpool/qthreadpool.pro index 47e16e8b4d..303b3cef69 100644 --- a/tests/benchmarks/corelib/thread/qthreadpool/qthreadpool.pro +++ b/tests/benchmarks/corelib/thread/qthreadpool/qthreadpool.pro @@ -1,5 +1,6 @@ TEMPLATE = app -TARGET = tst_bench_qthreadpool +CONFIG += benchmark +QT = core testlib +TARGET = tst_bench_qthreadpool SOURCES += tst_qthreadpool.cpp -QT = core testlib diff --git a/tests/benchmarks/corelib/thread/qthreadstorage/qthreadstorage.pro b/tests/benchmarks/corelib/thread/qthreadstorage/qthreadstorage.pro index 95afc951bc..3f62c4eb3c 100644 --- a/tests/benchmarks/corelib/thread/qthreadstorage/qthreadstorage.pro +++ b/tests/benchmarks/corelib/thread/qthreadstorage/qthreadstorage.pro @@ -1,5 +1,6 @@ TEMPLATE = app -TARGET = tst_bench_qthreadstorage +CONFIG += benchmark +QT = core testlib +TARGET = tst_bench_qthreadstorage SOURCES += tst_qthreadstorage.cpp -QT = core testlib diff --git a/tests/benchmarks/corelib/thread/qwaitcondition/qwaitcondition.pro b/tests/benchmarks/corelib/thread/qwaitcondition/qwaitcondition.pro index 43c7921a93..cc801bdc13 100644 --- a/tests/benchmarks/corelib/thread/qwaitcondition/qwaitcondition.pro +++ b/tests/benchmarks/corelib/thread/qwaitcondition/qwaitcondition.pro @@ -1,4 +1,6 @@ TEMPLATE = app -TARGET = tst_bench_qwaitcondition +CONFIG += benchmark QT = core testlib + +TARGET = tst_bench_qwaitcondition SOURCES += tst_qwaitcondition.cpp diff --git a/tests/benchmarks/corelib/time/qdate/qdate.pro b/tests/benchmarks/corelib/time/qdate/qdate.pro index a655917135..ecb229dfda 100644 --- a/tests/benchmarks/corelib/time/qdate/qdate.pro +++ b/tests/benchmarks/corelib/time/qdate/qdate.pro @@ -1,4 +1,5 @@ -TARGET = tst_bench_qdate +CONFIG += benchmark QT = core testlib +TARGET = tst_bench_qdate SOURCES += tst_bench_qdate.cpp diff --git a/tests/benchmarks/corelib/time/qdatetime/qdatetime.pro b/tests/benchmarks/corelib/time/qdatetime/qdatetime.pro index a85e7346c6..7133834ffc 100644 --- a/tests/benchmarks/corelib/time/qdatetime/qdatetime.pro +++ b/tests/benchmarks/corelib/time/qdatetime/qdatetime.pro @@ -1,4 +1,5 @@ -TARGET = tst_bench_qdatetime +CONFIG += benchmark QT = core testlib +TARGET = tst_bench_qdatetime SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/time/qtimezone/qtimezone.pro b/tests/benchmarks/corelib/time/qtimezone/qtimezone.pro index d0531b568b..6ebee0faf3 100644 --- a/tests/benchmarks/corelib/time/qtimezone/qtimezone.pro +++ b/tests/benchmarks/corelib/time/qtimezone/qtimezone.pro @@ -1,4 +1,5 @@ -TARGET = tst_bench_qtimezone +CONFIG += benchmark QT = core testlib +TARGET = tst_bench_qtimezone SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/tools/containers-associative/containers-associative.pro b/tests/benchmarks/corelib/tools/containers-associative/containers-associative.pro index 49edcbee70..89da01b02e 100644 --- a/tests/benchmarks/corelib/tools/containers-associative/containers-associative.pro +++ b/tests/benchmarks/corelib/tools/containers-associative/containers-associative.pro @@ -1,6 +1,6 @@ TEMPLATE = app -TARGET = tst_bench_containers-associative - +CONFIG += benchmark QT = core testlib +TARGET = tst_bench_containers-associative SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/tools/containers-sequential/containers-sequential.pro b/tests/benchmarks/corelib/tools/containers-sequential/containers-sequential.pro index 6f731cb6d8..509da95d22 100644 --- a/tests/benchmarks/corelib/tools/containers-sequential/containers-sequential.pro +++ b/tests/benchmarks/corelib/tools/containers-sequential/containers-sequential.pro @@ -1,6 +1,6 @@ TEMPLATE = app -TARGET = tst_bench_containers-sequential - +CONFIG += benchmark QT = core testlib +TARGET = tst_bench_containers-sequential SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/tools/qalgorithms/qalgorithms.pro b/tests/benchmarks/corelib/tools/qalgorithms/qalgorithms.pro index f54f8320d4..0bde3ac66a 100644 --- a/tests/benchmarks/corelib/tools/qalgorithms/qalgorithms.pro +++ b/tests/benchmarks/corelib/tools/qalgorithms/qalgorithms.pro @@ -1,3 +1,5 @@ -TARGET = tst_bench_qalgorithms +CONFIG += benchmark QT = core testlib + +TARGET = tst_bench_qalgorithms SOURCES = tst_qalgorithms.cpp diff --git a/tests/benchmarks/corelib/tools/qcontiguouscache/qcontiguouscache.pro b/tests/benchmarks/corelib/tools/qcontiguouscache/qcontiguouscache.pro index fe74dafef4..59adad6bbc 100644 --- a/tests/benchmarks/corelib/tools/qcontiguouscache/qcontiguouscache.pro +++ b/tests/benchmarks/corelib/tools/qcontiguouscache/qcontiguouscache.pro @@ -1,7 +1,6 @@ -TARGET = tst_bench_qcontiguouscache - -SOURCES += main.cpp - +CONFIG += benchmark CONFIG += parallel_test - QT = core testlib + +TARGET = tst_bench_qcontiguouscache +SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/tools/qcryptographichash/qcryptographichash.pro b/tests/benchmarks/corelib/tools/qcryptographichash/qcryptographichash.pro index cf9d640f7e..025c70c2d9 100644 --- a/tests/benchmarks/corelib/tools/qcryptographichash/qcryptographichash.pro +++ b/tests/benchmarks/corelib/tools/qcryptographichash/qcryptographichash.pro @@ -1,5 +1,6 @@ -TARGET = tst_bench_qcryptographichash -CONFIG -= debug -CONFIG += release cmdline +CONFIG += benchmark +CONFIG += cmdline QT = core testlib + +TARGET = tst_bench_qcryptographichash SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/tools/qhash/qhash.pro b/tests/benchmarks/corelib/tools/qhash/qhash.pro index 40f661c116..f9a873d096 100644 --- a/tests/benchmarks/corelib/tools/qhash/qhash.pro +++ b/tests/benchmarks/corelib/tools/qhash/qhash.pro @@ -1,5 +1,6 @@ -TARGET = tst_hash +CONFIG += benchmark QT = core testlib + INCLUDEPATH += . +TARGET = tst_hash SOURCES += main.cpp outofline.cpp -CONFIG += release diff --git a/tests/benchmarks/corelib/tools/qlist/qlist.pro b/tests/benchmarks/corelib/tools/qlist/qlist.pro index c83bc455d2..98767c3250 100644 --- a/tests/benchmarks/corelib/tools/qlist/qlist.pro +++ b/tests/benchmarks/corelib/tools/qlist/qlist.pro @@ -1,4 +1,5 @@ -TARGET = tst_bench_qlist +CONFIG += benchmark QT = core testlib +TARGET = tst_bench_qlist SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/tools/qmap/qmap.pro b/tests/benchmarks/corelib/tools/qmap/qmap.pro index 6c9bf5e8d6..0e06493c79 100644 --- a/tests/benchmarks/corelib/tools/qmap/qmap.pro +++ b/tests/benchmarks/corelib/tools/qmap/qmap.pro @@ -1,5 +1,6 @@ -TARGET = tst_bench_qmap +CONFIG += benchmark QT = core testlib + INCLUDEPATH += . +TARGET = tst_bench_qmap SOURCES += main.cpp -CONFIG += release diff --git a/tests/benchmarks/corelib/tools/qrect/qrect.pro b/tests/benchmarks/corelib/tools/qrect/qrect.pro index 42cfcd8924..211cdc5bcc 100644 --- a/tests/benchmarks/corelib/tools/qrect/qrect.pro +++ b/tests/benchmarks/corelib/tools/qrect/qrect.pro @@ -1,7 +1,6 @@ TEMPLATE = app -TARGET = tst_bench_qrect - QT = core testlib -CONFIG += release +CONFIG += benchmark +TARGET = tst_bench_qrect SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/tools/qringbuffer/qringbuffer.pro b/tests/benchmarks/corelib/tools/qringbuffer/qringbuffer.pro index 21b50e10e5..69750865b5 100644 --- a/tests/benchmarks/corelib/tools/qringbuffer/qringbuffer.pro +++ b/tests/benchmarks/corelib/tools/qringbuffer/qringbuffer.pro @@ -1,7 +1,6 @@ TEMPLATE = app -TARGET = tst_bench_qringbuffer - +CONFIG += benchmark QT = core-private testlib -CONFIG += release +TARGET = tst_bench_qringbuffer SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/tools/qset/qset.pro b/tests/benchmarks/corelib/tools/qset/qset.pro index 8fb8bcfa0b..e448683e94 100644 --- a/tests/benchmarks/corelib/tools/qset/qset.pro +++ b/tests/benchmarks/corelib/tools/qset/qset.pro @@ -1,4 +1,5 @@ -TARGET = tst_qset +CONFIG += benchmark QT = core testlib + +TARGET = tst_qset SOURCES += main.cpp -CONFIG += release diff --git a/tests/benchmarks/corelib/tools/qstack/qstack.pro b/tests/benchmarks/corelib/tools/qstack/qstack.pro index 7d8a839610..17b7ebd486 100644 --- a/tests/benchmarks/corelib/tools/qstack/qstack.pro +++ b/tests/benchmarks/corelib/tools/qstack/qstack.pro @@ -1,4 +1,5 @@ -TARGET = tst_bench_stack +CONFIG += benchmark QT = core testlib core-private + +TARGET = tst_bench_stack SOURCES += main.cpp -CONFIG += release diff --git a/tests/benchmarks/corelib/tools/qvector/qvector.pro b/tests/benchmarks/corelib/tools/qvector/qvector.pro index 24a65d8ee8..fce8a6cd78 100644 --- a/tests/benchmarks/corelib/tools/qvector/qvector.pro +++ b/tests/benchmarks/corelib/tools/qvector/qvector.pro @@ -1,5 +1,6 @@ -TARGET = tst_bench_vector +CONFIG += benchmark QT = core testlib core-private + INCLUDEPATH += . -SOURCES += main.cpp outofline.cpp -CONFIG += release +TARGET = tst_bench_vector +SOURCES += main.cpp outofline.cpp -- cgit v1.2.3 From 89bd12b9ad3e4c265ddf537e845330f76ca2d399 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 17 Mar 2020 12:09:30 +0100 Subject: Change QLocale to use CLDR's accounting formats for currencies In particular, this changed the US currency formats for negative amounts to be parenthesised versions of the positive amount forms, rather than having a minus sign after the $ sign. Test updated. [ChangeLog][QtCore][QLocale] Currency formats are now based on CLDR's accounting formats, where they were previously mostly based (more or less by accident) on standard formats. In particular, this now means negative currency formats are specified, where available, where they (mostly) were not previously. Task-number: QTBUG-79902 Change-Id: Ie0c07515ece8bd518a74a6956bf97ca85e9894eb Reviewed-by: Cristian Maureira-Fredes --- tests/auto/corelib/text/qlocale/tst_qlocale.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp index 5eb6a6a9a4..13bde34c7d 100644 --- a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp @@ -2569,12 +2569,12 @@ void tst_QLocale::currency() const QLocale en_US("en_US"); QCOMPARE(en_US.toCurrencyString(qulonglong(1234)), QString("$1,234")); - QCOMPARE(en_US.toCurrencyString(qlonglong(-1234)), QString("$-1,234")); + QCOMPARE(en_US.toCurrencyString(qlonglong(-1234)), QString("($1,234)")); QCOMPARE(en_US.toCurrencyString(double(1234.56)), QString("$1,234.56")); - QCOMPARE(en_US.toCurrencyString(double(-1234.56)), QString("$-1,234.56")); - QCOMPARE(en_US.toCurrencyString(double(-1234.5678)), QString("$-1,234.57")); - QCOMPARE(en_US.toCurrencyString(double(-1234.5678), NULL, 4), QString("$-1,234.5678")); - QCOMPARE(en_US.toCurrencyString(double(-1234.56), NULL, 4), QString("$-1,234.5600")); + QCOMPARE(en_US.toCurrencyString(double(-1234.56)), QString("($1,234.56)")); + QCOMPARE(en_US.toCurrencyString(double(-1234.5678)), QString("($1,234.57)")); + QCOMPARE(en_US.toCurrencyString(double(-1234.5678), NULL, 4), QString("($1,234.5678)")); + QCOMPARE(en_US.toCurrencyString(double(-1234.56), NULL, 4), QString("($1,234.5600)")); const QLocale ru_RU("ru_RU"); QCOMPARE(ru_RU.toCurrencyString(qulonglong(1234)), -- cgit v1.2.3 From ab4c22d47d196d5eb28fc16cd7262c77bcb6875f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 3 Apr 2020 12:45:36 +0200 Subject: macOS: Remove all use of deprecated Q_OS_OSX define Change-Id: I49c285604694c93d37c9d1c7cd6d3b1509858319 Reviewed-by: Volker Hilsheimer --- .../auto/gui/kernel/qclipboard/tst_qclipboard.cpp | 4 +- tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp | 2 +- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 78 +++++++++++----------- .../qstylesheetstyle/tst_qstylesheetstyle.cpp | 2 +- .../auto/widgets/widgets/qmenubar/tst_qmenubar.cpp | 2 +- .../widgets/qopenglwidget/tst_qopenglwidget.cpp | 2 +- 6 files changed, 45 insertions(+), 45 deletions(-) (limited to 'tests') diff --git a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp index bff9f7d0e0..e099b4dfc7 100644 --- a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp +++ b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp @@ -289,10 +289,10 @@ void tst_QClipboard::copyImage() image.fill(QColor(Qt::transparent)); image.setPixel(QPoint(1, 0), QColor(Qt::blue).rgba()); QGuiApplication::clipboard()->setImage(image); -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS // The Pasteboard needs a moment to breathe (at least on older Macs). QTest::qWait(100); -#endif // Q_OS_OSX +#endif // Q_OS_MACOS // paster will perform hard-coded checks on the copied image. QByteArray errorMessage; QVERIFY2(runHelper(QStringLiteral("paster/paster"), diff --git a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp index 1af3bade0e..10a3746e36 100644 --- a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp +++ b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp @@ -607,7 +607,7 @@ void tst_QDialog::snapToDefaultButton() + QPoint(100, 100), QSize(200, 200)); const QPoint startingPos = dialogGeometry.bottomRight() + QPoint(100, 100); QCursor::setPos(startingPos); -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS // On OS X we use CGEventPost to move the cursor, it needs at least // some time before the event handled and the position really set. QTest::qWait(100); diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 2483d7b5bb..5ffbbdd400 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -75,7 +75,7 @@ #include #include -#if defined(Q_OS_OSX) +#if defined(Q_OS_MACOS) #include "tst_qwidget_mac_helpers.h" // Abstract the ObjC stuff out so not everyone must run an ObjC++ compile. #endif @@ -110,7 +110,7 @@ static HWND winHandleOf(const QWidget *w) # define Q_CHECK_PAINTEVENTS #endif -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS #include bool macHasAccessToWindowsServer() { @@ -216,7 +216,7 @@ private slots: void restoreVersion1Geometry(); void widgetAt(); -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS void setMask(); #endif void optimizedResizeMove(); @@ -250,7 +250,7 @@ private slots: void update(); void isOpaque(); -#ifndef Q_OS_OSX +#ifndef Q_OS_MACOS void scroll(); void scrollNativeChildren(); #endif @@ -381,7 +381,7 @@ private slots: void taskQTBUG_7532_tabOrderWithFocusProxy(); void movedAndResizedAttributes(); void childAt(); -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS void taskQTBUG_11373(); #endif void taskQTBUG_17333_ResizeInfiniteRecursion(); @@ -2301,7 +2301,7 @@ void tst_QWidget::activation() void tst_QWidget::windowState() { -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS QSKIP("QTBUG-52974"); #endif @@ -2514,7 +2514,7 @@ void tst_QWidget::showMaximized() void tst_QWidget::showFullScreen() { -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS QSKIP("QTBUG-52974"); #endif @@ -2834,14 +2834,14 @@ void tst_QWidget::showMinimizedKeepsFocus() window.showNormal(); QApplication::setActiveWindow(&window); QVERIFY(QTest::qWaitForWindowActive(&window)); -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS if (!macHasAccessToWindowsServer()) QEXPECT_FAIL("", "When not having WindowServer access, we lose focus.", Continue); #elif defined(Q_OS_WINRT) QEXPECT_FAIL("", "Winrt fails here - QTBUG-68297", Continue); #endif QTRY_COMPARE(window.focusWidget(), firstchild); -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS if (!macHasAccessToWindowsServer()) QEXPECT_FAIL("", "When not having WindowServer access, we lose focus.", Continue); #elif defined(Q_OS_WINRT) @@ -2904,7 +2904,7 @@ void tst_QWidget::reparent() // Qt/Embedded does it differently. void tst_QWidget::icon() { -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS QSKIP("QTBUG-52974"); #endif @@ -2970,7 +2970,7 @@ void tst_QWidget::hideWhenFocusWidgetIsChild() void tst_QWidget::normalGeometry() { -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS QSKIP("QTBUG-52974"); #endif @@ -3230,7 +3230,7 @@ public: void tst_QWidget::lostUpdatesOnHide() { -#ifndef Q_OS_OSX +#ifndef Q_OS_MACOS UpdateWidget widget; widget.setAttribute(Qt::WA_DontShowOnScreen); widget.setWindowTitle(QLatin1String(QTest::currentTestFunction())); @@ -3271,7 +3271,7 @@ void tst_QWidget::raise() parentPtr->show(); QVERIFY(QTest::qWaitForWindowExposed(parentPtr.data())); -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS if (child1->internalWinId()) { QSKIP("Cocoa has no Z-Order for views, we hack it, but it results in paint events."); } @@ -3412,7 +3412,7 @@ void tst_QWidget::lower() void tst_QWidget::stackUnder() { -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS QSKIP("QTBUG-52974: Cocoa has no Z-Order for views, we hack it, but it results in paint events."); #endif @@ -3445,7 +3445,7 @@ void tst_QWidget::stackUnder() for (UpdateWidget *child : qAsConst(allChildren)) { int expectedPaintEvents = child == child4 ? 1 : 0; -#if defined(Q_OS_WIN) || defined(Q_OS_OSX) +#if defined(Q_OS_WIN) || defined(Q_OS_MACOS) if (expectedPaintEvents == 1 && child->numPaintEvents == 2) QEXPECT_FAIL(0, "Mac and Windows issues double repaints for Z-Order change", Continue); #endif @@ -3479,7 +3479,7 @@ void tst_QWidget::stackUnder() for (UpdateWidget *child : qAsConst(allChildren)) { int expectedZOrderChangeEvents = child == child1 ? 1 : 0; if (child == child3) { -#ifndef Q_OS_OSX +#ifndef Q_OS_MACOS QEXPECT_FAIL(0, "See QTBUG-493", Continue); #endif QCOMPARE(child->numPaintEvents, 0); @@ -3579,7 +3579,7 @@ void tst_QWidget::testContentsPropagation() void tst_QWidget::saveRestoreGeometry() { -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS QSKIP("QTBUG-52974"); #endif @@ -3817,7 +3817,7 @@ void tst_QWidget::restoreVersion1Geometry() void tst_QWidget::widgetAt() { -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS QSKIP("QTBUG-52974"); #endif @@ -4020,7 +4020,7 @@ void tst_QWidget::testDeletionInEventHandlers() delete w; } -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS class MaskedPainter : public QWidget { public: @@ -4887,7 +4887,7 @@ void tst_QWidget::update() QCOMPARE(sibling.numPaintEvents, 1); QCOMPARE(sibling.paintedRegion, sibling.visibleRegion()); -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS if (child.internalWinId()) // child is native QEXPECT_FAIL(0, "Cocoa compositor paints child and sibling", Continue); #endif @@ -4904,7 +4904,7 @@ void tst_QWidget::update() } } -#ifndef Q_OS_OSX +#ifndef Q_OS_MACOS static inline bool isOpaque(QWidget *widget) { if (!widget) @@ -4915,7 +4915,7 @@ static inline bool isOpaque(QWidget *widget) void tst_QWidget::isOpaque() { -#ifndef Q_OS_OSX +#ifndef Q_OS_MACOS QWidget w; QVERIFY(::isOpaque(&w)); @@ -4987,7 +4987,7 @@ void tst_QWidget::isOpaque() #endif } -#ifndef Q_OS_OSX +#ifndef Q_OS_MACOS /* Test that scrolling of a widget invalidates the correct regions */ @@ -5431,7 +5431,7 @@ void tst_QWidget::windowMoveResize() widget.move(r.topLeft()); widget.resize(r.size()); QApplication::processEvents(); -#if defined(Q_OS_OSX) +#if defined(Q_OS_MACOS) if (r.width() == 0 && r.height() > 0) { widget.move(r.topLeft()); widget.resize(r.size()); @@ -5502,7 +5502,7 @@ void tst_QWidget::windowMoveResize() widget.move(r.topLeft()); widget.resize(r.size()); QApplication::processEvents(); -#if defined(Q_OS_OSX) +#if defined(Q_OS_MACOS) if (r.width() == 0 && r.height() > 0) { widget.move(r.topLeft()); widget.resize(r.size()); @@ -5689,7 +5689,7 @@ void tst_QWidget::moveChild() QTRY_COMPARE(pos, child.pos()); QTRY_COMPARE(parent.r, QRegion(oldGeometry) - child.geometry()); -#if !defined(Q_OS_OSX) +#if !defined(Q_OS_MACOS) // should be scrolled in backingstore QCOMPARE(child.r, QRegion()); #endif @@ -5739,7 +5739,7 @@ void tst_QWidget::showAndMoveChild() void tst_QWidget::subtractOpaqueSiblings() { -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS QSKIP("QTBUG-52974: Cocoa only has rect granularity."); #endif @@ -5816,7 +5816,7 @@ public slots: void tst_QWidget::multipleToplevelFocusCheck() { -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS QSKIP("QTBUG-52974"); #endif @@ -7584,7 +7584,7 @@ void tst_QWidget::render_systemClip() // rrrrrrrrrr // ... -#ifndef Q_OS_OSX +#ifndef Q_OS_MACOS for (int i = 0; i < image.height(); ++i) { for (int j = 0; j < image.width(); ++j) { if (i < 50 && j < i) @@ -8618,11 +8618,11 @@ void tst_QWidget::sendUpdateRequestImmediately() void tst_QWidget::doubleRepaint() { -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS QSKIP("QTBUG-52974"); #endif -#if defined(Q_OS_OSX) +#if defined(Q_OS_MACOS) if (!macHasAccessToWindowsServer()) QSKIP("Not having window server access causes the wrong number of repaints to be issues"); #endif @@ -9330,7 +9330,7 @@ void tst_QWidget::setClearAndResizeMask() child.setMask(childMask); QTRY_COMPARE(child.mask(), childMask); // and ensure that the child widget doesn't get any update. -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS // Mac always issues a full update when calling setMask, and we cannot force it to not do so. if (child.internalWinId()) QCOMPARE(child.numPaintEvents, 1); @@ -9352,7 +9352,7 @@ void tst_QWidget::setClearAndResizeMask() // and ensure that that the child widget gets an update for the area outside the old mask. QTRY_COMPARE(child.numPaintEvents, 1); outsideOldMask = child.rect(); -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS // Mac always issues a full update when calling setMask, and we cannot force it to not do so. if (!child.internalWinId()) #endif @@ -9366,7 +9366,7 @@ void tst_QWidget::setClearAndResizeMask() // Mask child widget with a mask that is bigger than the rect child.setMask(QRegion(0, 0, 1000, 1000)); -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS // Mac always issues a full update when calling setMask, and we cannot force it to not do so. if (child.internalWinId()) QTRY_COMPARE(child.numPaintEvents, 1); @@ -9379,7 +9379,7 @@ void tst_QWidget::setClearAndResizeMask() // ...and the same applies when clearing the mask. child.clearMask(); QTest::qWait(100); -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS // Mac always issues a full update when calling setMask, and we cannot force it to not do so. if (child.internalWinId()) QTRY_VERIFY(child.numPaintEvents > 0); @@ -9409,7 +9409,7 @@ void tst_QWidget::setClearAndResizeMask() QTimer::singleShot(100, &resizeChild, SLOT(shrinkMask())); QTest::qWait(200); -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS // Mac always issues a full update when calling setMask, and we cannot force it to not do so. if (child.internalWinId()) QTRY_COMPARE(resizeChild.paintedRegion, resizeChild.mask()); @@ -9421,7 +9421,7 @@ void tst_QWidget::setClearAndResizeMask() const QRegion oldMask = resizeChild.mask(); QTimer::singleShot(0, &resizeChild, SLOT(enlargeMask())); QTest::qWait(100); -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS // Mac always issues a full update when calling setMask, and we cannot force it to not do so. if (child.internalWinId()) QTRY_COMPARE(resizeChild.paintedRegion, resizeChild.mask()); @@ -10265,7 +10265,7 @@ void tst_QWidget::childAt() QCOMPARE(parent.childAt(120, 120), grandChild); } -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS void tst_QWidget::taskQTBUG_11373() { @@ -11121,7 +11121,7 @@ public: // when mousing over it. void tst_QWidget::taskQTBUG_27643_enterEvents() { -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS QSKIP("QTBUG-52974: this test can crash!"); #endif // Move the mouse cursor to a safe location so it won't interfere diff --git a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp index 0ae2e6626f..82527849b0 100644 --- a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp +++ b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp @@ -995,7 +995,7 @@ void tst_QStyleSheetStyle::focusColors() #ifndef QT_NO_CURSOR void tst_QStyleSheetStyle::hoverColors() { -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS QSKIP("This test is fragile on Mac, most likely due to QTBUG-33959."); #endif if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp index b255930138..53f1e1fc5c 100644 --- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp @@ -1525,7 +1525,7 @@ void tst_QMenuBar::cornerWidgets() QFETCH(Qt::Corner, corner); -#if defined(Q_OS_OSX) +#if defined(Q_OS_MACOS) QSKIP("Test interferes with native menu bars on this platform"); #endif diff --git a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp index 17a5fe2cd9..7d70d49019 100644 --- a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp +++ b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp @@ -579,7 +579,7 @@ bool verifyColor(const QWidget *widget, const QRect &clipArea, const QColor &col void tst_QOpenGLWidget::stackWidgetOpaqueChildIsVisible() { -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS QSKIP("QScreen::grabWindow() doesn't work properly on OSX HighDPI screen: QTBUG-46803"); return; #endif -- cgit v1.2.3 From 0c2d6c163f6e7908a7cc9a626f027cb38a5d7786 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 2 Apr 2020 13:58:16 +0200 Subject: Fix deprecation warning in tst_QLocale()'s use of QProcess::start() Change-Id: I6f5dfa2d40984f86670288bdee4d1b7b060850ac Reviewed-by: Thiago Macieira --- tests/auto/corelib/text/qlocale/tst_qlocale.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp index 13bde34c7d..11ba032d82 100644 --- a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp @@ -512,7 +512,7 @@ static inline bool runSysApp(const QString &binary, errorMessage->clear(); QProcess process; process.setEnvironment(env); - process.start(binary); + process.start(binary, QStringList()); process.closeWriteChannel(); if (!process.waitForStarted()) { *errorMessage = QLatin1String("Cannot start '") + binary -- cgit v1.2.3 From 274e973dbe696f89d56d5a78d73208e27c638a77 Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Tue, 31 Mar 2020 16:43:54 +0300 Subject: Fix flakiness in tst_QApplication::testDeleteLater DeleteLaterWidget is a main application window of the test. So, its show() function should be called explicitly before starting the main event loop. Otherwise, it remains hidden for the whole time, which causes an incorrect emission of QApplication::lastWindowClosed signal when a dialog window is closed in the middle of the test. Also, fix synchronization between deferred deletion and timer event. Change-Id: Id3ce5adbcd9e5e22508825c52025eeea70202354 Reviewed-by: Thiago Macieira --- tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp index 3debfd4231..28bf851d37 100644 --- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp +++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp @@ -1229,6 +1229,11 @@ void DeleteLaterWidget::runTest() QCoreApplication::processEvents(); + // At this point, the event queue is empty. As we want a deferred + // deletion to occur before the timer event, we should provoke the + // event dispatcher for the next spin. + QCoreApplication::eventDispatcher()->interrupt(); + QVERIFY(!stillAlive); // verify at the end to make test terminate } @@ -1258,8 +1263,10 @@ void tst_QApplication::testDeleteLater() QObject *stillAlive = wgt->findChild("deleteLater"); QVERIFY(stillAlive); + wgt->show(); QCoreApplication::exec(); + QVERIFY(wgt->isHidden()); delete wgt; } -- cgit v1.2.3 From 8ed14a3c481c3fc59f10cd084ea203cb45e89309 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 1 Apr 2020 17:51:59 +0200 Subject: Stabilize QScroller test Show and activate the widget, otherwise we can't rely on geometry and gesture event delivery. Use QTRY_ macros in a few more places. As a drive-by, fix coding style. Change-Id: If3a13732ae6b07a137fec89e78b7e6b39e066bed Fixes: QTBUG-82947 Reviewed-by: Shawn Rutledge --- .../auto/widgets/util/qscroller/tst_qscroller.cpp | 157 +++++++++++---------- 1 file changed, 82 insertions(+), 75 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/util/qscroller/tst_qscroller.cpp b/tests/auto/widgets/util/qscroller/tst_qscroller.cpp index 8bdd4b4783..5e71c1888d 100644 --- a/tests/auto/widgets/util/qscroller/tst_qscroller.cpp +++ b/tests/auto/widgets/util/qscroller/tst_qscroller.cpp @@ -82,8 +82,8 @@ public: currentPos = se->contentPos(); overshoot = se->overshootDistance(); - if (!qFuzzyCompare( overshoot.x() + 1.0, 1.0 ) || - !qFuzzyCompare( overshoot.y() + 1.0, 1.0 )) + if (!qFuzzyCompare(overshoot.x() + 1.0, 1.0) || + !qFuzzyCompare(overshoot.y() + 1.0, 1.0)) receivedOvershoot = true; return true; } @@ -116,8 +116,8 @@ public: ~tst_QScroller() { } private: - void kineticScroll( tst_QScrollerWidget *sw, QPointF from, QPoint touchStart, QPoint touchUpdate, QPoint touchEnd); - void kineticScrollNoTest( tst_QScrollerWidget *sw, QPointF from, QPoint touchStart, QPoint touchUpdate, QPoint touchEnd); + void kineticScroll(tst_QScrollerWidget *sw, QPointF from, QPoint touchStart, QPoint touchUpdate, QPoint touchEnd); + void kineticScrollNoTest(tst_QScrollerWidget *sw, QPointF from, QPoint touchStart, QPoint touchUpdate, QPoint touchEnd); private slots: void staticScrollers(); @@ -135,13 +135,13 @@ private: Generates touchBegin, touchUpdate and touchEnd events to trigger scrolling. Tests some in between states but does not wait until scrolling is finished. */ -void tst_QScroller::kineticScroll( tst_QScrollerWidget *sw, QPointF from, QPoint touchStart, QPoint touchUpdate, QPoint touchEnd) +void tst_QScroller::kineticScroll(tst_QScrollerWidget *sw, QPointF from, QPoint touchStart, QPoint touchUpdate, QPoint touchEnd) { sw->scrollPosition = from; sw->currentPos= from; QScroller *s1 = QScroller::scroller(sw); - QCOMPARE( s1->state(), QScroller::Inactive ); + QCOMPARE(s1->state(), QScroller::Inactive); QScrollerProperties sp1 = QScroller::scroller(sw)->scrollerProperties(); @@ -161,7 +161,7 @@ void tst_QScroller::kineticScroll( tst_QScrollerWidget *sw, QPointF from, QPoint (QList() << touchPoint)); QApplication::sendEvent(sw, &touchEvent1); - QCOMPARE( s1->state(), QScroller::Pressed ); + QCOMPARE(s1->state(), QScroller::Pressed); // send the touch update far enough to trigger a scroll QTest::qWait(200); // we need to wait a little or else the speed would be infinite. now we have around 500 pixel per second. @@ -175,13 +175,13 @@ void tst_QScroller::kineticScroll( tst_QScrollerWidget *sw, QPointF from, QPoint (QList() << touchPoint)); QApplication::sendEvent(sw, &touchEvent2); - QCOMPARE( s1->state(), QScroller::Dragging ); - QCOMPARE( sw->receivedPrepare, true ); + QCOMPARE(s1->state(), QScroller::Dragging); + QCOMPARE(sw->receivedPrepare, true); - QTRY_COMPARE( sw->receivedFirst, true ); - QCOMPARE( sw->receivedScroll, true ); - QCOMPARE( sw->receivedOvershoot, false ); + QTRY_COMPARE(sw->receivedFirst, true); + QCOMPARE(sw->receivedScroll, true); + QCOMPARE(sw->receivedOvershoot, false); // note that the scrolling goes in a different direction than the mouse move QPoint calculatedPos = from.toPoint() - touchUpdate - touchStart; @@ -204,13 +204,13 @@ void tst_QScroller::kineticScroll( tst_QScrollerWidget *sw, QPointF from, QPoint Generates touchBegin, touchUpdate and touchEnd events to trigger scrolling. This function does not have any in between tests, it does not expect the scroller to actually scroll. */ -void tst_QScroller::kineticScrollNoTest( tst_QScrollerWidget *sw, QPointF from, QPoint touchStart, QPoint touchUpdate, QPoint touchEnd) +void tst_QScroller::kineticScrollNoTest(tst_QScrollerWidget *sw, QPointF from, QPoint touchStart, QPoint touchUpdate, QPoint touchEnd) { sw->scrollPosition = from; sw->currentPos = from; QScroller *s1 = QScroller::scroller(sw); - QCOMPARE( s1->state(), QScroller::Inactive ); + QCOMPARE(s1->state(), QScroller::Inactive); QScrollerProperties sp1 = s1->scrollerProperties(); int fps = 60; @@ -348,52 +348,57 @@ void tst_QScroller::scrollerProperties() void tst_QScroller::scrollTo() { - { - tst_QScrollerWidget *sw = new tst_QScrollerWidget(); - sw->scrollArea = QRectF( 0, 0, 1000, 1000 ); - sw->scrollPosition = QPointF( 500, 500 ); - - QScroller *s1 = QScroller::scroller(sw); - QCOMPARE( s1->state(), QScroller::Inactive ); - - // a normal scroll - s1->scrollTo(QPointF(100,100), 100); - QTest::qWait(200); - - QCOMPARE( sw->receivedPrepare, true ); - QCOMPARE( sw->receivedScroll, true ); - QCOMPARE( sw->receivedFirst, true ); - QCOMPARE( sw->receivedLast, true ); - QCOMPARE( sw->receivedOvershoot, false ); - QVERIFY(qFuzzyCompare( sw->currentPos.x(), 100 )); - QVERIFY(qFuzzyCompare( sw->currentPos.y(), 100 )); - - delete sw; - } + QScopedPointer sw(new tst_QScrollerWidget); + sw->show(); + QApplication::setActiveWindow(sw.data()); + if (!QTest::qWaitForWindowExposed(sw.data()) || !QTest::qWaitForWindowActive(sw.data())) + QSKIP("Failed to show and activate window"); + + sw->scrollArea = QRectF(0, 0, 1000, 1000); + sw->scrollPosition = QPointF(500, 500); + + QScroller *s1 = QScroller::scroller(sw.data()); + QCOMPARE(s1->state(), QScroller::Inactive); + + // a normal scroll + s1->scrollTo(QPointF(100,100), 100); + QTest::qWait(200); + + QTRY_COMPARE(sw->receivedPrepare, true); + QCOMPARE(sw->receivedScroll, true); + QCOMPARE(sw->receivedFirst, true); + QCOMPARE(sw->receivedLast, true); + QCOMPARE(sw->receivedOvershoot, false); + QTRY_VERIFY(qFuzzyCompare(sw->currentPos.x(), 100)); + QVERIFY(qFuzzyCompare(sw->currentPos.y(), 100)); } void tst_QScroller::scroll() { #if QT_CONFIG(gestures) && QT_CONFIG(scroller) // -- good case. normal scroll - tst_QScrollerWidget *sw = new tst_QScrollerWidget(); + QScopedPointer sw(new tst_QScrollerWidget()); sw->scrollArea = QRectF(0, 0, 1000, 1000); - QScroller::grabGesture(sw, QScroller::TouchGesture); + QScroller::grabGesture(sw.data(), QScroller::TouchGesture); sw->setGeometry(100, 100, 400, 300); + sw->show(); + QApplication::setActiveWindow(sw.data()); + if (!QTest::qWaitForWindowExposed(sw.data()) || !QTest::qWaitForWindowActive(sw.data())) + QSKIP("Failed to show and activate window"); - QScroller *s1 = QScroller::scroller(sw); - kineticScroll(sw, QPointF(500, 500), QPoint(0, 0), QPoint(100, 100), QPoint(200, 200)); + QScroller *s1 = QScroller::scroller(sw.data()); + kineticScroll(sw.data(), QPointF(500, 500), QPoint(0, 0), QPoint(100, 100), QPoint(200, 200)); // now we should be scrolling - QTRY_COMPARE( s1->state(), QScroller::Scrolling ); + QTRY_COMPARE(s1->state(), QScroller::Scrolling); // wait until finished, check that no further first scroll is sent sw->receivedFirst = false; sw->receivedScroll = false; QTRY_VERIFY(s1->state() != QScroller::Scrolling); - QCOMPARE( sw->receivedFirst, false ); - QCOMPARE( sw->receivedScroll, true ); - QCOMPARE( sw->receivedLast, true ); + QCOMPARE(sw->receivedFirst, false); + QCOMPARE(sw->receivedScroll, true); + QCOMPARE(sw->receivedLast, true); QVERIFY(sw->currentPos.x() < 400); QVERIFY(sw->currentPos.y() < 400); @@ -401,26 +406,28 @@ void tst_QScroller::scroll() sw->reset(); sw->scrollArea = QRectF(0, 0, 0, 1000); - kineticScrollNoTest(sw, QPointF(0, 500), QPoint(0, 0), QPoint(100, 0), QPoint(200, 0)); + kineticScrollNoTest(sw.data(), QPointF(0, 500), QPoint(0, 0), QPoint(100, 0), QPoint(200, 0)); QTRY_COMPARE(s1->state(), QScroller::Inactive); QCOMPARE(sw->currentPos.x(), 0.0); QCOMPARE(sw->currentPos.y(), 500.0); - - delete sw; #endif } void tst_QScroller::overshoot() { #if QT_CONFIG(gestures) && QT_CONFIG(scroller) - tst_QScrollerWidget *sw = new tst_QScrollerWidget(); + QScopedPointer sw(new tst_QScrollerWidget); sw->scrollArea = QRectF(0, 0, 1000, 1000); - QScroller::grabGesture(sw, QScroller::TouchGesture); + QScroller::grabGesture(sw.data(), QScroller::TouchGesture); sw->setGeometry(100, 100, 400, 300); + sw->show(); + QApplication::setActiveWindow(sw.data()); + if (!QTest::qWaitForWindowExposed(sw.data()) || !QTest::qWaitForWindowActive(sw.data())) + QSKIP("Failed to show and activate window"); - QScroller *s1 = QScroller::scroller(sw); + QScroller *s1 = QScroller::scroller(sw.data()); QScrollerProperties sp1 = s1->scrollerProperties(); sp1.setScrollMetric(QScrollerProperties::OvershootDragResistanceFactor, 0.5); @@ -431,14 +438,14 @@ void tst_QScroller::overshoot() sp1.setScrollMetric(QScrollerProperties::HorizontalOvershootPolicy, QVariant::fromValue(QScrollerProperties::OvershootWhenScrollable)); s1->setScrollerProperties(sp1); - kineticScrollNoTest(sw, QPointF(500, 500), QPoint(0, 0), QPoint(400, 0), QPoint(490, 0)); + kineticScrollNoTest(sw.data(), QPointF(500, 500), QPoint(0, 0), QPoint(400, 0), QPoint(490, 0)); QTRY_COMPARE(s1->state(), QScroller::Inactive); //qDebug() << "Overshoot fuzzy: "<currentPos; - QVERIFY(qFuzzyCompare( sw->currentPos.x(), 0 )); - QVERIFY(qFuzzyCompare( sw->currentPos.y(), 500 )); - QCOMPARE( sw->receivedOvershoot, true ); + QVERIFY(qFuzzyCompare(sw->currentPos.x(), 0)); + QVERIFY(qFuzzyCompare(sw->currentPos.y(), 500)); + QCOMPARE(sw->receivedOvershoot, true); // -- try to scroll with overshoot (when scrollable bad case) sw->reset(); @@ -446,14 +453,14 @@ void tst_QScroller::overshoot() sp1.setScrollMetric(QScrollerProperties::HorizontalOvershootPolicy, QVariant::fromValue(QScrollerProperties::OvershootWhenScrollable)); s1->setScrollerProperties(sp1); - kineticScrollNoTest(sw, QPointF(0, 500), QPoint(0, 0), QPoint(400, 0), QPoint(490, 0)); + kineticScrollNoTest(sw.data(), QPointF(0, 500), QPoint(0, 0), QPoint(400, 0), QPoint(490, 0)); QTRY_COMPARE(s1->state(), QScroller::Inactive); //qDebug() << "Overshoot fuzzy: "<currentPos; - QVERIFY(qFuzzyCompare( sw->currentPos.x(), 0 )); - QVERIFY(qFuzzyCompare( sw->currentPos.y(), 500 )); - QCOMPARE( sw->receivedOvershoot, false ); + QVERIFY(qFuzzyCompare(sw->currentPos.x(), 0)); + QVERIFY(qFuzzyCompare(sw->currentPos.y(), 500)); + QCOMPARE(sw->receivedOvershoot, false); // -- try to scroll with overshoot (always on) sw->reset(); @@ -461,15 +468,15 @@ void tst_QScroller::overshoot() sp1.setScrollMetric(QScrollerProperties::HorizontalOvershootPolicy, QVariant::fromValue(QScrollerProperties::OvershootAlwaysOn)); s1->setScrollerProperties(sp1); - kineticScrollNoTest(sw, QPointF(0, 500), QPoint(0, 0), QPoint(400, 0), QPoint(490, 0)); + kineticScrollNoTest(sw.data(), QPointF(0, 500), QPoint(0, 0), QPoint(400, 0), QPoint(490, 0)); QTRY_COMPARE(s1->state(), QScroller::Inactive); //qDebug() << "Overshoot fuzzy: "<currentPos; - QVERIFY(qFuzzyCompare( sw->currentPos.x(), 0 )); - QVERIFY(qFuzzyCompare( sw->currentPos.y(), 500 )); - QCOMPARE( sw->receivedOvershoot, true ); + QVERIFY(qFuzzyCompare(sw->currentPos.x(), 0)); + QVERIFY(qFuzzyCompare(sw->currentPos.y(), 500)); + QCOMPARE(sw->receivedOvershoot, true); // -- try to scroll with overshoot (always off) sw->reset(); @@ -477,13 +484,13 @@ void tst_QScroller::overshoot() sp1.setScrollMetric(QScrollerProperties::HorizontalOvershootPolicy, QVariant::fromValue(QScrollerProperties::OvershootAlwaysOff)); s1->setScrollerProperties(sp1); - kineticScrollNoTest(sw, QPointF(500, 500), QPoint(0, 0), QPoint(400, 0), QPoint(490, 0)); + kineticScrollNoTest(sw.data(), QPointF(500, 500), QPoint(0, 0), QPoint(400, 0), QPoint(490, 0)); QTRY_COMPARE(s1->state(), QScroller::Inactive); - QVERIFY(qFuzzyCompare( sw->currentPos.x(), 0 )); - QVERIFY(qFuzzyCompare( sw->currentPos.y(), 500 )); - QCOMPARE( sw->receivedOvershoot, false ); + QVERIFY(qFuzzyCompare(sw->currentPos.x(), 0)); + QVERIFY(qFuzzyCompare(sw->currentPos.y(), 500)); + QCOMPARE(sw->receivedOvershoot, false); // -- try to scroll with overshoot (always on but max overshoot = 0) sp1.setScrollMetric(QScrollerProperties::OvershootDragDistanceFactor, 0.0); @@ -493,39 +500,39 @@ void tst_QScroller::overshoot() sp1.setScrollMetric(QScrollerProperties::HorizontalOvershootPolicy, QVariant::fromValue(QScrollerProperties::OvershootAlwaysOn)); s1->setScrollerProperties(sp1); - kineticScrollNoTest(sw, QPointF(500, 500), QPoint(0, 0), QPoint(400, 0), QPoint(490, 0)); + kineticScrollNoTest(sw.data(), QPointF(500, 500), QPoint(0, 0), QPoint(400, 0), QPoint(490, 0)); QTRY_COMPARE(s1->state(), QScroller::Inactive); - QVERIFY(qFuzzyCompare( sw->currentPos.x(), 0 )); - QVERIFY(qFuzzyCompare( sw->currentPos.y(), 500 )); - QCOMPARE( sw->receivedOvershoot, false ); - - delete sw; + QVERIFY(qFuzzyCompare(sw->currentPos.x(), 0)); + QVERIFY(qFuzzyCompare(sw->currentPos.y(), 500)); + QCOMPARE(sw->receivedOvershoot, false); #endif } void tst_QScroller::multipleWindows() { #if QT_CONFIG(gestures) && QT_CONFIG(scroller) - QScopedPointer sw1(new tst_QScrollerWidget()); + QScopedPointer sw1(new tst_QScrollerWidget); sw1->scrollArea = QRectF(0, 0, 1000, 1000); QScroller::grabGesture(sw1.data(), QScroller::TouchGesture); sw1->setGeometry(100, 100, 400, 300); + QScroller *s1 = QScroller::scroller(sw1.data()); kineticScroll(sw1.data(), QPointF(500, 500), QPoint(0, 0), QPoint(100, 100), QPoint(200, 200)); // now we should be scrolling - QTRY_COMPARE( s1->state(), QScroller::Scrolling ); + QTRY_COMPARE(s1->state(), QScroller::Scrolling); // That was fun! Do it again! QScopedPointer sw2(new tst_QScrollerWidget()); sw2->scrollArea = QRectF(0, 0, 1000, 1000); QScroller::grabGesture(sw2.data(), QScroller::TouchGesture); sw2->setGeometry(100, 100, 400, 300); + QScroller *s2 = QScroller::scroller(sw2.data()); kineticScroll(sw2.data(), QPointF(500, 500), QPoint(0, 0), QPoint(100, 100), QPoint(200, 200)); // now we should be scrolling - QTRY_COMPARE( s2->state(), QScroller::Scrolling ); + QTRY_COMPARE(s2->state(), QScroller::Scrolling); // wait for both to stop QTRY_VERIFY(s1->state() != QScroller::Scrolling); -- cgit v1.2.3 From 4ee7adf59d13ada5bfaa4f0382e0bb70b66b8814 Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Tue, 10 Mar 2020 11:47:12 +0100 Subject: Try to stabilize flaky test cases of tst_qsequentialanimationgroup Use QTRY_COMPARE in the flaky tests instead of waiting. Change-Id: Ic18fc5fde3fa47f3b3ef21e6acd876bd6990981d Reviewed-by: Friedemann Kleint (cherry picked from commit 0ae6803d3956cf59801bbcc52143b95de9fc96d1) --- .../qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp b/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp index 06e9fe7a66..d6607dc813 100644 --- a/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp +++ b/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp @@ -1295,10 +1295,9 @@ void tst_QSequentialAnimationGroup::startGroupWithRunningChild() QCOMPARE(anim1->state(), QAnimationGroup::Running); QCOMPARE(anim2->state(), QAnimationGroup::Paused); - QTest::qWait(300); - + // Wait until anim1 finishes (anim2 should be still running) + QTRY_COMPARE(anim1->state(), QAnimationGroup::Stopped); QCOMPARE(group.state(), QAnimationGroup::Running); - QCOMPARE(anim1->state(), QAnimationGroup::Stopped); QCOMPARE(anim2->state(), QAnimationGroup::Running); QCOMPARE(stateChangedSpy2.count(), 4); @@ -1615,7 +1614,7 @@ void tst_QSequentialAnimationGroup::clear() group.start(); QTest::qWait(anim1->duration() + 100); QTRY_COMPARE(group.state(), QAbstractAnimation::Running); - QVERIFY(anim1 == 0); //anim1 should have been deleted + QTRY_COMPARE(anim1, nullptr); // anim1 should have been deleted } void tst_QSequentialAnimationGroup::pauseResume() -- cgit v1.2.3 From 9ead0b04318345e8f2f573125e10c99f0a4b8e3c Mon Sep 17 00:00:00 2001 From: Kari Oikarinen Date: Tue, 25 Feb 2020 17:23:48 +0200 Subject: tst_QScopeGuard: Fix build by giving template parameters explicitly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit std::function does not have deduction guides in older libc++ (presumably older than version 10). Omitting the template parameter isn't essential for the test, so just give it. Change-Id: Ia9bb91f961b0928203737ec976913effd06433e0 Reviewed-by: Jüri Valdmann --- tests/auto/corelib/tools/qscopeguard/tst_qscopeguard.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/tools/qscopeguard/tst_qscopeguard.cpp b/tests/auto/corelib/tools/qscopeguard/tst_qscopeguard.cpp index e5393f694e..dded694001 100644 --- a/tests/auto/corelib/tools/qscopeguard/tst_qscopeguard.cpp +++ b/tests/auto/corelib/tools/qscopeguard/tst_qscopeguard.cpp @@ -100,8 +100,8 @@ void tst_QScopeGuard::construction() QScopeGuard fromFunctionPointer(&func); QScopeGuard fromNonVoidFunction(intFunc); QScopeGuard fromNoDiscardFunction(noDiscardFunc); - QScopeGuard fromStdFunction{std::function(func)}; - std::function stdFunction(func); + QScopeGuard fromStdFunction{std::function(func)}; + std::function stdFunction(func); QScopeGuard fromNamedStdFunction(stdFunction); #else QSKIP("This test requires C++17 Class Template Argument Deduction support enabled in the compiler."); -- cgit v1.2.3