summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2009-11-19 05:04:28 (GMT)
committerBea Lam <bea.lam@nokia.com>2009-11-19 05:04:28 (GMT)
commit6e31d4b9b98169331196d123ae77e2a938070b3d (patch)
tree3723d6e68edad7a20f12881e6b3739708d5fae7f /tests/auto
parent49660c68e13538dc4427940da384121bbaa79793 (diff)
downloadQt-6e31d4b9b98169331196d123ae77e2a938070b3d.zip
Qt-6e31d4b9b98169331196d123ae77e2a938070b3d.tar.gz
Qt-6e31d4b9b98169331196d123ae77e2a938070b3d.tar.bz2
Set initial frame for remote image sources once they are loaded. Also
add more tests.
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/declarative/animatedimage/animatedimage.pro5
-rw-r--r--tests/auto/declarative/animatedimage/tst_animatedimage.cpp66
2 files changed, 69 insertions, 2 deletions
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"