diff options
author | Yann Bodson <yann.bodson@nokia.com> | 2011-03-10 06:41:57 (GMT) |
---|---|---|
committer | Yann Bodson <yann.bodson@nokia.com> | 2011-03-10 08:00:08 (GMT) |
commit | af33f9f2e7ec433b81f5c18e3e7395db4a56c5fe (patch) | |
tree | ec1442b95f958ac834bfd0c81be6f1883c377929 /tests/auto/declarative/qdeclarativeanimatedimage | |
parent | 5098b3cc1127a1a4cbd66d0eeea8f2ec5f625bb9 (diff) | |
download | Qt-af33f9f2e7ec433b81f5c18e3e7395db4a56c5fe.zip Qt-af33f9f2e7ec433b81f5c18e3e7395db4a56c5fe.tar.gz Qt-af33f9f2e7ec433b81f5c18e3e7395db4a56c5fe.tar.bz2 |
AnimatedImage does not change progress value
This fixes QTBUG-17964 and make AnimatedImage behave like Image.
Task-number: QTBUG-17964
Reviewed-By: Martin Jones
Change-Id: I33996353a3b4ee0edb03741998f3ea893d4d31e5
Diffstat (limited to 'tests/auto/declarative/qdeclarativeanimatedimage')
-rw-r--r-- | tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp b/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp index 104ee15..7d1b807 100644 --- a/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp +++ b/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp @@ -46,6 +46,7 @@ #include <private/qdeclarativeimage_p.h> #include <private/qdeclarativeanimatedimage_p.h> #include <QSignalSpy> +#include <QtDeclarative/qdeclarativecontext.h> #include "../shared/testhttpserver.h" #include "../../../shared/util.h" @@ -76,6 +77,7 @@ private slots: void sourceSizeReadOnly(); void invalidSource(); void qtbug_16520(); + void progressAndStatusChanges(); private: QPixmap grabScene(QGraphicsScene *scene, int width, int height); @@ -333,6 +335,53 @@ void tst_qdeclarativeanimatedimage::qtbug_16520() delete anim; } +void tst_qdeclarativeanimatedimage::progressAndStatusChanges() +{ + TestHTTPServer server(14449); + QVERIFY(server.isValid()); + server.serveDirectory(SRCDIR "/data"); + + QDeclarativeEngine engine; + QString componentStr = "import QtQuick 1.0\nAnimatedImage { source: srcImage }"; + QDeclarativeContext *ctxt = engine.rootContext(); + ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/stickman.gif")); + QDeclarativeComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QDeclarativeImage *obj = qobject_cast<QDeclarativeImage*>(component.create()); + QVERIFY(obj != 0); + QVERIFY(obj->status() == QDeclarativeImage::Ready); + QTRY_VERIFY(obj->progress() == 1.0); + + QSignalSpy sourceSpy(obj, SIGNAL(sourceChanged(const QUrl &))); + QSignalSpy progressSpy(obj, SIGNAL(progressChanged(qreal))); + QSignalSpy statusSpy(obj, SIGNAL(statusChanged(QDeclarativeImageBase::Status))); + + // Loading local file + ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/colors.gif")); + QTRY_VERIFY(obj->status() == QDeclarativeImage::Ready); + QTRY_VERIFY(obj->progress() == 1.0); + QTRY_COMPARE(sourceSpy.count(), 1); + QTRY_COMPARE(progressSpy.count(), 0); + QTRY_COMPARE(statusSpy.count(), 0); + + // Loading remote file + ctxt->setContextProperty("srcImage", "http://127.0.0.1:14449/stickman.gif"); + QTRY_VERIFY(obj->status() == QDeclarativeImage::Loading); + QTRY_VERIFY(obj->progress() == 0.0); + QTRY_VERIFY(obj->status() == QDeclarativeImage::Ready); + QTRY_VERIFY(obj->progress() == 1.0); + QTRY_COMPARE(sourceSpy.count(), 2); + QTRY_VERIFY(progressSpy.count() > 1); + QTRY_COMPARE(statusSpy.count(), 2); + + ctxt->setContextProperty("srcImage", ""); + QTRY_VERIFY(obj->status() == QDeclarativeImage::Null); + QTRY_VERIFY(obj->progress() == 0.0); + QTRY_COMPARE(sourceSpy.count(), 3); + QTRY_VERIFY(progressSpy.count() > 2); + QTRY_COMPARE(statusSpy.count(), 3); +} + QTEST_MAIN(tst_qdeclarativeanimatedimage) #include "tst_qdeclarativeanimatedimage.moc" |