Skip to content

Commit

Permalink
Fix QImageIOHandler autotest for static builds
Browse files Browse the repository at this point in the history
Some of the new imageIO plugin tests recently added would fail in
static builds, since the search order is different then.

Fixes: QTBUG-130739
Pick-to: 6.8
Change-Id: I074bb1bd314e8ff9a6ea90ba0cd27985aca5ad75
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
  • Loading branch information
aavit committed Nov 2, 2024
1 parent 4c0b455 commit 8f5ee7a
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions tests/auto/gui/image/qimageiohandler/tst_qimageiohandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <qimageiohandler.h>
#include <qfile.h>
#include <qimagereader.h>
#include <qlibraryinfo.h>
#include "pluginlog.h"

class tst_QImageIOHandler : public QObject
Expand Down Expand Up @@ -40,6 +41,7 @@ private slots:
private:
QString m_prefix;
QList<QByteArray> m_supportedReadFormats;
bool m_testPluginFoundLast = false;
};

class MyImageIOHandler : public QImageIOHandler
Expand All @@ -54,6 +56,7 @@ tst_QImageIOHandler::tst_QImageIOHandler()
{
m_prefix = QFINDTESTDATA("images/");
m_supportedReadFormats = QImageReader::supportedImageFormats();
m_testPluginFoundLast = QLibraryInfo::isSharedBuild();
}

tst_QImageIOHandler::~tst_QImageIOHandler()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 8f5ee7a

Please sign in to comment.