summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativeimage
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2011-03-31 00:32:26 (GMT)
committerMartin Jones <martin.jones@nokia.com>2011-03-31 00:47:57 (GMT)
commitaf05f64d3edc860c3cf79c7f0bdf2377faae5f40 (patch)
tree947c708b9d100feb63751bccef18561326e0cd64 /tests/auto/declarative/qdeclarativeimage
parent068652a52f0554b5ceb56798fe5ac4e5049bb9e3 (diff)
downloadQt-af05f64d3edc860c3cf79c7f0bdf2377faae5f40.zip
Qt-af05f64d3edc860c3cf79c7f0bdf2377faae5f40.tar.gz
Qt-af05f64d3edc860c3cf79c7f0bdf2377faae5f40.tar.bz2
Once Image sourceSize is set there is no way to clear it.
Image sourceSize lacked a RESET method to allow reverting to the natural size of the image. Change-Id: I4e9089d8e16991375745db553f891bd377143eab Task-number: QTBUG-18442 Reviewed-by: Yann Bodson
Diffstat (limited to 'tests/auto/declarative/qdeclarativeimage')
-rw-r--r--tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
index 9e090d2..c5a3d14 100644
--- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
+++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
@@ -91,6 +91,7 @@ private slots:
void sourceSize_QTBUG_14303();
void sourceSize_QTBUG_16389();
void nullPixmapPaint();
+ void resetSourceSize();
void testQtQuick11Attributes();
void testQtQuick11Attributes_data();
@@ -693,6 +694,27 @@ void tst_qdeclarativeimage::nullPixmapPaint()
delete image;
}
+void tst_qdeclarativeimage::resetSourceSize()
+{
+ QString src = QUrl::fromLocalFile(SRCDIR "/data/heart200.png").toString();
+ QString componentStr = "import QtQuick 1.1\nImage { function reset() { sourceSize = undefined }\nsource: \"" + src + "\"; sourceSize: Qt.size(100,100) }";
+
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeImage *obj = qobject_cast<QDeclarativeImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->pixmap().width(), 100);
+ QCOMPARE(obj->pixmap().height(), 100);
+ QCOMPARE(obj->sourceSize().height(), 100);
+ QCOMPARE(obj->sourceSize().width(), 100);
+
+ QMetaObject::invokeMethod(obj, "reset");
+ QCOMPARE(obj->pixmap().width(), 200);
+ QCOMPARE(obj->pixmap().height(), 200);
+ QCOMPARE(obj->sourceSize().height(), 200);
+ QCOMPARE(obj->sourceSize().width(), 200);
+}
+
void tst_qdeclarativeimage::testQtQuick11Attributes()
{
QFETCH(QString, code);