diff options
Diffstat (limited to 'tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp')
-rw-r--r-- | tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp index 9e090d2..87e3347 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(); @@ -247,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; @@ -693,6 +702,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); |