author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Wed, 21 Apr 2010 12:15:23 +0300 | |
branch | RCL_3 |
changeset 12 | cc75c76972ee |
parent 4 | 3b1da2848fc7 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the test suite of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
||
43 |
#include <QtTest/QtTest> |
|
44 |
||
45 |
||
46 |
#include <QIODevice> |
|
47 |
#include <QLabel> |
|
48 |
#include <QMovie> |
|
49 |
||
50 |
//TESTED_FILES= |
|
51 |
||
52 |
class tst_QMovie : public QObject |
|
53 |
{ |
|
54 |
Q_OBJECT |
|
55 |
||
56 |
public: |
|
57 |
tst_QMovie(); |
|
58 |
virtual ~tst_QMovie(); |
|
59 |
||
60 |
public slots: |
|
61 |
void init(); |
|
62 |
void cleanup(); |
|
63 |
||
64 |
protected slots: |
|
65 |
void exitLoopSlot(); |
|
66 |
||
67 |
private slots: |
|
68 |
void getSetCheck(); |
|
69 |
void construction(); |
|
70 |
void playMovie_data(); |
|
71 |
void playMovie(); |
|
72 |
void jumpToFrame_data(); |
|
73 |
void jumpToFrame(); |
|
74 |
void changeMovieFile(); |
|
75 |
}; |
|
76 |
||
77 |
// Testing get/set functions |
|
78 |
void tst_QMovie::getSetCheck() |
|
79 |
{ |
|
80 |
QMovie obj1; |
|
81 |
// QIODevice * QMovie::device() |
|
82 |
// void QMovie::setDevice(QIODevice *) |
|
83 |
QFile *var1 = new QFile; |
|
84 |
obj1.setDevice(var1); |
|
85 |
QCOMPARE(obj1.device(), (QIODevice *)var1); |
|
86 |
obj1.setDevice((QIODevice *)0); |
|
87 |
QCOMPARE(obj1.device(), (QIODevice *)0); |
|
88 |
delete var1; |
|
89 |
||
90 |
// CacheMode QMovie::cacheMode() |
|
91 |
// void QMovie::setCacheMode(CacheMode) |
|
92 |
obj1.setCacheMode(QMovie::CacheMode(QMovie::CacheNone)); |
|
93 |
QCOMPARE(QMovie::CacheMode(QMovie::CacheNone), obj1.cacheMode()); |
|
94 |
obj1.setCacheMode(QMovie::CacheMode(QMovie::CacheAll)); |
|
95 |
QCOMPARE(QMovie::CacheMode(QMovie::CacheAll), obj1.cacheMode()); |
|
96 |
||
97 |
// int QMovie::speed() |
|
98 |
// void QMovie::setSpeed(int) |
|
99 |
obj1.setSpeed(0); |
|
100 |
QCOMPARE(0, obj1.speed()); |
|
101 |
obj1.setSpeed(INT_MIN); |
|
102 |
QCOMPARE(INT_MIN, obj1.speed()); |
|
103 |
obj1.setSpeed(INT_MAX); |
|
104 |
QCOMPARE(INT_MAX, obj1.speed()); |
|
105 |
} |
|
106 |
||
107 |
tst_QMovie::tst_QMovie() |
|
108 |
{ |
|
109 |
} |
|
110 |
||
111 |
tst_QMovie::~tst_QMovie() |
|
112 |
{ |
|
113 |
||
114 |
} |
|
115 |
||
116 |
void tst_QMovie::init() |
|
117 |
{ |
|
118 |
} |
|
119 |
||
120 |
void tst_QMovie::cleanup() |
|
121 |
{ |
|
122 |
} |
|
123 |
||
124 |
void tst_QMovie::exitLoopSlot() |
|
125 |
{ |
|
126 |
QTestEventLoop::instance().exitLoop(); |
|
127 |
} |
|
128 |
||
129 |
void tst_QMovie::construction() |
|
130 |
{ |
|
131 |
QMovie movie; |
|
132 |
QCOMPARE(movie.device(), (QIODevice *)0); |
|
133 |
QCOMPARE(movie.fileName(), QString()); |
|
134 |
QCOMPARE(movie.state(), QMovie::NotRunning); |
|
135 |
} |
|
136 |
||
137 |
void tst_QMovie::playMovie_data() |
|
138 |
{ |
|
139 |
QTest::addColumn<QString>("fileName"); |
|
140 |
QTest::addColumn<int>("frameCount"); |
|
141 |
#if defined(QTEST_HAVE_MNG) && !defined(Q_OS_WINCE) |
|
142 |
// Qt/WinCE runs out of memory for this one... |
|
143 |
QTest::newRow("home") << QString("animations/dutch.mng") << 10; |
|
144 |
#endif |
|
145 |
#ifdef QTEST_HAVE_GIF |
|
146 |
QTest::newRow("comicsecard") << QString("animations/comicsecard.gif") << 5; |
|
147 |
QTest::newRow("trolltech") << QString("animations/trolltech.gif") << 34; |
|
148 |
#endif |
|
149 |
} |
|
150 |
||
151 |
void tst_QMovie::playMovie() |
|
152 |
{ |
|
153 |
QFETCH(QString, fileName); |
|
154 |
QFETCH(int, frameCount); |
|
155 |
||
156 |
QMovie movie(fileName); |
|
157 |
||
158 |
QCOMPARE(movie.state(), QMovie::NotRunning); |
|
159 |
movie.setSpeed(1000); |
|
160 |
movie.start(); |
|
161 |
QCOMPARE(movie.state(), QMovie::Running); |
|
162 |
movie.setPaused(true); |
|
163 |
QCOMPARE(movie.state(), QMovie::Paused); |
|
164 |
movie.start(); |
|
165 |
QCOMPARE(movie.state(), QMovie::Running); |
|
166 |
movie.stop(); |
|
167 |
QCOMPARE(movie.state(), QMovie::NotRunning); |
|
168 |
movie.jumpToFrame(0); |
|
169 |
QCOMPARE(movie.state(), QMovie::NotRunning); |
|
170 |
movie.start(); |
|
171 |
QCOMPARE(movie.state(), QMovie::Running); |
|
172 |
||
173 |
connect(&movie, SIGNAL(finished()), this, SLOT(exitLoopSlot())); |
|
174 |
||
175 |
QLabel label; |
|
176 |
label.setMovie(&movie); |
|
177 |
label.show(); |
|
178 |
||
179 |
QTestEventLoop::instance().enterLoop(20); |
|
180 |
QVERIFY2(!QTestEventLoop::instance().timeout(), |
|
181 |
"Timed out while waiting for finished() signal"); |
|
182 |
||
183 |
QCOMPARE(movie.state(), QMovie::NotRunning); |
|
184 |
QCOMPARE(movie.frameCount(), frameCount); |
|
185 |
} |
|
186 |
||
187 |
void tst_QMovie::jumpToFrame_data() |
|
188 |
{ |
|
189 |
playMovie_data(); |
|
190 |
} |
|
191 |
||
192 |
void tst_QMovie::jumpToFrame() |
|
193 |
{ |
|
194 |
QFETCH(QString, fileName); |
|
195 |
QMovie movie(fileName); |
|
196 |
movie.start(); |
|
197 |
movie.stop(); |
|
198 |
QVERIFY(movie.jumpToFrame(-1) == false); |
|
199 |
QVERIFY(movie.currentFrameNumber() == 0); |
|
200 |
} |
|
201 |
||
202 |
void tst_QMovie::changeMovieFile() |
|
203 |
{ |
|
204 |
QMovie movie("animations/comicsecard.gif"); |
|
205 |
movie.start(); |
|
206 |
movie.stop(); |
|
207 |
movie.setFileName("animations/trolltech.gif"); |
|
208 |
QVERIFY(movie.currentFrameNumber() == -1); |
|
209 |
} |
|
210 |
||
211 |
QTEST_MAIN(tst_QMovie) |
|
212 |
#include "tst_qmovie.moc" |