tst_qquickimage: modernize

Replace foreach with ranged-for and brace-initialize lists.

Change-Id: Ieccebcf953d36ffa1dcaf0a1eebef21f2e9074a4
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit e62f489209)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Volker Hilsheimer 2023-04-03 23:40:10 +02:00 committed by Qt Cherry-pick Bot
parent bb61f110fe
commit 981c6262d8
1 changed files with 11 additions and 8 deletions

View File

@ -308,15 +308,19 @@ void tst_qquickimage::mirror()
QSKIP("Skipping due to grabWindow not functional on minimal platforms"); QSKIP("Skipping due to grabWindow not functional on minimal platforms");
QMap<QQuickImage::FillMode, QImage> screenshots; QMap<QQuickImage::FillMode, QImage> screenshots;
QList<QQuickImage::FillMode> fillModes; const QList<QQuickImage::FillMode> fillModes{QQuickImage::Stretch,
fillModes << QQuickImage::Stretch << QQuickImage::PreserveAspectFit << QQuickImage::PreserveAspectCrop QQuickImage::PreserveAspectFit,
<< QQuickImage::Tile << QQuickImage::TileVertically << QQuickImage::TileHorizontally << QQuickImage::Pad; QQuickImage::PreserveAspectCrop,
QQuickImage::Tile,
QQuickImage::TileVertically,
QQuickImage::TileHorizontally,
QQuickImage::Pad};
qreal width = 300; qreal width = 300;
qreal height = 250; qreal height = 250;
qreal devicePixelRatio = 1.0; qreal devicePixelRatio = 1.0;
foreach (QQuickImage::FillMode fillMode, fillModes) { for (QQuickImage::FillMode fillMode : fillModes) {
QScopedPointer<QQuickView> window(new QQuickView); QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("mirror.qml")); window->setSource(testFileUrl("mirror.qml"));
@ -333,7 +337,7 @@ void tst_qquickimage::mirror()
devicePixelRatio = window->devicePixelRatio(); devicePixelRatio = window->devicePixelRatio();
} }
foreach (QQuickImage::FillMode fillMode, fillModes) { for (QQuickImage::FillMode fillMode : fillModes) {
QPixmap srcPixmap; QPixmap srcPixmap;
QVERIFY(srcPixmap.load(testFile("pattern.png"))); QVERIFY(srcPixmap.load(testFile("pattern.png")));
@ -453,9 +457,8 @@ void tst_qquickimage::geometry_data()
QTest::newRow("PreserveAspectCrop explicit width 300, height 400") << "PreserveAspectCrop" << true << true << 300.0 << 800.0 << 800.0 << 400.0 << 400.0 << 400.0; QTest::newRow("PreserveAspectCrop explicit width 300, height 400") << "PreserveAspectCrop" << true << true << 300.0 << 800.0 << 800.0 << 400.0 << 400.0 << 400.0;
// bounding rect, painted rect and item rect are equal in stretching and tiling images // bounding rect, painted rect and item rect are equal in stretching and tiling images
QStringList fillModes; QStringList fillModes{"Stretch", "Tile", "TileVertically", "TileHorizontally"};
fillModes << "Stretch" << "Tile" << "TileVertically" << "TileHorizontally"; for (const auto &fillMode : fillModes) {
foreach (QString fillMode, fillModes) {
QTest::newRow(fillMode.toLatin1()) << fillMode << false << false << 200.0 << 200.0 << 200.0 << 100.0 << 100.0 << 100.0; QTest::newRow(fillMode.toLatin1()) << fillMode << false << false << 200.0 << 200.0 << 200.0 << 100.0 << 100.0 << 100.0;
QTest::newRow(QString(fillMode + " explicit width 300").toLatin1()) << fillMode << true << false << 300.0 << 300.0 << 300.0 << 100.0 << 100.0 << 100.0; QTest::newRow(QString(fillMode + " explicit width 300").toLatin1()) << fillMode << true << false << 300.0 << 300.0 << 300.0 << 100.0 << 100.0 << 100.0;
QTest::newRow(QString(fillMode + " explicit height 400").toLatin1()) << fillMode << false << true << 200.0 << 200.0 << 200.0 << 400.0 << 400.0 << 400.0; QTest::newRow(QString(fillMode + " explicit height 400").toLatin1()) << fillMode << false << true << 200.0 << 200.0 << 200.0 << 400.0 << 400.0 << 400.0;