summaryrefslogtreecommitdiffstats
path: root/tests/auto/dds/tst_qdds.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/dds/tst_qdds.cpp')
-rw-r--r--tests/auto/dds/tst_qdds.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/dds/tst_qdds.cpp b/tests/auto/dds/tst_qdds.cpp
index de05ec4..4464b99 100644
--- a/tests/auto/dds/tst_qdds.cpp
+++ b/tests/auto/dds/tst_qdds.cpp
@@ -52,6 +52,8 @@ private slots:
void readImage();
void testMipmaps_data();
void testMipmaps();
+ void testWriteImage_data();
+ void testWriteImage();
};
void tst_qdds::readImage_data()
@@ -149,5 +151,32 @@ void tst_qdds::testMipmaps()
}
}
+void tst_qdds::testWriteImage_data()
+{
+ QTest::addColumn<QString>("fileName");
+ QTest::addColumn<QSize>("size");
+
+ QTest::newRow("1") << QString("A8R8G8B8") << QSize(64, 64);
+}
+
+void tst_qdds::testWriteImage()
+{
+ QFETCH(QString, fileName);
+ QFETCH(QSize, size);
+
+ const QString path = fileName + QStringLiteral(".dds");
+ const QString sourcePath = QStringLiteral(":/dds/") + fileName + QStringLiteral(".dds");
+
+ QImage image(sourcePath);
+ QVERIFY(!image.isNull());
+ QVERIFY(image.size() == size);
+
+ QImageWriter writer(path, QByteArrayLiteral("dds"));
+ QVERIFY2(writer.canWrite(), qPrintable(writer.errorString()));
+ QVERIFY2(writer.write(image), qPrintable(writer.errorString()));
+
+ QVERIFY(image == QImage(path));
+}
+
QTEST_MAIN(tst_qdds)
#include "tst_qdds.moc"