diff options
author | Martin Jones <martin.jones@nokia.com> | 2011-03-17 07:10:56 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2011-03-17 07:17:43 (GMT) |
commit | 695a39410c8ce186a2ce78cef51093c55fc32643 (patch) | |
tree | b33d7c5f1f0e24b1180fcbdb989a47e38f825868 /tests | |
parent | cb0b93e3ef107b8a47445c926753b6bcf07b796d (diff) | |
download | Qt-695a39410c8ce186a2ce78cef51093c55fc32643.zip Qt-695a39410c8ce186a2ce78cef51093c55fc32643.tar.gz Qt-695a39410c8ce186a2ce78cef51093c55fc32643.tar.bz2 |
Image.PreserveAspectFit has unexpected effect on Image's sourceSize
The sourceSize should always be the size of the image, unless set
otherwise. When calculating the size of an image with
Image.PreserveAspectFit set the natural image size should be used
for the calculation if no size has been set explicitly.
Change-Id: I104b7d1c3c16aa5b4fc98b1f9078ed8ae997cf69
Task-number: QTBUG-16389
Reviewed-by: Joona Petrell
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/qdeclarativeimage/data/qtbug_16389.qml | 30 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp | 24 |
2 files changed, 54 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeimage/data/qtbug_16389.qml b/tests/auto/declarative/qdeclarativeimage/data/qtbug_16389.qml new file mode 100644 index 0000000..29fba40 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimage/data/qtbug_16389.qml @@ -0,0 +1,30 @@ +import QtQuick 1.0 +Rectangle { + width: 400 + height: 400 + + Item { + anchors.top: parent.top + anchors.left: parent.left + anchors.bottom: blueHandle.top + anchors.right: blueHandle.left + + Image { + id: iconImage + objectName: "iconImage" + anchors.top: parent.top + anchors.bottom: parent.bottom + source: "heart200.png" + fillMode: Image.PreserveAspectFit + smooth: true + } + } + + Rectangle { + id: blueHandle + objectName: "blueHandle" + color: "blue" + width: 25 + height: 25 + } +} diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp index f1fe2bd..9e090d2 100644 --- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp +++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp @@ -89,6 +89,7 @@ private slots: void noLoading(); void paintedWidthHeight(); void sourceSize_QTBUG_14303(); + void sourceSize_QTBUG_16389(); void nullPixmapPaint(); void testQtQuick11Attributes(); void testQtQuick11Attributes_data(); @@ -640,6 +641,29 @@ void tst_qdeclarativeimage::sourceSize_QTBUG_14303() QTRY_COMPARE(sourceSizeSpy.count(), 2); } +void tst_qdeclarativeimage::sourceSize_QTBUG_16389() +{ + QDeclarativeView *canvas = new QDeclarativeView(0); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/qtbug_16389.qml")); + canvas->show(); + qApp->processEvents(); + + QDeclarativeImage *image = findItem<QDeclarativeImage>(canvas->rootObject(), "iconImage"); + QDeclarativeItem *handle = findItem<QDeclarativeItem>(canvas->rootObject(), "blueHandle"); + + QCOMPARE(image->sourceSize().width(), 200); + QCOMPARE(image->sourceSize().height(), 200); + QCOMPARE(image->paintedWidth(), 0.0); + QCOMPARE(image->paintedHeight(), 0.0); + + handle->setY(20); + + QCOMPARE(image->sourceSize().width(), 200); + QCOMPARE(image->sourceSize().height(), 200); + QCOMPARE(image->paintedWidth(), 20.0); + QCOMPARE(image->paintedHeight(), 20.0); +} + static int numberOfWarnings = 0; static void checkWarnings(QtMsgType, const char *) { |