Read / Write test: added NULL device test

DDS plugin crashes if I request supportedSubTypes()

- Fixed DDS plugin crash
- Added NULL device test on both read and write tests

Closes #14
This commit is contained in:
Mirco Miranda
2024-12-16 13:52:06 +00:00
committed by Albert Astals Cid
parent d91c7dd912
commit a6f7482957
3 changed files with 130 additions and 9 deletions

View File

@ -329,6 +329,52 @@ int formatTest(const QString &suffix, bool createTemplates)
return failed == 0 ? 0 : 1;
}
/*!
* \brief nullDeviceTest
* Checks the plugin behaviour when using a NULL device.
*/
int nullDeviceTest(const QString &suffix)
{
QTextStream(stdout) << "********* "
<< "Starting NULL device write tests for " << suffix << " images *********\n";
int passed = 0;
int failed = 0;
int skipped = 0;
QImageWriter writer;
writer.setFormat(suffix.toLatin1());
if (writer.canWrite()) {
QTextStream(stdout) << "FAIL : canWrite() returns TRUE\n";
++failed;
}
if (writer.write(QImage(16, 16, QImage::Format_ARGB32))) {
QTextStream(stdout) << "FAIL : write() returns TRUE\n";
++failed;
}
// test for crash only
writer.compression();
writer.quality();
writer.transformation();
writer.subType();
writer.supportedSubTypes();
writer.optimizedWrite();
writer.progressiveScanWrite();
if (failed == 0) {// success
++passed;
}
QTextStream(stdout) << "Totals: " << passed << " passed, " << failed << " failed, " << skipped << " skipped\n";
QTextStream(stdout) << "********* "
<< "Finished format write tests for " << suffix << " images *********\n";
return failed == 0 ? 0 : 1;
}
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
@ -382,6 +428,9 @@ int main(int argc, char **argv)
if (ret == 0) {
ret = formatTest(suffix, parser.isSet(createFormatTempates));
}
if (ret == 0) {
ret = nullDeviceTest(suffix);
}
return ret;
}