tests/auto/gui: use new QTest::addRow() more
... for calculated test data names. In tst_qimage.cpp, use QLatin1String instead of QString for image format pretty-printing, to avoid needless memory allocation and, more importantly in the context of this patch, to make the result usable with addRow(), which does not support %ls. Change-Id: Ib1953aee2da235ae912917a450491ac8be69ca3a Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
This commit is contained in:
parent
47fdb2c8e3
commit
ff93eddfd5
@ -222,65 +222,65 @@ private:
|
||||
const QString m_prefix;
|
||||
};
|
||||
|
||||
static QString formatToString(QImage::Format format)
|
||||
static QLatin1String formatToString(QImage::Format format)
|
||||
{
|
||||
switch (format) {
|
||||
case QImage::Format_Invalid:
|
||||
return QStringLiteral("Invalid");
|
||||
return QLatin1String("Invalid");
|
||||
case QImage::Format_Mono:
|
||||
return QStringLiteral("Mono");
|
||||
return QLatin1String("Mono");
|
||||
case QImage::Format_MonoLSB:
|
||||
return QStringLiteral("MonoLSB");
|
||||
return QLatin1String("MonoLSB");
|
||||
case QImage::Format_Indexed8:
|
||||
return QStringLiteral("Indexed8");
|
||||
return QLatin1String("Indexed8");
|
||||
case QImage::Format_RGB32:
|
||||
return QStringLiteral("RGB32");
|
||||
return QLatin1String("RGB32");
|
||||
case QImage::Format_ARGB32:
|
||||
return QStringLiteral("ARGB32");
|
||||
return QLatin1String("ARGB32");
|
||||
case QImage::Format_ARGB32_Premultiplied:
|
||||
return QStringLiteral("ARGB32pm");
|
||||
return QLatin1String("ARGB32pm");
|
||||
case QImage::Format_RGB16:
|
||||
return QStringLiteral("RGB16");
|
||||
return QLatin1String("RGB16");
|
||||
case QImage::Format_ARGB8565_Premultiplied:
|
||||
return QStringLiteral("ARGB8565pm");
|
||||
return QLatin1String("ARGB8565pm");
|
||||
case QImage::Format_RGB666:
|
||||
return QStringLiteral("RGB666");
|
||||
return QLatin1String("RGB666");
|
||||
case QImage::Format_ARGB6666_Premultiplied:
|
||||
return QStringLiteral("ARGB6666pm");
|
||||
return QLatin1String("ARGB6666pm");
|
||||
case QImage::Format_RGB555:
|
||||
return QStringLiteral("RGB555");
|
||||
return QLatin1String("RGB555");
|
||||
case QImage::Format_ARGB8555_Premultiplied:
|
||||
return QStringLiteral("ARGB8555pm");
|
||||
return QLatin1String("ARGB8555pm");
|
||||
case QImage::Format_RGB888:
|
||||
return QStringLiteral("RGB888");
|
||||
return QLatin1String("RGB888");
|
||||
case QImage::Format_RGB444:
|
||||
return QStringLiteral("RGB444");
|
||||
return QLatin1String("RGB444");
|
||||
case QImage::Format_ARGB4444_Premultiplied:
|
||||
return QStringLiteral("ARGB4444pm");
|
||||
return QLatin1String("ARGB4444pm");
|
||||
case QImage::Format_RGBX8888:
|
||||
return QStringLiteral("RGBx88888");
|
||||
return QLatin1String("RGBx88888");
|
||||
case QImage::Format_RGBA8888:
|
||||
return QStringLiteral("RGBA88888");
|
||||
return QLatin1String("RGBA88888");
|
||||
case QImage::Format_RGBA8888_Premultiplied:
|
||||
return QStringLiteral("RGBA88888pm");
|
||||
return QLatin1String("RGBA88888pm");
|
||||
case QImage::Format_BGR30:
|
||||
return QStringLiteral("BGR30");
|
||||
return QLatin1String("BGR30");
|
||||
case QImage::Format_A2BGR30_Premultiplied:
|
||||
return QStringLiteral("A2BGR30pm");
|
||||
return QLatin1String("A2BGR30pm");
|
||||
case QImage::Format_RGB30:
|
||||
return QStringLiteral("RGB30");
|
||||
return QLatin1String("RGB30");
|
||||
case QImage::Format_A2RGB30_Premultiplied:
|
||||
return QStringLiteral("A2RGB30pm");
|
||||
return QLatin1String("A2RGB30pm");
|
||||
case QImage::Format_Alpha8:
|
||||
return QStringLiteral("Alpha8");
|
||||
return QLatin1String("Alpha8");
|
||||
case QImage::Format_Grayscale8:
|
||||
return QStringLiteral("Grayscale8");
|
||||
return QLatin1String("Grayscale8");
|
||||
default:
|
||||
break;
|
||||
};
|
||||
Q_UNREACHABLE();
|
||||
qWarning("Unhandled image format");
|
||||
return QStringLiteral("unknown");
|
||||
return QLatin1String("unknown");
|
||||
}
|
||||
|
||||
tst_QImage::tst_QImage()
|
||||
@ -2321,7 +2321,7 @@ void tst_QImage::rgbSwapped_data()
|
||||
QTest::addColumn<QImage::Format>("format");
|
||||
|
||||
for (int i = QImage::Format_Indexed8; i < QImage::Format_Alpha8; ++i) {
|
||||
QTest::newRow(qPrintable(formatToString(QImage::Format(i)))) << QImage::Format(i);
|
||||
QTest::addRow("%s", formatToString(QImage::Format(i)).data()) << QImage::Format(i);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2576,11 +2576,12 @@ void tst_QImage::inplaceMirrored_data()
|
||||
continue;
|
||||
if (i == QImage::Format_RGB444 || i == QImage::Format_ARGB4444_Premultiplied)
|
||||
continue;
|
||||
QTest::newRow(qPrintable(formatToString(QImage::Format(i)) + QStringLiteral(", vertical")))
|
||||
const auto fmt = formatToString(QImage::Format(i));
|
||||
QTest::addRow("%s, vertical", fmt.data())
|
||||
<< QImage::Format(i) << true << false;
|
||||
QTest::newRow(qPrintable(formatToString(QImage::Format(i)) + QStringLiteral(", horizontal")))
|
||||
QTest::addRow("%s, horizontal", fmt.data())
|
||||
<< QImage::Format(i) << false << true;
|
||||
QTest::newRow(qPrintable(formatToString(QImage::Format(i)) + QStringLiteral(", horizontal+vertical")))
|
||||
QTest::addRow("%s, horizontal+vertical", fmt.data())
|
||||
<< QImage::Format(i) << true << true;
|
||||
}
|
||||
}
|
||||
@ -2744,12 +2745,12 @@ void tst_QImage::genericRgbConversion_data()
|
||||
QTest::addColumn<QImage::Format>("dest_format");
|
||||
|
||||
for (int i = QImage::Format_RGB32; i < QImage::Format_Alpha8; ++i) {
|
||||
const QString formatI = formatToString(QImage::Format(i));
|
||||
const QLatin1String formatI = formatToString(QImage::Format(i));
|
||||
for (int j = QImage::Format_RGB32; j < QImage::Format_Alpha8; ++j) {
|
||||
if (i == j)
|
||||
continue;
|
||||
const QString test = formatI + QLatin1String(" -> ") + formatToString(QImage::Format(j));
|
||||
QTest::newRow(qPrintable(test)) << QImage::Format(i) << QImage::Format(j);
|
||||
QTest::addRow("%s -> %s", formatI.data(), formatToString(QImage::Format(j)).data())
|
||||
<< QImage::Format(i) << QImage::Format(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2786,8 +2787,8 @@ void tst_QImage::inplaceRgbConversion_data()
|
||||
for (int j = QImage::Format_RGB32; j < QImage::Format_Alpha8; ++j) {
|
||||
if (i == j)
|
||||
continue;
|
||||
QString test = QString::fromLatin1("%1 -> %2").arg(formatToString(QImage::Format(i))).arg(formatToString(QImage::Format(j)));
|
||||
QTest::newRow(qPrintable(test)) << QImage::Format(i) << QImage::Format(j);
|
||||
QTest::addRow("%s -> %s", formatToString(QImage::Format(i)).data(), formatToString(QImage::Format(j)).data())
|
||||
<< QImage::Format(i) << QImage::Format(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2953,7 +2954,7 @@ void tst_QImage::invertPixelsRGB_data()
|
||||
QTest::addColumn<QImage::Format>("image_format");
|
||||
|
||||
for (int i = QImage::Format_RGB32; i < QImage::Format_Alpha8; ++i) {
|
||||
QTest::newRow(qPrintable(formatToString(QImage::Format(i)))) << QImage::Format(i);
|
||||
QTest::addRow("%s", formatToString(QImage::Format(i)).data()) << QImage::Format(i);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3130,10 +3131,10 @@ void tst_QImage::rgb30Repremul_data()
|
||||
{
|
||||
QTest::addColumn<uint>("color");
|
||||
for (int i = 255; i > 0; i -= 15) {
|
||||
QTest::newRow(qPrintable(QStringLiteral("100% red=") + QString::number(i))) << qRgba(i, 0, 0, 0xff);
|
||||
QTest::newRow(qPrintable(QStringLiteral("75% red=") + QString::number(i))) << qRgba(i, 0, 0, 0xc0);
|
||||
QTest::newRow(qPrintable(QStringLiteral("50% red=") + QString::number(i))) << qRgba(i, 0, 0, 0x80);
|
||||
QTest::newRow(qPrintable(QStringLiteral("37.5% red=") + QString::number(i))) << qRgba(i, 0, 0, 0x60);
|
||||
QTest::addRow("100%% red=%d", i) << qRgba(i, 0, 0, 0xff);
|
||||
QTest::addRow("75%% red=%d", i) << qRgba(i, 0, 0, 0xc0);
|
||||
QTest::addRow("50%% red=%d", i) << qRgba(i, 0, 0, 0x80);
|
||||
QTest::addRow("37.5%% red=%d", i) << qRgba(i, 0, 0, 0x60);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3393,7 +3394,7 @@ void tst_QImage::toCGImage_data()
|
||||
QImage::Format_RGBA8888, QImage::Format_RGBX8888, QImage::Format_ARGB32_Premultiplied };
|
||||
|
||||
for (int i = QImage::Format_Invalid; i < QImage::Format_Grayscale8; ++i) {
|
||||
QTest::newRow(qPrintable(formatToString(QImage::Format(i))))
|
||||
QTest::addRow("%s", formatToString(QImage::Format(i)).data())
|
||||
<< QImage::Format(i) << supported.contains(QImage::Format(i));
|
||||
}
|
||||
}
|
||||
|
@ -3508,11 +3508,9 @@ void tst_QPainter::drawImage_data()
|
||||
continue;
|
||||
for (int odd_x = 0; odd_x <= 1; ++odd_x) {
|
||||
for (int odd_width = 0; odd_width <= 1; ++odd_width) {
|
||||
QString description =
|
||||
QString("srcFormat %1, dstFormat %2, odd x: %3, odd width: %4")
|
||||
.arg(srcFormat).arg(dstFormat).arg(odd_x).arg(odd_width);
|
||||
|
||||
QTest::newRow(qPrintable(description)) << (10 + odd_x) << 10 << (20 + odd_width) << 20
|
||||
QTest::addRow("srcFormat %d, dstFormat %d, odd x: %d, odd width: %d",
|
||||
srcFormat, dstFormat, odd_x, odd_width)
|
||||
<< (10 + odd_x) << 10 << (20 + odd_width) << 20
|
||||
<< QImage::Format(srcFormat)
|
||||
<< QImage::Format(dstFormat);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user