summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2009-11-25 04:41:25 (GMT)
committerMartin Jones <martin.jones@nokia.com>2009-11-25 04:41:25 (GMT)
commit4e8ee5429339ec3c56656858ec7edc8ca726bd5c (patch)
treeadfef7f98a80d97d367e3bf53f87af09a37d3fdc
parent3570cb083def4c91d147ceab561ea449646ab515 (diff)
downloadQt-4e8ee5429339ec3c56656858ec7edc8ca726bd5c.zip
Qt-4e8ee5429339ec3c56656858ec7edc8ca726bd5c.tar.gz
Qt-4e8ee5429339ec3c56656858ec7edc8ca726bd5c.tar.bz2
Test for pixmap property of Image.
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsimage.cpp1
-rw-r--r--tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp30
2 files changed, 31 insertions, 0 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicsimage.cpp b/src/declarative/graphicsitems/qmlgraphicsimage.cpp
index 9d59796..38df0c7 100644
--- a/src/declarative/graphicsitems/qmlgraphicsimage.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsimage.cpp
@@ -171,6 +171,7 @@ void QmlGraphicsImagePrivate::setPixmap(const QPixmap &pixmap)
q->setImplicitWidth(pix.width());
q->setImplicitHeight(pix.height());
+ status = pix.isNull() ? QmlGraphicsImageBase::Null : QmlGraphicsImageBase::Ready;
q->update();
emit q->pixmapChanged();
diff --git a/tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp b/tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp
index 784ad42..c8a2d3f 100644
--- a/tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp
+++ b/tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp
@@ -81,6 +81,7 @@ private slots:
void clearSource();
void resized();
void smooth();
+ void pixmap();
private:
QmlEngine engine;
@@ -207,6 +208,35 @@ void tst_qmlgraphicsimage::smooth()
delete obj;
}
+void tst_qmlgraphicsimage::pixmap()
+{
+ QString componentStr = "import Qt 4.6\nImage { pixmap: testPixmap }";
+
+ QPixmap pixmap;
+ QmlContext *ctxt = engine.rootContext();
+ ctxt->setContextProperty("testPixmap", pixmap);
+
+ QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://"));
+
+ QmlGraphicsImage *obj = qobject_cast<QmlGraphicsImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->source(), QUrl());
+ QVERIFY(obj->status() == QmlGraphicsImage::Null);
+ QCOMPARE(obj->width(), 0.);
+ QCOMPARE(obj->height(), 0.);
+ QCOMPARE(obj->fillMode(), QmlGraphicsImage::Stretch);
+ QCOMPARE(obj->progress(), 0.0);
+ QVERIFY(obj->pixmap().isNull());
+
+ pixmap = QPixmap(SRCDIR "/data/colors.png");
+ ctxt->setContextProperty("testPixmap", pixmap);
+ QCOMPARE(obj->width(), 120.);
+ QCOMPARE(obj->height(), 120.);
+ QVERIFY(obj->status() == QmlGraphicsImage::Ready);
+
+ delete obj;
+}
+
QTEST_MAIN(tst_qmlgraphicsimage)
#include "tst_qmlgraphicsimage.moc"