diff options
author | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2022-04-07 15:21:56 +0300 |
---|---|---|
committer | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2022-04-07 15:21:56 +0300 |
commit | e89a6f03c4d24f18db36a906a7320035388504ba (patch) | |
tree | 47f7edb9faa26f6f4e2d3f2eea12133933d86e45 /tests/auto | |
parent | c8989ca20fa5798f7853f07df6e150cc407c64a4 (diff) | |
parent | 69b8ab23c93785dc69ae43ea04d5620656a4af44 (diff) |
Merge remote-tracking branch 'origin/tqtc/lts-5.15.4' into tqtc/lts-5.15-opensource
Change-Id: I3d223d54a832c8365fec4b399550da79f4c1abbb
Diffstat (limited to 'tests/auto')
15 files changed, 429 insertions, 57 deletions
diff --git a/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp b/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp index 40617c1f7d..e1ea7a4552 100644 --- a/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp @@ -116,6 +116,7 @@ private Q_SLOTS: void shouldPropagateDropBetweenItemsAtModelBoundary(); void shouldPropagateDropAfterLastRow_data(); void shouldPropagateDropAfterLastRow(); + void qtbug91788(); private: QStandardItemModel mod; @@ -453,6 +454,17 @@ void tst_QConcatenateTablesProxyModel::shouldUseSmallestColumnCount() const QModelIndex indexD = pm.mapFromSource(mod2.index(0, 0)); QVERIFY(indexD.isValid()); QCOMPARE(indexD, pm.index(1, 0)); + + // Test setData in an ignored column (QTBUG-91253) + QSignalSpy dataChangedSpy(&pm, SIGNAL(dataChanged(QModelIndex,QModelIndex))); + mod.setData(mod.index(0, 1), "b"); + QCOMPARE(dataChangedSpy.count(), 0); + + // Test dataChanged across all columns, some visible, some ignored + mod.dataChanged(mod.index(0, 0), mod.index(0, 2)); + QCOMPARE(dataChangedSpy.count(), 1); + QCOMPARE(dataChangedSpy.at(0).at(0).toModelIndex(), pm.index(0, 0)); + QCOMPARE(dataChangedSpy.at(0).at(1).toModelIndex(), pm.index(0, 0)); } void tst_QConcatenateTablesProxyModel::shouldIncreaseColumnCountWhenRemovingFirstModel() @@ -818,6 +830,19 @@ void tst_QConcatenateTablesProxyModel::shouldPropagateDropAfterLastRow() } +void tst_QConcatenateTablesProxyModel::qtbug91788() +{ + QConcatenateTablesProxyModel proxyConcat; + QStringList strList{QString("one"),QString("two")}; + QStringListModel strListModelA(strList); + QSortFilterProxyModel proxyFilter; + proxyFilter.setSourceModel(&proxyConcat); + + proxyConcat.addSourceModel(&strListModelA); + proxyConcat.removeSourceModel(&strListModelA); // This should not assert + QCOMPARE(proxyConcat.columnCount(), 0); +} + QTEST_GUILESS_MAIN(tst_QConcatenateTablesProxyModel) #include "tst_qconcatenatetablesproxymodel.moc" diff --git a/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp b/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp index 7aadd14466..ce03487496 100644 --- a/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp +++ b/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp @@ -69,6 +69,7 @@ private slots: void processEventsOnlySendsQueuedEvents(); void postedEventsPingPong(); void eventLoopExit(); + void interruptTrampling(); }; bool tst_QEventDispatcher::event(QEvent *e) @@ -419,5 +420,31 @@ void tst_QEventDispatcher::eventLoopExit() QVERIFY(!timeoutObserved); } +// Based on QTBUG-91539: In the event dispatcher on Windows we overwrite the +// interrupt once we start processing events (this pattern is also in the 'unix' dispatcher) +// which would lead the dispatcher to accidentally ignore certain interrupts and, +// as in the bug report, would not quit, leaving the thread alive and running. +void tst_QEventDispatcher::interruptTrampling() +{ + class WorkerThread : public QThread + { + void run() override { + auto dispatcher = eventDispatcher(); + QVERIFY(dispatcher); + dispatcher->processEvents(QEventLoop::AllEvents); + QTimer::singleShot(0, [dispatcher]() { + dispatcher->wakeUp(); + }); + dispatcher->processEvents(QEventLoop::WaitForMoreEvents); + dispatcher->interrupt(); + dispatcher->processEvents(QEventLoop::WaitForMoreEvents); + } + }; + WorkerThread thread; + thread.start(); + QVERIFY(thread.wait(1000)); + QVERIFY(thread.isFinished()); +} + QTEST_MAIN(tst_QEventDispatcher) #include "tst_qeventdispatcher.moc" diff --git a/tests/auto/corelib/time/qdate/tst_qdate.cpp b/tests/auto/corelib/time/qdate/tst_qdate.cpp index 274bf4f6f0..f94f1c5fa6 100644 --- a/tests/auto/corelib/time/qdate/tst_qdate.cpp +++ b/tests/auto/corelib/time/qdate/tst_qdate.cpp @@ -90,7 +90,6 @@ private slots: void yearsZeroToNinetyNine(); void printNegativeYear_data() const; void printNegativeYear() const; - void roundtripGermanLocale() const; #if QT_CONFIG(textdate) && QT_DEPRECATED_SINCE(5, 10) void shortDayName() const; void standaloneShortDayName() const; @@ -100,6 +99,7 @@ private slots: void standaloneShortMonthName() const; void longMonthName() const; void standaloneLongMonthName() const; + void roundtripString() const; #endif // textdate void roundtrip() const; void qdebug() const; @@ -1484,16 +1484,6 @@ void tst_QDate::printNegativeYear() const QCOMPARE(date.toString(QLatin1String("yyyy")), expect); } -void tst_QDate::roundtripGermanLocale() const -{ - /* This code path should not result in warnings. */ - const QDate theDate(QDate::currentDate()); - theDate.fromString(theDate.toString(Qt::TextDate), Qt::TextDate); - - const QDateTime theDateTime(QDateTime::currentDateTime()); - theDateTime.fromString(theDateTime.toString(Qt::TextDate), Qt::TextDate); -} - #if QT_CONFIG(textdate) && QT_DEPRECATED_SINCE(5, 10) QT_WARNING_PUSH // the methods tested here are all deprecated QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations") @@ -1626,6 +1616,17 @@ void tst_QDate::standaloneLongMonthName() const } } QT_WARNING_POP + +void tst_QDate::roundtripString() const +{ + /* This code path should not result in warnings, no matter what locale is set. */ + const QDate date(QDate::currentDate()); + QCOMPARE(date.fromString(date.toString(Qt::TextDate), Qt::TextDate), date); + + const QDateTime now(QDateTime::currentDateTime()); + const QDateTime when = now.addMSecs(-now.time().msec()); // TextDate rounds to whole seconds. + QCOMPARE(when.fromString(when.toString(Qt::TextDate), Qt::TextDate), when); +} #endif // textdate void tst_QDate::roundtrip() const diff --git a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp index 2a8c47a51f..d3afee96cd 100644 --- a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2020 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Copyright (C) 2016 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** @@ -152,6 +152,7 @@ private slots: void isDaylightTime() const; void daylightTransitions() const; void timeZones() const; + void systemTimeZoneChange_data() const; void systemTimeZoneChange() const; void invalid_data() const; @@ -825,7 +826,7 @@ void tst_QDateTime::toString_isoDate_data() QTest::newRow("negative non-integral OffsetFromUTC") << dt << Qt::ISODate << QString("1978-11-09T13:28:34-00:15"); - QTest::newRow("invalid") + QTest::newRow("invalid") // ISODate < 2019 doesn't allow -ve year numbers; QTBUG-91070 << QDateTime(QDate(-1, 11, 9), QTime(13, 28, 34), Qt::UTC) << Qt::ISODate << QString(); QTest::newRow("without-ms") @@ -838,30 +839,31 @@ void tst_QDateTime::toString_isoDate_data() void tst_QDateTime::toString_isoDate() { - QFETCH(QDateTime, datetime); - QFETCH(Qt::DateFormat, format); - QFETCH(QString, expected); + QFETCH(const QDateTime, datetime); + QFETCH(const Qt::DateFormat, format); + QFETCH(const QString, expected); #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QLocale oldLocale; QLocale::setDefault(QLocale("en_US")); #endif // ### Qt 6: remove - QString result = datetime.toString(format); + const QString result = datetime.toString(format); QCOMPARE(result, expected); - QDateTime resultDatetime = QDateTime::fromString(result, format); - // If expecting invalid result the datetime may still be valid, i.e. year < 0 or > 9999 - if (!expected.isEmpty()) { - QEXPECT_FAIL("without-ms", "Qt::ISODate truncates milliseconds (QTBUG-56552)", Abort); - - QCOMPARE(resultDatetime, datetime); - QCOMPARE(resultDatetime.date(), datetime.date()); - QCOMPARE(resultDatetime.time(), datetime.time()); - QCOMPARE(resultDatetime.timeSpec(), datetime.timeSpec()); - QCOMPARE(resultDatetime.offsetFromUtc(), datetime.offsetFromUtc()); - } else { + const QDateTime resultDatetime = QDateTime::fromString(result, format); + if (QByteArray(QTest::currentDataTag()) == "invalid") { QCOMPARE(resultDatetime, QDateTime()); + } else { + const QDateTime when = + QByteArray(QTest::currentDataTag()) == "without-ms" + ? datetime.addMSecs(-datetime.time().msec()) : datetime; + QCOMPARE(resultDatetime.toMSecsSinceEpoch(), when.toMSecsSinceEpoch()); + QCOMPARE(resultDatetime, when); + QCOMPARE(resultDatetime.date(), when.date()); + QCOMPARE(resultDatetime.time(), when.time()); + QCOMPARE(resultDatetime.timeSpec(), when.timeSpec()); + QCOMPARE(resultDatetime.offsetFromUtc(), when.offsetFromUtc()); } #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) @@ -3721,38 +3723,63 @@ void tst_QDateTime::timeZones() const #endif } -void tst_QDateTime::systemTimeZoneChange() const +void tst_QDateTime::systemTimeZoneChange_data() const { #ifdef Q_OS_WINRT QSKIP("UWP applications cannot change the system`s time zone (sandboxing)"); #endif - // Set the timezone to Brisbane time - TimeZoneRollback useZone(QByteArray("AEST-10:00")); + QTest::addColumn<QDate>("date"); + QTest::newRow("short") << QDate(1970, 1, 1); + QTest::newRow("2012") << QDate(2012, 6, 1); // short on 64-bit, pimpled on 32-bit + QTest::newRow("pimpled") << QDate(1150000, 6, 1); +} + +void tst_QDateTime::systemTimeZoneChange() const +{ + QFETCH(const QDate, date); + const QTime early(2, 15, 30); - QDateTime localDate = QDateTime(QDate(2012, 6, 1), QTime(2, 15, 30), Qt::LocalTime); - QDateTime utcDate = QDateTime(QDate(2012, 6, 1), QTime(2, 15, 30), Qt::UTC); + // Start out in Brisbane time: + TimeZoneRollback useZone(QByteArray("AEST-10:00")); + if (QDateTime(date, early, Qt::LocalTime).offsetFromUtc() != 600 * 60) + QSKIP("Test depends on system support for changing zone to AEST-10:00"); #if QT_CONFIG(timezone) - QDateTime tzDate = QDateTime(QDate(2012, 6, 1), QTime(2, 15, 30), QTimeZone("Australia/Brisbane")); + QVERIFY(QTimeZone::systemTimeZone().isValid()); #endif - qint64 localMsecs = localDate.toMSecsSinceEpoch(); - qint64 utcMsecs = utcDate.toMSecsSinceEpoch(); + + const QDateTime localDate = QDateTime(date, early, Qt::LocalTime); + const QDateTime utcDate = QDateTime(date, early, Qt::UTC); + const qint64 localMsecs = localDate.toMSecsSinceEpoch(); + const qint64 utcMsecs = utcDate.toMSecsSinceEpoch(); #if QT_CONFIG(timezone) - qint64 tzMsecs = tzDate.toMSecsSinceEpoch(); + const QTimeZone aest("Australia/Brisbane"); // no transitions since 1992 + // Check that Australia/Brisbane is known: + QVERIFY(aest.isValid()); + const QDateTime tzDate = QDateTime(date, early, aest); - // check that Australia/Brisbane is known + // Check we got the right zone ! QVERIFY(tzDate.timeZone().isValid()); + QCOMPARE(tzDate.timeZone(), aest); + const qint64 tzMsecs = tzDate.toMSecsSinceEpoch(); #endif // Change to Indian time useZone.reset(QByteArray("IST-05:30")); + if (QDateTime(date, early, Qt::LocalTime).offsetFromUtc() != 330 * 60) + QSKIP("Test depends on system support for changing zone to IST-05:30"); +#if QT_CONFIG(timezone) + QVERIFY(QTimeZone::systemTimeZone().isValid()); +#endif - QCOMPARE(localDate, QDateTime(QDate(2012, 6, 1), QTime(2, 15, 30), Qt::LocalTime)); - QVERIFY(localMsecs != localDate.toMSecsSinceEpoch()); - QCOMPARE(utcDate, QDateTime(QDate(2012, 6, 1), QTime(2, 15, 30), Qt::UTC)); + QCOMPARE(localDate, QDateTime(date, early, Qt::LocalTime)); + // Note: localDate.toMSecsSinceEpoch == localMsecs, unchanged, iff localDate is pimpled. + QVERIFY(localMsecs != QDateTime(date, early, Qt::LocalTime).toMSecsSinceEpoch()); + QCOMPARE(utcDate, QDateTime(date, early, Qt::UTC)); QCOMPARE(utcDate.toMSecsSinceEpoch(), utcMsecs); #if QT_CONFIG(timezone) - QCOMPARE(tzDate, QDateTime(QDate(2012, 6, 1), QTime(2, 15, 30), QTimeZone("Australia/Brisbane"))); QCOMPARE(tzDate.toMSecsSinceEpoch(), tzMsecs); + QCOMPARE(tzDate.timeZone(), aest); + QCOMPARE(tzDate, QDateTime(date, early, aest)); #endif } diff --git a/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp index 66f6b5163c..a59b58d57f 100644 --- a/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp +++ b/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp @@ -62,6 +62,7 @@ private slots: void windowsId(); void isValidId_data(); void isValidId(); + void malformed(); // Backend tests void utcTest(); void icuTest(); @@ -931,6 +932,21 @@ void tst_QTimeZone::isValidId() #endif } +void tst_QTimeZone::malformed() +{ + // Regression test for QTBUG-92808 + // Strings that look enough like a POSIX zone specifier that the constructor + // accepts them, but the specifier is invalid. + // Must not crash or trigger assertions when calling offsetFromUtc() + const QDateTime now = QDateTime::currentDateTime(); + QTimeZone barf("QUT4tCZ0 , /"); + if (barf.isValid()) + barf.offsetFromUtc(now); + barf = QTimeZone("QtC+09,,MA"); + if (barf.isValid()) + barf.offsetFromUtc(now); +} + void tst_QTimeZone::utcTest() { #ifdef QT_BUILD_INTERNAL diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index 4a408e9b7d..a36f538515 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -103,6 +103,10 @@ private slots: void setPixel_data(); void setPixel(); + void setPixelWithAlpha_data(); + void setPixelWithAlpha(); + void setPixelColorWithAlpha_data(); + void setPixelColorWithAlpha(); void defaultColorTable_data(); void defaultColorTable(); @@ -1478,6 +1482,62 @@ void tst_QImage::setPixel() } } +void tst_QImage::setPixelWithAlpha_data() +{ + QTest::addColumn<QImage::Format>("format"); + + for (int c = QImage::Format_RGB32; c < QImage::NImageFormats; ++c) { + if (c == QImage::Format_Grayscale8) + continue; + if (c == QImage::Format_Grayscale16) + continue; + if (c == QImage::Format_Alpha8) + continue; + QTest::newRow(qPrintable(formatToString(QImage::Format(c)))) << QImage::Format(c); + } +} + +void tst_QImage::setPixelWithAlpha() +{ + QFETCH(QImage::Format, format); + QImage image(1, 1, format); + QRgb referenceColor = qRgba(0, 170, 85, 170); + image.setPixel(0, 0, referenceColor); + + if (!image.hasAlphaChannel()) + referenceColor = 0xff000000 | referenceColor; + + QRgb color = image.pixel(0, 0); + QCOMPARE(qRed(color) & 0xf0, qRed(referenceColor) & 0xf0); + QCOMPARE(qGreen(color) & 0xf0, qGreen(referenceColor) & 0xf0); + QCOMPARE(qBlue(color) & 0xf0, qBlue(referenceColor) & 0xf0); + QCOMPARE(qAlpha(color) & 0xf0, qAlpha(referenceColor) & 0xf0); +} + +void tst_QImage::setPixelColorWithAlpha_data() +{ + setPixelWithAlpha_data(); +} + +void tst_QImage::setPixelColorWithAlpha() +{ + QFETCH(QImage::Format, format); + QImage image(1, 1, format); + image.setPixelColor(0, 0, QColor(170, 85, 255, 170)); + QRgb referenceColor = qRgba(170, 85, 255, 170); + + if (!image.hasAlphaChannel()) + referenceColor = 0xff000000 | referenceColor; + else if (image.pixelFormat().premultiplied() == QPixelFormat::Premultiplied) + referenceColor = qPremultiply(referenceColor); + + QRgb color = image.pixel(0, 0); + QCOMPARE(qRed(color) & 0xf0, qRed(referenceColor) & 0xf0); + QCOMPARE(qGreen(color) & 0xf0, qGreen(referenceColor) & 0xf0); + QCOMPARE(qBlue(color) & 0xf0, qBlue(referenceColor) & 0xf0); + QCOMPARE(qAlpha(color) & 0xf0, qAlpha(referenceColor) & 0xf0); +} + void tst_QImage::convertToFormatPreserveDotsPrMeter() { QImage img(100, 100, QImage::Format_ARGB32_Premultiplied); @@ -2345,17 +2405,7 @@ void tst_QImage::fillColor() void tst_QImage::fillColorWithAlpha_data() { - QTest::addColumn<QImage::Format>("format"); - - for (int c = QImage::Format_RGB32; c < QImage::NImageFormats; ++c) { - if (c == QImage::Format_Grayscale8) - continue; - if (c == QImage::Format_Grayscale16) - continue; - if (c == QImage::Format_Alpha8) - continue; - QTest::newRow(qPrintable(formatToString(QImage::Format(c)))) << QImage::Format(c); - } + setPixelWithAlpha_data(); } void tst_QImage::fillColorWithAlpha() @@ -2400,10 +2450,13 @@ void tst_QImage::fillPixel_data() QTest::newRow("RGB16, transparent") << QImage::Format_RGB16 << 0x0u << 0xff000000u; QTest::newRow("RGB32, transparent") << QImage::Format_RGB32 << 0x0u << 0xff000000u; + QTest::newRow("RGB444, transparent") << QImage::Format_RGB444 << 0x0u << 0xff000000u; + QTest::newRow("RGB666, transparent") << QImage::Format_RGB666 << 0x0u << 0xff000000u; QTest::newRow("RGBx8888, transparent") << QImage::Format_RGBX8888 << 0x0u << 0xff000000u; QTest::newRow("ARGB32, transparent") << QImage::Format_ARGB32 << 0x0u << 0x00000000u; QTest::newRow("ARGB32pm, transparent") << QImage::Format_ARGB32_Premultiplied << 0x0u << 0x00000000u; QTest::newRow("RGBA8888pm, transparent") << QImage::Format_RGBA8888_Premultiplied << 0x0u << 0x00000000u; + QTest::newRow("Grayscale8, transparent") << QImage::Format_Grayscale8 << 0x0u << 0xff000000u; QTest::newRow("Alpha8, transparent") << QImage::Format_Alpha8 << 0x0u << 0x00000000u; QTest::newRow("RGB16, red") << QImage::Format_RGB16 << (uint)qConvertRgb32To16(0xffff0000) << 0xffff0000u; @@ -2411,13 +2464,14 @@ void tst_QImage::fillPixel_data() QTest::newRow("ARGB32, red") << QImage::Format_ARGB32 << 0xffff0000u << 0xffff0000u; QTest::newRow("RGBA8888, red") << QImage::Format_RGBA8888 << 0xff0000ffu << 0xffff0000u; - QTest::newRow("Grayscale8, grey") << QImage::Format_Grayscale8 << 0xff808080u << 0xff808080u; + QTest::newRow("Grayscale8, grey") << QImage::Format_Grayscale8 << 0x80u << 0xff808080u; QTest::newRow("RGB32, semi-red") << QImage::Format_RGB32 << 0x80ff0000u << 0xffff0000u; QTest::newRow("ARGB32, semi-red") << QImage::Format_ARGB32 << 0x80ff0000u << 0x80ff0000u; QTest::newRow("ARGB32pm, semi-red") << QImage::Format_ARGB32 << 0x80800000u << 0x80800000u; QTest::newRow("RGBA8888pm, semi-red") << QImage::Format_RGBA8888_Premultiplied << 0x80000080u << 0x80800000u; - QTest::newRow("Alpha8, semi-red") << QImage::Format_Alpha8 << 0x80000080u << 0x80000000u; + + QTest::newRow("Alpha8, semi-transparent") << QImage::Format_Alpha8 << 0x80u << 0x80000000u; } void tst_QImage::fillPixel() @@ -2430,6 +2484,8 @@ void tst_QImage::fillPixel() image.fill(color); QCOMPARE(image.pixel(0, 0), pixelValue); + if (image.depth() == 8) + QCOMPARE(*(const uchar *)image.constBits(), color); } void tst_QImage::rgbSwapped_data() diff --git a/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp index 99fb3d3e72..7bfd2f7495 100644 --- a/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp +++ b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp @@ -59,6 +59,10 @@ private slots: void imageConversion_data(); void imageConversion(); + void imageConversion64_data(); + void imageConversion64(); + void imageConversionOverLargerGamut_data(); + void imageConversionOverLargerGamut(); void loadImage(); @@ -234,6 +238,7 @@ void tst_QColorSpace::imageConversion_data() QTest::newRow("Adobe RGB -> sRGB") << QColorSpace::AdobeRgb << QColorSpace::SRgb << 2; QTest::newRow("Display-P3 -> Adobe RGB") << QColorSpace::DisplayP3 << QColorSpace::AdobeRgb << 2; QTest::newRow("sRGB -> sRGB Linear") << QColorSpace::SRgb << QColorSpace::SRgbLinear << 0; + QTest::newRow("sRGB Linear -> sRGB") << QColorSpace::SRgbLinear << QColorSpace::SRgb << 0; } void tst_QColorSpace::imageConversion() @@ -284,6 +289,120 @@ void tst_QColorSpace::imageConversion() } } +void tst_QColorSpace::imageConversion64_data() +{ + QTest::addColumn<QColorSpace::NamedColorSpace>("fromColorSpace"); + QTest::addColumn<QColorSpace::NamedColorSpace>("toColorSpace"); + + QTest::newRow("sRGB -> Display-P3") << QColorSpace::SRgb << QColorSpace::DisplayP3; + QTest::newRow("sRGB -> Adobe RGB") << QColorSpace::SRgb << QColorSpace::AdobeRgb; + QTest::newRow("Display-P3 -> sRGB") << QColorSpace::DisplayP3 << QColorSpace::SRgb; + QTest::newRow("Display-P3 -> Adobe RGB") << QColorSpace::DisplayP3 << QColorSpace::AdobeRgb; + QTest::newRow("sRGB -> sRGB Linear") << QColorSpace::SRgb << QColorSpace::SRgbLinear; + QTest::newRow("sRGB Linear -> sRGB") << QColorSpace::SRgbLinear << QColorSpace::SRgb; +} + +void tst_QColorSpace::imageConversion64() +{ + QFETCH(QColorSpace::NamedColorSpace, fromColorSpace); + QFETCH(QColorSpace::NamedColorSpace, toColorSpace); + + QImage testImage(256, 1, QImage::Format_RGBX64); + + for (int i = 0; i < 256; ++i) + testImage.setPixel(i, 0, qRgb(i, i, i)); + + testImage.setColorSpace(fromColorSpace); + QCOMPARE(testImage.colorSpace(), QColorSpace(fromColorSpace)); + + testImage.convertToColorSpace(toColorSpace); + QCOMPARE(testImage.colorSpace(), QColorSpace(toColorSpace)); + + int lastRed = 0; + int lastGreen = 0; + int lastBlue = 0; + for (int i = 0; i < 256; ++i) { + QRgb p = testImage.pixel(i, 0); + QVERIFY(qRed(p) >= lastRed); + QVERIFY(qGreen(p) >= lastGreen); + QVERIFY(qBlue(p) >= lastBlue); + lastRed = qRed(p); + lastGreen = qGreen(p); + lastBlue = qBlue(p); + } + + lastRed = 0; + lastGreen = 0; + lastBlue = 0; + testImage.convertToColorSpace(fromColorSpace); + QCOMPARE(testImage.colorSpace(), QColorSpace(fromColorSpace)); + for (int i = 0; i < 256; ++i) { + QRgb p = testImage.pixel(i, 0); + QCOMPARE(qRed(p), qGreen(p)); + QCOMPARE(qRed(p), qBlue(p)); + QVERIFY((lastRed - qRed(p)) <= 0); + QVERIFY((lastGreen - qGreen(p)) <= 0); + QVERIFY((lastBlue - qBlue(p)) <= 0); + lastRed = qRed(p); + lastGreen = qGreen(p); + lastBlue = qBlue(p); + } +} + +void tst_QColorSpace::imageConversionOverLargerGamut_data() +{ + QTest::addColumn<QColorSpace::NamedColorSpace>("fromColorSpace"); + QTest::addColumn<QColorSpace::NamedColorSpace>("toColorSpace"); + + QTest::newRow("sRGB -> Display-P3") << QColorSpace::SRgb << QColorSpace::DisplayP3; + QTest::newRow("sRGB -> Adobe RGB") << QColorSpace::SRgb << QColorSpace::AdobeRgb; + QTest::newRow("sRGB -> ProPhoto RGB") << QColorSpace::SRgb << QColorSpace::ProPhotoRgb; + QTest::newRow("Display-P3 -> ProPhoto RGB") << QColorSpace::DisplayP3 << QColorSpace::ProPhotoRgb; + QTest::newRow("Adobe RGB -> ProPhoto RGB") << QColorSpace::AdobeRgb << QColorSpace::ProPhotoRgb; +} + +void tst_QColorSpace::imageConversionOverLargerGamut() +{ + QFETCH(QColorSpace::NamedColorSpace, fromColorSpace); + QFETCH(QColorSpace::NamedColorSpace, toColorSpace); + + QColorSpace csfrom(fromColorSpace); + QColorSpace csto(toColorSpace); + csfrom.setTransferFunction(QColorSpace::TransferFunction::Linear); + csto.setTransferFunction(QColorSpace::TransferFunction::Linear); + + QImage testImage(256, 256, QImage::Format_RGBX64); + testImage.setColorSpace(csfrom); + for (int y = 0; y < 256; ++y) + for (int x = 0; x < 256; ++x) + testImage.setPixel(x, y, qRgb(x, y, 0)); + + QImage resultImage = testImage.convertedToColorSpace(csto); + for (int y = 0; y < 256; ++y) { + int lastRed = 0; + for (int x = 0; x < 256; ++x) { + QRgb p = resultImage.pixel(x, y); + QVERIFY(qRed(p) >= lastRed); + lastRed = qRed(p); + } + } + for (int x = 0; x < 256; ++x) { + int lastGreen = 0; + for (int y = 0; y < 256; ++y) { + QRgb p = resultImage.pixel(x, y); + QVERIFY(qGreen(p) >= lastGreen); + lastGreen = qGreen(p); + } + } + + resultImage.convertToColorSpace(csfrom); + // The images are not exactly identical at 4x16bit, but they preserve 4x8bit accuracy. + for (int y = 0; y < 256; ++y) { + for (int x = 0; x < 256; ++x) { + QCOMPARE(resultImage.pixel(x, y), testImage.pixel(x, y)); + } + } +} void tst_QColorSpace::loadImage() { diff --git a/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp b/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp index 86a8965cec..b34a63cc6c 100644 --- a/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp +++ b/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp @@ -173,8 +173,18 @@ void tst_QPainterPath::clear() p1.setFillRule(Qt::WindingFill); QVERIFY(p1 != p3); p1.clear(); - QCOMPARE(p1.fillRule(), Qt::OddEvenFill); + QVERIFY(p1 != p3); + p1.setFillRule(Qt::OddEvenFill); QCOMPARE(p1, p2); + + QPainterPath p4; + QCOMPARE(p4.fillRule(), Qt::OddEvenFill); + p4.setFillRule(Qt::WindingFill); + QCOMPARE(p4.fillRule(), Qt::WindingFill); + p4.clear(); + QCOMPARE(p4.fillRule(), Qt::WindingFill); + p4 = QPainterPath(); + QCOMPARE(p4.fillRule(), Qt::OddEvenFill); } void tst_QPainterPath::reserveAndCapacity() diff --git a/tests/auto/network/ssl/qdtlscookie/tst_qdtlscookie.cpp b/tests/auto/network/ssl/qdtlscookie/tst_qdtlscookie.cpp index 00e4cfbe46..9dab3727f9 100644 --- a/tests/auto/network/ssl/qdtlscookie/tst_qdtlscookie.cpp +++ b/tests/auto/network/ssl/qdtlscookie/tst_qdtlscookie.cpp @@ -343,7 +343,7 @@ void tst_QDtlsCookie::verifyMultipleClients() clientsToAdd = clientsToWait = 100; - testLoop.enterLoop(handshakeTimeoutMS * clientsToWait); + testLoop.enterLoopMSecs(handshakeTimeoutMS * clientsToWait); QVERIFY(!testLoop.timeout()); QVERIFY(clientsToWait == 0); } diff --git a/tests/auto/other/gestures/BLACKLIST b/tests/auto/other/gestures/BLACKLIST index 2af5d40359..480b5a3ad1 100644 --- a/tests/auto/other/gestures/BLACKLIST +++ b/tests/auto/other/gestures/BLACKLIST @@ -2,6 +2,7 @@ rhel-7.4 rhel-7.6 ubuntu-18.04 +sles-15 [customGesture] opensuse-leap # QTBUG-67254 @@ -10,18 +11,22 @@ opensuse-42.3 ubuntu-18.04 rhel-7.4 rhel-7.6 +sles-15 [graphicsItemTreeGesture] ubuntu-18.04 [graphicsView] ubuntu-18.04 rhel-7.4 rhel-7.6 +sles-15 [explicitGraphicsObjectTarget] ubuntu-18.04 rhel-7.4 rhel-7.6 +sles-15 [autoCancelGestures2] ubuntu-18.04 rhel-7.4 rhel-7.6 +sles-15 diff --git a/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp b/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp index b305eee0ec..08419b335e 100644 --- a/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp +++ b/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp @@ -40,6 +40,7 @@ private slots: void stringListModel(); void treeWidgetModel(); void standardItemModel(); + void standardItemModelZeroColumns(); void testInsertThroughProxy(); void moveSourceItems(); void testResetThroughProxy(); @@ -104,6 +105,15 @@ void tst_QAbstractItemModelTester::standardItemModel() model.insertColumns(0, 5, model.index(1, 3)); } +void tst_QAbstractItemModelTester::standardItemModelZeroColumns() // QTBUG-92220 +{ + QStandardItemModel model; + + QAbstractItemModelTester t1(&model); + model.insertRows(0, 5); + model.removeRows(0, 5); +} + void tst_QAbstractItemModelTester::testInsertThroughProxy() { DynamicTreeModel *model = new DynamicTreeModel(this); diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp index 69a81bdead..a3b8ef78d8 100644 --- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp +++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp @@ -1493,6 +1493,11 @@ void tst_QApplication::desktopSettingsAware() { #if QT_CONFIG(process) QProcess testProcess; +#ifdef Q_OS_MACOS + QStringList environment = QProcess::systemEnvironment(); + environment += QLatin1String("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM=1"); + testProcess.setEnvironment(environment); +#endif testProcess.start("desktopsettingsaware_helper"); QVERIFY2(testProcess.waitForStarted(), qPrintable(QString::fromLatin1("Cannot start 'desktopsettingsaware_helper': %1").arg(testProcess.errorString()))); diff --git a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp index 1d63d140fb..d57da3c78f 100644 --- a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp +++ b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp @@ -75,6 +75,7 @@ private slots: void taskQTBUG_40609_addingWidgetToItsOwnLayout(); void taskQTBUG_40609_addingLayoutToItself(); void taskQTBUG_52357_spacingWhenItemIsHidden(); + void taskQTBUG_91261_itemIndexRange(); void replaceWidget(); void dontCrashWhenExtendsToEnd(); }; @@ -1666,6 +1667,56 @@ void tst_QGridLayout::taskQTBUG_52357_spacingWhenItemIsHidden() QTRY_COMPARE_WITH_TIMEOUT(tempWidth, button1.width() + button3.width() + layout.spacing(), 1000); } +void tst_QGridLayout::taskQTBUG_91261_itemIndexRange() +{ + QWidget widget; + QGridLayout lay(&widget); + QPushButton *btn = new QPushButton(&widget); + lay.addWidget(btn, 0, 0); + + { + auto ptr = lay.itemAt(-1); + QCOMPARE(ptr, nullptr); + + ptr = lay.itemAt(0); + QCOMPARE(ptr->widget(), btn); + + ptr = lay.itemAt(1); + QCOMPARE(ptr, nullptr); + } + + { + int row = -1; + int column = -1; + int rowSpan; + int columnSpan; + + lay.getItemPosition(-1, &row, &column, &rowSpan, &columnSpan); + QCOMPARE(row, -1); + QCOMPARE(column, -1); + + lay.getItemPosition(1, &row, &column, &rowSpan, &columnSpan); + QCOMPARE(row, -1); + QCOMPARE(column, -1); + + lay.getItemPosition(0, &row, &column, &rowSpan, &columnSpan); + QCOMPARE(row, 0); + QCOMPARE(column, 0); + } + + { + auto ptr = lay.takeAt(-1); + QCOMPARE(ptr, nullptr); + + ptr = lay.takeAt(1); + QCOMPARE(ptr, nullptr); + + ptr = lay.takeAt(0); + QCOMPARE(ptr->widget(), btn); + delete ptr; + } +} + void tst_QGridLayout::replaceWidget() { QWidget wdg; diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp index 5a24995caf..48b171f234 100644 --- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp +++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp @@ -174,7 +174,9 @@ void tst_QMenu::getSetCheck() tst_QMenu::tst_QMenu() : m_onStatusTipTimerExecuted(false) { + QApplication::setEffectEnabled(Qt::UI_FadeTooltip, false); QApplication::setEffectEnabled(Qt::UI_AnimateMenu, false); + QApplication::setEffectEnabled(Qt::UI_AnimateTooltip, false); } void tst_QMenu::initTestCase() diff --git a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp index 94cb42cc00..e818514a79 100644 --- a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp +++ b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp @@ -68,6 +68,7 @@ private slots: void taskQTBUG_20191_shortcutWithKeypadModifer(); void emitReleasedAfterChange(); void hitButton(); + void iconOnlyStyleSheet(); protected slots: void resetCounters(); @@ -695,5 +696,22 @@ void tst_QPushButton::hitButton() QVERIFY(!button2->hitButton(QPoint(2, 2))); } +/* + Test that a style sheet with only icon doesn't crash. + QTBUG-91735 +*/ +void tst_QPushButton::iconOnlyStyleSheet() +{ + QIcon icon(":/qt-project.org/styles/commonstyle/images/dvd-32.png"); + QVERIFY(!icon.isNull()); + QPushButton pb; + pb.setStyleSheet("QPushButton {" + "icon: url(:/qt-project.org/styles/commonstyle/images/dvd-32.png);" + "border: red;" + "}"); + pb.show(); + QVERIFY(QTest::qWaitForWindowExposed(&pb)); +} + QTEST_MAIN(tst_QPushButton) #include "tst_qpushbutton.moc" |