author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Thu, 22 Apr 2010 16:15:11 +0300 | |
branch | RCL_3 |
changeset 14 | 8c4229025c0b |
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:
3
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 |
#include <QtTest/QtTest> |
|
43 |
||
44 |
#include <QtCore/qpauseanimation.h> |
|
45 |
#include <QtCore/qpropertyanimation.h> |
|
46 |
#include <QtCore/qsequentialanimationgroup.h> |
|
47 |
||
48 |
#include <private/qabstractanimation_p.h> |
|
49 |
||
50 |
//TESTED_CLASS=QPauseAnimation |
|
51 |
//TESTED_FILES= |
|
52 |
||
53 |
class TestablePauseAnimation : public QPauseAnimation |
|
54 |
{ |
|
55 |
Q_OBJECT |
|
56 |
public: |
|
57 |
TestablePauseAnimation(QObject *parent = 0) |
|
58 |
: QPauseAnimation(parent), |
|
59 |
m_updateCurrentTimeCount(0) |
|
60 |
{ |
|
61 |
} |
|
62 |
||
63 |
int m_updateCurrentTimeCount; |
|
64 |
protected: |
|
65 |
void updateCurrentTime(int currentTime) |
|
66 |
{ |
|
67 |
//qDebug() << this << "update current time: " << currentTime; |
|
68 |
QPauseAnimation::updateCurrentTime(currentTime); |
|
69 |
++m_updateCurrentTimeCount; |
|
70 |
} |
|
71 |
}; |
|
72 |
||
73 |
class EnableConsistentTiming |
|
74 |
{ |
|
75 |
public: |
|
76 |
EnableConsistentTiming() |
|
77 |
{ |
|
78 |
QUnifiedTimer *timer = QUnifiedTimer::instance(); |
|
79 |
timer->setConsistentTiming(true); |
|
80 |
} |
|
81 |
~EnableConsistentTiming() |
|
82 |
{ |
|
83 |
QUnifiedTimer *timer = QUnifiedTimer::instance(); |
|
84 |
timer->setConsistentTiming(false); |
|
85 |
} |
|
86 |
}; |
|
87 |
||
88 |
class tst_QPauseAnimation : public QObject |
|
89 |
{ |
|
90 |
Q_OBJECT |
|
91 |
public: |
|
92 |
tst_QPauseAnimation(); |
|
93 |
virtual ~tst_QPauseAnimation(); |
|
94 |
||
95 |
public Q_SLOTS: |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
96 |
void initTestCase(); |
0 | 97 |
|
98 |
private slots: |
|
99 |
void changeDirectionWhileRunning(); |
|
100 |
void noTimerUpdates_data(); |
|
101 |
void noTimerUpdates(); |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
102 |
void multiplePauseAnimations(); |
0 | 103 |
void pauseAndPropertyAnimations(); |
104 |
void pauseResume(); |
|
105 |
void sequentialPauseGroup(); |
|
106 |
void sequentialGroupWithPause(); |
|
107 |
void multipleSequentialGroups(); |
|
108 |
void zeroDuration(); |
|
109 |
}; |
|
110 |
||
111 |
tst_QPauseAnimation::tst_QPauseAnimation() |
|
112 |
{ |
|
113 |
} |
|
114 |
||
115 |
tst_QPauseAnimation::~tst_QPauseAnimation() |
|
116 |
{ |
|
117 |
} |
|
118 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
119 |
void tst_QPauseAnimation::initTestCase() |
0 | 120 |
{ |
121 |
qRegisterMetaType<QAbstractAnimation::State>("QAbstractAnimation::State"); |
|
122 |
qRegisterMetaType<QAbstractAnimation::DeletionPolicy>("QAbstractAnimation::DeletionPolicy"); |
|
123 |
} |
|
124 |
||
125 |
void tst_QPauseAnimation::changeDirectionWhileRunning() |
|
126 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
127 |
EnableConsistentTiming enabled; |
0 | 128 |
|
129 |
TestablePauseAnimation animation; |
|
130 |
animation.setDuration(400); |
|
131 |
animation.start(); |
|
132 |
QTest::qWait(100); |
|
133 |
QVERIFY(animation.state() == QAbstractAnimation::Running); |
|
134 |
animation.setDirection(QAbstractAnimation::Backward); |
|
135 |
QTest::qWait(animation.totalDuration() + 50); |
|
136 |
QVERIFY(animation.state() == QAbstractAnimation::Stopped); |
|
137 |
} |
|
138 |
||
139 |
void tst_QPauseAnimation::noTimerUpdates_data() |
|
140 |
{ |
|
141 |
QTest::addColumn<int>("duration"); |
|
142 |
QTest::addColumn<int>("loopCount"); |
|
143 |
||
144 |
QTest::newRow("0") << 200 << 1; |
|
145 |
QTest::newRow("1") << 160 << 1; |
|
146 |
QTest::newRow("2") << 160 << 2; |
|
147 |
QTest::newRow("3") << 200 << 3; |
|
148 |
} |
|
149 |
||
150 |
void tst_QPauseAnimation::noTimerUpdates() |
|
151 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
152 |
EnableConsistentTiming enabled; |
0 | 153 |
|
154 |
QFETCH(int, duration); |
|
155 |
QFETCH(int, loopCount); |
|
156 |
||
157 |
TestablePauseAnimation animation; |
|
158 |
animation.setDuration(duration); |
|
159 |
animation.setLoopCount(loopCount); |
|
160 |
animation.start(); |
|
161 |
QTest::qWait(animation.totalDuration() + 100); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
162 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
163 |
#ifdef Q_OS_WIN |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
164 |
if (animation.state() != QAbstractAnimation::Stopped) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
165 |
QEXPECT_FAIL("", "On windows, consistent timing is not working properly due to bad timer resolution", Abort); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
166 |
#endif |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
167 |
|
0 | 168 |
QVERIFY(animation.state() == QAbstractAnimation::Stopped); |
169 |
QCOMPARE(animation.m_updateCurrentTimeCount, 1 + loopCount); |
|
170 |
} |
|
171 |
||
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
172 |
void tst_QPauseAnimation::multiplePauseAnimations() |
0 | 173 |
{ |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
174 |
EnableConsistentTiming enabled; |
0 | 175 |
|
176 |
TestablePauseAnimation animation; |
|
177 |
animation.setDuration(200); |
|
178 |
||
179 |
TestablePauseAnimation animation2; |
|
180 |
animation2.setDuration(800); |
|
181 |
||
182 |
animation.start(); |
|
183 |
animation2.start(); |
|
184 |
QTest::qWait(animation.totalDuration() + 100); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
185 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
186 |
#ifdef Q_OS_WIN |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
187 |
if (animation.state() != QAbstractAnimation::Stopped) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
188 |
QEXPECT_FAIL("", "On windows, consistent timing is not working properly due to bad timer resolution", Abort); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
189 |
#endif |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
190 |
|
0 | 191 |
QVERIFY(animation.state() == QAbstractAnimation::Stopped); |
192 |
QVERIFY(animation2.state() == QAbstractAnimation::Running); |
|
193 |
QCOMPARE(animation.m_updateCurrentTimeCount, 2); |
|
194 |
QCOMPARE(animation2.m_updateCurrentTimeCount, 2); |
|
195 |
||
196 |
QTest::qWait(550); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
197 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
198 |
#ifdef Q_OS_WIN |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
199 |
if (animation2.state() != QAbstractAnimation::Stopped) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
200 |
QEXPECT_FAIL("", "On windows, consistent timing is not working properly due to bad timer resolution", Abort); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
201 |
#endif |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
202 |
|
0 | 203 |
QVERIFY(animation2.state() == QAbstractAnimation::Stopped); |
204 |
QCOMPARE(animation2.m_updateCurrentTimeCount, 3); |
|
205 |
} |
|
206 |
||
207 |
void tst_QPauseAnimation::pauseAndPropertyAnimations() |
|
208 |
{ |
|
209 |
EnableConsistentTiming enabled; |
|
210 |
||
211 |
TestablePauseAnimation pause; |
|
212 |
pause.setDuration(200); |
|
213 |
||
214 |
QObject o; |
|
215 |
o.setProperty("ole", 42); |
|
216 |
||
217 |
QPropertyAnimation animation(&o, "ole"); |
|
218 |
animation.setEndValue(43); |
|
219 |
||
220 |
pause.start(); |
|
221 |
||
222 |
QTest::qWait(100); |
|
223 |
animation.start(); |
|
224 |
||
225 |
QVERIFY(animation.state() == QAbstractAnimation::Running); |
|
226 |
QVERIFY(pause.state() == QAbstractAnimation::Running); |
|
227 |
QCOMPARE(pause.m_updateCurrentTimeCount, 2); |
|
228 |
||
229 |
QTest::qWait(animation.totalDuration() + 100); |
|
230 |
||
231 |
#ifdef Q_OS_WIN |
|
232 |
if (animation.state() != QAbstractAnimation::Stopped) |
|
233 |
QEXPECT_FAIL("", "On windows, consistent timing is not working properly due to bad timer resolution", Abort); |
|
234 |
#endif |
|
235 |
QVERIFY(animation.state() == QAbstractAnimation::Stopped); |
|
236 |
QVERIFY(pause.state() == QAbstractAnimation::Stopped); |
|
237 |
QVERIFY(pause.m_updateCurrentTimeCount > 3); |
|
238 |
} |
|
239 |
||
240 |
void tst_QPauseAnimation::pauseResume() |
|
241 |
{ |
|
242 |
TestablePauseAnimation animation; |
|
243 |
animation.setDuration(400); |
|
244 |
animation.start(); |
|
245 |
QVERIFY(animation.state() == QAbstractAnimation::Running); |
|
246 |
QTest::qWait(200); |
|
247 |
animation.pause(); |
|
248 |
QVERIFY(animation.state() == QAbstractAnimation::Paused); |
|
249 |
animation.start(); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
250 |
QTest::qWait(300); |
0 | 251 |
QVERIFY(animation.state() == QAbstractAnimation::Stopped); |
252 |
QCOMPARE(animation.m_updateCurrentTimeCount, 3); |
|
253 |
} |
|
254 |
||
255 |
void tst_QPauseAnimation::sequentialPauseGroup() |
|
256 |
{ |
|
257 |
QSequentialAnimationGroup group; |
|
258 |
||
259 |
TestablePauseAnimation animation1(&group); |
|
260 |
animation1.setDuration(200); |
|
261 |
TestablePauseAnimation animation2(&group); |
|
262 |
animation2.setDuration(200); |
|
263 |
TestablePauseAnimation animation3(&group); |
|
264 |
animation3.setDuration(200); |
|
265 |
||
266 |
group.start(); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
267 |
QCOMPARE(animation1.m_updateCurrentTimeCount, 1); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
268 |
QCOMPARE(animation2.m_updateCurrentTimeCount, 0); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
269 |
QCOMPARE(animation3.m_updateCurrentTimeCount, 0); |
0 | 270 |
|
271 |
QVERIFY(group.state() == QAbstractAnimation::Running); |
|
272 |
QVERIFY(animation1.state() == QAbstractAnimation::Running); |
|
273 |
QVERIFY(animation2.state() == QAbstractAnimation::Stopped); |
|
274 |
QVERIFY(animation3.state() == QAbstractAnimation::Stopped); |
|
275 |
||
276 |
group.setCurrentTime(250); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
277 |
QCOMPARE(animation1.m_updateCurrentTimeCount, 2); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
278 |
QCOMPARE(animation2.m_updateCurrentTimeCount, 1); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
279 |
QCOMPARE(animation3.m_updateCurrentTimeCount, 0); |
0 | 280 |
|
281 |
QVERIFY(group.state() == QAbstractAnimation::Running); |
|
282 |
QVERIFY(animation1.state() == QAbstractAnimation::Stopped); |
|
283 |
QCOMPARE(&animation2, group.currentAnimation()); |
|
284 |
QVERIFY(animation2.state() == QAbstractAnimation::Running); |
|
285 |
QVERIFY(animation3.state() == QAbstractAnimation::Stopped); |
|
286 |
||
287 |
group.setCurrentTime(500); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
288 |
QCOMPARE(animation1.m_updateCurrentTimeCount, 2); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
289 |
QCOMPARE(animation2.m_updateCurrentTimeCount, 2); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
290 |
QCOMPARE(animation3.m_updateCurrentTimeCount, 1); |
0 | 291 |
|
292 |
QVERIFY(group.state() == QAbstractAnimation::Running); |
|
293 |
QVERIFY(animation1.state() == QAbstractAnimation::Stopped); |
|
294 |
QVERIFY(animation2.state() == QAbstractAnimation::Stopped); |
|
295 |
QCOMPARE(&animation3, group.currentAnimation()); |
|
296 |
QVERIFY(animation3.state() == QAbstractAnimation::Running); |
|
297 |
||
298 |
group.setCurrentTime(750); |
|
299 |
||
300 |
QVERIFY(group.state() == QAbstractAnimation::Stopped); |
|
301 |
QVERIFY(animation1.state() == QAbstractAnimation::Stopped); |
|
302 |
QVERIFY(animation2.state() == QAbstractAnimation::Stopped); |
|
303 |
QVERIFY(animation3.state() == QAbstractAnimation::Stopped); |
|
304 |
||
305 |
QCOMPARE(animation1.m_updateCurrentTimeCount, 2); |
|
306 |
QCOMPARE(animation2.m_updateCurrentTimeCount, 2); |
|
307 |
QCOMPARE(animation3.m_updateCurrentTimeCount, 2); |
|
308 |
} |
|
309 |
||
310 |
void tst_QPauseAnimation::sequentialGroupWithPause() |
|
311 |
{ |
|
312 |
QSequentialAnimationGroup group; |
|
313 |
||
314 |
QObject o; |
|
315 |
o.setProperty("ole", 42); |
|
316 |
||
317 |
QPropertyAnimation animation(&o, "ole", &group); |
|
318 |
animation.setEndValue(43); |
|
319 |
TestablePauseAnimation pause(&group); |
|
320 |
pause.setDuration(250); |
|
321 |
||
322 |
group.start(); |
|
323 |
||
324 |
QVERIFY(group.state() == QAbstractAnimation::Running); |
|
325 |
QVERIFY(animation.state() == QAbstractAnimation::Running); |
|
326 |
QVERIFY(pause.state() == QAbstractAnimation::Stopped); |
|
327 |
||
328 |
group.setCurrentTime(300); |
|
329 |
||
330 |
QVERIFY(group.state() == QAbstractAnimation::Running); |
|
331 |
QVERIFY(animation.state() == QAbstractAnimation::Stopped); |
|
332 |
QCOMPARE(&pause, group.currentAnimation()); |
|
333 |
QVERIFY(pause.state() == QAbstractAnimation::Running); |
|
334 |
||
335 |
group.setCurrentTime(600); |
|
336 |
||
337 |
QVERIFY(group.state() == QAbstractAnimation::Stopped); |
|
338 |
QVERIFY(animation.state() == QAbstractAnimation::Stopped); |
|
339 |
QVERIFY(pause.state() == QAbstractAnimation::Stopped); |
|
340 |
||
341 |
QCOMPARE(pause.m_updateCurrentTimeCount, 2); |
|
342 |
} |
|
343 |
||
344 |
void tst_QPauseAnimation::multipleSequentialGroups() |
|
345 |
{ |
|
346 |
EnableConsistentTiming enabled; |
|
347 |
||
348 |
QParallelAnimationGroup group; |
|
349 |
group.setLoopCount(2); |
|
350 |
||
351 |
QSequentialAnimationGroup subgroup1(&group); |
|
352 |
||
353 |
QObject o; |
|
354 |
o.setProperty("ole", 42); |
|
355 |
||
356 |
QPropertyAnimation animation(&o, "ole", &subgroup1); |
|
357 |
animation.setEndValue(43); |
|
358 |
animation.setDuration(300); |
|
359 |
TestablePauseAnimation pause(&subgroup1); |
|
360 |
pause.setDuration(200); |
|
361 |
||
362 |
QSequentialAnimationGroup subgroup2(&group); |
|
363 |
||
364 |
o.setProperty("ole2", 42); |
|
365 |
QPropertyAnimation animation2(&o, "ole2", &subgroup2); |
|
366 |
animation2.setEndValue(43); |
|
367 |
animation2.setDuration(200); |
|
368 |
TestablePauseAnimation pause2(&subgroup2); |
|
369 |
pause2.setDuration(250); |
|
370 |
||
371 |
QSequentialAnimationGroup subgroup3(&group); |
|
372 |
||
373 |
TestablePauseAnimation pause3(&subgroup3); |
|
374 |
pause3.setDuration(400); |
|
375 |
||
376 |
o.setProperty("ole3", 42); |
|
377 |
QPropertyAnimation animation3(&o, "ole3", &subgroup3); |
|
378 |
animation3.setEndValue(43); |
|
379 |
animation3.setDuration(200); |
|
380 |
||
381 |
QSequentialAnimationGroup subgroup4(&group); |
|
382 |
||
383 |
TestablePauseAnimation pause4(&subgroup4); |
|
384 |
pause4.setDuration(310); |
|
385 |
||
386 |
TestablePauseAnimation pause5(&subgroup4); |
|
387 |
pause5.setDuration(60); |
|
388 |
||
389 |
group.start(); |
|
390 |
||
391 |
QVERIFY(group.state() == QAbstractAnimation::Running); |
|
392 |
QVERIFY(subgroup1.state() == QAbstractAnimation::Running); |
|
393 |
QVERIFY(subgroup2.state() == QAbstractAnimation::Running); |
|
394 |
QVERIFY(subgroup3.state() == QAbstractAnimation::Running); |
|
395 |
QVERIFY(subgroup4.state() == QAbstractAnimation::Running); |
|
396 |
||
397 |
QTest::qWait(group.totalDuration() + 100); |
|
398 |
||
399 |
#ifdef Q_OS_WIN |
|
400 |
if (group.state() != QAbstractAnimation::Stopped) |
|
401 |
QEXPECT_FAIL("", "On windows, consistent timing is not working properly due to bad timer resolution", Abort); |
|
402 |
#endif |
|
403 |
QVERIFY(group.state() == QAbstractAnimation::Stopped); |
|
404 |
QVERIFY(subgroup1.state() == QAbstractAnimation::Stopped); |
|
405 |
QVERIFY(subgroup2.state() == QAbstractAnimation::Stopped); |
|
406 |
QVERIFY(subgroup3.state() == QAbstractAnimation::Stopped); |
|
407 |
QVERIFY(subgroup4.state() == QAbstractAnimation::Stopped); |
|
408 |
||
409 |
QCOMPARE(pause5.m_updateCurrentTimeCount, 4); |
|
410 |
} |
|
411 |
||
412 |
void tst_QPauseAnimation::zeroDuration() |
|
413 |
{ |
|
414 |
TestablePauseAnimation animation; |
|
415 |
animation.setDuration(0); |
|
416 |
animation.start(); |
|
417 |
QTest::qWait(animation.totalDuration() + 100); |
|
418 |
QVERIFY(animation.state() == QAbstractAnimation::Stopped); |
|
419 |
QCOMPARE(animation.m_updateCurrentTimeCount, 1); |
|
420 |
} |
|
421 |
||
422 |
QTEST_MAIN(tst_QPauseAnimation) |
|
423 |
#include "tst_qpauseanimation.moc" |