summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/image/qimagewriter
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2013-12-16 16:59:33 +0100
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2013-12-16 16:59:33 +0100
commit3f3be55835427ea9f1bbcc046e05ee538ca214d7 (patch)
tree09d1f54d114855c2b06cc505dfbf74c5890c8419 /tests/auto/gui/image/qimagewriter
parentae293c1cb220847194fba6dcebdbb9194837bb56 (diff)
parent9764f8602719676d1fa15e6fd1e7980af16bfc63 (diff)
Merge remote-tracking branch 'origin/stable' into dev
Conflicts: src/gui/kernel/qplatformtheme.h tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp Change-Id: Iecd3343d6a050b8764f78d809c4a1532aeba69e5
Diffstat (limited to 'tests/auto/gui/image/qimagewriter')
-rw-r--r--tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp
index f1d0e227f6..b10b5704c3 100644
--- a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp
+++ b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp
@@ -50,6 +50,7 @@
#include <QImageWriter>
#include <QPainter>
#include <QSet>
+#include <QTemporaryDir>
#ifdef Q_OS_UNIX // for geteuid()
# include <sys/types.h>
@@ -84,6 +85,7 @@ private slots:
void supportedMimeTypes();
void writeToInvalidDevice();
+ void testCanWrite();
void supportsOption_data();
void supportsOption();
@@ -402,6 +404,28 @@ void tst_QImageWriter::writeToInvalidDevice()
}
}
+void tst_QImageWriter::testCanWrite()
+{
+ {
+ // device is not set
+ QImageWriter writer;
+ QVERIFY(!writer.canWrite());
+ QCOMPARE(writer.error(), QImageWriter::DeviceError);
+ }
+
+ {
+ // check if canWrite won't leave an empty file
+ QTemporaryDir dir;
+ QVERIFY(dir.isValid());
+ QString fileName(dir.path() + QLatin1String("/001.garble"));
+ QVERIFY(!QFileInfo(fileName).exists());
+ QImageWriter writer(fileName);
+ QVERIFY(!writer.canWrite());
+ QCOMPARE(writer.error(), QImageWriter::UnsupportedFormatError);
+ QVERIFY(!QFileInfo(fileName).exists());
+ }
+}
+
void tst_QImageWriter::supportsOption_data()
{
QTest::addColumn<QString>("fileName");