summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative
diff options
context:
space:
mode:
authorJoona Petrell <joona.t.petrell@nokia.com>2010-11-30 01:37:09 (GMT)
committerJoona Petrell <joona.t.petrell@nokia.com>2010-11-30 02:08:20 (GMT)
commit282441f72a7704aadc5525a360430d0c3d49aea6 (patch)
tree45e07dd72accbcaf5c75550f7e7b292010f13a56 /tests/auto/declarative
parente960316477982d21061ca8894109f1f8426b2dec (diff)
downloadQt-282441f72a7704aadc5525a360430d0c3d49aea6.zip
Qt-282441f72a7704aadc5525a360430d0c3d49aea6.tar.gz
Qt-282441f72a7704aadc5525a360430d0c3d49aea6.tar.bz2
Don't draw null pixmap in QDeclarativeImage paint function
Task-number: QTBUG-15690 Reviewed-by: Martin Jones
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r--tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
index bf779ad..447210d 100644
--- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
+++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
@@ -87,6 +87,7 @@ private slots:
void noLoading();
void paintedWidthHeight();
void sourceSize_QTBUG_14303();
+ void nullPixmapPaint();
private:
template<typename T>
@@ -540,6 +541,35 @@ void tst_qdeclarativeimage::sourceSize_QTBUG_14303()
QTRY_COMPARE(sourceSizeSpy.count(), 2);
}
+static int numberOfWarnings = 0;
+static void checkWarnings(QtMsgType, const char *)
+{
+ numberOfWarnings++;
+}
+
+// QTBUG-15690
+void tst_qdeclarativeimage::nullPixmapPaint()
+{
+ QString componentStr = QString("import QtQuick 1.0\nImage { width: 10; height:10; fillMode: Image.PreserveAspectFit; source: \"")
+ + SERVER_ADDR + QString("/no-such-file.png\" }");
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeImage *image = qobject_cast<QDeclarativeImage*>(component.create());
+
+ QTRY_VERIFY(image != 0);
+
+ QtMsgHandler previousMsgHandler = qInstallMsgHandler(checkWarnings);
+
+ QPixmap pm(100, 100);
+ QPainter p(&pm);
+
+ // used to print "QTransform::translate with NaN called"
+ image->paint(&p, 0, 0);
+ qInstallMsgHandler(previousMsgHandler);
+ QVERIFY(numberOfWarnings == 0);
+ delete image;
+}
+
/*
Find an item with the specified objectName. If index is supplied then the
item must also evaluate the {index} expression equal to index