aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTobias Koenig <tobias.koenig@kdab.com>2016-04-27 08:12:12 +0200
committerTobias Koenig <tobias.koenig@kdab.com>2016-05-02 06:49:54 +0000
commitbe031102c226ab9bccc1e73018af25082240bcc3 (patch)
tree1d7a271174527b9dbb48e2bda5d72510f45e0221 /tests
parent1650377af7dfb01a0641d4e21bf1ba33e6a7320f (diff)
AnimatedImage: Fix value of sourceSize property
Cache the source size of the internal QMovie object during the change of the 'source' property to ensure that always a valid source size is returned without emitting more sourceSizeChanged() signals than necessary. Change-Id: I637b80efb133197b7345b09fcf8a7bb80c5643c9 Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp b/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp
index c5bb6132da..5d9b3ceb04 100644
--- a/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp
+++ b/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp
@@ -65,6 +65,7 @@ private slots:
void remote_data();
void sourceSize();
void sourceSizeChanges();
+ void sourceSizeChanges_intermediate();
void sourceSizeReadOnly();
void invalidSource();
void qtbug_16520();
@@ -375,6 +376,28 @@ void tst_qquickanimatedimage::sourceSizeChanges()
delete anim;
}
+void tst_qquickanimatedimage::sourceSizeChanges_intermediate()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\nAnimatedImage { readonly property int testWidth: status === AnimatedImage.Ready ? sourceSize.width : -1; source: srcImage }", QUrl::fromLocalFile(""));
+ QTRY_VERIFY(component.isReady());
+ QQmlContext *ctxt = engine.rootContext();
+ ctxt->setContextProperty("srcImage", "");
+
+ QScopedPointer<QQuickAnimatedImage> anim(qobject_cast<QQuickAnimatedImage*>(component.create()));
+ QVERIFY(anim != 0);
+
+ ctxt->setContextProperty("srcImage", testFileUrl("hearts.gif"));
+ QTRY_COMPARE(anim->status(), QQuickAnimatedImage::Ready);
+ QTRY_COMPARE(anim->property("testWidth").toInt(), anim->sourceSize().width());
+
+ ctxt->setContextProperty("srcImage", testFileUrl("hearts_copy.gif"));
+ QTRY_COMPARE(anim->status(), QQuickAnimatedImage::Ready);
+ QTRY_COMPARE(anim->property("testWidth").toInt(), anim->sourceSize().width());
+}
+
+
void tst_qquickanimatedimage::qtbug_16520()
{
TestHTTPServer server;