From f6b36eaafec24b4c67efff621d380a4ca4257d0b Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 22 May 2017 20:01:04 +0200 Subject: QHeaderView: fix visual/logical index corruption when restoring state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a followup to 77a8e90cddcfa1c34518ef846a4838874a7bc0c7 which didn't handle the case where no columns had been moved. visualIndices and logicalIndices are empty until initializeIndexMapping() is called, in which case appending is wrong. As a result, visualIndex(i) would return -1 for the values over those added by read(), and an assert would happen at painting time. The fix is to leave visualIndices and logicalIndices empty if they are empty already, leaving it to initializeIndexMapping() to fill them later if necessary (e.g. when moving a column). Task-number: QTBUG-60837 Change-Id: Ia7e4b9d3122647984acd434dfaa0400df319d065 Reviewed-by: Marc Mutz Reviewed-by: Thorbjørn Lund Martsum --- .../itemviews/qheaderview/tst_qheaderview.cpp | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp index 7bfec2831d..b13e7b2f33 100644 --- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp @@ -171,6 +171,7 @@ private slots: void saveRestore(); void restoreQt4State(); void restoreToMoreColumns(); + void restoreToMoreColumnsNoMovedColumns(); void restoreBeforeSetModel(); void defaultSectionSizeTest(); void defaultSectionSizeTestStyles(); @@ -1690,6 +1691,55 @@ void tst_QHeaderView::restoreToMoreColumns() QCOMPARE(h4.hiddenSectionCount(), 1); QCOMPARE(h4.sortIndicatorSection(), 2); QCOMPARE(h4.sortIndicatorOrder(), Qt::DescendingOrder); + QCOMPARE(h4.logicalIndex(0), 2); + QCOMPARE(h4.logicalIndex(1), 1); + QCOMPARE(h4.logicalIndex(2), 0); + QCOMPARE(h4.visualIndex(0), 2); + QCOMPARE(h4.visualIndex(1), 1); + QCOMPARE(h4.visualIndex(2), 0); + + // Repainting shouldn't crash + h4.show(); + QVERIFY(QTest::qWaitForWindowExposed(&h4)); +} + +void tst_QHeaderView::restoreToMoreColumnsNoMovedColumns() +{ + // Given a model with 2 columns, for saving state + QHeaderView h1(Qt::Horizontal); + QStandardItemModel model1(1, 2); + h1.setModel(&model1); + QCOMPARE(h1.visualIndex(0), 0); + QCOMPARE(h1.visualIndex(1), 1); + QCOMPARE(h1.logicalIndex(0), 0); + QCOMPARE(h1.logicalIndex(1), 1); + const QByteArray savedState = h1.saveState(); + + // And a model with 3 columns, to apply that state upon + QHeaderView h2(Qt::Horizontal); + QStandardItemModel model2(1, 3); + h2.setModel(&model2); + QCOMPARE(h2.visualIndex(0), 0); + QCOMPARE(h2.visualIndex(1), 1); + QCOMPARE(h2.visualIndex(2), 2); + QCOMPARE(h2.logicalIndex(0), 0); + QCOMPARE(h2.logicalIndex(1), 1); + QCOMPARE(h2.logicalIndex(2), 2); + + // When calling restoreState() + QVERIFY(h2.restoreState(savedState)); + + // Then the index mapping should still be as default + QCOMPARE(h2.visualIndex(0), 0); + QCOMPARE(h2.visualIndex(1), 1); + QCOMPARE(h2.visualIndex(2), 2); + QCOMPARE(h2.logicalIndex(0), 0); + QCOMPARE(h2.logicalIndex(1), 1); + QCOMPARE(h2.logicalIndex(2), 2); + + // And repainting shouldn't crash + h2.show(); + QVERIFY(QTest::qWaitForWindowExposed(&h2)); } void tst_QHeaderView::restoreBeforeSetModel() -- cgit v1.2.3 From 315f634180697a2c47286817d7c54aeb11b6bc11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tony=20Saraj=C3=A4rvi?= Date: Wed, 17 May 2017 09:06:07 +0300 Subject: Fix autotest not to open too many files on a Unix tst_QSharedPointer can't create a pipe as the OS has too many files open. Systems like macOS have a lower limit to these simultaneous files open. Task-number: QTBUG-60410 Change-Id: I21e89f992ada2a7d09b706522a05b5952f00ec33 Reviewed-by: Simon Hausmann --- .../tools/qsharedpointer/tst_qsharedpointer.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp index 7850478602..442d4d089c 100644 --- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp @@ -43,6 +43,10 @@ #include #include +#ifdef Q_OS_UNIX +#include +#endif + QT_BEGIN_NAMESPACE namespace QtSharedPointer { Q_CORE_EXPORT void internalSafetyCheckCleanCheck(); @@ -54,6 +58,7 @@ class tst_QSharedPointer: public QObject Q_OBJECT private slots: + void initTestCase(); void basics_data(); void basics(); void operators(); @@ -118,6 +123,20 @@ public: } }; +void tst_QSharedPointer::initTestCase() +{ +#if defined(Q_OS_UNIX) + // The tests create a lot of threads, which require file descriptors. On systems like + // OS X low defaults such as 256 as the limit for the number of simultaneously + // open files is not sufficient. + struct rlimit numFiles; + if (getrlimit(RLIMIT_NOFILE, &numFiles) == 0 && numFiles.rlim_cur < 1024) { + numFiles.rlim_cur = qMin(rlim_t(1024), numFiles.rlim_max); + setrlimit(RLIMIT_NOFILE, &numFiles); + } +#endif +} + template static inline QtSharedPointer::ExternalRefCountData *refCountData(const QSharedPointer &b) { -- cgit v1.2.3 From 8b1377fde16a2049a1c27f6d005bff84a8f85f28 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 25 Apr 2017 13:29:07 +0200 Subject: QWidgetEffectSourcePrivate::draw(): Call render() when no shared painter exists Task-number: QTBUG-60231 Change-Id: If07274a01bb9a4b9323865a3e061b3674507fd5b Reviewed-by: Andy Shaw Reviewed-by: Frederik Gladhorn --- .../effects/qgraphicseffect/tst_qgraphicseffect.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp index a1cb729849..4d289dcb02 100644 --- a/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp +++ b/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp @@ -52,6 +52,7 @@ private slots: void boundingRect2(); void draw(); void opacity(); + void nestedOpaqueOpacity(); void grayscale(); void colorize(); void drawPixmapItem(); @@ -407,6 +408,26 @@ void tst_QGraphicsEffect::opacity() QCOMPARE(effect->m_opacity, qreal(0.5)); } +void tst_QGraphicsEffect::nestedOpaqueOpacity() +{ + // QTBUG-60231: Nesting widgets with a QGraphicsEffect on a toplevel with + // QGraphicsOpacityEffect caused crashes due to constructing several + // QPainter instances on a device in the fast path for + // QGraphicsOpacityEffect::opacity=1 + QWidget topLevel; + topLevel.setWindowTitle(QTest::currentTestFunction()); + topLevel.resize(QApplication::desktop()->screenGeometry(&topLevel).size() / 8); + QGraphicsOpacityEffect *opacityEffect = new QGraphicsOpacityEffect; + opacityEffect->setOpacity(1); + topLevel.setGraphicsEffect(opacityEffect); + QWidget *child = new QWidget(&topLevel); + child->resize(topLevel.size() / 2); + QGraphicsDropShadowEffect *childEffect = new QGraphicsDropShadowEffect; + child->setGraphicsEffect(childEffect); + topLevel.show(); + QVERIFY(QTest::qWaitForWindowExposed(&topLevel)); +} + void tst_QGraphicsEffect::grayscale() { if (qApp->desktop()->depth() < 24) -- cgit v1.2.3 From a089de0d992072bb06aa35323a53ca6cb5d76557 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Fri, 26 May 2017 13:28:55 +0200 Subject: Fix tst_QWidget::translucentWidget() on high DPI displays It was grabbing a QLabel without accounting for the size of the window in the case where the DPI is larger than 1: FAIL! : tst_QWidget::translucentWidget() Compared values are not the same Actual (actual.size()) : QSize(32x32) Expected (expected.size()): QSize(16x16) Change-Id: I4873f3c6364ee2696f5612d91e6c97c60b2cd915 Reviewed-by: Friedemann Kleint --- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index e68f0f57ef..0933dc991d 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -8526,8 +8526,8 @@ void tst_QWidget::translucentWidget() else #endif widgetSnapshot = label.grab(QRect(QPoint(0, 0), label.size())); - QImage actual = widgetSnapshot.toImage().convertToFormat(QImage::Format_RGB32); - QImage expected = pm.toImage().convertToFormat(QImage::Format_RGB32); + const QImage actual = widgetSnapshot.toImage().convertToFormat(QImage::Format_RGB32); + const QImage expected = pm.toImage().scaled(label.devicePixelRatioF() * pm.size()); QCOMPARE(actual.size(),expected.size()); QCOMPARE(actual,expected); } -- cgit v1.2.3 From e579c822c5bedf5e626e4eb72db3b49a4a4015dc Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 26 May 2017 13:33:29 -0700 Subject: tst_qudpsocket: Blacklist "utun" interfaces on Darwin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Packets sent to to link-local addresses on it are never received. We don't know why this happens, as the tooling provided by Apple for development is close to useless. So we just ignore this interface. Task-number: QTBUG-61041 Change-Id: Ia608df1fff6bdee5238e107d8a50292a1f9e5c03 Reviewed-by: Tony Sarajärvi --- tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests') diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp index 9a604e5d04..b476fdd334 100644 --- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp @@ -1553,9 +1553,17 @@ void tst_QUdpSocket::linkLocalIPv6() //Windows preallocates link local addresses to interfaces that are down. //These may or may not work depending on network driver if (iface.flags() & QNetworkInterface::IsUp) { +#if defined(Q_OS_WIN) // Do not add the Teredo Tunneling Pseudo Interface on Windows. if (iface.humanReadableName().contains("Teredo")) continue; +#elif defined(Q_OS_DARWIN) + // Do not add "utun" interfaces on macOS: nothing ever gets received + // (we don't know why) + if (iface.name().startsWith("utun")) + continue; +#endif + foreach (QNetworkAddressEntry addressEntry, iface.addressEntries()) { QHostAddress addr(addressEntry.ip()); if (!addr.scopeId().isEmpty() && addr.isInSubnet(localMask, 64)) { -- cgit v1.2.3 From 64a4216254a49ae0ba946717599c4f52dac978c5 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 24 May 2017 16:06:28 +0200 Subject: tst_QFiledialog: use escape to close dialogs instead of timer This makes the test a lot faster and perhaps more reliable. Change-Id: I055cfde627c75f71735eabbf01af2a196bd8b00a Reviewed-by: Friedemann Kleint --- tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp index 44cb5a5bf8..8d209fc241 100644 --- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp @@ -1463,10 +1463,7 @@ class DialogRejecter : public QObject public: DialogRejecter() { - QTimer *timer = new QTimer(this); - timer->setInterval(1000); - connect(timer, &QTimer::timeout, this, &DialogRejecter::rejectFileDialog); - timer->start(); + connect(qApp, &QApplication::focusChanged, this, &DialogRejecter::rejectFileDialog); } public slots: @@ -1474,7 +1471,7 @@ public slots: { if (QWidget *w = QApplication::activeModalWidget()) if (QDialog *d = qobject_cast(w)) - d->reject(); + QTest::keyClick(d, Qt::Key_Escape); } }; -- cgit v1.2.3 From c25ad981a334a4a720ae48cfe800868c4aef51a9 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 24 May 2017 17:15:17 +0200 Subject: QWidgetWindow: don't give focus to windows that are being destroyed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the referenced bug report, dismissing a QFileDialog while the Qt Virtual Keyboard was in use would result in a crash. Dismissing a file dialog created with e.g. QFileDialog::getOpenFileName() causes it to eventually be destroyed. When this happens, it starts deleting its children. Each child widget's destructor calls clearFocus(). In clearFocus(), there is a block of code that emits QWindow::focusChanged(), passing the result of focusObject() called on that widget's window. QWidgetWindow::focusObject() could end up using itself as a fallback focus object if it had no other focus objects (e.g. children) to use instead, even though it was in the process of being destroyed; as were all of its children. The Qt Virtual Keyboard plugin would then try to use the focus object, even though it was in an invalid state. To fix this problem, we return early from QWidgetWindow::focusObject() if the window is in the process of being destroyed. Task-number: QTBUG-57193 Change-Id: I137cf9415812ce2e0419c0afe8076ce150f248cb Reviewed-by: Friedemann Kleint Reviewed-by: Jarkko Koivikko Reviewed-by: Tor Arne Vestbø --- .../dialogs/qfiledialog/tst_qfiledialog.cpp | 34 +++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp index 8d209fc241..05410f4a0f 100644 --- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp @@ -144,6 +144,7 @@ private slots: #endif void rejectModalDialogs(); void QTBUG49600_nativeIconProviderCrash(); + void focusObjectDuringDestruction(); // NOTE: Please keep widgetlessNativeDialog() as the LAST test! // @@ -1467,7 +1468,7 @@ public: } public slots: - void rejectFileDialog() + virtual void rejectFileDialog() { if (QWidget *w = QApplication::activeModalWidget()) if (QDialog *d = qobject_cast(w)) @@ -1511,5 +1512,36 @@ void tst_QFiledialog::QTBUG49600_nativeIconProviderCrash() fd.iconProvider(); } +class qtbug57193DialogRejecter : public DialogRejecter +{ +public: + void rejectFileDialog() override + { + QCOMPARE(QGuiApplication::topLevelWindows().size(), 1); + const QWindow *window = QGuiApplication::topLevelWindows().constFirst(); + + const QFileDialog *fileDialog = qobject_cast(QApplication::activeModalWidget()); + QVERIFY(fileDialog); + + // The problem in QTBUG-57193 was from a platform input context plugin that was + // connected to QWindow::focusObjectChanged(), and consequently accessed the focus + // object (the QFileDialog) that was in the process of being destroyed. This test + // checks that the QFileDialog is never set as the focus object after its destruction process begins. + connect(window, &QWindow::focusObjectChanged, [=](QObject *focusObject) { + QVERIFY(focusObject != fileDialog); + }); + DialogRejecter::rejectFileDialog(); + } +}; + +void tst_QFiledialog::focusObjectDuringDestruction() +{ + QTRY_VERIFY(QGuiApplication::topLevelWindows().isEmpty()); + + qtbug57193DialogRejecter dialogRejecter; + + QFileDialog::getOpenFileName(nullptr, QString(), QString(), QString(), nullptr); +} + QTEST_MAIN(tst_QFiledialog) #include "tst_qfiledialog.moc" -- cgit v1.2.3 From dbeb748de30bcc0e0615d21c593b761408404950 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Mon, 29 May 2017 17:35:58 +0200 Subject: Convert features.printdialog to QT_[REQUIRE_]CONFIG Change-Id: Ifb016ae2a0986b436f788b34513c81ea91f3804a Reviewed-by: Oswald Buddenhagen --- .../dialogs/qabstractprintdialog/tst_qabstractprintdialog.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/printsupport/dialogs/qabstractprintdialog/tst_qabstractprintdialog.cpp b/tests/auto/printsupport/dialogs/qabstractprintdialog/tst_qabstractprintdialog.cpp index 79c910cb5b..bb3624a51d 100644 --- a/tests/auto/printsupport/dialogs/qabstractprintdialog/tst_qabstractprintdialog.cpp +++ b/tests/auto/printsupport/dialogs/qabstractprintdialog/tst_qabstractprintdialog.cpp @@ -31,14 +31,17 @@ #include #include +#include +#if QT_CONFIG(printdialog) #include #include +#endif class tst_QAbstractPrintDialog : public QObject { Q_OBJECT -#if defined(QT_NO_PRINTER) || defined(QT_NO_PRINTDIALOG) +#if !QT_CONFIG(printdialog) public slots: void initTestCase(); #else @@ -49,7 +52,7 @@ private slots: #endif }; -#if defined(QT_NO_PRINTER) || defined(QT_NO_PRINTDIALOG) +#if !QT_CONFIG(printdialog) void tst_QAbstractPrintDialog::initTestCase() { QSKIP("This test requires printing and print dialog support"); -- cgit v1.2.3 From a0d3b5bb2b19cec782a395700ef3a087c27c71f6 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Tue, 16 May 2017 10:53:49 +0200 Subject: Fix tst_qmessagehandler for configurations without process support Change-Id: If61a7b1e389e7fffb9cfa85d6b5d77a7b777215f Reviewed-by: Friedemann Kleint --- tests/auto/corelib/global/qlogging/tst_qlogging.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp index bb8bb6cc21..3465385ba7 100644 --- a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp +++ b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp @@ -100,11 +100,11 @@ tst_qmessagehandler::tst_qmessagehandler() void tst_qmessagehandler::initTestCase() { +#if QT_CONFIG(process) m_appDir = QFINDTESTDATA("app"); QVERIFY2(!m_appDir.isEmpty(), qPrintable( QString::fromLatin1("Couldn't find helper app dir starting from %1.").arg(QDir::currentPath()))); -#if QT_CONFIG(process) m_baseEnvironment = QProcess::systemEnvironment(); for (int i = 0; i < m_baseEnvironment.count(); ++i) { if (m_baseEnvironment.at(i).startsWith("QT_MESSAGE_PATTERN=")) { -- cgit v1.2.3 From 00d9033fa03fd1f9160f1d1320cc05f1f15fb160 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Tue, 16 May 2017 10:55:04 +0200 Subject: Fix tst_QFile for configurations without process support Change-Id: Icca2d55f0b9402bf4bcb009d972f21075d144f87 Reviewed-by: Friedemann Kleint --- tests/auto/corelib/io/qfile/tst_qfile.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index 81c11ef085..9751bb4c9e 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -412,8 +412,10 @@ static QByteArray msgFileDoesNotExist(const QString &name) void tst_QFile::initTestCase() { QVERIFY2(m_temporaryDir.isValid(), qPrintable(m_temporaryDir.errorString())); +#if QT_CONFIG(process) m_stdinProcessDir = QFINDTESTDATA("stdinprocess"); QVERIFY(!m_stdinProcessDir.isEmpty()); +#endif m_testSourceFile = QFINDTESTDATA("tst_qfile.cpp"); QVERIFY(!m_testSourceFile.isEmpty()); m_testLogFile = QFINDTESTDATA("testlog.txt"); -- cgit v1.2.3 From 72e9aee500cbd1363edf8a517b007ebb8ac6e88a Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Wed, 24 May 2017 12:53:17 +0200 Subject: winrt: Fix tst_QPainterPath We have to use a temporary data path for winrt, as the applications are sandboxed and cannot just put data anywhere. Change-Id: I8f95de132e5b5ac77441cbbf26af873b8018c7cb Reviewed-by: Friedemann Kleint --- tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp b/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp index 757e4d16e4..16215714f3 100644 --- a/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp +++ b/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp @@ -699,9 +699,11 @@ void tst_QPainterPath::testOperatorDatastream() path.addRect(0, 0, 100, 100); path.setFillRule(Qt::WindingFill); + QTemporaryDir tempDir(QDir::tempPath() + "/tst_qpainterpath.XXXXXX"); + QVERIFY2(tempDir.isValid(), qPrintable(tempDir.errorString())); // Write out { - QFile data("data"); + QFile data(tempDir.path() + "/data"); bool ok = data.open(QFile::WriteOnly); QVERIFY(ok); QDataStream stream(&data); @@ -711,7 +713,7 @@ void tst_QPainterPath::testOperatorDatastream() QPainterPath other; // Read in { - QFile data("data"); + QFile data(tempDir.path() + "/data"); bool ok = data.open(QFile::ReadOnly); QVERIFY(ok); QDataStream stream(&data); -- cgit v1.2.3 From 600454578d9e378c2918f0191240ac2f6e2aeabe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tony=20Saraj=C3=A4rvi?= Date: Fri, 26 May 2017 09:19:55 +0300 Subject: Extend blacklisting of tst_QSemaphore tryAcquireWithTimeout(0.2s) was already blacklisted and now the same failed with "(2s)". Task-number: QTBUG-58745 Change-Id: I82363238c08056d2969a7616e3a6e5af080d537d Reviewed-by: Liang Qi --- tests/auto/corelib/thread/qsemaphore/BLACKLIST | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/auto/corelib/thread/qsemaphore/BLACKLIST b/tests/auto/corelib/thread/qsemaphore/BLACKLIST index c198b90253..eb83b03556 100644 --- a/tests/auto/corelib/thread/qsemaphore/BLACKLIST +++ b/tests/auto/corelib/thread/qsemaphore/BLACKLIST @@ -3,3 +3,4 @@ windows osx-10.12 [tryAcquireWithTimeout:2s] windows +osx-10.12 -- cgit v1.2.3 From 32a94e54b58f311f37689f4bc8e0c8a54f0f9216 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 23 May 2017 13:57:20 +0200 Subject: Do not always use argb32pm for subsurfaces A number of drawing paths were never tested by lancelot because we always used argb32pm for subsurfaces. This patch switches the subsurfaces to use the painter format or its alpha version. This means changes to composition tests as it changes precision, especially of alpha in the a2rgb30 formats. Change-Id: I24d53bf6e1db8cca36bda69e2ddf07f20256b3c8 Reviewed-by: Eirik Aavitsland --- tests/auto/other/lancelot/lancelot.pro | 2 +- tests/auto/other/lancelot/paintcommands.cpp | 9 ++++++++- tests/auto/other/lancelot/paintcommands.h | 5 +++-- tests/auto/other/lancelot/scripts/porter_duff.qps | 12 ++++++------ tests/auto/other/lancelot/scripts/porter_duff2.qps | 12 ++++++------ tests/auto/other/lancelot/tst_lancelot.cpp | 10 +++++----- 6 files changed, 29 insertions(+), 21 deletions(-) (limited to 'tests') diff --git a/tests/auto/other/lancelot/lancelot.pro b/tests/auto/other/lancelot/lancelot.pro index 73c12e67a2..6ece7315ed 100644 --- a/tests/auto/other/lancelot/lancelot.pro +++ b/tests/auto/other/lancelot/lancelot.pro @@ -1,6 +1,6 @@ CONFIG += testcase TARGET = tst_lancelot -QT += testlib +QT += testlib gui-private SOURCES += tst_lancelot.cpp \ paintcommands.cpp diff --git a/tests/auto/other/lancelot/paintcommands.cpp b/tests/auto/other/lancelot/paintcommands.cpp index c28812e120..8419f93e3b 100644 --- a/tests/auto/other/lancelot/paintcommands.cpp +++ b/tests/auto/other/lancelot/paintcommands.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #ifndef QT_NO_OPENGL #include @@ -2402,7 +2403,13 @@ void PaintCommands::command_surface_begin(QRegExp re) m_painter = new QPainter(&m_surface_pixmap); #endif } else { - m_surface_image = QImage(qRound(w), qRound(h), QImage::Format_ARGB32_Premultiplied); + QImage::Format surface_format; + if (QImage::toPixelFormat(m_format).alphaUsage() != QPixelFormat::UsesAlpha) + surface_format = qt_alphaVersion(m_format); + else + surface_format = m_format; + + m_surface_image = QImage(qRound(w), qRound(h), surface_format); m_surface_image.fill(0); m_painter = new QPainter(&m_surface_image); } diff --git a/tests/auto/other/lancelot/paintcommands.h b/tests/auto/other/lancelot/paintcommands.h index 4113fd6881..fc7496ce11 100644 --- a/tests/auto/other/lancelot/paintcommands.h +++ b/tests/auto/other/lancelot/paintcommands.h @@ -68,9 +68,10 @@ class PaintCommands { public: // construction / initialization - PaintCommands(const QStringList &cmds, int w, int h) + PaintCommands(const QStringList &cmds, int w, int h, QImage::Format format) : m_painter(0) , m_surface_painter(0) + , m_format(format) , m_commands(cmds) , m_gradientSpread(QGradient::PadSpread) , m_gradientCoordinate(QGradient::LogicalMode) @@ -246,8 +247,8 @@ private: // attributes QPainter *m_painter; QPainter *m_surface_painter; + QImage::Format m_format; QImage m_surface_image; - QPixmap m_surface_pixmap; QRectF m_surface_rect; QStringList m_commands; QString m_currentCommand; diff --git a/tests/auto/other/lancelot/scripts/porter_duff.qps b/tests/auto/other/lancelot/scripts/porter_duff.qps index 166e48a57f..94e9c68522 100644 --- a/tests/auto/other/lancelot/scripts/porter_duff.qps +++ b/tests/auto/other/lancelot/scripts/porter_duff.qps @@ -184,7 +184,7 @@ repeat_block postdraw surface_end -# Multiply +# ColorBurn surface_begin 100 300 100 100 repeat_block predraw setCompositionMode ColorBurn @@ -192,7 +192,7 @@ repeat_block postdraw surface_end -# Screen +# HardLight surface_begin 200 300 100 100 repeat_block predraw setCompositionMode HardLight @@ -200,7 +200,7 @@ repeat_block postdraw surface_end -# Overlay +# SoftLight surface_begin 300 300 100 100 repeat_block predraw setCompositionMode SoftLight @@ -208,7 +208,7 @@ repeat_block postdraw surface_end -# Darken +# Difference surface_begin 400 300 100 100 repeat_block predraw setCompositionMode Difference @@ -216,7 +216,7 @@ repeat_block postdraw surface_end -# Lighten +# Exclusion surface_begin 500 300 100 100 repeat_block predraw setCompositionMode Exclusion @@ -248,4 +248,4 @@ drawText 100 500 "ColorBurn" drawText 200 500 "HardLight" drawText 300 500 "SoftLight" drawText 400 500 "Difference" -drawText 500 500 "Exclusion" \ No newline at end of file +drawText 500 500 "Exclusion" diff --git a/tests/auto/other/lancelot/scripts/porter_duff2.qps b/tests/auto/other/lancelot/scripts/porter_duff2.qps index a792d9b278..f538371ca1 100644 --- a/tests/auto/other/lancelot/scripts/porter_duff2.qps +++ b/tests/auto/other/lancelot/scripts/porter_duff2.qps @@ -194,7 +194,7 @@ repeat_block postdraw surface_end -# Multiply +# ColorBurn surface_begin 100 300 100 100 repeat_block predraw setCompositionMode ColorBurn @@ -202,7 +202,7 @@ repeat_block postdraw surface_end -# Screen +# HardLight surface_begin 200 300 100 100 repeat_block predraw setCompositionMode HardLight @@ -210,7 +210,7 @@ repeat_block postdraw surface_end -# Overlay +# SoftLight surface_begin 300 300 100 100 repeat_block predraw setCompositionMode SoftLight @@ -218,7 +218,7 @@ repeat_block postdraw surface_end -# Darken +# Difference surface_begin 400 300 100 100 repeat_block predraw setCompositionMode Difference @@ -226,7 +226,7 @@ repeat_block postdraw surface_end -# Lighten +# Exclusion surface_begin 500 300 100 100 repeat_block predraw setCompositionMode Exclusion @@ -258,4 +258,4 @@ drawText 100 500 "ColorBurn" drawText 200 500 "HardLight" drawText 300 500 "SoftLight" drawText 400 500 "Difference" -drawText 500 500 "Exclusion" \ No newline at end of file +drawText 500 500 "Exclusion" diff --git a/tests/auto/other/lancelot/tst_lancelot.cpp b/tests/auto/other/lancelot/tst_lancelot.cpp index 63c62bab86..79d0f7c6cf 100644 --- a/tests/auto/other/lancelot/tst_lancelot.cpp +++ b/tests/auto/other/lancelot/tst_lancelot.cpp @@ -54,7 +54,7 @@ private: void setupTestSuite(const QStringList& blacklist = QStringList()); void runTestSuite(GraphicsEngine engine, QImage::Format format, const QSurfaceFormat &contextFormat = QSurfaceFormat()); - void paint(QPaintDevice *device, GraphicsEngine engine, const QStringList &script, const QString &filePath); + void paint(QPaintDevice *device, GraphicsEngine engine, QImage::Format format, const QStringList &script, const QString &filePath); QStringList qpsFiles; QHash scripts; @@ -318,7 +318,7 @@ void tst_Lancelot::runTestSuite(GraphicsEngine engine, QImage::Format format, co if (engine == Raster) { QImage img(800, 800, format); - paint(&img, engine, script, QFileInfo(filePath).absoluteFilePath()); + paint(&img, engine, format, script, QFileInfo(filePath).absoluteFilePath()); rendered = img; #ifndef QT_NO_OPENGL } else if (engine == OpenGL) { @@ -336,7 +336,7 @@ void tst_Lancelot::runTestSuite(GraphicsEngine engine, QImage::Format format, co QOpenGLFramebufferObject fbo(800, 800, fmt); fbo.bind(); QOpenGLPaintDevice pdv(800, 800); - paint(&pdv, engine, script, QFileInfo(filePath).absoluteFilePath()); + paint(&pdv, engine, format, script, QFileInfo(filePath).absoluteFilePath()); rendered = fbo.toImage().convertToFormat(format); #endif } @@ -344,10 +344,10 @@ void tst_Lancelot::runTestSuite(GraphicsEngine engine, QImage::Format format, co QBASELINE_TEST(rendered); } -void tst_Lancelot::paint(QPaintDevice *device, GraphicsEngine engine, const QStringList &script, const QString &filePath) +void tst_Lancelot::paint(QPaintDevice *device, GraphicsEngine engine, QImage::Format format, const QStringList &script, const QString &filePath) { QPainter p(device); - PaintCommands pcmd(script, 800, 800); + PaintCommands pcmd(script, 800, 800, format); //pcmd.setShouldDrawText(false); switch (engine) { case OpenGL: -- cgit v1.2.3 From f33cf18d882ada727da0f378525e55d9421e3b16 Mon Sep 17 00:00:00 2001 From: David Faure Date: Sun, 28 May 2017 10:49:21 +0200 Subject: QAbstractItemModel::supportedDragActions: fix regression This method now returns -1 by default, due to commit 6255cb893d which mistakenly replaced -1 with Qt::IgnoreAction (0x0). As a result, dropping is forbidden in a number of applications (I detected this in zanshin). Change-Id: I4922451216e08d5d3fe36f8ba87364a361b691bf Reviewed-by: Giuseppe D'Angelo --- .../qabstractitemmodel/tst_qabstractitemmodel.cpp | 22 ++++++++++++++++++++++ .../qstringlistmodel/tst_qstringlistmodel.cpp | 9 +++++++++ .../qstandarditemmodel/tst_qstandarditemmodel.cpp | 8 ++++++++ 3 files changed, 39 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp index dcd9eda4bb..9f67ccd9c9 100644 --- a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp +++ b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp @@ -101,6 +101,7 @@ private slots: void testRoleNames(); void testDragActions(); + void dragActionsFallsBackToDropActions(); void testFunctionPointerSignalConnection(); @@ -2157,6 +2158,27 @@ void tst_QAbstractItemModel::testDragActions() QVERIFY(actions & Qt::MoveAction); } +class OverrideDropActions : public QStringListModel +{ + Q_OBJECT +public: + OverrideDropActions(QObject *parent = 0) + : QStringListModel(parent) + { + } + Qt::DropActions supportedDropActions() const override + { + return Qt::MoveAction; + } +}; + +void tst_QAbstractItemModel::dragActionsFallsBackToDropActions() +{ + QAbstractItemModel *model = new OverrideDropActions(this); + QCOMPARE(model->supportedDragActions(), Qt::MoveAction); + QCOMPARE(model->supportedDropActions(), Qt::MoveAction); +} + class SignalConnectionTester : public QObject { Q_OBJECT diff --git a/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp b/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp index f99241da3b..adc8c59bf7 100644 --- a/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp +++ b/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp @@ -80,6 +80,8 @@ private slots: void setData_emits_both_roles_data(); void setData_emits_both_roles(); + + void supportedDragDropActions(); }; void tst_QStringListModel::rowsAboutToBeRemoved_rowsRemoved_data() @@ -250,5 +252,12 @@ void tst_QStringListModel::setData_emits_both_roles() expected); } +void tst_QStringListModel::supportedDragDropActions() +{ + QStringListModel model; + QCOMPARE(model.supportedDragActions(), Qt::CopyAction | Qt::MoveAction); + QCOMPARE(model.supportedDropActions(), Qt::CopyAction | Qt::MoveAction); +} + QTEST_MAIN(tst_QStringListModel) #include "tst_qstringlistmodel.moc" diff --git a/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp b/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp index dca718a6d8..cff26be7bb 100644 --- a/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp +++ b/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp @@ -125,6 +125,7 @@ private slots: void itemRoleNames(); void getMimeDataWithInvalidModelIndex(); + void supportedDragDropActions(); private: QAbstractItemModel *m_model; @@ -1666,5 +1667,12 @@ void tst_QStandardItemModel::getMimeDataWithInvalidModelIndex() QVERIFY(!data); } +void tst_QStandardItemModel::supportedDragDropActions() +{ + QStandardItemModel model; + QCOMPARE(model.supportedDragActions(), Qt::CopyAction | Qt::MoveAction); + QCOMPARE(model.supportedDropActions(), Qt::CopyAction | Qt::MoveAction); +} + QTEST_MAIN(tst_QStandardItemModel) #include "tst_qstandarditemmodel.moc" -- cgit v1.2.3 From c214c000ccebda30ed867934a9d56af29cb34264 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 3 Aug 2016 16:04:22 -0700 Subject: qEnvironmentVariableIntValue: fix the case of a non-numeric value The documentation says that it's equivalent to qgetenv(varName).toInt() But the implementation wasn't. QByteArray::toInt() verifies that the entire string was consumed, so QByteArray("1a").toInt() == 0, but qstrtoll alone doesn't. That is, qstrtoll("1a", ...) == 1. The implementation also detected the base, a behavior I kept. Instead, I updated the documentation. Change-Id: I0031aa609e714ae983c3fffd14676ea6061a9268 Reviewed-by: Marc Mutz --- .../corelib/global/qgetputenv/tst_qgetputenv.cpp | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp b/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp index 66fc578d5f..09abb953ba 100644 --- a/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp +++ b/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp @@ -97,17 +97,33 @@ void tst_QGetPutEnv::intValue_data() QTest::addColumn("expected"); QTest::addColumn("ok"); - // most non-success cases already tested in getSetCheck() + // some repetition from what is tested in getSetCheck() + QTest::newRow("empty") << QByteArray() << 0 << false; + QTest::newRow("spaces-heading") << QByteArray(" 1") << 1 << true; + QTest::newRow("spaces-trailing") << QByteArray("1 ") << 0 << false; #define ROW(x, i, b) \ QTest::newRow(#x) << QByteArray(#x) << (i) << (b) ROW(auto, 0, false); + ROW(1auto, 0, false); ROW(0, 0, true); + ROW(+0, 0, true); ROW(1, 1, true); + ROW(+1, 1, true); + ROW(09, 0, false); ROW(010, 8, true); ROW(0x10, 16, true); + ROW(0x, 0, false); + ROW(0xg, 0, false); + ROW(0x1g, 0, false); + ROW(000000000000000000000000000000000000000000000000001, 0, false); + ROW(+000000000000000000000000000000000000000000000000001, 0, false); + ROW(000000000000000000000000000000000000000000000000001g, 0, false); + ROW(-0, 0, true); ROW(-1, -1, true); ROW(-010, -8, true); + ROW(-000000000000000000000000000000000000000000000000001, 0, false); + ROW(2147483648, 0, false); // ROW(0xffffffff, -1, true); // could be expected, but not how QByteArray::toInt() works ROW(0xffffffff, 0, false); const int bases[] = {10, 8, 16}; @@ -125,6 +141,7 @@ void tst_QGetPutEnv::intValue_data() void tst_QGetPutEnv::intValue() { + const int maxlen = (sizeof(int) * CHAR_BIT + 2) / 3; const char varName[] = "should_not_exist"; QFETCH(QByteArray, value); @@ -133,6 +150,13 @@ void tst_QGetPutEnv::intValue() bool actualOk = !ok; + // Self-test: confirm that it was like the docs said it should be + if (value.length() < maxlen) { + QCOMPARE(value.toInt(&actualOk, 0), expected); + QCOMPARE(actualOk, ok); + } + + actualOk = !ok; QVERIFY(qputenv(varName, value)); QCOMPARE(qEnvironmentVariableIntValue(varName), expected); QCOMPARE(qEnvironmentVariableIntValue(varName, &actualOk), expected); -- cgit v1.2.3 From 40a7c57ba990dfd58814a4a9dc69948991458cd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tony=20Saraj=C3=A4rvi?= Date: Wed, 24 May 2017 14:05:29 +0300 Subject: Blacklist tst_QTimer::basic_chrono on macOS Task-number: QTBUG-61013 Change-Id: I1c877aeb3e141e0e19b71bf9e595ff478e313b10 Reviewed-by: Thiago Macieira Reviewed-by: Lars Knoll --- tests/auto/corelib/kernel/qtimer/BLACKLIST | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/kernel/qtimer/BLACKLIST b/tests/auto/corelib/kernel/qtimer/BLACKLIST index e5136624d8..b355bc22c2 100644 --- a/tests/auto/corelib/kernel/qtimer/BLACKLIST +++ b/tests/auto/corelib/kernel/qtimer/BLACKLIST @@ -1,3 +1,5 @@ [remainingTime] windows osx +[basic_chrono] +osx ci -- cgit v1.2.3 From 61f67c12fa1e46894c50cd72983354f8c6834717 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Wed, 31 May 2017 09:02:39 +0200 Subject: winrt: Use styleHint as clue for fallbacks for font families Similar on how it is done for Windows desktop we also use the given style hint when building the list of fallbacks a font family. Change-Id: I71378581d07f20ebe5bf0bc757bba919cc70e118 Reviewed-by: Maurice Kalinowski --- tests/auto/gui/text/qfont/tst_qfont.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/gui/text/qfont/tst_qfont.cpp b/tests/auto/gui/text/qfont/tst_qfont.cpp index 1f826c01cf..7d230d3bb3 100644 --- a/tests/auto/gui/text/qfont/tst_qfont.cpp +++ b/tests/auto/gui/text/qfont/tst_qfont.cpp @@ -515,7 +515,7 @@ void tst_QFont::defaultFamily_data() QTest::newRow("monospace") << QFont::Monospace << (QStringList() << "Courier New" << "Monaco" << "Droid Sans Mono" << getPlatformGenericFont("monospace").split(",")); QTest::newRow("cursive") << QFont::Cursive << (QStringList() << "Comic Sans MS" << "Apple Chancery" << "Roboto" << "Droid Sans" << getPlatformGenericFont("cursive").split(",")); QTest::newRow("fantasy") << QFont::Fantasy << (QStringList() << "Impact" << "Zapfino" << "Roboto" << "Droid Sans" << getPlatformGenericFont("fantasy").split(",")); - QTest::newRow("sans-serif") << QFont::SansSerif << (QStringList() << "Arial" << "Lucida Grande" << "Roboto" << "Droid Sans" << getPlatformGenericFont("sans-serif").split(",")); + QTest::newRow("sans-serif") << QFont::SansSerif << (QStringList() << "Arial" << "Lucida Grande" << "Roboto" << "Droid Sans" << "Segoe UI" << getPlatformGenericFont("sans-serif").split(",")); } void tst_QFont::defaultFamily() -- cgit v1.2.3