summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2011-04-06 05:46:35 (GMT)
committerMartin Jones <martin.jones@nokia.com>2011-04-07 03:47:36 (GMT)
commit051a76c1d65d698f71dc75c89f91ae9021357eae (patch)
tree3a5120fc40ef877014deba478bdf5ad67c0acaf8 /tests
parent5f741649cff218367100f3a9d7cdf9e0d393e327 (diff)
downloadQt-051a76c1d65d698f71dc75c89f91ae9021357eae.zip
Qt-051a76c1d65d698f71dc75c89f91ae9021357eae.tar.gz
Qt-051a76c1d65d698f71dc75c89f91ae9021357eae.tar.bz2
Image w/ PreserveAspectFit has its width changed once more than needed.
Avoid an extra setImplicitWidth/setImplicitHeight on image load. Change-Id: I8bec1c97244068000c7a7f5fb3e937f80f3b36f5 Task-number: QTBUG-18573 Reviewed-by: Michael Brasser
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qdeclarativeimage/data/aspectratio.qml4
-rw-r--r--tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp10
2 files changed, 13 insertions, 1 deletions
diff --git a/tests/auto/declarative/qdeclarativeimage/data/aspectratio.qml b/tests/auto/declarative/qdeclarativeimage/data/aspectratio.qml
index 739299d..cd092bc 100644
--- a/tests/auto/declarative/qdeclarativeimage/data/aspectratio.qml
+++ b/tests/auto/declarative/qdeclarativeimage/data/aspectratio.qml
@@ -1,6 +1,10 @@
import QtQuick 1.0
Image {
+ property int widthChange: 0
+ property int heightChange: 0
source: "heart.png"
fillMode: Image.PreserveAspectFit;
+ onWidthChanged: widthChange += 1
+ onHeightChanged: heightChange += 1
}
diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
index c5a3d14..87e3347 100644
--- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
+++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
@@ -248,14 +248,22 @@ void tst_qdeclarativeimage::preserveAspectRatio()
canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/aspectratio.qml"));
QDeclarativeImage *image = qobject_cast<QDeclarativeImage*>(canvas->rootObject());
QVERIFY(image != 0);
+ QCOMPARE(image->property("widthChange").toInt(), 1);
+ QCOMPARE(image->property("heightChange").toInt(), 1);
image->setWidth(80.0);
+ QCOMPARE(image->property("widthChange").toInt(), 2);
+ QCOMPARE(image->property("heightChange").toInt(), 2);
QCOMPARE(image->width(), 80.);
QCOMPARE(image->height(), 80.);
canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/aspectratio.qml"));
image = qobject_cast<QDeclarativeImage*>(canvas->rootObject());
- image->setHeight(60.0);
QVERIFY(image != 0);
+ QCOMPARE(image->property("widthChange").toInt(), 1);
+ QCOMPARE(image->property("heightChange").toInt(), 1);
+ image->setHeight(60.0);
+ QCOMPARE(image->property("widthChange").toInt(), 2);
+ QCOMPARE(image->property("heightChange").toInt(), 2);
QCOMPARE(image->height(), 60.);
QCOMPARE(image->width(), 60.);
delete canvas;