From 075b3f16e2cfcdf331416b3f1fc5024a80db5f45 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Thu, 31 Oct 2024 15:58:19 +0100 Subject: [PATCH] Fix QImageIOHandler autotest for static builds Some of the new imageIO plugin tests recently added would fail in static builds, since the search order is different then. Fixes: QTBUG-130739 Change-Id: I074bb1bd314e8ff9a6ea90ba0cd27985aca5ad75 Reviewed-by: Allan Sandfeld Jensen (cherry picked from commit 8f5ee7acbdf957ecb4568927df24bd5076da3262) Reviewed-by: Qt Cherry-pick Bot --- .../qimageiohandler/tst_qimageiohandler.cpp | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/tests/auto/gui/image/qimageiohandler/tst_qimageiohandler.cpp b/tests/auto/gui/image/qimageiohandler/tst_qimageiohandler.cpp index aefc427cac5..b36c2decc38 100644 --- a/tests/auto/gui/image/qimageiohandler/tst_qimageiohandler.cpp +++ b/tests/auto/gui/image/qimageiohandler/tst_qimageiohandler.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include "pluginlog.h" class tst_QImageIOHandler : public QObject @@ -40,6 +41,7 @@ private slots: private: QString m_prefix; QList m_supportedReadFormats; + bool m_testPluginFoundLast = false; }; class MyImageIOHandler : public QImageIOHandler @@ -54,6 +56,7 @@ tst_QImageIOHandler::tst_QImageIOHandler() { m_prefix = QFINDTESTDATA("images/"); m_supportedReadFormats = QImageReader::supportedImageFormats(); + m_testPluginFoundLast = QLibraryInfo::isSharedBuild(); } tst_QImageIOHandler::~tst_QImageIOHandler() @@ -95,8 +98,12 @@ void tst_QImageIOHandler::pluginRead_data() QTest::newRow("unknown-suffix") << "black" << "bar" << QStringList({ "formatname-unmatched", "contents-unmatched" }); if (m_supportedReadFormats.contains("jpeg")) QTest::newRow("wrong-suffix2") << "white" << "foo" << QStringList({ "formatname-matched" }); - if (m_supportedReadFormats.contains("gif")) - QTest::newRow("plugin-writeonly") << "cyan" << "gif" << QStringList(); + if (m_supportedReadFormats.contains("gif")) { + if (m_testPluginFoundLast) + QTest::newRow("plugin-writeonly") << "cyan" << "gif" << QStringList(); + else + QTest::newRow("plugin-writeonly") << "cyan" << "gif" << QStringList({ "formatname-matched" }); + } } void tst_QImageIOHandler::pluginRead() @@ -129,7 +136,12 @@ void tst_QImageIOHandler::pluginNoAutoDetection_data() QTest::newRow("wrong-suffix") << "yellow" << "jpg" << QStringList() << false; QTest::newRow("unknown-suffix") << "black" << "bar" << QStringList() << false; QTest::newRow("wrong-suffix2") << "white" << "foo" << QStringList({ "formatname-matched" }) << false; - QTest::newRow("plugin-writeonly") << "cyan" << "gif" << QStringList() << true; + if (m_supportedReadFormats.contains("gif")) { + if (m_testPluginFoundLast) + QTest::newRow("plugin-writeonly") << "cyan" << "gif" << QStringList() << true; + else + QTest::newRow("plugin-writeonly") << "cyan" << "gif" << QStringList({ "formatname-matched" }) << true; + } } void tst_QImageIOHandler::pluginNoAutoDetection() @@ -175,8 +187,12 @@ void tst_QImageIOHandler::pluginDecideFromContent_data() QTest::newRow("no-suffix") << "blue" << "" << QStringList({ "contents-matched" }); QTest::newRow("wrong-suffix") << "yellow" << "jpg" << QStringList({ "contents-matched" }); QTest::newRow("unknown-suffix") << "black" << "bar" << QStringList({ "contents-unmatched" }); - if (m_supportedReadFormats.contains("jpeg")) - QTest::newRow("wrong-suffix2") << "white" << "foo" << QStringList(); + if (m_supportedReadFormats.contains("jpeg")) { + if (m_testPluginFoundLast) + QTest::newRow("wrong-suffix2") << "white" << "foo" << QStringList(); + else + QTest::newRow("wrong-suffix2") << "white" << "foo" << QStringList({ "contents-unmatched" }); + } } void tst_QImageIOHandler::pluginDecideFromContent()