diff options
Diffstat (limited to 'tests/auto/quickcontrols2/qquickninepatchimage')
-rw-r--r-- | tests/auto/quickcontrols2/qquickninepatchimage/CMakeLists.txt | 6 | ||||
-rw-r--r-- | tests/auto/quickcontrols2/qquickninepatchimage/data/logo.pkm | bin | 0 -> 32784 bytes | |||
-rw-r--r-- | tests/auto/quickcontrols2/qquickninepatchimage/data/o1_bc1.ktx | bin | 0 -> 2116 bytes | |||
-rw-r--r-- | tests/auto/quickcontrols2/qquickninepatchimage/data/qt4.astc | bin | 0 -> 12816 bytes | |||
-rw-r--r-- | tests/auto/quickcontrols2/qquickninepatchimage/tst_qquickninepatchimage.cpp | 59 |
5 files changed, 60 insertions, 5 deletions
diff --git a/tests/auto/quickcontrols2/qquickninepatchimage/CMakeLists.txt b/tests/auto/quickcontrols2/qquickninepatchimage/CMakeLists.txt index 56edab461d..b0fdebd1aa 100644 --- a/tests/auto/quickcontrols2/qquickninepatchimage/CMakeLists.txt +++ b/tests/auto/quickcontrols2/qquickninepatchimage/CMakeLists.txt @@ -7,11 +7,7 @@ # 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) + ${CMAKE_CURRENT_SOURCE_DIR}/data/*) list(APPEND test_data ${test_data_glob}) qt_internal_add_test(tst_qquickninepatchimage diff --git a/tests/auto/quickcontrols2/qquickninepatchimage/data/logo.pkm b/tests/auto/quickcontrols2/qquickninepatchimage/data/logo.pkm Binary files differnew file mode 100644 index 0000000000..c0987c5c36 --- /dev/null +++ b/tests/auto/quickcontrols2/qquickninepatchimage/data/logo.pkm diff --git a/tests/auto/quickcontrols2/qquickninepatchimage/data/o1_bc1.ktx b/tests/auto/quickcontrols2/qquickninepatchimage/data/o1_bc1.ktx Binary files differnew file mode 100644 index 0000000000..d61194a745 --- /dev/null +++ b/tests/auto/quickcontrols2/qquickninepatchimage/data/o1_bc1.ktx diff --git a/tests/auto/quickcontrols2/qquickninepatchimage/data/qt4.astc b/tests/auto/quickcontrols2/qquickninepatchimage/data/qt4.astc Binary files differnew file mode 100644 index 0000000000..7f7a3f4739 --- /dev/null +++ b/tests/auto/quickcontrols2/qquickninepatchimage/data/qt4.astc diff --git a/tests/auto/quickcontrols2/qquickninepatchimage/tst_qquickninepatchimage.cpp b/tests/auto/quickcontrols2/qquickninepatchimage/tst_qquickninepatchimage.cpp index c1fb1f7264..dc88d0c5ed 100644 --- a/tests/auto/quickcontrols2/qquickninepatchimage/tst_qquickninepatchimage.cpp +++ b/tests/auto/quickcontrols2/qquickninepatchimage/tst_qquickninepatchimage.cpp @@ -11,8 +11,10 @@ #include <QtQuick/qquickview.h> #include <QtQuick/qquickitemgrabresult.h> #include <QtQuick/private/qquickimage_p.h> +#include <QtQuick/private/qquickimage_p_p.h> #include <QtQuickTestUtils/private/qmlutils_p.h> #include <QtQuickTestUtils/private/visualtestutils_p.h> +#include <QtGui/private/qrhi_p.h> using namespace QQuickVisualTestUtils; @@ -32,6 +34,8 @@ private slots: void inset(); void implicitSize_data(); void implicitSize(); + void hwCompressedImages_data(); + void hwCompressedImages(); }; static QImage grabItemToImage(QQuickItem *item) @@ -230,6 +234,61 @@ void tst_qquickninepatchimage::implicitSize() QCOMPARE(ninePatchImage->implicitHeight(), implicitSize.height()); } +void tst_qquickninepatchimage::hwCompressedImages_data() +{ + QTest::addColumn<int>("dpr"); + QTest::addColumn<QString>("file"); + QTest::addColumn<QSize>("size"); + QTest::addColumn<QRhiTexture::Format>("format"); + + const struct TestFile { + QString name; + QSize size; + QRhiTexture::Format format; + } testFiles [] = { + { "o1_bc1.ktx", QSize(64, 64), QRhiTexture::BC1 }, + { "logo.pkm", QSize(256, 256), QRhiTexture::ETC2_RGB8 }, + { "qt4.astc", QSize(250, 200), QRhiTexture::ASTC_8x8 } + }; + + 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.size << file.format; + } +} + +void tst_qquickninepatchimage::hwCompressedImages() +{ + QFETCH(int, dpr); + QFETCH(QString, file); + QFETCH(QSize, size); + QFETCH(QRhiTexture::Format, format); + + QHighDpiScaling::setGlobalFactor(dpr); + + QQuickView view(testFileUrl("ninepatchimage.qml")); + QCOMPARE(view.status(), QQuickView::Ready); + view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + + if (!QSGRendererInterface::isApiRhiBased(view.rendererInterface()->graphicsApi())) + QSKIP("Skipping due to using software backend"); + + QRhi *rhi = static_cast<QRhi *>(view.rendererInterface()->getResource(&view, QSGRendererInterface::RhiResource)); + if (!rhi->isTextureFormatSupported(format)) + QSKIP(qPrintable(QString::fromLatin1("%1 not supported, skip").arg(format))); + + QQuickImage *ninePatchImage = qobject_cast<QQuickImage *>(view.rootObject()); + QVERIFY(ninePatchImage); + ninePatchImage->setSource(testFileUrl(file)); + ninePatchImage->setSize(size); + QSignalSpy spy(&view, SIGNAL(afterSynchronizing())); + QTRY_VERIFY(spy.size() >= 1); + + QQuickImagePrivate *ninePatchImagePrivate = static_cast<QQuickImagePrivate *>(QQuickItemPrivate::get(ninePatchImage)); + QVERIFY(ninePatchImagePrivate->paintNode); +} + QTEST_MAIN(tst_qquickninepatchimage) #include "tst_qquickninepatchimage.moc" |