diff options
author | Yann Bodson <yann.bodson@nokia.com> | 2010-10-05 05:34:59 (GMT) |
---|---|---|
committer | Yann Bodson <yann.bodson@nokia.com> | 2010-10-05 05:34:59 (GMT) |
commit | 47284ca360c1875663207996740bf6ed6e93d364 (patch) | |
tree | 02496fb98624fc56cd8614067028118f55710ed1 /tests/auto/declarative | |
parent | 4bc735e48020c23aaa99c006ed014214a82c1a68 (diff) | |
download | Qt-47284ca360c1875663207996740bf6ed6e93d364.zip Qt-47284ca360c1875663207996740bf6ed6e93d364.tar.gz Qt-47284ca360c1875663207996740bf6ed6e93d364.tar.bz2 |
Document and test paintedWidth and paintedHeight properties of Image
Task-number: QTBUG-14197
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r-- | tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp index 6fce2ad..8f9b2ea 100644 --- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp +++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp @@ -83,6 +83,7 @@ private slots: void big(); void tiling_QTBUG_6716(); void noLoading(); + void paintedWidthHeight(); private: template<typename T> @@ -395,6 +396,46 @@ void tst_qdeclarativeimage::noLoading() QTRY_COMPARE(statusSpy.count(), 2); } +void tst_qdeclarativeimage::paintedWidthHeight() +{ + { + QString src = QUrl::fromLocalFile(SRCDIR "/data/heart.png").toString(); + QString componentStr = "import QtQuick 1.0\nImage { source: \"" + src + "\"; width: 200; height: 25; fillMode: Image.PreserveAspectFit }"; + + QDeclarativeComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QDeclarativeImage *obj = qobject_cast<QDeclarativeImage*>(component.create()); + QVERIFY(obj != 0); + QCOMPARE(obj->pixmap().width(), 300); + QCOMPARE(obj->pixmap().height(), 300); + QCOMPARE(obj->width(), 200.0); + QCOMPARE(obj->height(), 25.0); + QCOMPARE(obj->paintedWidth(), 25.0); + QCOMPARE(obj->paintedHeight(), 25.0); + QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart.png")); + + delete obj; + } + + { + QString src = QUrl::fromLocalFile(SRCDIR "/data/heart.png").toString(); + QString componentStr = "import QtQuick 1.0\nImage { source: \"" + src + "\"; width: 26; height: 175; fillMode: Image.PreserveAspectFit }"; + QDeclarativeComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QDeclarativeImage *obj = qobject_cast<QDeclarativeImage*>(component.create()); + QVERIFY(obj != 0); + QCOMPARE(obj->pixmap().width(), 300); + QCOMPARE(obj->pixmap().height(), 300); + QCOMPARE(obj->width(), 26.0); + QCOMPARE(obj->height(), 175.0); + QCOMPARE(obj->paintedWidth(), 26.0); + QCOMPARE(obj->paintedHeight(), 26.0); + QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart.png")); + + delete obj; + } +} + /* Find an item with the specified objectName. If index is supplied then the item must also evaluate the {index} expression equal to index |