aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quickcontrols2/qquickninepatchimage
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2021-07-20 13:30:11 +0200
committerMitch Curtis <mitch.curtis@qt.io>2021-08-02 13:05:48 +0200
commit357f8490606f32c43b36494fc4c68220e94fbd89 (patch)
tree0bcf82dfb35facd37a7c398607269ac6ff7df3ca /tests/auto/quickcontrols2/qquickninepatchimage
parent4c841bda4877c39e49a52e34877f991af7a2dbc1 (diff)
Restructure tests in preparation for merging into qtdeclarative
Task-number: QTBUG-95173 Change-Id: I541dc26cf2cdd6f2640824f693f7d059445367d9 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit f865f4b76d9385077c9ba4ca91a91246554dd36e) Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/quickcontrols2/qquickninepatchimage')
-rw-r--r--tests/auto/quickcontrols2/qquickninepatchimage/CMakeLists.txt56
-rw-r--r--tests/auto/quickcontrols2/qquickninepatchimage/data/foo.9.pngbin0 -> 139 bytes
-rw-r--r--tests/auto/quickcontrols2/qquickninepatchimage/data/foo@2x.9.pngbin0 -> 153 bytes
-rw-r--r--tests/auto/quickcontrols2/qquickninepatchimage/data/foo@3x.9.pngbin0 -> 174 bytes
-rw-r--r--tests/auto/quickcontrols2/qquickninepatchimage/data/foo@4x.9.pngbin0 -> 185 bytes
-rw-r--r--tests/auto/quickcontrols2/qquickninepatchimage/data/inset-all.9.pngbin0 -> 169 bytes
-rw-r--r--tests/auto/quickcontrols2/qquickninepatchimage/data/inset-all@2x.9.pngbin0 -> 209 bytes
-rw-r--r--tests/auto/quickcontrols2/qquickninepatchimage/data/inset-all@3x.9.pngbin0 -> 236 bytes
-rw-r--r--tests/auto/quickcontrols2/qquickninepatchimage/data/inset-all@4x.9.pngbin0 -> 265 bytes
-rw-r--r--tests/auto/quickcontrols2/qquickninepatchimage/data/inset-bottomright.9.pngbin0 -> 185 bytes
-rw-r--r--tests/auto/quickcontrols2/qquickninepatchimage/data/inset-bottomright@2x.9.pngbin0 -> 222 bytes
-rw-r--r--tests/auto/quickcontrols2/qquickninepatchimage/data/inset-bottomright@3x.9.pngbin0 -> 249 bytes
-rw-r--r--tests/auto/quickcontrols2/qquickninepatchimage/data/inset-bottomright@4x.9.pngbin0 -> 281 bytes
-rw-r--r--tests/auto/quickcontrols2/qquickninepatchimage/data/inset-topleft.9.pngbin0 -> 155 bytes
-rw-r--r--tests/auto/quickcontrols2/qquickninepatchimage/data/inset-topleft@2x.9.pngbin0 -> 183 bytes
-rw-r--r--tests/auto/quickcontrols2/qquickninepatchimage/data/inset-topleft@3x.9.pngbin0 -> 205 bytes
-rw-r--r--tests/auto/quickcontrols2/qquickninepatchimage/data/inset-topleft@4x.9.pngbin0 -> 225 bytes
-rw-r--r--tests/auto/quickcontrols2/qquickninepatchimage/data/ninepatchimage.qml7
-rw-r--r--tests/auto/quickcontrols2/qquickninepatchimage/data/padding.9.pngbin0 -> 162 bytes
-rw-r--r--tests/auto/quickcontrols2/qquickninepatchimage/data/padding@2x.9.pngbin0 -> 153 bytes
-rw-r--r--tests/auto/quickcontrols2/qquickninepatchimage/data/padding@3x.9.pngbin0 -> 176 bytes
-rw-r--r--tests/auto/quickcontrols2/qquickninepatchimage/data/padding@4x.9.pngbin0 -> 187 bytes
-rw-r--r--tests/auto/quickcontrols2/qquickninepatchimage/tst_qquickninepatchimage.cpp254
23 files changed, 317 insertions, 0 deletions
diff --git a/tests/auto/quickcontrols2/qquickninepatchimage/CMakeLists.txt b/tests/auto/quickcontrols2/qquickninepatchimage/CMakeLists.txt
new file mode 100644
index 0000000000..2b74749271
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquickninepatchimage/CMakeLists.txt
@@ -0,0 +1,56 @@
+# Generated from qquickninepatchimage.pro.
+
+#####################################################################
+## tst_qquickninepatchimage Test:
+#####################################################################
+
+# Collect test data
+file(GLOB_RECURSE test_data_glob
+ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}/data/*.qml)
+list(APPEND test_data ${test_data_glob})
+file(GLOB_RECURSE test_data_glob
+ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}/data/*.png)
+list(APPEND test_data ${test_data_glob})
+
+qt_internal_add_test(tst_qquickninepatchimage
+ SOURCES
+ ../shared/qtest_quickcontrols.h
+ ../shared/util.cpp ../shared/util.h
+ ../shared/visualtestutil.cpp ../shared/visualtestutil.h
+ tst_qquickninepatchimage.cpp
+ DEFINES
+ QQC2_IMPORT_PATH=\\\"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src\\\"
+ LIBRARIES
+ Qt::GuiPrivate
+ Qt::QuickControls2Private
+ Qt::QuickPrivate
+ PUBLIC_LIBRARIES
+ Qt::CorePrivate
+ Qt::Gui
+ Qt::GuiPrivate
+ Qt::Qml
+ Qt::QmlPrivate
+ Qt::Quick
+ Qt::QuickControls2
+ Qt::QuickControls2Private
+ Qt::QuickPrivate
+ Qt::QuickTemplates2Private
+ Qt::QuickTest
+ Qt::TestPrivate
+ TESTDATA ${test_data}
+)
+
+## Scopes:
+#####################################################################
+
+qt_internal_extend_target(tst_qquickninepatchimage CONDITION ANDROID OR IOS
+ DEFINES
+ QT_QMLTEST_DATADIR=\\\":/data\\\"
+)
+
+qt_internal_extend_target(tst_qquickninepatchimage CONDITION NOT ANDROID AND NOT IOS
+ DEFINES
+ QT_QMLTEST_DATADIR=\\\"${CMAKE_CURRENT_SOURCE_DIR}/data\\\"
+)
diff --git a/tests/auto/quickcontrols2/qquickninepatchimage/data/foo.9.png b/tests/auto/quickcontrols2/qquickninepatchimage/data/foo.9.png
new file mode 100644
index 0000000000..bac09a4d1a
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquickninepatchimage/data/foo.9.png
Binary files differ
diff --git a/tests/auto/quickcontrols2/qquickninepatchimage/data/foo@2x.9.png b/tests/auto/quickcontrols2/qquickninepatchimage/data/foo@2x.9.png
new file mode 100644
index 0000000000..43e4b47881
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquickninepatchimage/data/foo@2x.9.png
Binary files differ
diff --git a/tests/auto/quickcontrols2/qquickninepatchimage/data/foo@3x.9.png b/tests/auto/quickcontrols2/qquickninepatchimage/data/foo@3x.9.png
new file mode 100644
index 0000000000..4d199c8424
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquickninepatchimage/data/foo@3x.9.png
Binary files differ
diff --git a/tests/auto/quickcontrols2/qquickninepatchimage/data/foo@4x.9.png b/tests/auto/quickcontrols2/qquickninepatchimage/data/foo@4x.9.png
new file mode 100644
index 0000000000..018b8341a2
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquickninepatchimage/data/foo@4x.9.png
Binary files differ
diff --git a/tests/auto/quickcontrols2/qquickninepatchimage/data/inset-all.9.png b/tests/auto/quickcontrols2/qquickninepatchimage/data/inset-all.9.png
new file mode 100644
index 0000000000..a189942957
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquickninepatchimage/data/inset-all.9.png
Binary files differ
diff --git a/tests/auto/quickcontrols2/qquickninepatchimage/data/inset-all@2x.9.png b/tests/auto/quickcontrols2/qquickninepatchimage/data/inset-all@2x.9.png
new file mode 100644
index 0000000000..d00d719cc2
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquickninepatchimage/data/inset-all@2x.9.png
Binary files differ
diff --git a/tests/auto/quickcontrols2/qquickninepatchimage/data/inset-all@3x.9.png b/tests/auto/quickcontrols2/qquickninepatchimage/data/inset-all@3x.9.png
new file mode 100644
index 0000000000..6130fd5020
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquickninepatchimage/data/inset-all@3x.9.png
Binary files differ
diff --git a/tests/auto/quickcontrols2/qquickninepatchimage/data/inset-all@4x.9.png b/tests/auto/quickcontrols2/qquickninepatchimage/data/inset-all@4x.9.png
new file mode 100644
index 0000000000..2c2d1694d4
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquickninepatchimage/data/inset-all@4x.9.png
Binary files differ
diff --git a/tests/auto/quickcontrols2/qquickninepatchimage/data/inset-bottomright.9.png b/tests/auto/quickcontrols2/qquickninepatchimage/data/inset-bottomright.9.png
new file mode 100644
index 0000000000..2b3e58cbf1
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquickninepatchimage/data/inset-bottomright.9.png
Binary files differ
diff --git a/tests/auto/quickcontrols2/qquickninepatchimage/data/inset-bottomright@2x.9.png b/tests/auto/quickcontrols2/qquickninepatchimage/data/inset-bottomright@2x.9.png
new file mode 100644
index 0000000000..70aceb618f
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquickninepatchimage/data/inset-bottomright@2x.9.png
Binary files differ
diff --git a/tests/auto/quickcontrols2/qquickninepatchimage/data/inset-bottomright@3x.9.png b/tests/auto/quickcontrols2/qquickninepatchimage/data/inset-bottomright@3x.9.png
new file mode 100644
index 0000000000..032400ceda
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquickninepatchimage/data/inset-bottomright@3x.9.png
Binary files differ
diff --git a/tests/auto/quickcontrols2/qquickninepatchimage/data/inset-bottomright@4x.9.png b/tests/auto/quickcontrols2/qquickninepatchimage/data/inset-bottomright@4x.9.png
new file mode 100644
index 0000000000..d5cf85aa10
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquickninepatchimage/data/inset-bottomright@4x.9.png
Binary files differ
diff --git a/tests/auto/quickcontrols2/qquickninepatchimage/data/inset-topleft.9.png b/tests/auto/quickcontrols2/qquickninepatchimage/data/inset-topleft.9.png
new file mode 100644
index 0000000000..05a2ff703c
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquickninepatchimage/data/inset-topleft.9.png
Binary files differ
diff --git a/tests/auto/quickcontrols2/qquickninepatchimage/data/inset-topleft@2x.9.png b/tests/auto/quickcontrols2/qquickninepatchimage/data/inset-topleft@2x.9.png
new file mode 100644
index 0000000000..a88f87a5ce
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquickninepatchimage/data/inset-topleft@2x.9.png
Binary files differ
diff --git a/tests/auto/quickcontrols2/qquickninepatchimage/data/inset-topleft@3x.9.png b/tests/auto/quickcontrols2/qquickninepatchimage/data/inset-topleft@3x.9.png
new file mode 100644
index 0000000000..16349d2287
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquickninepatchimage/data/inset-topleft@3x.9.png
Binary files differ
diff --git a/tests/auto/quickcontrols2/qquickninepatchimage/data/inset-topleft@4x.9.png b/tests/auto/quickcontrols2/qquickninepatchimage/data/inset-topleft@4x.9.png
new file mode 100644
index 0000000000..160fab6164
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquickninepatchimage/data/inset-topleft@4x.9.png
Binary files differ
diff --git a/tests/auto/quickcontrols2/qquickninepatchimage/data/ninepatchimage.qml b/tests/auto/quickcontrols2/qquickninepatchimage/data/ninepatchimage.qml
new file mode 100644
index 0000000000..410a61f9fe
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquickninepatchimage/data/ninepatchimage.qml
@@ -0,0 +1,7 @@
+import QtQuick.Controls
+import QtQuick.Controls.impl
+import QtQuick.Controls.Imagine
+import QtQuick.Controls.Imagine.impl
+
+NinePatchImage {
+}
diff --git a/tests/auto/quickcontrols2/qquickninepatchimage/data/padding.9.png b/tests/auto/quickcontrols2/qquickninepatchimage/data/padding.9.png
new file mode 100644
index 0000000000..8a65afadec
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquickninepatchimage/data/padding.9.png
Binary files differ
diff --git a/tests/auto/quickcontrols2/qquickninepatchimage/data/padding@2x.9.png b/tests/auto/quickcontrols2/qquickninepatchimage/data/padding@2x.9.png
new file mode 100644
index 0000000000..101fc0cbbe
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquickninepatchimage/data/padding@2x.9.png
Binary files differ
diff --git a/tests/auto/quickcontrols2/qquickninepatchimage/data/padding@3x.9.png b/tests/auto/quickcontrols2/qquickninepatchimage/data/padding@3x.9.png
new file mode 100644
index 0000000000..e07a93a231
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquickninepatchimage/data/padding@3x.9.png
Binary files differ
diff --git a/tests/auto/quickcontrols2/qquickninepatchimage/data/padding@4x.9.png b/tests/auto/quickcontrols2/qquickninepatchimage/data/padding@4x.9.png
new file mode 100644
index 0000000000..a3506444b1
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquickninepatchimage/data/padding@4x.9.png
Binary files differ
diff --git a/tests/auto/quickcontrols2/qquickninepatchimage/tst_qquickninepatchimage.cpp b/tests/auto/quickcontrols2/qquickninepatchimage/tst_qquickninepatchimage.cpp
new file mode 100644
index 0000000000..5a62c00a7f
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquickninepatchimage/tst_qquickninepatchimage.cpp
@@ -0,0 +1,254 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 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 <qtest.h>
+#include <QtTest/qsignalspy.h>
+
+#include <QtCore/qmath.h>
+#include <QtCore/qsize.h>
+#include <QtGui/private/qhighdpiscaling_p.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQuick/qquickitem.h>
+#include <QtQuick/qquickview.h>
+#include <QtQuick/qquickitemgrabresult.h>
+#include <QtQuick/private/qquickimage_p.h>
+
+#include "../shared/util.h"
+#include "../shared/visualtestutil.h"
+
+using namespace QQuickVisualTestUtil;
+
+class tst_qquickninepatchimage : public QQmlDataTest
+{
+ Q_OBJECT
+
+private slots:
+ void ninePatch_data();
+ void ninePatch();
+ void padding_data();
+ void padding();
+ void inset_data();
+ void inset();
+ void implicitSize_data();
+ void implicitSize();
+};
+
+static QImage grabItemToImage(QQuickItem *item)
+{
+ QSharedPointer<QQuickItemGrabResult> result = item->grabToImage();
+ QSignalSpy spy(result.data(), SIGNAL(ready()));
+ spy.wait();
+ return result->image();
+}
+
+void tst_qquickninepatchimage::ninePatch_data()
+{
+ QTest::addColumn<int>("dpr");
+ QTest::addColumn<QSize>("size");
+
+ // original size, downsized, stretched
+ const QList<QSize> sizes = QList<QSize>()
+ << QSize(40, 40) // original
+ << QSize(10, 40) // downsized (h)
+ << QSize(40, 10) // downsized (v)
+ << QSize(10, 10) // downsized (h & v)
+ << QSize(80, 40) // stretched (h)
+ << QSize(40, 80) // stretched (v)
+ << QSize(80, 80) // stretched (h & v)
+ << QSize(8, 8); // minimal (borders only)
+
+ for (const QSize &sz : sizes) {
+ for (int dpr = 1; dpr <= 4; ++dpr)
+ QTest::newRow(qPrintable(QString::fromLatin1("DPR=%1, %2x%3").arg(dpr).arg(sz.width()).arg(sz.height()))) << dpr << sz;
+ }
+}
+
+void tst_qquickninepatchimage::ninePatch()
+{
+ QFETCH(int, dpr);
+ QFETCH(QSize, size);
+
+ QHighDpiScaling::setGlobalFactor(dpr);
+
+ QQuickView view(testFileUrl("ninepatchimage.qml"));
+ QCOMPARE(view.status(), QQuickView::Ready);
+ view.show();
+ view.requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(&view));
+
+ QQuickImage *ninePatchImage = qobject_cast<QQuickImage *>(view.rootObject());
+ QVERIFY(ninePatchImage);
+ ninePatchImage->setSource(testFileUrl("foo.9.png"));
+ ninePatchImage->setSize(size);
+
+ const QImage ninePatchImageGrab = grabItemToImage(ninePatchImage).scaled(size * dpr);
+
+ // Generate an image to compare against the actual 9-patch image.
+ QImage generatedImage(size * dpr, ninePatchImageGrab.format());
+ generatedImage.fill(Qt::red);
+
+ QImage blueRect(4 * dpr, 4 * dpr, ninePatchImageGrab.format());
+ blueRect.fill(Qt::blue);
+
+ QPainter painter(&generatedImage);
+ // Top-left
+ painter.drawImage(0, 0, blueRect);
+ // Top-right
+ painter.drawImage(generatedImage.width() - blueRect.width(), 0, blueRect);
+ // Bottom-right
+ painter.drawImage(generatedImage.width() - blueRect.width(), generatedImage.height() - blueRect.height(), blueRect);
+ // Bottom-left
+ painter.drawImage(0, generatedImage.height() - blueRect.height(), blueRect);
+
+ if ((QGuiApplication::platformName() == QLatin1String("offscreen"))
+ || (QGuiApplication::platformName() == QLatin1String("minimal")))
+ QEXPECT_FAIL("", "Grabbing does not work on offscreen/minimal platforms", Abort);
+
+ QCOMPARE(ninePatchImageGrab, generatedImage);
+}
+
+void tst_qquickninepatchimage::padding_data()
+{
+ QTest::addColumn<int>("dpr");
+
+ for (int dpr = 1; dpr <= 4; ++dpr)
+ QTest::newRow(qPrintable(QString::fromLatin1("DPR=%1").arg(dpr))) << dpr;
+}
+
+void tst_qquickninepatchimage::padding()
+{
+ QFETCH(int, dpr);
+
+ QHighDpiScaling::setGlobalFactor(dpr);
+
+ QQuickView view(testFileUrl("ninepatchimage.qml"));
+ QCOMPARE(view.status(), QQuickView::Ready);
+ view.show();
+ view.requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(&view));
+
+ QQuickImage *ninePatchImage = qobject_cast<QQuickImage *>(view.rootObject());
+ QVERIFY(ninePatchImage);
+ ninePatchImage->setSource(testFileUrl("padding.9.png"));
+
+ QCOMPARE(ninePatchImage->property("topPadding").toReal(), 8);
+ QCOMPARE(ninePatchImage->property("leftPadding").toReal(), 18);
+ QCOMPARE(ninePatchImage->property("rightPadding").toReal(), 20);
+ QCOMPARE(ninePatchImage->property("bottomPadding").toReal(), 10);
+}
+
+void tst_qquickninepatchimage::inset_data()
+{
+ QTest::addColumn<int>("dpr");
+ QTest::addColumn<QString>("file");
+ QTest::addColumn<QMarginsF>("insets");
+
+ const QStringList files = QStringList() << "inset-all.9.png" << "inset-topleft.9.png" << "inset-bottomright.9.png";
+ const QList<QMarginsF> insets = QList<QMarginsF>() << QMarginsF(2, 1, 3, 4) << QMarginsF(2, 1, 0, 0) << QMarginsF(0, 0, 3, 4);
+
+ for (int i = 0; i < files.count(); ++i) {
+ QString file = files.at(i);
+ for (int dpr = 1; dpr <= 4; ++dpr)
+ QTest::newRow(qPrintable(QString::fromLatin1("%1 DPR=%2").arg(file).arg(dpr))) << dpr << file << insets.at(i);
+ }
+}
+
+Q_DECLARE_METATYPE(QMarginsF)
+
+void tst_qquickninepatchimage::inset()
+{
+ QFETCH(int, dpr);
+ QFETCH(QString, file);
+ QFETCH(QMarginsF, insets);
+
+ QHighDpiScaling::setGlobalFactor(dpr);
+
+ QQuickView view(testFileUrl("ninepatchimage.qml"));
+ QCOMPARE(view.status(), QQuickView::Ready);
+ view.show();
+ view.requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(&view));
+
+ QQuickImage *ninePatchImage = qobject_cast<QQuickImage *>(view.rootObject());
+ QVERIFY(ninePatchImage);
+ ninePatchImage->setSource(testFileUrl(file));
+
+ QCOMPARE(ninePatchImage->property("topInset").toReal(), insets.top());
+ QCOMPARE(ninePatchImage->property("leftInset").toReal(), insets.left());
+ QCOMPARE(ninePatchImage->property("rightInset").toReal(), insets.right());
+ QCOMPARE(ninePatchImage->property("bottomInset").toReal(), insets.bottom());
+}
+
+void tst_qquickninepatchimage::implicitSize_data()
+{
+ QTest::addColumn<int>("dpr");
+ QTest::addColumn<QString>("file");
+ QTest::addColumn<QSizeF>("implicitSize");
+
+ const struct TestFile {
+ QString name;
+ QSizeF sizeHint;
+ } testFiles [] = {
+ { "foo.9.png", QSizeF(40, 40) },
+ { "padding.9.png", QSizeF(40, 40) },
+ { "inset-all.9.png", QSizeF(45, 45) },
+ { "inset-topleft.9.png", QSizeF(42, 41) },
+ { "inset-bottomright.9.png", QSizeF(43, 44) }
+ };
+
+ for (const TestFile &file : testFiles) {
+ for (int dpr = 1; dpr <= 4; ++dpr)
+ QTest::newRow(qPrintable(QString::fromLatin1("%1 DPR=%2").arg(file.name).arg(dpr))) << dpr << file.name << file.sizeHint;
+ }
+}
+
+void tst_qquickninepatchimage::implicitSize()
+{
+ QFETCH(int, dpr);
+ QFETCH(QString, file);
+ QFETCH(QSizeF, implicitSize);
+
+ QHighDpiScaling::setGlobalFactor(dpr);
+
+ QQuickView view(testFileUrl("ninepatchimage.qml"));
+ QCOMPARE(view.status(), QQuickView::Ready);
+ view.show();
+ view.requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(&view));
+
+ QQuickImage *ninePatchImage = qobject_cast<QQuickImage *>(view.rootObject());
+ QVERIFY(ninePatchImage);
+ ninePatchImage->setSource(testFileUrl(file));
+
+ QCOMPARE(ninePatchImage->implicitWidth(), implicitSize.width());
+ QCOMPARE(ninePatchImage->implicitHeight(), implicitSize.height());
+}
+
+QTEST_MAIN(tst_qquickninepatchimage)
+
+#include "tst_qquickninepatchimage.moc"