From f70392700c63d81ef8bcee7351d903e4823b4571 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Mon, 26 Feb 2018 12:00:04 +0100 Subject: Fix: Do not read texture files when backend is not opengl The software backend would assert for the compressed GL texture files. Autotests updated for this functionality. Moved tests of the optional texture-file support out of qmltest (where it did not belong) and into tst_qquickimage, side by side with the tests of the optional svg format. Change-Id: I98c407093ccebeb70ba5a93ff0882dbd0b8060d5 Reviewed-by: Laszlo Agocs --- tests/auto/quick/qquickimage/data/car.ktx | Bin 0 -> 11908 bytes tests/auto/quick/qquickimage/data/logo.pkm | Bin 0 -> 32784 bytes tests/auto/quick/qquickimage/tst_qquickimage.cpp | 28 ++++++++++++++++++++--- 3 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 tests/auto/quick/qquickimage/data/car.ktx create mode 100644 tests/auto/quick/qquickimage/data/logo.pkm (limited to 'tests/auto/quick') diff --git a/tests/auto/quick/qquickimage/data/car.ktx b/tests/auto/quick/qquickimage/data/car.ktx new file mode 100644 index 0000000000..2aefdd306b Binary files /dev/null and b/tests/auto/quick/qquickimage/data/car.ktx differ diff --git a/tests/auto/quick/qquickimage/data/logo.pkm b/tests/auto/quick/qquickimage/data/logo.pkm new file mode 100644 index 0000000000..c0987c5c36 Binary files /dev/null and b/tests/auto/quick/qquickimage/data/logo.pkm differ diff --git a/tests/auto/quick/qquickimage/tst_qquickimage.cpp b/tests/auto/quick/qquickimage/tst_qquickimage.cpp index 9a93bf8892..3613ba6d87 100644 --- a/tests/auto/quick/qquickimage/tst_qquickimage.cpp +++ b/tests/auto/quick/qquickimage/tst_qquickimage.cpp @@ -62,6 +62,7 @@ public: tst_qquickimage(); private slots: + void initTestCase(); void cleanup(); void noSource(); void imageSource(); @@ -97,12 +98,22 @@ private slots: private: QQmlEngine engine; + QSGRendererInterface::GraphicsApi graphicsApi = QSGRendererInterface::Unknown; }; tst_qquickimage::tst_qquickimage() { } +void tst_qquickimage::initTestCase() +{ + QQmlDataTest::initTestCase(); + QScopedPointer window(new QQuickView(0)); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); + graphicsApi = window->rendererInterface()->graphicsApi(); +} + void tst_qquickimage::cleanup() { QQuickWindow window; @@ -150,6 +161,11 @@ void tst_qquickimage::imageSource_data() QTest::newRow("remote svg") << "/heart.svg" << 595.0 << 841.0 << true << false << false << ""; if (QImageReader::supportedImageFormats().contains("svgz")) QTest::newRow("remote svgz") << "/heart.svgz" << 595.0 << 841.0 << true << false << false << ""; + if (graphicsApi == QSGRendererInterface::OpenGL) { + QTest::newRow("texturefile pkm format") << testFileUrl("logo.pkm").toString() << 256.0 << 256.0 << false << false << true << ""; + QTest::newRow("texturefile ktx format") << testFileUrl("car.ktx").toString() << 146.0 << 80.0 << false << false << true << ""; + QTest::newRow("texturefile async") << testFileUrl("logo.pkm").toString() << 256.0 << 256.0 << false << true << true << ""; + } QTest::newRow("remote not found") << "/no-such-file.png" << 0.0 << 0.0 << true << false << true << ":2:1: QML Image: Error transferring {{ServerBaseUrl}}/no-such-file.png - server replied: Not found"; QTest::newRow("extless") << testFileUrl("colors").toString() << 120.0 << 120.0 << false << false << true << ""; @@ -157,9 +173,15 @@ void tst_qquickimage::imageSource_data() QTest::newRow("extless async") << testFileUrl("colors1").toString() << 120.0 << 120.0 << false << true << true << ""; QTest::newRow("extless not found") << testFileUrl("no-such-file").toString() << 0.0 << 0.0 << false << false << true << ":2:1: QML Image: Cannot open: " + testFileUrl("no-such-file").toString(); - // Test that pkm is preferred over png. As pattern.pkm has different size than pattern.png, these tests verify that the right file has been loaded - QTest::newRow("extless prefer-tex") << testFileUrl("pattern").toString() << 64.0 << 64.0 << false << false << true << ""; - QTest::newRow("extless prefer-tex async") << testFileUrl("pattern").toString() << 64.0 << 64.0 << false << true << true << ""; + // Test that texture file is preferred over image file, when supported. + // Since pattern.pkm has different size than pattern.png, these tests verify that the right file has been loaded + if (graphicsApi == QSGRendererInterface::OpenGL) { + QTest::newRow("extless prefer-tex") << testFileUrl("pattern").toString() << 64.0 << 64.0 << false << false << true << ""; + QTest::newRow("extless prefer-tex async") << testFileUrl("pattern").toString() << 64.0 << 64.0 << false << true << true << ""; + } else { + QTest::newRow("extless ignore-tex") << testFileUrl("pattern").toString() << 200.0 << 200.0 << false << false << true << ""; + QTest::newRow("extless ignore-tex async") << testFileUrl("pattern").toString() << 200.0 << 200.0 << false << true << true << ""; + } } -- cgit v1.2.3