summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/animatedimage/tst_animatedimage.cpp
blob: bedf97c88a848064628c494d8130caea1dc2194e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <qtest.h>
#include <QtDeclarative/qmlengine.h>
#include <QtDeclarative/qmlcomponent.h>
#include <QtDeclarative/qmlview.h>
#include <private/qmlgraphicsrect_p.h>
#include <private/qmlgraphicsimage_p.h>
#include "qmlgraphicsanimatedimageitem_p.h"

class tst_animatedimage : public QObject
{
    Q_OBJECT
public:
    tst_animatedimage() {}

private slots:
    void play();
    void pause();
    void setFrame();
    void frameCount();
};

void tst_animatedimage::play()
{
    QmlGraphicsAnimatedImageItem anim;
    anim.setSource(QUrl("file://" SRCDIR "/data/stickman.gif"));
    QVERIFY(anim.isPlaying());
}

void tst_animatedimage::pause()
{
    QmlGraphicsAnimatedImageItem anim;
    anim.setSource(QUrl("file://" SRCDIR "/data/stickman.gif"));
    anim.setPaused(true);
    QVERIFY(!anim.isPlaying());
}

void tst_animatedimage::setFrame()
{
    QmlGraphicsAnimatedImageItem anim;
    anim.setSource(QUrl("file://" SRCDIR "/data/stickman.gif"));
    anim.setPaused(true);
    QVERIFY(!anim.isPlaying());
    anim.setCurrentFrame(2);
    QCOMPARE(anim.currentFrame(), 2);
}

void tst_animatedimage::frameCount()
{
    QmlGraphicsAnimatedImageItem anim;
    anim.setSource(QUrl("file://" SRCDIR "/data/stickman.gif"));
    QCOMPARE(anim.frameCount(), 299);
}

QTEST_MAIN(tst_animatedimage)

#include "tst_animatedimage.moc"