diff options
Diffstat (limited to 'tests/auto/gui')
45 files changed, 1173 insertions, 72 deletions
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index 5ffd75f931..441ec17412 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -230,9 +230,12 @@ private slots: void convertColorTable(); + void wideImage(); + #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) void toWinHBITMAP_data(); void toWinHBITMAP(); + void fromMonoHBITMAP(); #endif // Q_OS_WIN && !Q_OS_WINRT private: @@ -298,6 +301,8 @@ static QLatin1String formatToString(QImage::Format format) return QLatin1String("RGBA64"); case QImage::Format_RGBA64_Premultiplied: return QLatin1String("RGBA64pm"); + case QImage::Format_Grayscale16: + return QLatin1String("Grayscale16"); default: break; }; @@ -1847,7 +1852,9 @@ void tst_QImage::smoothScale4_data() QTest::addColumn<QImage::Format>("format"); QTest::newRow("RGB32") << QImage::Format_RGB32; +#if QT_CONFIG(raster_64bit) QTest::newRow("RGBx64") << QImage::Format_RGBX64; +#endif } void tst_QImage::smoothScale4() @@ -2366,8 +2373,11 @@ void tst_QImage::rgbSwapped_data() QTest::addColumn<QImage::Format>("format"); for (int i = QImage::Format_Indexed8; i < QImage::NImageFormats; ++i) { - if (i == QImage::Format_Alpha8 || i == QImage::Format_Grayscale8) + if (i == QImage::Format_Alpha8 + || i == QImage::Format_Grayscale8 + || i == QImage::Format_Grayscale16) { continue; + } QTest::addRow("%s", formatToString(QImage::Format(i)).data()) << QImage::Format(i); } } @@ -2612,8 +2622,11 @@ void tst_QImage::inplaceMirrored_data() QTest::addColumn<bool>("swap_horizontal"); for (int i = QImage::Format_Mono; i < QImage::NImageFormats; ++i) { - if (i == QImage::Format_Alpha8 || i == QImage::Format_Grayscale8) + if (i == QImage::Format_Alpha8 + || i == QImage::Format_Grayscale8 + || i == QImage::Format_Grayscale16) { continue; + } if (i == QImage::Format_RGB444 || i == QImage::Format_ARGB4444_Premultiplied) continue; const auto fmt = formatToString(QImage::Format(i)); @@ -2785,11 +2798,11 @@ void tst_QImage::genericRgbConversion_data() QTest::addColumn<QImage::Format>("dest_format"); for (int i = QImage::Format_RGB32; i < QImage::NImageFormats; ++i) { - if (i == QImage::Format_Alpha8 || i == QImage::Format_Grayscale8) + if (i == QImage::Format_Alpha8) continue; const QLatin1String formatI = formatToString(QImage::Format(i)); for (int j = QImage::Format_RGB32; j < QImage::NImageFormats; ++j) { - if (j == QImage::Format_Alpha8 || j == QImage::Format_Grayscale8) + if (j == QImage::Format_Alpha8) continue; if (i == j) continue; @@ -2805,6 +2818,9 @@ void tst_QImage::genericRgbConversion() QFETCH(QImage::Format, format); QFETCH(QImage::Format, dest_format); + bool srcGrayscale = format == QImage::Format_Grayscale8 || format == QImage::Format_Grayscale16; + bool dstGrayscale = dest_format == QImage::Format_Grayscale8 || dest_format == QImage::Format_Grayscale16; + QImage image(16, 16, format); for (int i = 0; i < image.height(); ++i) @@ -2816,8 +2832,12 @@ void tst_QImage::genericRgbConversion() for (int i = 0; i < imageConverted.height(); ++i) { for (int j = 0; j < imageConverted.width(); ++j) { QRgb convertedColor = imageConverted.pixel(j,i); - QCOMPARE(qRed(convertedColor) & 0xF0, j * 16); - QCOMPARE(qGreen(convertedColor) & 0xF0, i * 16); + if (srcGrayscale || dstGrayscale) { + QVERIFY(qAbs(qGray(convertedColor) - qGray(qRgb(j*16, i*16, 0))) < 15); + } else { + QCOMPARE(qRed(convertedColor) & 0xF0, j * 16); + QCOMPARE(qGreen(convertedColor) & 0xF0, i * 16); + } } } } @@ -2828,11 +2848,17 @@ void tst_QImage::inplaceRgbConversion_data() QTest::addColumn<QImage::Format>("dest_format"); for (int i = QImage::Format_RGB32; i < QImage::NImageFormats; ++i) { - if (i == QImage::Format_Alpha8 || i == QImage::Format_Grayscale8) + if (i == QImage::Format_Alpha8 + || i == QImage::Format_Grayscale8 + || i == QImage::Format_Grayscale16) { continue; + } for (int j = QImage::Format_RGB32; j < QImage::NImageFormats; ++j) { - if (j == QImage::Format_Alpha8 || j == QImage::Format_Grayscale8) + if (j == QImage::Format_Alpha8 + || j == QImage::Format_Grayscale8 + || j == QImage::Format_Grayscale16) { continue; + } if (i == j) continue; QTest::addRow("%s -> %s", formatToString(QImage::Format(i)).data(), formatToString(QImage::Format(j)).data()) @@ -3002,8 +3028,11 @@ void tst_QImage::invertPixelsRGB_data() QTest::addColumn<QImage::Format>("image_format"); for (int i = QImage::Format_RGB32; i < QImage::NImageFormats; ++i) { - if (i == QImage::Format_Alpha8 || i == QImage::Format_Grayscale8) + if (i == QImage::Format_Alpha8 + || i == QImage::Format_Grayscale8 + || i == QImage::Format_Grayscale16) { continue; + } QTest::addRow("%s", formatToString(QImage::Format(i)).data()) << QImage::Format(i); } } @@ -3257,11 +3286,46 @@ void tst_QImage::metadataPassthrough() QCOMPARE(mirrored.dotsPerMeterY(), a.dotsPerMeterY()); QCOMPARE(mirrored.devicePixelRatio(), a.devicePixelRatio()); + QTransform t; + t.rotate(90); + QImage rotated = a.transformed(t); + QCOMPARE(rotated.text(QStringLiteral("Test")), a.text(QStringLiteral("Test"))); + QCOMPARE(rotated.dotsPerMeterX(), a.dotsPerMeterX()); + QCOMPARE(rotated.dotsPerMeterY(), a.dotsPerMeterY()); + QCOMPARE(rotated.devicePixelRatio(), a.devicePixelRatio()); + QImage swapped = a.rgbSwapped(); QCOMPARE(swapped.text(QStringLiteral("Test")), a.text(QStringLiteral("Test"))); QCOMPARE(swapped.dotsPerMeterX(), a.dotsPerMeterX()); QCOMPARE(swapped.dotsPerMeterY(), a.dotsPerMeterY()); QCOMPARE(swapped.devicePixelRatio(), a.devicePixelRatio()); + + QImage converted = a.convertToFormat(QImage::Format_RGB32); + QCOMPARE(converted.text(QStringLiteral("Test")), a.text(QStringLiteral("Test"))); + QCOMPARE(converted.dotsPerMeterX(), a.dotsPerMeterX()); + QCOMPARE(converted.dotsPerMeterY(), a.dotsPerMeterY()); + QCOMPARE(converted.devicePixelRatio(), a.devicePixelRatio()); + + QImage copied = a.copy(0, 0, a.width() / 2, a.height() / 2); + QCOMPARE(copied.text(QStringLiteral("Test")), a.text(QStringLiteral("Test"))); + QCOMPARE(copied.dotsPerMeterX(), a.dotsPerMeterX()); + QCOMPARE(copied.dotsPerMeterY(), a.dotsPerMeterY()); + QCOMPARE(copied.devicePixelRatio(), a.devicePixelRatio()); + + QImage alphaMask = a.createAlphaMask(); + QCOMPARE(alphaMask.dotsPerMeterX(), a.dotsPerMeterX()); + QCOMPARE(alphaMask.dotsPerMeterY(), a.dotsPerMeterY()); + QCOMPARE(alphaMask.devicePixelRatio(), a.devicePixelRatio()); + + QImage heuristicMask = a.createHeuristicMask(); + QCOMPARE(heuristicMask.dotsPerMeterX(), a.dotsPerMeterX()); + QCOMPARE(heuristicMask.dotsPerMeterY(), a.dotsPerMeterY()); + QCOMPARE(heuristicMask.devicePixelRatio(), a.devicePixelRatio()); + + QImage maskFromColor = a.createMaskFromColor(qRgb(0, 0, 0)); + QCOMPARE(maskFromColor.dotsPerMeterX(), a.dotsPerMeterX()); + QCOMPARE(maskFromColor.dotsPerMeterY(), a.dotsPerMeterY()); + QCOMPARE(maskFromColor.devicePixelRatio(), a.devicePixelRatio()); } void tst_QImage::pixelColor() @@ -3341,7 +3405,7 @@ void tst_QImage::ditherGradient_data() QTest::newRow("rgb32 -> rgb666 (dithering)") << rgb32 << QImage::Format_RGB666 << int(Qt::PreferDither | Qt::OrderedDither) << 129; // Test we get the same results for opaque input in the ARGBPM implementation. - rgb32 = qMove(rgb32).convertToFormat(QImage::Format_ARGB32_Premultiplied); + rgb32 = std::move(rgb32).convertToFormat(QImage::Format_ARGB32_Premultiplied); QTest::newRow("argb32pm -> argb4444pm (no dither)") << rgb32 << QImage::Format_ARGB4444_Premultiplied << 0 << 16; QTest::newRow("argb32pm -> rgb444 (dithering)") << rgb32 << QImage::Format_RGB444 << int(Qt::PreferDither | Qt::OrderedDither) << 33; QTest::newRow("argb32pm -> argb4444pm (dithering)") << rgb32 << QImage::Format_ARGB4444_Premultiplied << int(Qt::PreferDither | Qt::OrderedDither) << 33; @@ -3350,6 +3414,7 @@ void tst_QImage::ditherGradient_data() QTest::newRow("argb32pm -> argb6666pm (no dither)") << rgb32 << QImage::Format_ARGB6666_Premultiplied << 0 << 64; QTest::newRow("argb32pm -> argb6666pm (dithering)") << rgb32 << QImage::Format_ARGB6666_Premultiplied << int(Qt::PreferDither | Qt::OrderedDither) << 129; +#if QT_CONFIG(raster_64bit) QImage rgb30(1024, 16, QImage::Format_RGB30); QLinearGradient gradient30(QRectF(rgb30.rect()).topLeft(), QRectF(rgb30.rect()).topRight()); gradient30.setColorAt(0.0, QColor(0, 0, 0)); @@ -3362,6 +3427,7 @@ void tst_QImage::ditherGradient_data() QTest::newRow("rgb30 -> rgb32 (dithering)") << rgb30 << QImage::Format_RGB32 << int(Qt::PreferDither | Qt::OrderedDither) << 513; QTest::newRow("rgb30 -> rgb888 (no dither)") << rgb30 << QImage::Format_RGB888 << 0 << 256; QTest::newRow("rgb30 -> rgb888 (dithering)") << rgb30 << QImage::Format_RGB888 << int(Qt::PreferDither | Qt::OrderedDither) << 513; +#endif } void tst_QImage::ditherGradient() @@ -3534,6 +3600,24 @@ void tst_QImage::convertColorTable() QCOMPARE(rgb32.pixel(0,0), 0xffffffff); } +void tst_QImage::wideImage() +{ + // QTBUG-73731 and QTBUG-73732 + QImage i(538994187, 2, QImage::Format_ARGB32); + QImage i2(32, 32, QImage::Format_ARGB32); + i2.fill(Qt::white); + + // Test that it doesn't crash: + QPainter painter(&i); + // With the composition mode is SourceOver out it's an invalid write + // With the composition mode is Source it's an invalid read + painter.drawImage(0, 0, i2); + painter.setCompositionMode(QPainter::CompositionMode_Source); + painter.drawImage(0, 0, i2); + + // Qt6: Test that it actually works on 64bit architectures. +} + #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) QT_BEGIN_NAMESPACE Q_GUI_EXPORT HBITMAP qt_imageToWinHBITMAP(const QImage &p, int hbitmapFormat = 0); @@ -3635,6 +3719,19 @@ void tst_QImage::toWinHBITMAP() DeleteDC(bitmapDc); ReleaseDC(0, displayDc); } + +void tst_QImage::fromMonoHBITMAP() // QTBUG-72343, corruption for mono bitmaps +{ + enum : int { width = 32, height = 32, size = width * height / 8 }; // 32x32 mono bitmap + char bitmapData[size]; + memset(bitmapData, 0, size); + const HBITMAP hbitmap = CreateBitmap(width, height, /* planes */ 1, /* bitcount */ 1, bitmapData); + const QImage image = qt_imageFromWinHBITMAP(hbitmap); + QCOMPARE(image.size(), QSize(width, height)); + QCOMPARE(image.scanLine(0)[0], 0u); + DeleteObject(hbitmap); +} + #endif // Q_OS_WIN && !Q_OS_WINRT QTEST_GUILESS_MAIN(tst_QImage) diff --git a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp index aa9a990fef..1cf01133b2 100644 --- a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp @@ -525,7 +525,7 @@ void tst_QImageReader::imageFormat_data() QTest::newRow("png") << QString("kollada.png") << QByteArray("png") << QImage::Format_ARGB32; QTest::newRow("png-2") << QString("YCbCr_cmyk.png") << QByteArray("png") << QImage::Format_RGB32; QTest::newRow("png-3") << QString("kollada-16bpc.png") << QByteArray("png") << QImage::Format_RGBA64; - QTest::newRow("png-4") << QString("basn0g16.png") << QByteArray("png") << QImage::Format_RGBX64; // Grayscale16 + QTest::newRow("png-4") << QString("basn0g16.png") << QByteArray("png") << QImage::Format_Grayscale16; QTest::newRow("png-5") << QString("basn2c16.png") << QByteArray("png") << QImage::Format_RGBX64; QTest::newRow("png-6") << QString("basn4a16.png") << QByteArray("png") << QImage::Format_RGBA64; // Grayscale16Alpha16 QTest::newRow("png-7") << QString("basn6a16.png") << QByteArray("png") << QImage::Format_RGBA64; @@ -1603,6 +1603,7 @@ void tst_QImageReader::supportsOption_data() << (QIntList() << QImageIOHandler::Gamma << QImageIOHandler::Description << QImageIOHandler::Quality + << QImageIOHandler::CompressionRatio << QImageIOHandler::Size << QImageIOHandler::ScaledSize); } diff --git a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp index a53c2ddb5b..aaa8475c74 100644 --- a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp +++ b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp @@ -239,7 +239,7 @@ void tst_QImageWriter::writeImage2_data() // QLatin1String("jpeg"), }; - QImage image0(70, 70, QImage::Format_ARGB32); + QImage image0(70, 70, QImage::Format_RGB32); image0.fill(QColor(Qt::red).rgb()); QImage::Format imgFormat = QImage::Format_Mono; @@ -304,10 +304,10 @@ void tst_QImageWriter::writeImage2() if (!equalImageContents(written, image)) { qDebug() << "image" << image.format() << image.width() << image.height() << image.depth() - << hex << image.pixel(0, 0); + << image.pixelColor(0, 0); qDebug() << "written" << written.format() << written.width() << written.height() << written.depth() - << hex << written.pixel(0, 0); + << written.pixelColor(0, 0); } QVERIFY(equalImageContents(written, image)); @@ -408,6 +408,7 @@ void tst_QImageWriter::supportsOption_data() << (QIntList() << QImageIOHandler::Gamma << QImageIOHandler::Description << QImageIOHandler::Quality + << QImageIOHandler::CompressionRatio << QImageIOHandler::Size << QImageIOHandler::ScaledSize); } diff --git a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp index 9a338ad55a..4d31d80246 100644 --- a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp @@ -121,6 +121,7 @@ private slots: void copy(); void deepCopyPreservesDpr(); + void dprPassthrough(); void depthOfNullObjects(); void transformed(); @@ -1169,6 +1170,39 @@ void tst_QPixmap::deepCopyPreservesDpr() QCOMPARE(dest.devicePixelRatio(), dpr); } +void tst_QPixmap::dprPassthrough() +{ + const qreal dpr = 2; + QPixmap src(32, 32); + src.setDevicePixelRatio(dpr); + src.fill(Qt::transparent); + QCOMPARE(src.devicePixelRatio(), dpr); + + QImage img = src.toImage(); + QCOMPARE(img.devicePixelRatio(), dpr); + + QPixmap pm(1, 1); + pm.convertFromImage(img); + QCOMPARE(pm.devicePixelRatio(), dpr); + + QBitmap heuristicMask = src.createHeuristicMask(); + QCOMPARE(heuristicMask.devicePixelRatio(), dpr); + + QBitmap maskFromColor = src.createMaskFromColor(Qt::white); + QCOMPARE(maskFromColor.devicePixelRatio(), dpr); + + QBitmap mask = src.mask(); + QCOMPARE(mask.devicePixelRatio(), dpr); + + QPixmap scaled = src.scaled(16, 16); + QCOMPARE(scaled.devicePixelRatio(), dpr); + + QTransform t; + t.rotate(90); + QPixmap transformed = src.transformed(t); + QCOMPARE(transformed.devicePixelRatio(), dpr); +} + void tst_QPixmap::depthOfNullObjects() { QBitmap b1; diff --git a/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp b/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp index d19aa9b54f..2deb84fa5f 100644 --- a/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp +++ b/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp @@ -202,9 +202,7 @@ void tst_QStandardItem::getSetData() QCOMPARE(qvariant_cast<QSize>(item.data(Qt::SizeHintRole)), sizeHint); QCOMPARE(qvariant_cast<QFont>(item.data(Qt::FontRole)), font); QCOMPARE(qvariant_cast<int>(item.data(Qt::TextAlignmentRole)), int(textAlignment)); - QCOMPARE(qvariant_cast<QBrush>(item.data(Qt::BackgroundColorRole)), QBrush(backgroundColor)); QCOMPARE(qvariant_cast<QBrush>(item.data(Qt::BackgroundRole)), QBrush(backgroundColor)); - QCOMPARE(qvariant_cast<QBrush>(item.data(Qt::TextColorRole)), QBrush(textColor)); QCOMPARE(qvariant_cast<QBrush>(item.data(Qt::ForegroundRole)), QBrush(textColor)); QCOMPARE(qvariant_cast<int>(item.data(Qt::CheckStateRole)), int(checkState)); QCOMPARE(qvariant_cast<QString>(item.data(Qt::AccessibleTextRole)), accessibleText); @@ -236,9 +234,7 @@ void tst_QStandardItem::getSetData() QCOMPARE(item.data(Qt::SizeHintRole), QVariant()); QCOMPARE(item.data(Qt::FontRole), QVariant()); QCOMPARE(item.data(Qt::TextAlignmentRole), QVariant()); - QCOMPARE(item.data(Qt::BackgroundColorRole), QVariant()); QCOMPARE(item.data(Qt::BackgroundRole), QVariant()); - QCOMPARE(item.data(Qt::TextColorRole), QVariant()); QCOMPARE(item.data(Qt::ForegroundRole), QVariant()); QCOMPARE(item.data(Qt::CheckStateRole), QVariant()); QCOMPARE(item.data(Qt::AccessibleTextRole), QVariant()); diff --git a/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp b/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp index e2d7a41bd1..550f70890e 100644 --- a/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp +++ b/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp @@ -1160,7 +1160,7 @@ void tst_QStandardItemModel::getSetItemData() QColor backgroundColor(Qt::blue); roles.insert(Qt::BackgroundRole, backgroundColor); QColor textColor(Qt::green); - roles.insert(Qt::TextColorRole, textColor); + roles.insert(Qt::ForegroundRole, textColor); Qt::CheckState checkState(Qt::PartiallyChecked); roles.insert(Qt::CheckStateRole, int(checkState)); QLatin1String accessibleText("accessibleText"); diff --git a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp index 993ebbaac6..bff9f7d0e0 100644 --- a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp +++ b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp @@ -215,7 +215,7 @@ static bool runHelper(const QString &program, const QStringList &arguments, QByt { #if QT_CONFIG(process) QProcess process; - process.setReadChannelMode(QProcess::ForwardedChannels); + process.setProcessChannelMode(QProcess::ForwardedChannels); process.start(program, arguments); if (!process.waitForStarted()) { *errorMessage = "Unable to start '" + program.toLocal8Bit() + " ': " diff --git a/tests/auto/gui/kernel/qguieventdispatcher/BLACKLIST b/tests/auto/gui/kernel/qguieventdispatcher/BLACKLIST new file mode 100644 index 0000000000..b1590a5ccf --- /dev/null +++ b/tests/auto/gui/kernel/qguieventdispatcher/BLACKLIST @@ -0,0 +1,5 @@ +[sendPostedEvents] +windows +[registerTimer] +windows +winrt diff --git a/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp b/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp index a0ac1b3631..234793a7cf 100644 --- a/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp +++ b/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp @@ -37,6 +37,7 @@ class tst_QPalette : public QObject private Q_SLOTS: void roleValues_data(); void roleValues(); + void resolve(); void copySemantics(); void moveSemantics(); void setBrush(); @@ -80,6 +81,43 @@ void tst_QPalette::roleValues() QCOMPARE(role, value); } +void tst_QPalette::resolve() +{ + QPalette p1; + p1.setBrush(QPalette::WindowText, Qt::green); + p1.setBrush(QPalette::Button, Qt::green); + + QVERIFY(p1.isBrushSet(QPalette::Active, QPalette::WindowText)); + QVERIFY(p1.isBrushSet(QPalette::Active, QPalette::Button)); + + QPalette p2; + p2.setBrush(QPalette::WindowText, Qt::red); + + QVERIFY(p2.isBrushSet(QPalette::Active, QPalette::WindowText)); + QVERIFY(!p2.isBrushSet(QPalette::Active, QPalette::Button)); + + QPalette p1ResolvedTo2 = p1.resolve(p2); + // p1ResolvedTo2 gets everything from p1 and nothing copied from p2 because + // it already has a WindowText. That is two brushes, and to the same value + // as p1. + QCOMPARE(p1ResolvedTo2, p1); + QVERIFY(p1ResolvedTo2.isBrushSet(QPalette::Active, QPalette::WindowText)); + QCOMPARE(p1.windowText(), p1ResolvedTo2.windowText()); + QVERIFY(p1ResolvedTo2.isBrushSet(QPalette::Active, QPalette::Button)); + QCOMPARE(p1.button(), p1ResolvedTo2.button()); + + QPalette p2ResolvedTo1 = p2.resolve(p1); + // p2ResolvedTo1 gets the WindowText set, and to the same value as the + // original p2, however, Button gets set from p1. + QVERIFY(p2ResolvedTo1.isBrushSet(QPalette::Active, QPalette::WindowText)); + QCOMPARE(p2.windowText(), p2ResolvedTo1.windowText()); + QVERIFY(p2ResolvedTo1.isBrushSet(QPalette::Active, QPalette::Button)); + QCOMPARE(p1.button(), p2ResolvedTo1.button()); + + QVERIFY(p2ResolvedTo1 != p1); + QVERIFY(p2ResolvedTo1 != p2); +} + void tst_QPalette::copySemantics() { QPalette src(Qt::red), dst; @@ -110,14 +148,14 @@ void tst_QPalette::moveSemantics() QCOMPARE(src, control); QVERIFY(!dst.isCopyOf(src)); QVERIFY(!dst.isCopyOf(control)); - dst = qMove(src); // move assignment + dst = std::move(src); // move assignment QVERIFY(!dst.isCopyOf(src)); // isCopyOf() works on moved-from palettes, too QVERIFY(dst.isCopyOf(control)); QCOMPARE(dst, control); src = control; // check moved-from 'src' can still be assigned to (doesn't crash) QVERIFY(src.isCopyOf(dst)); QVERIFY(src.isCopyOf(control)); - QPalette dst2(qMove(src)); // move construction + QPalette dst2(std::move(src)); // move construction QVERIFY(!src.isCopyOf(dst)); QVERIFY(!src.isCopyOf(dst2)); QVERIFY(!src.isCopyOf(control)); diff --git a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp index db5e83e2c7..13dc924f93 100644 --- a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp +++ b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp @@ -204,6 +204,7 @@ private slots: void basicRawEventTranslationOfIds(); void multiPointRawEventTranslationOnTouchScreen(); void multiPointRawEventTranslationOnTouchPad(); + void touchOnMultipleTouchscreens(); void deleteInEventHandler(); void deleteInRawEventTranslation(); void crashInQGraphicsSceneAfterNotHandlingTouchBegin(); @@ -213,11 +214,13 @@ private slots: private: QTouchDevice *touchScreenDevice; + QTouchDevice *secondaryTouchScreenDevice; QTouchDevice *touchPadDevice; }; tst_QTouchEvent::tst_QTouchEvent() : touchScreenDevice(QTest::createTouchDevice()) + , secondaryTouchScreenDevice(QTest::createTouchDevice()) , touchPadDevice(QTest::createTouchDevice(QTouchDevice::TouchPad)) { } @@ -225,6 +228,7 @@ tst_QTouchEvent::tst_QTouchEvent() void tst_QTouchEvent::cleanup() { QVERIFY(QGuiApplication::topLevelWindows().isEmpty()); + QWindowSystemInterfacePrivate::clearPointIdMap(); } void tst_QTouchEvent::qPointerUniqueId() @@ -951,6 +955,157 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen() } } +void tst_QTouchEvent::touchOnMultipleTouchscreens() +{ + tst_QTouchEventWidget touchWidget; + touchWidget.setWindowTitle(QTest::currentTestFunction()); + touchWidget.setAttribute(Qt::WA_AcceptTouchEvents); + touchWidget.setGeometry(100, 100, 400, 300); + touchWidget.show(); + QVERIFY(QTest::qWaitForWindowExposed(&touchWidget)); + QWindow *window = touchWidget.windowHandle(); + + QPointF pos = touchWidget.rect().center(); + QPointF screenPos = touchWidget.mapToGlobal(pos.toPoint()); + QPointF delta(10, 10); + QRectF screenGeometry = QApplication::desktop()->screenGeometry(&touchWidget); + + QVector<QTouchEvent::TouchPoint> rawTouchPoints(3); + rawTouchPoints[0].setId(0); + rawTouchPoints[1].setId(10); + rawTouchPoints[2].setId(11); + + // this should be translated to a TouchBegin + rawTouchPoints[0].setState(Qt::TouchPointPressed); + rawTouchPoints[0].setScreenPos(screenPos); + rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].pos(), screenGeometry)); + rawTouchPoints[0].setRawScreenPositions({{12, 34}, {56, 78}}); + ulong timestamp = 1234; + QList<QWindowSystemInterface::TouchPoint> nativeTouchPoints = + QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QTouchEvent::TouchPoint>() << rawTouchPoints[0], window); + QWindowSystemInterface::handleTouchEvent(window, timestamp, touchScreenDevice, nativeTouchPoints); + QCoreApplication::processEvents(); + QVERIFY(touchWidget.seenTouchBegin); + QVERIFY(!touchWidget.seenTouchUpdate); + QVERIFY(!touchWidget.seenTouchEnd); + QCOMPARE(touchWidget.touchBeginPoints.count(), 1); + QCOMPARE(touchWidget.timestamp, timestamp); + QTouchEvent::TouchPoint touchBeginPoint = touchWidget.touchBeginPoints.first(); + const int touchPointId = (QTouchDevicePrivate::get(touchScreenDevice)->id << 24) + 1; + const int secTouchPointId = (QTouchDevicePrivate::get(secondaryTouchScreenDevice)->id << 24) + 2; + QCOMPARE(touchBeginPoint.id(), touchPointId); + QCOMPARE(touchBeginPoint.state(), rawTouchPoints[0].state()); + QCOMPARE(touchBeginPoint.pos(), pos); + + // press a point on secondaryTouchScreenDevice + touchWidget.seenTouchBegin = false; + rawTouchPoints[1].setState(Qt::TouchPointPressed); + rawTouchPoints[1].setScreenPos(screenPos); + rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); + rawTouchPoints[1].setRawScreenPositions({{90, 100}, {110, 120}}); + nativeTouchPoints = + QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QTouchEvent::TouchPoint>() << rawTouchPoints[1], window); + QWindowSystemInterface::handleTouchEvent(window, ++timestamp, secondaryTouchScreenDevice, nativeTouchPoints); + QCoreApplication::processEvents(); + QVERIFY(!touchWidget.seenTouchEnd); + QCOMPARE(touchWidget.touchBeginPoints.count(), 1); + QCOMPARE(touchWidget.timestamp, timestamp); + touchBeginPoint = touchWidget.touchBeginPoints[0]; + QCOMPARE(touchBeginPoint.id(), (QTouchDevicePrivate::get(secondaryTouchScreenDevice)->id << 24) + 2); + QCOMPARE(touchBeginPoint.state(), rawTouchPoints[1].state()); + QCOMPARE(touchBeginPoint.pos(), pos); + + // press another point on secondaryTouchScreenDevice + touchWidget.seenTouchBegin = false; + rawTouchPoints[2].setState(Qt::TouchPointPressed); + rawTouchPoints[2].setScreenPos(screenPos); + rawTouchPoints[2].setNormalizedPos(normalized(rawTouchPoints[2].pos(), screenGeometry)); + rawTouchPoints[2].setRawScreenPositions({{130, 140}, {150, 160}}); + nativeTouchPoints = + QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QTouchEvent::TouchPoint>() << rawTouchPoints[2], window); + QWindowSystemInterface::handleTouchEvent(window, ++timestamp, secondaryTouchScreenDevice, nativeTouchPoints); + QCoreApplication::processEvents(); + QVERIFY(!touchWidget.seenTouchEnd); + QCOMPARE(touchWidget.touchBeginPoints.count(), 1); + QCOMPARE(touchWidget.timestamp, timestamp); + touchBeginPoint = touchWidget.touchBeginPoints[0]; + QCOMPARE(touchBeginPoint.id(), (QTouchDevicePrivate::get(secondaryTouchScreenDevice)->id << 24) + 3); + QCOMPARE(touchBeginPoint.state(), rawTouchPoints[2].state()); + QCOMPARE(touchBeginPoint.pos(), pos); + + // moving the first point should translate to TouchUpdate + rawTouchPoints[0].setState(Qt::TouchPointMoved); + rawTouchPoints[0].setScreenPos(screenPos + delta); + rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].pos(), screenGeometry)); + nativeTouchPoints = + QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QTouchEvent::TouchPoint>() << rawTouchPoints[0], window); + QWindowSystemInterface::handleTouchEvent(window, ++timestamp, touchScreenDevice, nativeTouchPoints); + QCoreApplication::processEvents(); + QVERIFY(touchWidget.seenTouchBegin); + QVERIFY(touchWidget.seenTouchUpdate); + QVERIFY(!touchWidget.seenTouchEnd); + QCOMPARE(touchWidget.touchUpdatePoints.count(), 1); + QTouchEvent::TouchPoint touchUpdatePoint = touchWidget.touchUpdatePoints.first(); + QCOMPARE(touchUpdatePoint.id(), touchPointId); + QCOMPARE(touchUpdatePoint.state(), rawTouchPoints[0].state()); + QCOMPARE(touchUpdatePoint.pos(), pos + delta); + + // releasing the first point translates to TouchEnd + rawTouchPoints[0].setState(Qt::TouchPointReleased); + rawTouchPoints[0].setScreenPos(screenPos + delta + delta); + rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].pos(), screenGeometry)); + nativeTouchPoints = + QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QTouchEvent::TouchPoint>() << rawTouchPoints[0], window); + QWindowSystemInterface::handleTouchEvent(window, ++timestamp, touchScreenDevice, nativeTouchPoints); + QCoreApplication::processEvents(); + QVERIFY(touchWidget.seenTouchBegin); + QVERIFY(touchWidget.seenTouchUpdate); + QVERIFY(touchWidget.seenTouchEnd); + QCOMPARE(touchWidget.touchEndPoints.count(), 1); + QTouchEvent::TouchPoint touchEndPoint = touchWidget.touchEndPoints.first(); + QCOMPARE(touchEndPoint.id(), touchPointId); + QCOMPARE(touchEndPoint.state(), rawTouchPoints[0].state()); + QCOMPARE(touchEndPoint.pos(), pos + delta + delta); + + // Widgets don't normally handle this case: if a TouchEnd was seen before, then + // WA_WState_AcceptedTouchBeginEvent will be false, and + // QApplicationPrivate::translateRawTouchEvent will ignore touch events that aren't TouchBegin. + // So we have to set it true. It _did_ in fact accept the touch begin from the secondary device, + // but it also got a TouchEnd from the primary device in the meantime. + touchWidget.setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent, true); + + // Releasing one point on the secondary touchscreen does not yet generate TouchEnd. + touchWidget.seenTouchEnd = false; + touchWidget.touchEndPoints.clear(); + rawTouchPoints[1].setState(Qt::TouchPointReleased); + rawTouchPoints[2].setState(Qt::TouchPointStationary); + nativeTouchPoints = + QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QTouchEvent::TouchPoint>() << rawTouchPoints[1] << rawTouchPoints[2], window); + QWindowSystemInterface::handleTouchEvent(window, ++timestamp, secondaryTouchScreenDevice, nativeTouchPoints); + QCoreApplication::processEvents(); + QVERIFY(touchWidget.seenTouchBegin); + QVERIFY(touchWidget.seenTouchUpdate); + QVERIFY(!touchWidget.seenTouchEnd); + QCOMPARE(touchWidget.touchUpdatePoints.count(), 2); + QCOMPARE(touchWidget.touchUpdatePoints[0].id(), secTouchPointId); + QCOMPARE(touchWidget.touchUpdatePoints[1].id(), secTouchPointId + 1); + + // releasing the last point on the secondary touchscreen translates to TouchEnd + touchWidget.seenTouchEnd = false; + rawTouchPoints[2].setState(Qt::TouchPointReleased); + nativeTouchPoints = + QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QTouchEvent::TouchPoint>() << rawTouchPoints[2], window); + QWindowSystemInterface::handleTouchEvent(window, ++timestamp, secondaryTouchScreenDevice, nativeTouchPoints); + QCoreApplication::processEvents(); + QVERIFY(touchWidget.seenTouchBegin); + QVERIFY(touchWidget.seenTouchUpdate); + QVERIFY(touchWidget.seenTouchEnd); + QCOMPARE(touchWidget.touchEndPoints.count(), 1); + touchEndPoint = touchWidget.touchEndPoints.first(); + QCOMPARE(touchEndPoint.id(), secTouchPointId + 1); + QCOMPARE(touchEndPoint.state(), rawTouchPoints[2].state()); +} + void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad() { tst_QTouchEventWidget touchWidget; diff --git a/tests/auto/gui/kernel/qwindow/BLACKLIST b/tests/auto/gui/kernel/qwindow/BLACKLIST index e9a0d44ba7..caf39742f6 100644 --- a/tests/auto/gui/kernel/qwindow/BLACKLIST +++ b/tests/auto/gui/kernel/qwindow/BLACKLIST @@ -26,7 +26,6 @@ osx # QTBUG-69163 android [visibility] -osx-10.11 ci osx-10.12 ci [testInputEvents] @@ -40,6 +39,7 @@ android [exposeEventOnShrink_QTBUG54040] # QTBUG-69155 android +opensuse [initialSize] # QTBUG-69159 android diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index 7c24bbaadd..9415908383 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -29,6 +29,7 @@ #include <qrasterwindow.h> #include <qpa/qwindowsysteminterface.h> #include <qpa/qplatformintegration.h> +#include <qpa/qplatformwindow.h> #include <private/qguiapplication_p.h> #include <private/qhighdpiscaling_p.h> #include <QtGui/QPainter> @@ -114,6 +115,7 @@ private slots: void cleanup(); void testBlockingWindowShownAfterModalDialog(); void generatedMouseMove(); + void keepPendingUpdateRequests(); private: QPoint m_availableTopLeft; @@ -2451,6 +2453,27 @@ void tst_QWindow::generatedMouseMove() QVERIFY(w.mouseMovedCount == 5); } +void tst_QWindow::keepPendingUpdateRequests() +{ + QRect geometry(m_availableTopLeft + QPoint(80, 80), m_testWindowSize); + + Window window; + window.setGeometry(geometry); + window.show(); + QCoreApplication::processEvents(); + QTRY_VERIFY(window.isExposed()); + + window.requestUpdate(); + window.close(); + window.setVisible(true); + + QPlatformWindow *platformWindow = window.handle(); + QVERIFY(platformWindow); + + QVERIFY(platformWindow->hasPendingUpdateRequest()); + QTRY_VERIFY(!platformWindow->hasPendingUpdateRequest()); +} + #include <tst_qwindow.moc> QTEST_MAIN(tst_QWindow) diff --git a/tests/auto/gui/painting/painting.pro b/tests/auto/gui/painting/painting.pro index 831fffab30..26e84c1b15 100644 --- a/tests/auto/gui/painting/painting.pro +++ b/tests/auto/gui/painting/painting.pro @@ -3,6 +3,7 @@ SUBDIRS=\ qpainterpath \ qpainterpathstroker \ qcolor \ + qcolorspace \ qbrush \ qregion \ qpagelayout \ diff --git a/tests/auto/gui/painting/qbrush/tst_qbrush.cpp b/tests/auto/gui/painting/qbrush/tst_qbrush.cpp index cd3eaa1478..ce6ce15767 100644 --- a/tests/auto/gui/painting/qbrush/tst_qbrush.cpp +++ b/tests/auto/gui/painting/qbrush/tst_qbrush.cpp @@ -345,6 +345,8 @@ void tst_QBrush::gradientPresets() QGradient invalidPreset(QGradient::Preset(-1)); QCOMPARE(invalidPreset.type(), QGradient::NoGradient); + QBrush brush(invalidPreset); + QCOMPARE(brush.style(), Qt::NoBrush); } void fill(QPaintDevice *pd) { diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp index ece7a30830..13d0618bd9 100644 --- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp +++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp @@ -33,7 +33,7 @@ #include <qcolor.h> #include <qdebug.h> -#include <private/qcolorprofile_p.h> +#include <private/qcolortrclut_p.h> #include <private/qdrawingprimitive_sse2_p.h> #include <qrgba64.h> @@ -318,6 +318,9 @@ void tst_QColor::namehex_data() QTest::newRow("global color darkCyan") << "#008080" << QColor(Qt::darkCyan); QTest::newRow("global color darkMagenta") << "#800080" << QColor(Qt::darkMagenta); QTest::newRow("global color darkYellow") << "#808000" << QColor(Qt::darkYellow); + QTest::newRow("#RGB") << "#888" << QColor(0x88, 0x88, 0x88); + QTest::newRow("#RRRGGGBBB") << "#80F80F80F" << QColor(qRgba64(0x80f8, 0x80f8, 0x80f8, 0xffff)); + QTest::newRow("#RRRRGGGGBBBB") << "#808180818081" << QColor(qRgba64(0x8081, 0x8081, 0x8081, 0xffff)); QTest::newRow("transparent red") << "#66ff0000" << QColor(255, 0, 0, 102); QTest::newRow("invalid red") << "#gg0000" << QColor(); QTest::newRow("invalid transparent") << "#gg00ff00" << QColor(); @@ -1288,7 +1291,7 @@ void tst_QColor::toCmyk_data() << QColor::fromHslF(180./360., 1., 0.5, 1.0); QTest::newRow("data1") - << QColor::fromCmyk(255, 255, 255, 255) + << QColor::fromCmyk(0, 0, 0, 255) << QColor::fromRgb(0, 0, 0) << QColor::fromRgb(0, 0, 0).toHsv() << QColor::fromRgb(0, 0, 0).toHsl(); @@ -1629,14 +1632,13 @@ void tst_QColor::qcolorprofile_data() QTest::newRow("gamma=1.7") << qreal(1.7) << 2; QTest::newRow("gamma=2.0") << qreal(2.0) << 8; QTest::newRow("gamma=2.31") << qreal(2.31) << 33; - QTest::newRow("SRgb") << qreal(0.0) << 7; } void tst_QColor::qcolorprofile() { QFETCH(qreal, gammaC); QFETCH(int, tolerance); - QColorProfile *cp = (gammaC == 0) ? QColorProfile::fromSRgb(): QColorProfile::fromGamma(gammaC); + QColorTrcLut *cp = QColorTrcLut::fromGamma(gammaC); // Test we are accurate for most values after converting through gamma-correction. int error = 0; diff --git a/tests/auto/gui/painting/qcolorspace/qcolorspace.pro b/tests/auto/gui/painting/qcolorspace/qcolorspace.pro new file mode 100644 index 0000000000..14bd699bf7 --- /dev/null +++ b/tests/auto/gui/painting/qcolorspace/qcolorspace.pro @@ -0,0 +1,9 @@ +CONFIG += testcase +QT += testlib gui-private core-private + +TARGET = tst_qcolorspace +SOURCES += tst_qcolorspace.cpp + +RESOURCES += $$files(resources/*) + +TESTDATA += resources/* diff --git a/tests/auto/gui/painting/qcolorspace/resources/ProPhoto.jpg b/tests/auto/gui/painting/qcolorspace/resources/ProPhoto.jpg Binary files differnew file mode 100644 index 0000000000..481d35ca8e --- /dev/null +++ b/tests/auto/gui/painting/qcolorspace/resources/ProPhoto.jpg diff --git a/tests/auto/gui/painting/qcolorspace/resources/sRGB2014.icc b/tests/auto/gui/painting/qcolorspace/resources/sRGB2014.icc Binary files differnew file mode 100644 index 0000000000..49afbfef10 --- /dev/null +++ b/tests/auto/gui/painting/qcolorspace/resources/sRGB2014.icc diff --git a/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp new file mode 100644 index 0000000000..9bd4b75443 --- /dev/null +++ b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp @@ -0,0 +1,238 @@ +/**************************************************************************** +** +** Copyright (C) 2018 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 <QtTest/QtTest> + +#include <qcolorspace.h> +#include <qimage.h> +#include <qimagereader.h> + +Q_DECLARE_METATYPE(QColorSpace::ColorSpaceId) +Q_DECLARE_METATYPE(QColorSpace::Gamut) +Q_DECLARE_METATYPE(QColorSpace::TransferFunction) + +class tst_QColorSpace : public QObject +{ + Q_OBJECT + +public: + tst_QColorSpace(); + +private slots: + void namedColorSpaces_data(); + void namedColorSpaces(); + + void toIccProfile_data(); + void toIccProfile(); + + void fromIccProfile(); + + void imageConversion_data(); + void imageConversion(); + + void loadImage(); +}; + +tst_QColorSpace::tst_QColorSpace() +{ } + + +void tst_QColorSpace::namedColorSpaces_data() +{ + QTest::addColumn<QColorSpace::ColorSpaceId>("colorSpaceId"); + QTest::addColumn<QColorSpace::Gamut>("gamutId"); + QTest::addColumn<QColorSpace::TransferFunction>("transferFunctionId"); + + QTest::newRow("sRGB") << QColorSpace::SRgb + << QColorSpace::Gamut::SRgb + << QColorSpace::TransferFunction::SRgb; + QTest::newRow("sRGB Linear") << QColorSpace::SRgbLinear + << QColorSpace::Gamut::SRgb + << QColorSpace::TransferFunction::Linear; + QTest::newRow("Adobe RGB") << QColorSpace::AdobeRgb + << QColorSpace::Gamut::AdobeRgb + << QColorSpace::TransferFunction::Gamma; + QTest::newRow("Display-P3") << QColorSpace::DisplayP3 + << QColorSpace::Gamut::DciP3D65 + << QColorSpace::TransferFunction::SRgb; + QTest::newRow("ProPhoto RGB") << QColorSpace::ProPhotoRgb + << QColorSpace::Gamut::ProPhotoRgb + << QColorSpace::TransferFunction::ProPhotoRgb; + QTest::newRow("BT.2020") << QColorSpace::Bt2020 + << QColorSpace::Gamut::Bt2020 + << QColorSpace::TransferFunction::Bt2020; +} + +void tst_QColorSpace::namedColorSpaces() +{ + QFETCH(QColorSpace::ColorSpaceId, colorSpaceId); + QFETCH(QColorSpace::Gamut, gamutId); + QFETCH(QColorSpace::TransferFunction, transferFunctionId); + + QColorSpace colorSpace = colorSpaceId; + + QVERIFY(colorSpace.isValid()); + + QCOMPARE(colorSpace.colorSpaceId(), colorSpaceId); + QCOMPARE(colorSpace.gamut(), gamutId); + QCOMPARE(colorSpace.transferFunction(), transferFunctionId); +} + + +void tst_QColorSpace::toIccProfile_data() +{ + namedColorSpaces_data(); +} + +void tst_QColorSpace::toIccProfile() +{ + QFETCH(QColorSpace::ColorSpaceId, colorSpaceId); + QFETCH(QColorSpace::Gamut, gamutId); + QFETCH(QColorSpace::TransferFunction, transferFunctionId); + + Q_UNUSED(gamutId); + Q_UNUSED(transferFunctionId); + + QColorSpace colorSpace = colorSpaceId; + QByteArray iccProfile = colorSpace.iccProfile(); + QVERIFY(!iccProfile.isEmpty()); + + QColorSpace colorSpace2 = QColorSpace::fromIccProfile(iccProfile); + QVERIFY(colorSpace2.isValid()); + + QCOMPARE(colorSpace2, colorSpace); + + QByteArray iccProfile2 = colorSpace2.iccProfile(); + QVERIFY(!iccProfile2.isEmpty()); + + QCOMPARE(iccProfile2, iccProfile); +} + +void tst_QColorSpace::fromIccProfile() +{ + // Read the official sRGB ICCv2 profile: + QString prefix = QFINDTESTDATA("resources/"); + QFile file(prefix + "sRGB2014.icc"); + file.open(QIODevice::ReadOnly); + QByteArray iccProfile = file.readAll(); + QColorSpace stdSRgb = QColorSpace::fromIccProfile(iccProfile); + QVERIFY(stdSRgb.isValid()); + + QCOMPARE(stdSRgb.gamut(), QColorSpace::Gamut::SRgb); + QCOMPARE(stdSRgb.transferFunction(), QColorSpace::TransferFunction::SRgb); + QCOMPARE(stdSRgb.colorSpaceId(), QColorSpace::SRgb); + + QCOMPARE(stdSRgb, QColorSpace(QColorSpace::SRgb)); +} + +void tst_QColorSpace::imageConversion_data() +{ + QTest::addColumn<QColorSpace::ColorSpaceId>("fromColorSpace"); + QTest::addColumn<QColorSpace::ColorSpaceId>("toColorSpace"); + QTest::addColumn<int>("tolerance"); + + QTest::newRow("sRGB -> Display-P3") << QColorSpace::SRgb << QColorSpace::DisplayP3 << 0; + QTest::newRow("sRGB -> Adobe RGB") << QColorSpace::SRgb << QColorSpace::AdobeRgb << 2; + QTest::newRow("Display-P3 -> sRGB") << QColorSpace::DisplayP3 << QColorSpace::SRgb << 0; + QTest::newRow("Adobe RGB -> sRGB") << QColorSpace::AdobeRgb << QColorSpace::SRgb << 2; + QTest::newRow("Display-P3 -> Adobe RGB") << QColorSpace::DisplayP3 << QColorSpace::AdobeRgb << 2; + QTest::newRow("Display-P3 -> BT.2020") << QColorSpace::DisplayP3 << QColorSpace::Bt2020 << 4; + QTest::newRow("sRGB -> sRGB Linear") << QColorSpace::SRgb << QColorSpace::SRgbLinear << 0; +} + +void tst_QColorSpace::imageConversion() +{ + QFETCH(QColorSpace::ColorSpaceId, fromColorSpace); + QFETCH(QColorSpace::ColorSpaceId, toColorSpace); + QFETCH(int, tolerance); + + QImage testImage(256, 1, QImage::Format_RGB32); + + 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); + QVERIFY(qAbs(qRed(p) - qGreen(p)) <= tolerance); + QVERIFY(qAbs(qRed(p) - qBlue(p)) <= tolerance); + QVERIFY((lastRed - qRed(p)) <= (tolerance / 2)); + QVERIFY((lastGreen - qGreen(p)) <= (tolerance / 2)); + QVERIFY((lastBlue - qBlue(p)) <= (tolerance / 2)); + lastRed = qRed(p); + lastGreen = qGreen(p); + lastBlue = qBlue(p); + } +} + + +void tst_QColorSpace::loadImage() +{ + QString prefix = QFINDTESTDATA("resources/"); + QImageReader reader(prefix + "ProPhoto.jpg"); + QImage image = reader.read(); + + QVERIFY(!image.isNull()); + QVERIFY(image.colorSpace().isValid()); + QCOMPARE(image.colorSpace().colorSpaceId(), QColorSpace::ProPhotoRgb); + QVERIFY(!image.colorSpace().iccProfile().isEmpty()); + + QColorSpace defaultProPhotoRgb = QColorSpace::ProPhotoRgb; + QVERIFY(!defaultProPhotoRgb.iccProfile().isEmpty()); + + // Test the iccProfile getter returns the ICC profile from the image + // which since we didn't write it, isn't identical to our defaults. + QVERIFY(defaultProPhotoRgb.iccProfile() != image.colorSpace().iccProfile()); +} + +QTEST_MAIN(tst_QColorSpace) +#include "tst_qcolorspace.moc" diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index 9bf9e99bf9..cec164b8b2 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -185,10 +185,12 @@ private slots: void gradientPixelFormat_data(); void gradientPixelFormat(); +#if QT_CONFIG(raster_64bit) void linearGradientRgb30_data(); void linearGradientRgb30(); void radialGradientRgb30_data(); void radialGradientRgb30(); +#endif void fpe_pixmapTransform(); void fpe_zeroLengthLines(); @@ -299,6 +301,8 @@ private slots: void fillPolygon(); + void drawImageAtPointF(); + private: void fillData(); void setPenColor(QPainter& p); @@ -3944,6 +3948,7 @@ void tst_QPainter::gradientInterpolation() } } +#if QT_CONFIG(raster_64bit) void tst_QPainter::linearGradientRgb30_data() { QTest::addColumn<QColor>("stop0"); @@ -4002,6 +4007,7 @@ void tst_QPainter::radialGradientRgb30() QVERIFY(qGray(p1.rgb()) >= qGray(p2.rgb())); } } +#endif void tst_QPainter::drawPolygon() { @@ -4882,14 +4888,18 @@ void tst_QPainter::blendARGBonRGB_data() << QPainter::CompositionMode_SourceOver << qRgba(255, 0, 0, 85) << 85; QTest::newRow("ARGB_PM over RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32_Premultiplied << QPainter::CompositionMode_SourceOver << qRgba(85, 0, 0, 85) << 85; +#if QT_CONFIG(raster_64bit) QTest::newRow("ARGB source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32 << QPainter::CompositionMode_Source << qRgba(255, 0, 0, 85) << 85; QTest::newRow("ARGB source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32 << QPainter::CompositionMode_Source << qRgba(255, 0, 0, 120) << 85; +#endif QTest::newRow("ARGB_PM source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32_Premultiplied << QPainter::CompositionMode_Source << qRgba(85, 0, 0, 85) << 85; +#if QT_CONFIG(raster_64bit) QTest::newRow("ARGB_PM source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32_Premultiplied << QPainter::CompositionMode_Source << qRgba(180, 0, 0, 180) << 170; +#endif QTest::newRow("ARGB source-in RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32 << QPainter::CompositionMode_SourceIn << qRgba(255, 0, 0, 85) << 85; QTest::newRow("ARGB_PM source-in RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32_Premultiplied @@ -5292,6 +5302,20 @@ void tst_QPainter::fillPolygon() } } +void tst_QPainter::drawImageAtPointF() +{ + // Just test we do not crash + QImage image1(10, 10, QImage::Format_RGB32); + QImage image2(200, 200, QImage::Format_RGB32); + + QPainter paint(&image2); + paint.setClipRect(97, 46, 14, 14); + paint.setCompositionMode(QPainter::CompositionMode_Source); + paint.drawImage(QPointF(96, std::numeric_limits<int>::max()), image1); + paint.drawImage(QPointF(std::numeric_limits<int>::min(), 48), image1); + paint.end(); +} + QTEST_MAIN(tst_QPainter) #include "tst_qpainter.moc" diff --git a/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp b/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp index 16215714f3..69c961c1a1 100644 --- a/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp +++ b/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp @@ -43,6 +43,8 @@ public slots: void cleanupTestCase(); private slots: void getSetCheck(); + void clear(); + void reserveAndCapacity(); void swap(); void contains_QPointF_data(); @@ -148,6 +150,47 @@ void tst_QPainterPath::swap() QCOMPARE(p2.boundingRect().toRect(), QRect( 0, 0,10,10)); } +void tst_QPainterPath::clear() +{ + QPainterPath p1; + QPainterPath p2; + p1.clear(); + QCOMPARE(p1, p2); + + p1.addRect(0, 0, 10, 10); + p1.clear(); + QCOMPARE(p1, p2); + + QCOMPARE(p1.fillRule(), Qt::OddEvenFill); + p1.setFillRule(Qt::WindingFill); + p1.clear(); + QCOMPARE(p1.fillRule(), Qt::WindingFill); +} + +void tst_QPainterPath::reserveAndCapacity() +{ + QPainterPath p; + QVERIFY(p.capacity() == 0); + + p.addRect(0, 0, 10, 10); + QVERIFY(p.capacity() > 0); + + p.clear(); + QVERIFY(p.capacity() > 0); + + p = QPainterPath{}; + QVERIFY(p.capacity() == 0); + + p.moveTo(100, 100); + QVERIFY(p.capacity() > 1); + + p.reserve(1000); + QVERIFY(p.capacity() >= 1000); + + p.reserve(0); + QVERIFY(p.capacity() >= 1000); +} + Q_DECLARE_METATYPE(QPainterPath) void tst_QPainterPath::currentPosition() diff --git a/tests/auto/gui/painting/qpen/tst_qpen.cpp b/tests/auto/gui/painting/qpen/tst_qpen.cpp index ef65d653ce..295ae27d17 100644 --- a/tests/auto/gui/painting/qpen/tst_qpen.cpp +++ b/tests/auto/gui/painting/qpen/tst_qpen.cpp @@ -95,7 +95,7 @@ void tst_QPen::move() QPen p1(Qt::black); // check that moving does the right thing: - QPen p2 = qMove(p1); // could be move or copy construction, so don't check p1's state + QPen p2 = std::move(p1); // could be move or copy construction, so don't check p1's state QCOMPARE(p2.color(), QColor(Qt::black)); // this, executed ehre, would crash: @@ -110,7 +110,7 @@ void tst_QPen::move() QCOMPARE(p1.color(), QColor(Qt::yellow)); // check that moved-from QPens p2, p3 can still be safely destroyed: - QPen p5 = qMove(p2); + QPen p5 = std::move(p2); // intentionally no more statements beyond this point } @@ -120,7 +120,7 @@ void tst_QPen::move_assign() QPen p1(Qt::black), p2(Qt::white); // check that moving does the right thing: - p2 = qMove(p1); // could be move or copy assignment, so don't check p1's state + p2 = std::move(p1); // could be move or copy assignment, so don't check p1's state QCOMPARE(p2.color(), QColor(Qt::black)); // check that move-assigned-from QPen p1 can still be used, albeit @@ -137,7 +137,7 @@ void tst_QPen::move_assign() // check that moved-from QPens p2, p3 can still be safely destroyed: QPen p5; - p5 = qMove(p2); + p5 = std::move(p2); // intentionally no more statements beyond this point } diff --git a/tests/auto/gui/painting/qregion/tst_qregion.cpp b/tests/auto/gui/painting/qregion/tst_qregion.cpp index 5256fbd1dc..24c4583819 100644 --- a/tests/auto/gui/painting/qregion/tst_qregion.cpp +++ b/tests/auto/gui/painting/qregion/tst_qregion.cpp @@ -84,6 +84,8 @@ private slots: #endif void regionFromPath(); + void scaleRegions_data(); + void scaleRegions(); #ifdef QT_BUILD_INTERNAL void regionToPath_data(); @@ -973,6 +975,59 @@ void tst_QRegion::regionFromPath() } } +void tst_QRegion::scaleRegions_data() +{ + QTest::addColumn<qreal>("scale"); + QTest::addColumn<QVector<QRect>>("inputRects"); + QTest::addColumn<QVector<QRect>>("expectedRects"); + + QTest::newRow("1.0 single") << 1.0 + << QVector<QRect>{ QRect(10, 10, 20, 20) } + << QVector<QRect>{ QRect(10, 10, 20, 20) }; + QTest::newRow("1.0 multi") << 1.0 + << QVector<QRect>{ QRect(10, 10, 20, 20), QRect(40, 10, 20, 20) } + << QVector<QRect>{ QRect(10, 10, 20, 20), QRect(40, 10, 20, 20) }; + QTest::newRow("2.0 single") << 2.0 + << QVector<QRect>{ QRect(10, 10, 20, 20) } + << QVector<QRect>{ QRect(20, 20, 40, 40) }; + QTest::newRow("2.0 multi") << 2.0 + << QVector<QRect>{ QRect(10, 10, 20, 20), QRect(40, 10, 20, 20) } + << QVector<QRect>{ QRect(20, 20, 40, 40), QRect(80, 20, 40, 40) }; + QTest::newRow("-1.0 single") << -1.0 + << QVector<QRect>{ QRect(10, 10, 20, 20) } + << QVector<QRect>{ QRect(-30, -30, 20, 20) }; + QTest::newRow("-1.0 multi") << -1.0 + << QVector<QRect>{ QRect(10, 10, 20, 20), QRect(40, 10, 20, 20) } + << QVector<QRect>{ QRect(-60, -30, 20, 20), QRect(-30, -30, 20, 20) }; + QTest::newRow("-2.0 single") << -2.0 + << QVector<QRect>{ QRect(10, 10, 20, 20) } + << QVector<QRect>{ QRect(-60, -60, 40, 40) }; + QTest::newRow("-2.0 multi") << -2.0 + << QVector<QRect>{ QRect(10, 10, 20, 20), QRect(40, 10, 20, 20) } + << QVector<QRect>{ QRect(-120, -60, 40, 40), QRect(-60, -60, 40, 40) }; +} + +void tst_QRegion::scaleRegions() +{ + QFETCH(qreal, scale); + QFETCH(QVector<QRect>, inputRects); + QFETCH(QVector<QRect>, expectedRects); + + QRegion region; + region.setRects(inputRects.constData(), inputRects.size()); + + QRegion expected(expectedRects.first()); + expected.setRects(expectedRects.constData(), expectedRects.size()); + + QTransform t; + t.scale(scale, scale); + + auto result = t.map(region); + + QCOMPARE(result.rectCount(), expectedRects.size()); + QCOMPARE(result, expected); +} + Q_DECLARE_METATYPE(QPainterPath) #ifdef QT_BUILD_INTERNAL diff --git a/tests/auto/gui/qopengl/qopengl.pro b/tests/auto/gui/qopengl/qopengl.pro index d744d37280..722c99ee0b 100644 --- a/tests/auto/gui/qopengl/qopengl.pro +++ b/tests/auto/gui/qopengl/qopengl.pro @@ -8,4 +8,4 @@ QT += gui-private core-private testlib SOURCES += tst_qopengl.cpp -linux:qtConfig(xcb):qtConfig(xcb-glx):qtConfig(xcb-xlib):!qtConfig(egl): DEFINES += USE_GLX +linux:qtConfig(xcb):qtConfig(xcb-glx-plugin): DEFINES += USE_GLX diff --git a/tests/auto/gui/qopengl/tst_qopengl.cpp b/tests/auto/gui/qopengl/tst_qopengl.cpp index f1360b9efe..ede1e58a53 100644 --- a/tests/auto/gui/qopengl/tst_qopengl.cpp +++ b/tests/auto/gui/qopengl/tst_qopengl.cpp @@ -642,6 +642,8 @@ static bool supportsInternalFboFormat(QOpenGLContext *ctx, int glFormat) return false; } } +#else + Q_UNUSED(glFormat); #endif return true; } diff --git a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp index df9e8dab71..7dbeb13aa7 100644 --- a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp +++ b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp @@ -1524,6 +1524,12 @@ void tst_QCssParser::gradient_data() "spread: repeat, stop:0.2 rgb(1, 2, 3), stop:0.5 rgba(1, 2, 3, 4))" << "conical" << QPointF(4, 2) << QPointF() << 2 << qreal(0.2) << QColor(1, 2, 3) << qreal(0.5) << QColor(1, 2, 3, 4); + // spaces before first function parameter lead to parser errors + QTest::newRow("QTBUG-61795") << + "selection-background-color: qconicalgradient( cx: 4, cy : 2, angle: 23, " + "spread: repeat, stop:0.2 rgb( 1, 2, 3), stop:0.5 rgba( 1, 2, 3, 4))" << "conical" << QPointF(4, 2) << QPointF() + << 2 << qreal(0.2) << QColor(1, 2, 3) << qreal(0.5) << QColor(1, 2, 3, 4); + /* won't pass: stop values are expected to be sorted QTest::newRow("unsorted-stop") << "selection-background: lineargradient(x1:0, y1:0, x2:0, y2:1, " diff --git a/tests/auto/gui/text/qfont/qfont.pro b/tests/auto/gui/text/qfont/qfont.pro index 048d952faf..96cd4cfdab 100644 --- a/tests/auto/gui/text/qfont/qfont.pro +++ b/tests/auto/gui/text/qfont/qfont.pro @@ -4,3 +4,4 @@ QT += testlib QT += core-private gui-private qtHaveModule(widgets): QT += widgets SOURCES += tst_qfont.cpp +RESOURCES += testfont.qrc diff --git a/tests/auto/gui/text/qfont/testfont.qrc b/tests/auto/gui/text/qfont/testfont.qrc new file mode 100644 index 0000000000..cf51e4a2b4 --- /dev/null +++ b/tests/auto/gui/text/qfont/testfont.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>weirdfont.otf</file> + </qresource> +</RCC> diff --git a/tests/auto/gui/text/qfont/tst_qfont.cpp b/tests/auto/gui/text/qfont/tst_qfont.cpp index 8090f38a2c..9acf877790 100644 --- a/tests/auto/gui/text/qfont/tst_qfont.cpp +++ b/tests/auto/gui/text/qfont/tst_qfont.cpp @@ -66,6 +66,12 @@ private slots: void fromStringWithoutStyleName(); void sharing(); + void familyNameWithCommaQuote_data(); + void familyNameWithCommaQuote(); + void setFamilies_data(); + void setFamilies(); + void setFamiliesAndFamily_data(); + void setFamiliesAndFamily(); }; // Testing get/set functions @@ -116,6 +122,14 @@ void tst_QFont::exactMatch() QVERIFY(!QFont("sans-serif").exactMatch()); QVERIFY(!QFont("serif").exactMatch()); QVERIFY(!QFont("monospace").exactMatch()); + + font.setFamilies(QStringList() << "BogusFont"); + QVERIFY(!font.exactMatch()); + QVERIFY(!QFont("sans").exactMatch()); + QVERIFY(!QFont("sans-serif").exactMatch()); + QVERIFY(!QFont("serif").exactMatch()); + QVERIFY(!QFont("monospace").exactMatch()); + } void tst_QFont::italicOblique() @@ -277,6 +291,12 @@ void tst_QFont::resolve() QCOMPARE(f4.pointSize(), 45); f4 = f4.resolve(f3); QCOMPARE(f4.pointSize(), 55); + + QFont font5, font6; + const QStringList fontFamilies = { QStringLiteral("Arial") }; + font5.setFamilies(fontFamilies); + font6 = font6.resolve(font5); + QCOMPARE(font6.families(), fontFamilies); } #ifndef QT_NO_WIDGETS @@ -624,5 +644,108 @@ void tst_QFont::sharing() QVERIFY(QFontPrivate::get(f2)->engineData != QFontPrivate::get(f)->engineData); } +void tst_QFont::familyNameWithCommaQuote_data() +{ + QTest::addColumn<QString>("familyName"); + QTest::addColumn<QString>("chosenFamilyName"); + + const QString standardFont(QFont().defaultFamily()); + if (standardFont.isEmpty()) + QSKIP("No default font available on the system"); + const QString weirdFont(QLatin1String("'My, weird'' font name',")); + const QString commaSeparated(standardFont + QLatin1String(",Times New Roman")); + const QString commaSeparatedWeird(weirdFont + QLatin1String(",") + standardFont); + const QString commaSeparatedBogus(QLatin1String("BogusFont,") + standardFont); + + QTest::newRow("standard") << standardFont << standardFont; + QTest::newRow("weird") << weirdFont << weirdFont; + QTest::newRow("commaSeparated") << commaSeparated << standardFont; + QTest::newRow("commaSeparatedWeird") << commaSeparatedWeird << weirdFont; + QTest::newRow("commaSeparatedBogus") << commaSeparatedBogus << standardFont; +} + +void tst_QFont::familyNameWithCommaQuote() +{ + QFETCH(QString, familyName); + QFETCH(QString, chosenFamilyName); + + const int weirdFontId = QFontDatabase::addApplicationFont(":/weirdfont.otf"); + + QVERIFY(weirdFontId != -1); + QFont f(familyName); + QCOMPARE(f.family(), familyName); + QCOMPARE(QFontInfo(f).family(), chosenFamilyName); + + QFontDatabase::removeApplicationFont(weirdFontId); +} + +void tst_QFont::setFamilies_data() +{ + QTest::addColumn<QStringList>("families"); + QTest::addColumn<QString>("chosenFamilyName"); + + const QString weirdFont(QLatin1String("'My, weird'' font name',")); + const QString standardFont(QFont().defaultFamily()); + if (standardFont.isEmpty()) + QSKIP("No default font available on the system"); + + QTest::newRow("standard") << (QStringList() << standardFont) << standardFont; + QTest::newRow("weird") << (QStringList() << weirdFont) << weirdFont; + QTest::newRow("standard-weird") << (QStringList() << standardFont << weirdFont) << standardFont; + QTest::newRow("weird-standard") << (QStringList() << weirdFont << standardFont) << weirdFont; + QTest::newRow("nonexist-weird") << (QStringList() << "NonExistentFont" << weirdFont) << weirdFont; +} + +void tst_QFont::setFamilies() +{ + QFETCH(QStringList, families); + QFETCH(QString, chosenFamilyName); + + const int weirdFontId = QFontDatabase::addApplicationFont(":/weirdfont.otf"); + + QVERIFY(weirdFontId != -1); + QFont f; + f.setFamilies(families); + QCOMPARE(QFontInfo(f).family(), chosenFamilyName); + + QFontDatabase::removeApplicationFont(weirdFontId); +} + +void tst_QFont::setFamiliesAndFamily_data() +{ + QTest::addColumn<QStringList>("families"); + QTest::addColumn<QString>("family"); + QTest::addColumn<QString>("chosenFamilyName"); + + const QString weirdFont(QLatin1String("'My, weird'' font name',")); + const QString defaultFont(QFont().defaultFamily()); + if (defaultFont.isEmpty()) + QSKIP("No default font available on the system"); + + const QString timesFont(QLatin1String("Times")); + const QString nonExistFont(QLatin1String("NonExistentFont")); + + QTest::newRow("firstInFamilies") << (QStringList() << defaultFont << timesFont) << weirdFont << defaultFont; + QTest::newRow("secondInFamilies") << (QStringList() << nonExistFont << weirdFont) << defaultFont << weirdFont; + QTest::newRow("family") << (QStringList() << nonExistFont) << defaultFont << defaultFont; +} + +void tst_QFont::setFamiliesAndFamily() +{ + QFETCH(QStringList, families); + QFETCH(QString, family); + QFETCH(QString, chosenFamilyName); + + const int weirdFontId = QFontDatabase::addApplicationFont(":/weirdfont.otf"); + + QVERIFY(weirdFontId != -1); + QFont f; + f.setFamilies(families); + f.setFamily(family); + QCOMPARE(QFontInfo(f).family(), chosenFamilyName); + + QFontDatabase::removeApplicationFont(weirdFontId); +} + QTEST_MAIN(tst_QFont) #include "tst_qfont.moc" diff --git a/tests/auto/gui/text/qfont/weirdfont.otf b/tests/auto/gui/text/qfont/weirdfont.otf Binary files differnew file mode 100644 index 0000000000..b91c559f5b --- /dev/null +++ b/tests/auto/gui/text/qfont/weirdfont.otf diff --git a/tests/auto/gui/text/qfontcache/tst_qfontcache.cpp b/tests/auto/gui/text/qfontcache/tst_qfontcache.cpp index fbca313ea3..785cc3fef2 100644 --- a/tests/auto/gui/text/qfontcache/tst_qfontcache.cpp +++ b/tests/auto/gui/text/qfontcache/tst_qfontcache.cpp @@ -45,6 +45,8 @@ public: private slots: void engineData_data(); void engineData(); + void engineDataFamilies_data(); + void engineDataFamilies(); void clear(); }; @@ -109,6 +111,49 @@ void tst_QFontCache::engineData() QCOMPARE(engineData, QFontPrivate::get(f)->engineData); } +void tst_QFontCache::engineDataFamilies_data() +{ + QTest::addColumn<QStringList>("families"); + + const QStringList multiple = { QLatin1String("invalid"), QLatin1String("Times New Roman") }; + const QStringList multipleQuotes = { QLatin1String("'invalid'"), QLatin1String("Times New Roman") }; + const QStringList multiple2 = { QLatin1String("invalid"), QLatin1String("Times New Roman"), + QLatin1String("foobar"), QLatin1String("'baz'") }; + + QTest::newRow("unquoted-family-name") << QStringList(QLatin1String("Times New Roman")); + QTest::newRow("quoted-family-name") << QStringList(QLatin1String("Times New Roman")); + QTest::newRow("invalid") << QStringList(QLatin1String("invalid")); + QTest::newRow("multiple") << multiple; + QTest::newRow("multiple spaces quotes") << multipleQuotes; + QTest::newRow("multiple2") << multiple2; +} + +void tst_QFontCache::engineDataFamilies() +{ + QFETCH(QStringList, families); + + QFont f; + f.setFamily(QString()); // Unset the family as taken from the QGuiApplication default + f.setFamilies(families); + f.exactMatch(); // loads engine + QFontPrivate *d = QFontPrivate::get(f); + + QFontDef req = d->request; + // copy-pasted from QFontDatabase::load(), to engineer the cache key + if (req.pixelSize == -1) { + req.pixelSize = std::floor(((req.pointSize * d->dpi) / 72) * 100 + 0.5) / 100; + req.pixelSize = qRound(req.pixelSize); + } + if (req.pointSize < 0) + req.pointSize = req.pixelSize*72.0/d->dpi; + + req.families = families; + + QFontEngineData *engineData = QFontCache::instance()->findEngineData(req); + + QCOMPARE(engineData, QFontPrivate::get(f)->engineData); +} + void tst_QFontCache::clear() { #ifdef QT_BUILD_INTERNAL diff --git a/tests/auto/gui/text/qfontdatabase/testdata.qrc b/tests/auto/gui/text/qfontdatabase/testdata.qrc index 81a0b5b0bf..224e845601 100644 --- a/tests/auto/gui/text/qfontdatabase/testdata.qrc +++ b/tests/auto/gui/text/qfontdatabase/testdata.qrc @@ -3,5 +3,6 @@ <file>LED_REAL.TTF</file> <file alias="testfont.ttf">../../../shared/resources/testfont.ttf</file> <file alias="testfont_condensed.ttf">../../../shared/resources/testfont_condensed.ttf</file> + <file alias="testfont_italic.ttf">../../../shared/resources/testfont_italic.ttf</file> </qresource> </RCC> diff --git a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp index da2f100c0b..68664cdd2f 100644 --- a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp +++ b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp @@ -61,6 +61,8 @@ private slots: void addAppFont_data(); void addAppFont(); + void addTwoAppFontsFromFamily(); + void aliases(); void fallbackFonts(); @@ -75,6 +77,7 @@ private: QString m_ledFont; QString m_testFont; QString m_testFontCondensed; + QString m_testFontItalic; }; tst_QFontDatabase::tst_QFontDatabase() @@ -86,9 +89,11 @@ void tst_QFontDatabase::initTestCase() m_ledFont = QFINDTESTDATA("LED_REAL.TTF"); m_testFont = QFINDTESTDATA("testfont.ttf"); m_testFontCondensed = QFINDTESTDATA("testfont_condensed.ttf"); + m_testFontItalic = QFINDTESTDATA("testfont_italic.ttf"); QVERIFY(!m_ledFont.isEmpty()); QVERIFY(!m_testFont.isEmpty()); QVERIFY(!m_testFontCondensed.isEmpty()); + QVERIFY(!m_testFontItalic.isEmpty()); } void tst_QFontDatabase::styles_data() @@ -259,6 +264,30 @@ void tst_QFontDatabase::addAppFont() QCOMPARE(db.families(), oldFamilies); } +void tst_QFontDatabase::addTwoAppFontsFromFamily() +{ + int regularId = QFontDatabase::addApplicationFont(m_testFont); + if (regularId == -1) + QSKIP("Skip the test since app fonts are not supported on this system"); + + int italicId = QFontDatabase::addApplicationFont(m_testFontItalic); + QVERIFY(italicId != -1); + + QVERIFY(!QFontDatabase::applicationFontFamilies(regularId).isEmpty()); + QVERIFY(!QFontDatabase::applicationFontFamilies(italicId).isEmpty()); + + QString regularFontName = QFontDatabase::applicationFontFamilies(regularId).first(); + QString italicFontName = QFontDatabase::applicationFontFamilies(italicId).first(); + QCOMPARE(regularFontName, italicFontName); + + QFont italicFont = QFontDatabase().font(italicFontName, + QString::fromLatin1("Italic"), 14); + QVERIFY(italicFont.italic()); + + QFontDatabase::removeApplicationFont(regularId); + QFontDatabase::removeApplicationFont(italicId); +} + void tst_QFontDatabase::aliases() { QFontDatabase db; diff --git a/tests/auto/gui/text/qfontmetrics/testfont.qrc b/tests/auto/gui/text/qfontmetrics/testfont.qrc index bc0c0b0959..30b4a3f82e 100644 --- a/tests/auto/gui/text/qfontmetrics/testfont.qrc +++ b/tests/auto/gui/text/qfontmetrics/testfont.qrc @@ -1,5 +1,6 @@ <RCC> <qresource prefix="/fonts"> <file>ucs4font.ttf</file> + <file alias="testfont.ttf">../../../shared/resources/testfont.ttf</file> </qresource> </RCC> diff --git a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp index 9e705b4a00..a0e8525268 100644 --- a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp +++ b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp @@ -58,6 +58,7 @@ private slots: void lineWidth(); void mnemonicTextWidth(); void leadingBelowLine(); + void elidedMetrics(); }; void tst_QFontMetrics::same() @@ -331,5 +332,31 @@ void tst_QFontMetrics::leadingBelowLine() QCOMPARE(line.base(), line.ascent); } +void tst_QFontMetrics::elidedMetrics() +{ + QString testFont = QFINDTESTDATA("fonts/testfont.ttf"); + QVERIFY(!testFont.isEmpty()); + + int id = QFontDatabase::addApplicationFont(testFont); + QVERIFY(id >= 0); + + QFont font(QFontDatabase::applicationFontFamilies(id).at(0)); + font.setPixelSize(12.0); + + QFontMetricsF metrics(font); + QString s = QStringLiteral("VeryLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongText"); + + QRectF boundingRect = metrics.boundingRect(s); + + QString elided = metrics.elidedText(s, Qt::ElideRight, boundingRect.width() / 2.0); + + QRectF elidedBoundingRect = metrics.boundingRect(elided); + + QCOMPARE(boundingRect.height(), elidedBoundingRect.height()); + QCOMPARE(boundingRect.y(), elidedBoundingRect.y()); + + QFontDatabase::removeApplicationFont(id); +} + QTEST_MAIN(tst_QFontMetrics) #include "tst_qfontmetrics.moc" diff --git a/tests/auto/gui/text/qglyphrun/BLACKLIST b/tests/auto/gui/text/qglyphrun/BLACKLIST index 57f32c683d..d8dbdabb4b 100644 --- a/tests/auto/gui/text/qglyphrun/BLACKLIST +++ b/tests/auto/gui/text/qglyphrun/BLACKLIST @@ -1,3 +1,4 @@ [mixedScripts] ubuntu-18.04 b2qt +windows diff --git a/tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp b/tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp index 0a2e024701..55fff34a8e 100644 --- a/tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp +++ b/tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp @@ -74,6 +74,7 @@ private slots: void emptyBlocks(); void setCharFormat(); void highlightOnInit(); + void highlightOnInitAndAppend(); void stopHighlightingWhenStateDoesNotChange(); void unindent(); void highlightToEndOfDocument(); @@ -81,6 +82,7 @@ private slots: void preservePreeditArea(); void task108530(); void avoidUnnecessaryRehighlight(); + void avoidUnnecessaryDelayedRehighlight(); void noContentsChangedDuringHighlight(); void rehighlight(); void rehighlightBlock(); @@ -265,6 +267,19 @@ void tst_QSyntaxHighlighter::highlightOnInit() QTRY_VERIFY(hl->highlighted); } +void tst_QSyntaxHighlighter::highlightOnInitAndAppend() +{ + cursor.insertText("Hello"); + cursor.insertBlock(); + cursor.insertText("World"); + + TestHighlighter *hl = new TestHighlighter(doc); + cursor.insertBlock(); + cursor.insertText("More text"); + QTRY_VERIFY(hl->highlighted); + QVERIFY(hl->highlightedText.endsWith(doc->toPlainText().remove(QLatin1Char('\n')))); +} + class StateTestHighlighter : public QSyntaxHighlighter { public: @@ -330,6 +345,7 @@ void tst_QSyntaxHighlighter::unindent() QCOMPARE(doc->toPlainText(), plainText); TestHighlighter *hl = new TestHighlighter(doc); + QTRY_VERIFY(hl->highlighted); hl->callCount = 0; cursor.movePosition(QTextCursor::Start); @@ -460,7 +476,26 @@ void tst_QSyntaxHighlighter::avoidUnnecessaryRehighlight() QVERIFY(hl->highlighted); hl->highlighted = false; - QTRY_VERIFY(!hl->highlighted); + QCoreApplication::processEvents(); + QVERIFY(!hl->highlighted); +} + +void tst_QSyntaxHighlighter::avoidUnnecessaryDelayedRehighlight() +{ + // Having text in the document before creating the highlighter starts the delayed rehighlight + cursor.insertText("Hello World"); + + TestHighlighter *hl = new TestHighlighter(doc); + QVERIFY(!hl->highlighted); + + hl->rehighlight(); + QVERIFY(hl->highlighted); + + hl->highlighted = false; + // Process events, including delayed rehighlight emission + QCoreApplication::processEvents(); + // Should be cancelled and no extra rehighlight should be done + QVERIFY(!hl->highlighted); } void tst_QSyntaxHighlighter::noContentsChangedDuringHighlight() diff --git a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp index 3f602f5aae..97546c34fd 100644 --- a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp +++ b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp @@ -1128,7 +1128,7 @@ void tst_QTextDocument::toHtml_data() QTextCharFormat fmt; fmt.setAnchor(true); - fmt.setAnchorName("blub"); + fmt.setAnchorNames({"blub"}); cursor.insertText("Blah", fmt); QTest::newRow("named anchor") << QTextDocumentFragment(&doc) diff --git a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp index 3e354b7523..fe0b6dae49 100644 --- a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp +++ b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp @@ -159,6 +159,7 @@ private slots: void nonZeroMarginOnImport(); void html_charFormatPropertiesUnset(); void html_headings(); + void html_quotedFontFamily_data(); void html_quotedFontFamily(); void html_spanBackgroundColor(); void defaultFont(); @@ -195,6 +196,8 @@ private slots: void css_linkPseudo(); void css_pageBreaks(); void css_cellPaddings(); + void css_whiteSpace_data(); + void css_whiteSpace(); void universalSelectors_data(); void universalSelectors(); void screenMedia(); @@ -1770,6 +1773,26 @@ void tst_QTextDocumentFragment::css_cellPaddings() QCOMPARE(cell.format().toTableCellFormat().bottomPadding(), qreal(15)); } +void tst_QTextDocumentFragment::css_whiteSpace_data() +{ + QTest::addColumn<QString>("htmlText"); + QTest::addColumn<bool>("nowrap"); + + QTest::newRow("default") << QString("<p>Normal Text</p>") << false; + QTest::newRow("white-space:nowrap") << QString("<p style=white-space:nowrap>Normal Text</p>") << true; + QTest::newRow("white-space:pre") << QString("<p style=white-space:pre>Normal Text</p>") << true; +} + +void tst_QTextDocumentFragment::css_whiteSpace() +{ + QFETCH(QString, htmlText); + QFETCH(bool, nowrap); + + doc->setHtml(htmlText); + QCOMPARE(doc->blockCount(), 1); + QCOMPARE(doc->begin().blockFormat().nonBreakableLines(), nowrap); +} + void tst_QTextDocumentFragment::html_blockLevelDiv() { const char html[] = "<div align=right><b>Hello World"; @@ -2184,23 +2207,45 @@ void tst_QTextDocumentFragment::html_headings() QCOMPARE(doc->blockCount(), 2); } -void tst_QTextDocumentFragment::html_quotedFontFamily() +void tst_QTextDocumentFragment::html_quotedFontFamily_data() { - setHtml("<div style=\"font-family: 'Foo Bar';\">Test</div>"); - QCOMPARE(doc->begin().begin().fragment().charFormat().fontFamily(), QString("Foo Bar")); - - setHtml("<div style='font-family: \"Foo Bar\";'>Test</div>"); - QCOMPARE(doc->begin().begin().fragment().charFormat().fontFamily(), QString("Foo Bar")); - - setHtml("<div style='font-family: \"Foo Bar\";'>Test</div>"); - QCOMPARE(doc->begin().begin().fragment().charFormat().fontFamily(), QString("Foo Bar")); - - setHtml("<div style='font-family: Foo\n Bar;'>Test</div>"); - QCOMPARE(doc->begin().begin().fragment().charFormat().fontFamily(), QString("Foo Bar")); + QTest::addColumn<QString>("html"); + QTest::addColumn<QString>("fontFamily"); + QTest::addColumn<QStringList>("fontFamilies"); + + const QString fooFamily = QLatin1String("Foo Bar"); + const QString weirdFamily = QLatin1String("'Weird, & font '' name',"); + + QTest::newRow("data1") << QString("<div style=\"font-family: 'Foo Bar';\">Test</div>") + << fooFamily << QStringList(fooFamily); + QTest::newRow("data2") << QString("<div style='font-family: \"Foo Bar\";'>Test</div>") + << QString("Foo Bar") << QStringList("Foo Bar"); + QTest::newRow("data3") << QString("<div style='font-family: Foo\n Bar;'>Test</div>") + << fooFamily << QStringList(fooFamily); + QTest::newRow("data4") << QString("<div style='font-family: Foo\n Bar, serif, \"bar foo\";'>Test" + "</div>") + << fooFamily << (QStringList() << "Foo Bar" << "serif" << "bar foo"); + QTest::newRow("data5") << QString("<div style='font-family: \"\\'Weird, & font \\'\\' name\\'," + "\";'>Test</div>") + << weirdFamily << QStringList(weirdFamily); + QTest::newRow("data6") << QString("<div style='font-family: \"\\'Weird, & font \\'\\' name\\'," + "\";'>Test</div>") + << weirdFamily << QStringList(weirdFamily); + QTest::newRow("data7") << QString("<div style='font-family: \"\\'Weird, & font \\'\\' name\\',\", " + "serif, \"bar foo\";'>Test</div>") + << weirdFamily + << (QStringList() << weirdFamily << "serif" << "bar foo"); +} - setHtml("<div style='font-family: Foo\n Bar, serif, \"bar foo\";'>Test</div>"); - QCOMPARE(doc->begin().begin().fragment().charFormat().fontFamily(), QString("Foo Bar,serif,bar foo")); +void tst_QTextDocumentFragment::html_quotedFontFamily() +{ + QFETCH(QString, html); + QFETCH(QString, fontFamily); + QFETCH(QStringList, fontFamilies); + setHtml(html); + QCOMPARE(doc->begin().begin().fragment().charFormat().fontFamily(), fontFamily); + QCOMPARE(doc->begin().begin().fragment().charFormat().font().families(), fontFamilies); } void tst_QTextDocumentFragment::defaultFont() diff --git a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp index 9c477589f9..9610e5b830 100644 --- a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp @@ -138,6 +138,7 @@ private slots: void noModificationOfInputString(); void superscriptCrash_qtbug53911(); void showLineAndParagraphSeparatorsCrash(); + void koreanWordWrap(); private: QFont testFont; @@ -2309,5 +2310,30 @@ void tst_QTextLayout::nbspWithFormat() QCOMPARE(layout.lineAt(1).textLength(), s2.length() + 1 + s3.length()); } +void tst_QTextLayout::koreanWordWrap() +{ + QString s = QString::fromUtf8("안녕하세요 여러분!"); + QTextLayout layout; + QTextOption option = layout.textOption(); + option.setWrapMode(QTextOption::WordWrap); + option.setFlags(QTextOption::Flag(QTextOption::IncludeTrailingSpaces)); + layout.setTextOption(option); + layout.setText(s); + + QFontMetrics metrics(layout.font()); + + layout.beginLayout(); + forever { + QTextLine line = layout.createLine(); + if (!line.isValid()) + break; + line.setLineWidth(metrics.width(s) * 0.8); + } + layout.endLayout(); + QCOMPARE(layout.lineCount(), 2); + QCOMPARE(layout.lineAt(0).textLength(), 6); + QCOMPARE(layout.lineAt(1).textLength(), 4); +} + QTEST_MAIN(tst_QTextLayout) #include "tst_qtextlayout.moc" diff --git a/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp b/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp index 29eef506bf..22f00c677d 100644 --- a/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp +++ b/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp @@ -431,6 +431,12 @@ void tst_QTextTable::insertRows() table->insertRows(5, 2); QCOMPARE(table->rows(), 7); + table = cursor.insertTable(5,5); + table->mergeCells(0,0,3,3); + table->insertRows(2,1); + + QCOMPARE(table->rows(), 6); + } void tst_QTextTable::deleteInTable() diff --git a/tests/auto/gui/util/qtexturefilereader/qtexturefilereader.qrc b/tests/auto/gui/util/qtexturefilereader/qtexturefilereader.qrc index ab882b5db2..8aab86e1ff 100644 --- a/tests/auto/gui/util/qtexturefilereader/qtexturefilereader.qrc +++ b/tests/auto/gui/util/qtexturefilereader/qtexturefilereader.qrc @@ -3,5 +3,7 @@ <file>texturefiles/car.ktx</file> <file>texturefiles/pattern.pkm</file> <file>texturefiles/car_mips.ktx</file> + <file>texturefiles/newlogo_srgb.astc</file> + <file>texturefiles/newlogo.astc</file> </qresource> </RCC> diff --git a/tests/auto/gui/util/qtexturefilereader/texturefiles/newlogo.astc b/tests/auto/gui/util/qtexturefilereader/texturefiles/newlogo.astc Binary files differnew file mode 100644 index 0000000000..39bf3f1734 --- /dev/null +++ b/tests/auto/gui/util/qtexturefilereader/texturefiles/newlogo.astc diff --git a/tests/auto/gui/util/qtexturefilereader/texturefiles/newlogo_srgb.astc b/tests/auto/gui/util/qtexturefilereader/texturefiles/newlogo_srgb.astc Binary files differnew file mode 100644 index 0000000000..38e876829b --- /dev/null +++ b/tests/auto/gui/util/qtexturefilereader/texturefiles/newlogo_srgb.astc diff --git a/tests/auto/gui/util/qtexturefilereader/tst_qtexturefilereader.cpp b/tests/auto/gui/util/qtexturefilereader/tst_qtexturefilereader.cpp index 9ff4f0ccf2..9b78d18954 100644 --- a/tests/auto/gui/util/qtexturefilereader/tst_qtexturefilereader.cpp +++ b/tests/auto/gui/util/qtexturefilereader/tst_qtexturefilereader.cpp @@ -49,33 +49,55 @@ void tst_qtexturefilereader::checkHandlers_data() QTest::addColumn<QList<int>>("dataOffsets"); QTest::addColumn<QList<int>>("dataLengths"); - QTest::addRow("pattern.pkm") << QStringLiteral(":/texturefiles/pattern.pkm") - << QSize(64, 64) - << quint32(0x0) - << quint32(0x8d64) - << quint32(0x0) - << 1 - << (QList<int>() << 16) - << (QList<int>() << 2048); + QTest::addRow("pattern.pkm") + << QStringLiteral(":/texturefiles/pattern.pkm") + << QSize(64, 64) + << quint32(0x0) + << quint32(0x8d64) + << quint32(0x0) + << 1 + << (QList<int>() << 16) + << (QList<int>() << 2048); - QTest::addRow("car.ktx") << QStringLiteral(":/texturefiles/car.ktx") - << QSize(146, 80) - << quint32(0x0) - << quint32(0x9278) - << quint32(0x1908) - << 1 - << (QList<int>() << 68) - << (QList<int>() << 11840); + QTest::addRow("car.ktx") + << QStringLiteral(":/texturefiles/car.ktx") + << QSize(146, 80) + << quint32(0x0) + << quint32(0x9278) + << quint32(0x1908) + << 1 + << (QList<int>() << 68) + << (QList<int>() << 11840); - QTest::addRow("car_mips.ktx") << QStringLiteral(":/texturefiles/car_mips.ktx") - << QSize(146, 80) - << quint32(0x0) - << quint32(0x9274) - << quint32(0x1907) - << 8 - << (QList<int>() << 68 << 5992 << 7516 << 7880 << 8004 << 8056 << 8068 << 8080) - << (QList<int>() << 5920 << 1520 << 360 << 120 << 48 << 8 << 8 << 8); + QTest::addRow("car_mips.ktx") + << QStringLiteral(":/texturefiles/car_mips.ktx") + << QSize(146, 80) + << quint32(0x0) + << quint32(0x9274) + << quint32(0x1907) + << 8 + << (QList<int>() << 68 << 5992 << 7516 << 7880 << 8004 << 8056 << 8068 << 8080) + << (QList<int>() << 5920 << 1520 << 360 << 120 << 48 << 8 << 8 << 8); + QTest::addRow("newlogo.astc") + << QStringLiteral(":/texturefiles/newlogo.astc") + << QSize(111, 78) + << quint32(0x0) + << quint32(0x93b9) + << quint32(0x0) + << 1 + << (QList<int>() << 16) + << (QList<int>() << 2496); + + QTest::addRow("newlogo_srgb.astc") + << QStringLiteral(":/texturefiles/newlogo_srgb.astc") + << QSize(111, 78) + << quint32(0x0) + << quint32(0x93d9) + << quint32(0x0) + << 1 + << (QList<int>() << 16) + << (QList<int>() << 2496); } void tst_qtexturefilereader::checkHandlers() |