aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2023-04-03 23:40:10 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-04-11 16:42:15 +0000
commit981c6262d896202df511070962c2663e901de0de (patch)
tree1ecbb7fd413319bdddd9679ad7c5b3c045602bc1 /tests
parentbb61f110fe390f5bd443ed5bca4ababc127113d7 (diff)
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 e62f489209e1cf03d5bcb16247d84d5e7563948c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qquickimage/tst_qquickimage.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/tests/auto/quick/qquickimage/tst_qquickimage.cpp b/tests/auto/quick/qquickimage/tst_qquickimage.cpp
index 89b20c3131..343bde5f5f 100644
--- a/tests/auto/quick/qquickimage/tst_qquickimage.cpp
+++ b/tests/auto/quick/qquickimage/tst_qquickimage.cpp
@@ -308,15 +308,19 @@ void tst_qquickimage::mirror()
QSKIP("Skipping due to grabWindow not functional on minimal platforms");
QMap<QQuickImage::FillMode, QImage> screenshots;
- QList<QQuickImage::FillMode> fillModes;
- fillModes << QQuickImage::Stretch << QQuickImage::PreserveAspectFit << QQuickImage::PreserveAspectCrop
- << QQuickImage::Tile << QQuickImage::TileVertically << QQuickImage::TileHorizontally << QQuickImage::Pad;
+ const QList<QQuickImage::FillMode> fillModes{QQuickImage::Stretch,
+ QQuickImage::PreserveAspectFit,
+ QQuickImage::PreserveAspectCrop,
+ QQuickImage::Tile,
+ QQuickImage::TileVertically,
+ QQuickImage::TileHorizontally,
+ QQuickImage::Pad};
qreal width = 300;
qreal height = 250;
qreal devicePixelRatio = 1.0;
- foreach (QQuickImage::FillMode fillMode, fillModes) {
+ for (QQuickImage::FillMode fillMode : fillModes) {
QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("mirror.qml"));
@@ -333,7 +337,7 @@ void tst_qquickimage::mirror()
devicePixelRatio = window->devicePixelRatio();
}
- foreach (QQuickImage::FillMode fillMode, fillModes) {
+ for (QQuickImage::FillMode fillMode : fillModes) {
QPixmap srcPixmap;
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;
// bounding rect, painted rect and item rect are equal in stretching and tiling images
- QStringList fillModes;
- fillModes << "Stretch" << "Tile" << "TileVertically" << "TileHorizontally";
- foreach (QString fillMode, fillModes) {
+ QStringList fillModes{"Stretch", "Tile", "TileVertically", "TileHorizontally"};
+ for (const auto &fillMode : fillModes) {
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 height 400").toLatin1()) << fillMode << false << true << 200.0 << 200.0 << 200.0 << 400.0 << 400.0 << 400.0;