summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsanimatedimage.cpp10
-rw-r--r--tests/auto/declarative/animatedimage/animatedimage.pro5
-rw-r--r--tests/auto/declarative/animatedimage/tst_animatedimage.cpp66
3 files changed, 75 insertions, 6 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicsanimatedimage.cpp b/src/declarative/graphicsitems/qmlgraphicsanimatedimage.cpp
index 97fdc6a..f389295 100644
--- a/src/declarative/graphicsitems/qmlgraphicsanimatedimage.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsanimatedimage.cpp
@@ -209,7 +209,7 @@ void QmlGraphicsAnimatedImage::setSource(const QUrl &url)
//### should be unified with movieRequestFinished
d->_movie = new QMovie(lf);
if (!d->_movie->isValid()){
- qWarning() << "Error Reading Animated Image File " << d->url;
+ qWarning() << "Error Reading Animated Image File" << d->url;
delete d->_movie;
d->_movie = 0;
return;
@@ -261,7 +261,7 @@ void QmlGraphicsAnimatedImage::movieRequestFinished()
d->_movie->setCacheMode(QMovie::CacheAll);
if(d->playing)
d->_movie->start();
- else {
+ if (d->paused || !d->playing) {
d->_movie->jumpToFrame(d->preset_currentframe);
d->preset_currentframe = 0;
}
@@ -293,8 +293,10 @@ void QmlGraphicsAnimatedImage::playingStatusChanged()
void QmlGraphicsAnimatedImage::componentComplete()
{
Q_D(QmlGraphicsAnimatedImage);
- setCurrentFrame(d->preset_currentframe);
- d->preset_currentframe = 0;
+ if (!d->reply) {
+ setCurrentFrame(d->preset_currentframe);
+ d->preset_currentframe = 0;
+ }
}
QT_END_NAMESPACE
diff --git a/tests/auto/declarative/animatedimage/animatedimage.pro b/tests/auto/declarative/animatedimage/animatedimage.pro
index 4ff9db4..5a8ec6c 100644
--- a/tests/auto/declarative/animatedimage/animatedimage.pro
+++ b/tests/auto/declarative/animatedimage/animatedimage.pro
@@ -1,6 +1,7 @@
load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-SOURCES += tst_animatedimage.cpp
+contains(QT_CONFIG,declarative): QT += declarative network
+HEADERS += ../shared/testhttpserver.h
+SOURCES += tst_animatedimage.cpp ../shared/testhttpserver.cpp
macx:CONFIG -= app_bundle
DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/animatedimage/tst_animatedimage.cpp b/tests/auto/declarative/animatedimage/tst_animatedimage.cpp
index 484fd1a..5ba0068 100644
--- a/tests/auto/declarative/animatedimage/tst_animatedimage.cpp
+++ b/tests/auto/declarative/animatedimage/tst_animatedimage.cpp
@@ -46,6 +46,18 @@
#include <private/qmlgraphicsimage_p.h>
#include <private/qmlgraphicsanimatedimage_p.h>
+#include "../shared/testhttpserver.h"
+
+#define TRY_WAIT(expr) \
+ do { \
+ for (int ii = 0; ii < 6; ++ii) { \
+ if ((expr)) break; \
+ QTest::qWait(50); \
+ } \
+ QVERIFY((expr)); \
+ } while (false)
+
+
class tst_animatedimage : public QObject
{
Q_OBJECT
@@ -58,6 +70,9 @@ private slots:
void stopped();
void setFrame();
void frameCount();
+ void remote();
+ void remote_data();
+ void invalidSource();
};
void tst_animatedimage::play()
@@ -121,6 +136,57 @@ void tst_animatedimage::frameCount()
delete anim;
}
+void tst_animatedimage::remote()
+{
+ QFETCH(QString, fileName);
+ QFETCH(bool, paused);
+
+ TestHTTPServer server(14445);
+ QVERIFY(server.isValid());
+ server.serveDirectory(SRCDIR "/data");
+
+ QmlEngine engine;
+ QmlComponent component(&engine, QUrl("http://127.0.0.1:14445/" + fileName));
+ TRY_WAIT(component.isReady());
+
+ QmlGraphicsAnimatedImage *anim = qobject_cast<QmlGraphicsAnimatedImage *>(component.create());
+ QVERIFY(anim);
+
+ TRY_WAIT(anim->isPlaying());
+ if (paused) {
+ TRY_WAIT(anim->isPaused());
+ QCOMPARE(anim->currentFrame(), 2);
+ }
+
+ delete anim;
+}
+
+void tst_animatedimage::remote_data()
+{
+ QTest::addColumn<QString>("fileName");
+ QTest::addColumn<bool>("paused");
+
+ QTest::newRow("playing") << "stickman.qml" << false;
+ QTest::newRow("paused") << "stickmanpause.qml" << true;
+}
+
+void tst_animatedimage::invalidSource()
+{
+ QmlEngine engine;
+ QmlComponent component(&engine, "import Qt 4.6\n AnimatedImage { source: \"no-such-file.gif\" }", QUrl("file://"));
+ QVERIFY(component.isReady());
+
+ QTest::ignoreMessage(QtWarningMsg, "Error Reading Animated Image File QUrl( \"file:no-such-file.gif\" ) ");
+
+ QmlGraphicsAnimatedImage *anim = qobject_cast<QmlGraphicsAnimatedImage *>(component.create());
+ QVERIFY(anim);
+
+ QVERIFY(!anim->isPlaying());
+ QVERIFY(!anim->isPaused());
+ QCOMPARE(anim->currentFrame(), 0);
+ QCOMPARE(anim->frameCount(), 0);
+}
+
QTEST_MAIN(tst_animatedimage)
#include "tst_animatedimage.moc"