d06085d29eedb671eded5cfe8f95bb7d41772e93
[profile/ivi/qtdeclarative.git] / tests / auto / qtquick2 / qdeclarativeanimations / tst_qdeclarativeanimations.cpp
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: http://www.qt-project.org/
6 **
7 ** This file is part of the test suite of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 **
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 **
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
29 **
30 ** Other Usage
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 #include <QtTest/QtTest>
42 #include <QtDeclarative/qdeclarativeengine.h>
43 #include <QtDeclarative/qdeclarativecomponent.h>
44 #include <QtQuick/qquickview.h>
45 #include <QtQuick/private/qquickrectangle_p.h>
46 #include <QtQuick/private/qdeclarativeanimation_p.h>
47 #include <QtQuick/private/qdeclarativetransition_p.h>
48 #include <QtQuick/private/qquickanimation_p.h>
49 #include <QtQuick/private/qdeclarativepathinterpolator_p.h>
50 #include <QtQuick/private/qquickitem_p.h>
51 #include <QVariantAnimation>
52 #include <QEasingCurve>
53
54 #include <limits.h>
55 #include <math.h>
56
57 #include "../../shared/util.h"
58
59 class tst_qdeclarativeanimations : public QDeclarativeDataTest
60 {
61     Q_OBJECT
62 public:
63     tst_qdeclarativeanimations() {}
64
65 private slots:
66     void initTestCase()
67     {
68         QDeclarativeEngine engine;  // ensure types are registered
69         QDeclarativeDataTest::initTestCase();
70     }
71
72     void simpleProperty();
73     void simpleNumber();
74     void simpleColor();
75     void simpleRotation();
76     void simplePath();
77     void pathInterpolator();
78     void pathInterpolatorBackwardJump();
79     void pathWithNoStart();
80     void alwaysRunToEnd();
81     void complete();
82     void resume();
83     void dotProperty();
84     void badTypes();
85     void badProperties();
86     void mixedTypes();
87     void properties();
88     void propertiesTransition();
89     void pathTransition();
90     void disabledTransition();
91     void invalidDuration();
92     void attached();
93     void propertyValueSourceDefaultStart();
94     void dontStart();
95     void easingProperties();
96     void rotation();
97     void runningTrueBug();
98     void nonTransitionBug();
99     void registrationBug();
100     void doubleRegistrationBug();
101     void alwaysRunToEndRestartBug();
102     void transitionAssignmentBug();
103     void pauseBindingBug();
104     void pauseBug();
105 };
106
107 #define QTIMED_COMPARE(lhs, rhs) do { \
108     for (int ii = 0; ii < 5; ++ii) { \
109         if (lhs == rhs)  \
110             break; \
111         QTest::qWait(50); \
112     } \
113     QCOMPARE(lhs, rhs); \
114 } while (false)
115
116 void tst_qdeclarativeanimations::simpleProperty()
117 {
118     QQuickRectangle rect;
119     QDeclarativePropertyAnimation animation;
120     animation.setTarget(&rect);
121     animation.setProperty("x");
122     animation.setTo(200);
123     QVERIFY(animation.target() == &rect);
124     QVERIFY(animation.property() == "x");
125     QVERIFY(animation.to().toReal() == 200.0);
126     animation.start();
127     QVERIFY(animation.isRunning());
128     QTest::qWait(animation.duration());
129     QTIMED_COMPARE(rect.x(), 200.0);
130
131     rect.setPos(QPointF(0,0));
132     animation.start();
133     animation.pause();
134     QVERIFY(animation.isRunning());
135     QVERIFY(animation.isPaused());
136     animation.setCurrentTime(125);
137     QVERIFY(animation.currentTime() == 125);
138     QCOMPARE(rect.x(),100.0);
139 }
140
141 void tst_qdeclarativeanimations::simpleNumber()
142 {
143     QQuickRectangle rect;
144     QDeclarativeNumberAnimation animation;
145     animation.setTarget(&rect);
146     animation.setProperty("x");
147     animation.setTo(200);
148     QVERIFY(animation.target() == &rect);
149     QVERIFY(animation.property() == "x");
150     QVERIFY(animation.to() == 200);
151     animation.start();
152     QVERIFY(animation.isRunning());
153     QTest::qWait(animation.duration());
154     QTIMED_COMPARE(rect.x(), qreal(200));
155
156     rect.setX(0);
157     animation.start();
158     animation.pause();
159     QVERIFY(animation.isRunning());
160     QVERIFY(animation.isPaused());
161     animation.setCurrentTime(125);
162     QVERIFY(animation.currentTime() == 125);
163     QCOMPARE(rect.x(), qreal(100));
164 }
165
166 void tst_qdeclarativeanimations::simpleColor()
167 {
168     QQuickRectangle rect;
169     QDeclarativeColorAnimation animation;
170     animation.setTarget(&rect);
171     animation.setProperty("color");
172     animation.setTo(QColor("red"));
173     QVERIFY(animation.target() == &rect);
174     QVERIFY(animation.property() == "color");
175     QVERIFY(animation.to() == QColor("red"));
176     animation.start();
177     QVERIFY(animation.isRunning());
178     QTest::qWait(animation.duration());
179     QTIMED_COMPARE(rect.color(), QColor("red"));
180
181     rect.setColor(QColor("blue"));
182     animation.start();
183     animation.pause();
184     QVERIFY(animation.isRunning());
185     QVERIFY(animation.isPaused());
186     animation.setCurrentTime(125);
187     QVERIFY(animation.currentTime() == 125);
188 #if defined(UBUNTU_ONEIRIC) && defined(__x86_64__)
189     QEXPECT_FAIL("", "Fails on this platform - QTBUG-23385", Abort);
190 #endif
191     QCOMPARE(rect.color(), QColor::fromRgbF(0.498039, 0, 0.498039, 1));
192
193     rect.setColor(QColor("green"));
194     animation.setFrom(QColor("blue"));
195     QVERIFY(animation.from() == QColor("blue"));
196     animation.restart();
197     QCOMPARE(rect.color(), QColor("blue"));
198     QVERIFY(animation.isRunning());
199     animation.setCurrentTime(125);
200     QCOMPARE(rect.color(), QColor::fromRgbF(0.498039, 0, 0.498039, 1));
201 }
202
203 void tst_qdeclarativeanimations::simpleRotation()
204 {
205     QQuickRectangle rect;
206     QDeclarativeRotationAnimation animation;
207     animation.setTarget(&rect);
208     animation.setProperty("rotation");
209     animation.setTo(270);
210     QVERIFY(animation.target() == &rect);
211     QVERIFY(animation.property() == "rotation");
212     QVERIFY(animation.to() == 270);
213     QVERIFY(animation.direction() == QDeclarativeRotationAnimation::Numerical);
214     animation.start();
215     QVERIFY(animation.isRunning());
216     QTest::qWait(animation.duration());
217     QTIMED_COMPARE(rect.rotation(), qreal(270));
218
219     rect.setRotation(0);
220     animation.start();
221     animation.pause();
222     QVERIFY(animation.isRunning());
223     QVERIFY(animation.isPaused());
224     animation.setCurrentTime(125);
225     QVERIFY(animation.currentTime() == 125);
226     QCOMPARE(rect.rotation(), qreal(135));
227 }
228
229 void tst_qdeclarativeanimations::simplePath()
230 {
231     {
232         QDeclarativeEngine engine;
233         QDeclarativeComponent c(&engine, testFileUrl("pathAnimation.qml"));
234         QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
235         QVERIFY(rect);
236
237         QQuickRectangle *redRect = rect->findChild<QQuickRectangle*>();
238         QVERIFY(redRect);
239         QQuickPathAnimation *pathAnim = rect->findChild<QQuickPathAnimation*>();
240         QVERIFY(pathAnim);
241
242         pathAnim->start();
243         pathAnim->pause();
244
245         pathAnim->setCurrentTime(30);
246         QCOMPARE(redRect->x(), qreal(167));
247         QCOMPARE(redRect->y(), qreal(104));
248
249         pathAnim->setCurrentTime(100);
250         QCOMPARE(redRect->x(), qreal(300));
251         QCOMPARE(redRect->y(), qreal(300));
252
253         //verify animation runs to end
254         pathAnim->start();
255         QCOMPARE(redRect->x(), qreal(50));
256         QCOMPARE(redRect->y(), qreal(50));
257         QTRY_COMPARE(redRect->x(), qreal(300));
258         QCOMPARE(redRect->y(), qreal(300));
259
260         pathAnim->setOrientation(QQuickPathAnimation::RightFirst);
261         QCOMPARE(pathAnim->orientation(), QQuickPathAnimation::RightFirst);
262         pathAnim->start();
263         QTRY_VERIFY(redRect->rotation() != 0);
264         pathAnim->stop();
265     }
266
267     {
268         QDeclarativeEngine engine;
269         QDeclarativeComponent c(&engine, testFileUrl("pathAnimation2.qml"));
270         QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
271         QVERIFY(rect);
272
273         QQuickRectangle *redRect = rect->findChild<QQuickRectangle*>();
274         QVERIFY(redRect);
275         QQuickPathAnimation *pathAnim = rect->findChild<QQuickPathAnimation*>();
276         QVERIFY(pathAnim);
277
278         QCOMPARE(pathAnim->orientation(), QQuickPathAnimation::RightFirst);
279
280         pathAnim->start();
281         pathAnim->pause();
282         QCOMPARE(redRect->x(), qreal(50));
283         QCOMPARE(redRect->y(), qreal(50));
284         QCOMPARE(redRect->rotation(), qreal(-360));
285
286         pathAnim->setCurrentTime(50);
287         QCOMPARE(redRect->x(), qreal(175));
288         QCOMPARE(redRect->y(), qreal(175));
289         QCOMPARE(redRect->rotation(), qreal(-315));
290
291         pathAnim->setCurrentTime(100);
292         QCOMPARE(redRect->x(), qreal(300));
293         QCOMPARE(redRect->y(), qreal(300));
294         QCOMPARE(redRect->rotation(), qreal(0));
295     }
296 }
297
298 void tst_qdeclarativeanimations::pathInterpolator()
299 {
300     QDeclarativeEngine engine;
301     QDeclarativeComponent c(&engine, testFileUrl("pathInterpolator.qml"));
302     QDeclarativePathInterpolator *interpolator = qobject_cast<QDeclarativePathInterpolator*>(c.create());
303     QVERIFY(interpolator);
304
305     QCOMPARE(interpolator->progress(), qreal(0));
306     QCOMPARE(interpolator->x(), qreal(50));
307     QCOMPARE(interpolator->y(), qreal(50));
308     QCOMPARE(interpolator->angle(), qreal(0));
309
310     interpolator->setProgress(.5);
311     QCOMPARE(interpolator->progress(), qreal(.5));
312     QCOMPARE(interpolator->x(), qreal(175));
313     QCOMPARE(interpolator->y(), qreal(175));
314     QCOMPARE(interpolator->angle(), qreal(90));
315
316     interpolator->setProgress(1);
317     QCOMPARE(interpolator->progress(), qreal(1));
318     QCOMPARE(interpolator->x(), qreal(300));
319     QCOMPARE(interpolator->y(), qreal(300));
320     QCOMPARE(interpolator->angle(), qreal(0));
321 }
322
323 void tst_qdeclarativeanimations::pathInterpolatorBackwardJump()
324 {
325     {
326         QDeclarativeEngine engine;
327         QDeclarativeComponent c(&engine, testFileUrl("pathInterpolatorBack.qml"));
328         QDeclarativePathInterpolator *interpolator = qobject_cast<QDeclarativePathInterpolator*>(c.create());
329         QVERIFY(interpolator);
330
331         QCOMPARE(interpolator->progress(), qreal(0));
332         QCOMPARE(interpolator->x(), qreal(50));
333         QCOMPARE(interpolator->y(), qreal(50));
334         QCOMPARE(interpolator->angle(), qreal(90));
335
336         interpolator->setProgress(.5);
337         QCOMPARE(interpolator->progress(), qreal(.5));
338         QCOMPARE(interpolator->x(), qreal(100));
339         QCOMPARE(interpolator->y(), qreal(75));
340         QCOMPARE(interpolator->angle(), qreal(270));
341
342         interpolator->setProgress(1);
343         QCOMPARE(interpolator->progress(), qreal(1));
344         QCOMPARE(interpolator->x(), qreal(200));
345         QCOMPARE(interpolator->y(), qreal(50));
346         QCOMPARE(interpolator->angle(), qreal(0));
347
348         //make sure we don't get caught in infinite loop here
349         interpolator->setProgress(0);
350         QCOMPARE(interpolator->progress(), qreal(0));
351         QCOMPARE(interpolator->x(), qreal(50));
352         QCOMPARE(interpolator->y(), qreal(50));
353         QCOMPARE(interpolator->angle(), qreal(90));
354     }
355
356     {
357         QDeclarativeEngine engine;
358         QDeclarativeComponent c(&engine, testFileUrl("pathInterpolatorBack2.qml"));
359         QDeclarativePathInterpolator *interpolator = qobject_cast<QDeclarativePathInterpolator*>(c.create());
360         QVERIFY(interpolator);
361
362         QCOMPARE(interpolator->progress(), qreal(0));
363         QCOMPARE(interpolator->x(), qreal(200));
364         QCOMPARE(interpolator->y(), qreal(280));
365         QCOMPARE(interpolator->angle(), qreal(180));
366
367         interpolator->setProgress(1);
368         QCOMPARE(interpolator->progress(), qreal(1));
369         QCOMPARE(interpolator->x(), qreal(0));
370         QCOMPARE(interpolator->y(), qreal(80));
371         QCOMPARE(interpolator->angle(), qreal(180));
372
373         //make sure we don't get caught in infinite loop here
374         interpolator->setProgress(0);
375         QCOMPARE(interpolator->progress(), qreal(0));
376         QCOMPARE(interpolator->x(), qreal(200));
377         QCOMPARE(interpolator->y(), qreal(280));
378         QCOMPARE(interpolator->angle(), qreal(180));
379     }
380 }
381
382 void tst_qdeclarativeanimations::pathWithNoStart()
383 {
384     QDeclarativeEngine engine;
385     QDeclarativeComponent c(&engine, testFileUrl("pathAnimationNoStart.qml"));
386     QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
387     QVERIFY(rect);
388
389     QQuickRectangle *redRect = rect->findChild<QQuickRectangle*>();
390     QVERIFY(redRect);
391     QQuickPathAnimation *pathAnim = rect->findChild<QQuickPathAnimation*>();
392     QVERIFY(pathAnim);
393
394     pathAnim->start();
395     pathAnim->pause();
396     QCOMPARE(redRect->x(), qreal(50));
397     QCOMPARE(redRect->y(), qreal(50));
398
399     pathAnim->setCurrentTime(50);
400     QCOMPARE(redRect->x(), qreal(175));
401     QCOMPARE(redRect->y(), qreal(175));
402
403     pathAnim->setCurrentTime(100);
404     QCOMPARE(redRect->x(), qreal(300));
405     QCOMPARE(redRect->y(), qreal(300));
406
407     redRect->setX(100);
408     redRect->setY(100);
409     pathAnim->start();
410     QCOMPARE(redRect->x(), qreal(100));
411     QCOMPARE(redRect->y(), qreal(100));
412     QTRY_COMPARE(redRect->x(), qreal(300));
413     QCOMPARE(redRect->y(), qreal(300));
414 }
415
416 void tst_qdeclarativeanimations::alwaysRunToEnd()
417 {
418     QQuickRectangle rect;
419     QDeclarativePropertyAnimation animation;
420     animation.setTarget(&rect);
421     animation.setProperty("x");
422     animation.setTo(200);
423     animation.setDuration(1000);
424     animation.setLoops(-1);
425     animation.setAlwaysRunToEnd(true);
426     QVERIFY(animation.loops() == -1);
427     QVERIFY(animation.alwaysRunToEnd() == true);
428     animation.start();
429     QTest::qWait(1500);
430     animation.stop();
431     QVERIFY(rect.x() != qreal(200));
432     QTest::qWait(500);
433     QTIMED_COMPARE(rect.x(), qreal(200));
434 }
435
436 void tst_qdeclarativeanimations::complete()
437 {
438     QQuickRectangle rect;
439     QDeclarativePropertyAnimation animation;
440     animation.setTarget(&rect);
441     animation.setProperty("x");
442     animation.setFrom(1);
443     animation.setTo(200);
444     animation.setDuration(500);
445     QVERIFY(animation.from() == 1);
446     animation.start();
447     QTest::qWait(50);
448     animation.stop();
449     QVERIFY(rect.x() != qreal(200));
450     animation.start();
451     QTest::qWait(50);
452     QVERIFY(animation.isRunning());
453     animation.complete();
454     QCOMPARE(rect.x(), qreal(200));
455 }
456
457 void tst_qdeclarativeanimations::resume()
458 {
459     QQuickRectangle rect;
460     QDeclarativePropertyAnimation animation;
461     animation.setTarget(&rect);
462     animation.setProperty("x");
463     animation.setFrom(10);
464     animation.setTo(200);
465     animation.setDuration(1000);
466     QVERIFY(animation.from() == 10);
467
468     animation.start();
469     QTest::qWait(400);
470     animation.pause();
471     qreal x = rect.x();
472     QVERIFY(x != qreal(200) && x != qreal(10));
473     QVERIFY(animation.isRunning());
474     QVERIFY(animation.isPaused());
475
476     animation.resume();
477     QVERIFY(animation.isRunning());
478     QVERIFY(!animation.isPaused());
479     QTest::qWait(400);
480     animation.stop();
481     QVERIFY(rect.x() > x);
482 }
483
484 void tst_qdeclarativeanimations::dotProperty()
485 {
486     QQuickRectangle rect;
487     QDeclarativeNumberAnimation animation;
488     animation.setTarget(&rect);
489     animation.setProperty("border.width");
490     animation.setTo(10);
491     animation.start();
492     QTest::qWait(animation.duration()+50);
493     QTIMED_COMPARE(rect.border()->width(), 10.0);
494
495     rect.border()->setWidth(0);
496     animation.start();
497     animation.pause();
498     animation.setCurrentTime(125);
499     QVERIFY(animation.currentTime() == 125);
500     QCOMPARE(rect.border()->width(), 5.0);
501 }
502
503 void tst_qdeclarativeanimations::badTypes()
504 {
505     //don't crash
506     {
507         QQuickView *view = new QQuickView;
508         view->setSource(testFileUrl("badtype1.qml"));
509
510         qApp->processEvents();
511
512         delete view;
513     }
514
515     //make sure we get a compiler error
516     {
517         QDeclarativeEngine engine;
518         QDeclarativeComponent c(&engine, testFileUrl("badtype2.qml"));
519         QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready");
520         c.create();
521
522         QVERIFY(c.errors().count() == 1);
523         QCOMPARE(c.errors().at(0).description(), QLatin1String("Invalid property assignment: number expected"));
524     }
525
526     //make sure we get a compiler error
527     {
528         QDeclarativeEngine engine;
529         QDeclarativeComponent c(&engine, testFileUrl("badtype3.qml"));
530         QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready");
531         c.create();
532
533         QVERIFY(c.errors().count() == 1);
534         QCOMPARE(c.errors().at(0).description(), QLatin1String("Invalid property assignment: color expected"));
535     }
536
537     //don't crash
538     {
539         QDeclarativeEngine engine;
540         QDeclarativeComponent c(&engine, testFileUrl("badtype4.qml"));
541         QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
542         QVERIFY(rect);
543
544         QQuickItemPrivate::get(rect)->setState("state1");
545         QTest::qWait(1000 + 50);
546         QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("MyRect");
547         QVERIFY(myRect);
548         QCOMPARE(myRect->x(),qreal(200));
549     }
550 }
551
552 void tst_qdeclarativeanimations::badProperties()
553 {
554     //make sure we get a runtime error
555     {
556         QDeclarativeEngine engine;
557
558         QDeclarativeComponent c1(&engine, testFileUrl("badproperty1.qml"));
559         QByteArray message = testFileUrl("badproperty1.qml").toString().toUtf8() + ":18:9: QML ColorAnimation: Cannot animate non-existent property \"border.colr\"";
560         QTest::ignoreMessage(QtWarningMsg, message);
561         QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c1.create());
562         QVERIFY(rect);
563
564         QDeclarativeComponent c2(&engine, testFileUrl("badproperty2.qml"));
565         message = testFileUrl("badproperty2.qml").toString().toUtf8() + ":18:9: QML ColorAnimation: Cannot animate read-only property \"border\"";
566         QTest::ignoreMessage(QtWarningMsg, message);
567         rect = qobject_cast<QQuickRectangle*>(c2.create());
568         QVERIFY(rect);
569
570         //### should we warn here are well?
571         //rect->setState("state1");
572     }
573 }
574
575 //test animating mixed types with property animation in a transition
576 //for example, int + real; color + real; etc
577 void tst_qdeclarativeanimations::mixedTypes()
578 {
579     //assumes border.width stays a real -- not real robust
580     {
581         QDeclarativeEngine engine;
582         QDeclarativeComponent c(&engine, testFileUrl("mixedtype1.qml"));
583         QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
584         QVERIFY(rect);
585
586         QQuickItemPrivate::get(rect)->setState("state1");
587         QTest::qWait(500);
588         QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("MyRect");
589         QVERIFY(myRect);
590
591         //rather inexact -- is there a better way?
592         QVERIFY(myRect->x() > 100 && myRect->x() < 200);
593         QVERIFY(myRect->border()->width() > 1 && myRect->border()->width() < 10);
594     }
595
596     {
597         QDeclarativeEngine engine;
598         QDeclarativeComponent c(&engine, testFileUrl("mixedtype2.qml"));
599         QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
600         QVERIFY(rect);
601
602         QQuickItemPrivate::get(rect)->setState("state1");
603         QTest::qWait(500);
604         QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("MyRect");
605         QVERIFY(myRect);
606
607         //rather inexact -- is there a better way?
608         QVERIFY(myRect->x() > 100 && myRect->x() < 200);
609 #if defined(UBUNTU_ONEIRIC) && defined(__x86_64__)
610         QEXPECT_FAIL("", "Fails on this platform - QTBUG-23385", Continue);
611 #endif
612         QVERIFY(myRect->color() != QColor("red") && myRect->color() != QColor("blue"));
613     }
614 }
615
616 void tst_qdeclarativeanimations::properties()
617 {
618     const int waitDuration = 300;
619     {
620         QDeclarativeEngine engine;
621         QDeclarativeComponent c(&engine, testFileUrl("properties.qml"));
622         QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
623         QVERIFY(rect);
624
625         QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
626         QVERIFY(myRect);
627         QTest::qWait(waitDuration);
628         QTIMED_COMPARE(myRect->x(),qreal(200));
629     }
630
631     {
632         QDeclarativeEngine engine;
633         QDeclarativeComponent c(&engine, testFileUrl("properties2.qml"));
634         QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
635         QVERIFY(rect);
636
637         QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
638         QVERIFY(myRect);
639         QTest::qWait(waitDuration);
640         QTIMED_COMPARE(myRect->x(),qreal(200));
641     }
642
643     {
644         QDeclarativeEngine engine;
645         QDeclarativeComponent c(&engine, testFileUrl("properties3.qml"));
646         QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
647         QVERIFY(rect);
648
649         QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
650         QVERIFY(myRect);
651         QTest::qWait(waitDuration);
652         QTIMED_COMPARE(myRect->x(),qreal(300));
653     }
654
655     {
656         QDeclarativeEngine engine;
657         QDeclarativeComponent c(&engine, testFileUrl("properties4.qml"));
658         QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
659         QVERIFY(rect);
660
661         QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
662         QVERIFY(myRect);
663         QTest::qWait(waitDuration);
664         QTIMED_COMPARE(myRect->y(),qreal(200));
665         QTIMED_COMPARE(myRect->x(),qreal(100));
666     }
667
668     {
669         QDeclarativeEngine engine;
670         QDeclarativeComponent c(&engine, testFileUrl("properties5.qml"));
671         QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
672         QVERIFY(rect);
673
674         QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
675         QVERIFY(myRect);
676         QTest::qWait(waitDuration);
677         QTIMED_COMPARE(myRect->x(),qreal(100));
678         QTIMED_COMPARE(myRect->y(),qreal(200));
679     }
680 }
681
682 void tst_qdeclarativeanimations::propertiesTransition()
683 {
684     const int waitDuration = 300;
685     {
686         QDeclarativeEngine engine;
687         QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition.qml"));
688         QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
689         QVERIFY(rect);
690
691         QQuickItemPrivate::get(rect)->setState("moved");
692         QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
693         QVERIFY(myRect);
694         QTest::qWait(waitDuration);
695         QTIMED_COMPARE(myRect->x(),qreal(200));
696     }
697
698     {
699         QDeclarativeEngine engine;
700         QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition2.qml"));
701         QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
702         QVERIFY(rect);
703
704         QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
705         QVERIFY(myRect);
706         QQuickItemPrivate::get(rect)->setState("moved");
707         QCOMPARE(myRect->x(),qreal(200));
708         QCOMPARE(myRect->y(),qreal(100));
709         QTest::qWait(waitDuration);
710         QTIMED_COMPARE(myRect->y(),qreal(200));
711     }
712
713     {
714         QDeclarativeEngine engine;
715         QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition3.qml"));
716         QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
717         QVERIFY(rect);
718
719         QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
720         QVERIFY(myRect);
721         QQuickItemPrivate::get(rect)->setState("moved");
722         QCOMPARE(myRect->x(),qreal(200));
723         QCOMPARE(myRect->y(),qreal(100));
724     }
725
726     {
727         QDeclarativeEngine engine;
728         QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition4.qml"));
729         QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
730         QVERIFY(rect);
731
732         QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
733         QVERIFY(myRect);
734         QQuickItemPrivate::get(rect)->setState("moved");
735         QCOMPARE(myRect->x(),qreal(100));
736         QTest::qWait(waitDuration);
737         QTIMED_COMPARE(myRect->x(),qreal(200));
738     }
739
740     {
741         QDeclarativeEngine engine;
742         QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition5.qml"));
743         QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
744         QVERIFY(rect);
745
746         QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
747         QVERIFY(myRect);
748         QQuickItemPrivate::get(rect)->setState("moved");
749         QCOMPARE(myRect->x(),qreal(100));
750         QTest::qWait(waitDuration);
751         QTIMED_COMPARE(myRect->x(),qreal(200));
752     }
753
754     /*{
755         QDeclarativeEngine engine;
756         QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition6.qml"));
757         QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
758         QVERIFY(rect);
759
760         QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
761         QVERIFY(myRect);
762         QQuickItemPrivate::get(rect)->setState("moved");
763         QCOMPARE(myRect->x(),qreal(100));
764         QTest::qWait(waitDuration);
765         QTIMED_COMPARE(myRect->x(),qreal(100));
766     }*/
767
768     {
769         QDeclarativeEngine engine;
770         QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition7.qml"));
771         QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
772         QVERIFY(rect);
773
774         QQuickItemPrivate::get(rect)->setState("moved");
775         QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
776         QVERIFY(myRect);
777         QTest::qWait(waitDuration);
778         QTIMED_COMPARE(myRect->x(),qreal(200));
779     }
780
781 }
782
783 void tst_qdeclarativeanimations::pathTransition()
784 {
785     QDeclarativeEngine engine;
786     QDeclarativeComponent c(&engine, testFileUrl("pathTransition.qml"));
787     QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
788     QVERIFY(rect);
789
790     QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("redRect");
791     QVERIFY(myRect);
792
793     QQuickItemPrivate::get(rect)->setState("moved");
794     QTRY_VERIFY(myRect->x() < 500 && myRect->x() > 100 && myRect->y() > 50 && myRect->y() < 700 );  //animation started
795     QTRY_VERIFY(qFuzzyCompare(myRect->x(), qreal(100)) && qFuzzyCompare(myRect->y(), qreal(700)));
796     QTest::qWait(100);
797
798     QQuickItemPrivate::get(rect)->setState("");
799     QTRY_VERIFY(myRect->x() < 500 && myRect->x() > 100 && myRect->y() > 50 && myRect->y() < 700 );  //animation started
800     QTRY_VERIFY(qFuzzyCompare(myRect->x(), qreal(500)) && qFuzzyCompare(myRect->y(), qreal(50)));
801 }
802
803 void tst_qdeclarativeanimations::disabledTransition()
804 {
805     QDeclarativeEngine engine;
806     QDeclarativeComponent c(&engine, testFileUrl("disabledTransition.qml"));
807     QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
808     QVERIFY(rect);
809
810     QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
811     QVERIFY(myRect);
812
813     QDeclarativeTransition *trans = rect->findChild<QDeclarativeTransition*>();
814     QVERIFY(trans);
815
816     QCOMPARE(trans->enabled(), false);
817
818     QQuickItemPrivate::get(rect)->setState("moved");
819     QCOMPARE(myRect->x(),qreal(200));
820
821     trans->setEnabled(true);
822
823     QQuickItemPrivate::get(rect)->setState("");
824     QCOMPARE(myRect->x(),qreal(200));
825     QTest::qWait(300);
826     QTIMED_COMPARE(myRect->x(),qreal(100));
827 }
828
829 void tst_qdeclarativeanimations::invalidDuration()
830 {
831     QDeclarativePropertyAnimation *animation = new QDeclarativePropertyAnimation;
832     QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML PropertyAnimation: Cannot set a duration of < 0");
833     animation->setDuration(-1);
834     QCOMPARE(animation->duration(), 250);
835
836     QDeclarativePauseAnimation *pauseAnimation = new QDeclarativePauseAnimation;
837     QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML PauseAnimation: Cannot set a duration of < 0");
838     pauseAnimation->setDuration(-1);
839     QCOMPARE(pauseAnimation->duration(), 250);
840 }
841
842 void tst_qdeclarativeanimations::attached()
843 {
844     QDeclarativeEngine engine;
845
846     QDeclarativeComponent c(&engine, testFileUrl("attached.qml"));
847     QTest::ignoreMessage(QtDebugMsg, "off");
848     QTest::ignoreMessage(QtDebugMsg, "on");
849     QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
850     QVERIFY(rect);
851 }
852
853 void tst_qdeclarativeanimations::propertyValueSourceDefaultStart()
854 {
855     {
856         QDeclarativeEngine engine;
857
858         QDeclarativeComponent c(&engine, testFileUrl("valuesource.qml"));
859
860         QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
861         QVERIFY(rect);
862
863         QDeclarativeAbstractAnimation *myAnim = rect->findChild<QDeclarativeAbstractAnimation*>("MyAnim");
864         QVERIFY(myAnim);
865         QVERIFY(myAnim->isRunning());
866     }
867
868     {
869         QDeclarativeEngine engine;
870
871         QDeclarativeComponent c(&engine, testFileUrl("valuesource2.qml"));
872
873         QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
874         QVERIFY(rect);
875
876         QDeclarativeAbstractAnimation *myAnim = rect->findChild<QDeclarativeAbstractAnimation*>("MyAnim");
877         QVERIFY(myAnim);
878         QVERIFY(myAnim->isRunning() == false);
879     }
880
881     {
882         QDeclarativeEngine engine;
883
884         QDeclarativeComponent c(&engine, testFileUrl("dontAutoStart.qml"));
885
886         QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
887         QVERIFY(rect);
888
889         QDeclarativeAbstractAnimation *myAnim = rect->findChild<QDeclarativeAbstractAnimation*>("MyAnim");
890         QVERIFY(myAnim && myAnim->qtAnimation());
891         QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped);
892     }
893 }
894
895
896 void tst_qdeclarativeanimations::dontStart()
897 {
898     {
899         QDeclarativeEngine engine;
900
901         QDeclarativeComponent c(&engine, testFileUrl("dontStart.qml"));
902
903         QString warning = c.url().toString() + ":14:13: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes.";
904         QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
905         QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
906         QVERIFY(rect);
907
908         QDeclarativeAbstractAnimation *myAnim = rect->findChild<QDeclarativeAbstractAnimation*>("MyAnim");
909         QVERIFY(myAnim && myAnim->qtAnimation());
910         QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped);
911     }
912
913     {
914         QDeclarativeEngine engine;
915
916         QDeclarativeComponent c(&engine, testFileUrl("dontStart2.qml"));
917
918         QString warning = c.url().toString() + ":15:17: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes.";
919         QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
920         QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
921         QVERIFY(rect);
922
923         QDeclarativeAbstractAnimation *myAnim = rect->findChild<QDeclarativeAbstractAnimation*>("MyAnim");
924         QVERIFY(myAnim && myAnim->qtAnimation());
925         QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped);
926     }
927 }
928
929 void tst_qdeclarativeanimations::easingProperties()
930 {
931     {
932         QDeclarativeEngine engine;
933         QString componentStr = "import QtQuick 2.0\nNumberAnimation { easing.type: \"InOutQuad\" }";
934         QDeclarativeComponent animationComponent(&engine);
935         animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
936         QDeclarativePropertyAnimation *animObject = qobject_cast<QDeclarativePropertyAnimation*>(animationComponent.create());
937
938         QVERIFY(animObject != 0);
939         QCOMPARE(animObject->easing().type(), QEasingCurve::InOutQuad);
940     }
941
942     {
943         QDeclarativeEngine engine;
944         QString componentStr = "import QtQuick 2.0\nPropertyAnimation { easing.type: \"OutBounce\"; easing.amplitude: 5.0 }";
945         QDeclarativeComponent animationComponent(&engine);
946         animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
947         QDeclarativePropertyAnimation *animObject = qobject_cast<QDeclarativePropertyAnimation*>(animationComponent.create());
948
949         QVERIFY(animObject != 0);
950         QCOMPARE(animObject->easing().type(), QEasingCurve::OutBounce);
951         QCOMPARE(animObject->easing().amplitude(), 5.0);
952     }
953
954     {
955         QDeclarativeEngine engine;
956         QString componentStr = "import QtQuick 2.0\nPropertyAnimation { easing.type: \"OutElastic\"; easing.amplitude: 5.0; easing.period: 3.0}";
957         QDeclarativeComponent animationComponent(&engine);
958         animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
959         QDeclarativePropertyAnimation *animObject = qobject_cast<QDeclarativePropertyAnimation*>(animationComponent.create());
960
961         QVERIFY(animObject != 0);
962         QCOMPARE(animObject->easing().type(), QEasingCurve::OutElastic);
963         QCOMPARE(animObject->easing().amplitude(), 5.0);
964         QCOMPARE(animObject->easing().period(), 3.0);
965     }
966
967     {
968         QDeclarativeEngine engine;
969         QString componentStr = "import QtQuick 2.0\nPropertyAnimation { easing.type: \"InOutBack\"; easing.overshoot: 2 }";
970         QDeclarativeComponent animationComponent(&engine);
971         animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
972         QDeclarativePropertyAnimation *animObject = qobject_cast<QDeclarativePropertyAnimation*>(animationComponent.create());
973
974         QVERIFY(animObject != 0);
975         QCOMPARE(animObject->easing().type(), QEasingCurve::InOutBack);
976         QCOMPARE(animObject->easing().overshoot(), 2.0);
977     }
978
979     {
980         QDeclarativeEngine engine;
981         QString componentStr = "import QtQuick 2.0\nPropertyAnimation { easing.type: \"Bezier\"; easing.bezierCurve: [0.5, 0.2, 0.13, 0.65, 1.0, 1.0] }";
982         QDeclarativeComponent animationComponent(&engine);
983         animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
984         QDeclarativePropertyAnimation *animObject = qobject_cast<QDeclarativePropertyAnimation*>(animationComponent.create());
985
986         QVERIFY(animObject != 0);
987         QCOMPARE(animObject->easing().type(), QEasingCurve::BezierSpline);
988         QList<QPointF> points = animObject->easing().cubicBezierSpline();
989         QCOMPARE(points.count(), 3);
990         QCOMPARE(points.at(0), QPointF(0.5, 0.2));
991         QCOMPARE(points.at(1), QPointF(0.13, 0.65));
992         QCOMPARE(points.at(2), QPointF(1.0, 1.0));
993     }
994 }
995
996 void tst_qdeclarativeanimations::rotation()
997 {
998     QDeclarativeEngine engine;
999     QDeclarativeComponent c(&engine, testFileUrl("rotation.qml"));
1000     QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
1001     QVERIFY(rect);
1002
1003     QQuickRectangle *rr = rect->findChild<QQuickRectangle*>("rr");
1004     QQuickRectangle *rr2 = rect->findChild<QQuickRectangle*>("rr2");
1005     QQuickRectangle *rr3 = rect->findChild<QQuickRectangle*>("rr3");
1006     QQuickRectangle *rr4 = rect->findChild<QQuickRectangle*>("rr4");
1007
1008     QQuickItemPrivate::get(rect)->setState("state1");
1009     QTest::qWait(800);
1010     qreal r1 = rr->rotation();
1011     qreal r2 = rr2->rotation();
1012     qreal r3 = rr3->rotation();
1013     qreal r4 = rr4->rotation();
1014
1015     QVERIFY(r1 > qreal(0) && r1 < qreal(370));
1016     QVERIFY(r2 > qreal(0) && r2 < qreal(370));
1017     QVERIFY(r3 < qreal(0) && r3 > qreal(-350));
1018     QVERIFY(r4 > qreal(0) && r4 < qreal(10));
1019     QCOMPARE(r1,r2);
1020     QVERIFY(r4 < r2);
1021
1022     QTest::qWait(800);
1023     QTIMED_COMPARE(rr->rotation() + rr2->rotation() + rr3->rotation() + rr4->rotation(), qreal(370*4));
1024 }
1025
1026 void tst_qdeclarativeanimations::runningTrueBug()
1027 {
1028     //ensure we start correctly when "running: true" is explicitly set
1029     QDeclarativeEngine engine;
1030     QDeclarativeComponent c(&engine, testFileUrl("runningTrueBug.qml"));
1031     QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
1032     QVERIFY(rect);
1033
1034     QQuickRectangle *cloud = rect->findChild<QQuickRectangle*>("cloud");
1035     QVERIFY(cloud);
1036     QTest::qWait(1000);
1037     QVERIFY(cloud->x() > qreal(0));
1038 }
1039
1040 //QTBUG-12805
1041 void tst_qdeclarativeanimations::nonTransitionBug()
1042 {
1043     //tests that the animation values from the previous transition are properly cleared
1044     //in the case where an animation in the transition doesn't match anything (but previously did)
1045     QDeclarativeEngine engine;
1046
1047     QDeclarativeComponent c(&engine, testFileUrl("nonTransitionBug.qml"));
1048     QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
1049     QVERIFY(rect != 0);
1050     QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
1051     QQuickRectangle *mover = rect->findChild<QQuickRectangle*>("mover");
1052
1053     mover->setX(100);
1054     QCOMPARE(mover->x(), qreal(100));
1055
1056     rectPrivate->setState("left");
1057     QTRY_COMPARE(mover->x(), qreal(0));
1058
1059     mover->setX(100);
1060     QCOMPARE(mover->x(), qreal(100));
1061
1062     //make sure we don't try to animate back to 0
1063     rectPrivate->setState("free");
1064     QTest::qWait(300);
1065     QCOMPARE(mover->x(), qreal(100));
1066 }
1067
1068 //QTBUG-14042
1069 void tst_qdeclarativeanimations::registrationBug()
1070 {
1071     QDeclarativeEngine engine;
1072
1073     QDeclarativeComponent c(&engine, testFileUrl("registrationBug.qml"));
1074     QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
1075     QVERIFY(rect != 0);
1076     QTRY_COMPARE(rect->property("value"), QVariant(int(100)));
1077 }
1078
1079 void tst_qdeclarativeanimations::doubleRegistrationBug()
1080 {
1081     QDeclarativeEngine engine;
1082
1083     QDeclarativeComponent c(&engine, testFileUrl("doubleRegistrationBug.qml"));
1084     QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
1085     QVERIFY(rect != 0);
1086
1087     QDeclarativeAbstractAnimation *anim = rect->findChild<QDeclarativeAbstractAnimation*>("animation");
1088     QVERIFY(anim != 0);
1089     QTRY_COMPARE(anim->qtAnimation()->state(), QAbstractAnimation::Stopped);
1090 }
1091
1092 //QTBUG-16736
1093 void tst_qdeclarativeanimations::alwaysRunToEndRestartBug()
1094 {
1095     QQuickRectangle rect;
1096     QDeclarativePropertyAnimation animation;
1097     animation.setTarget(&rect);
1098     animation.setProperty("x");
1099     animation.setTo(200);
1100     animation.setDuration(1000);
1101     animation.setLoops(-1);
1102     animation.setAlwaysRunToEnd(true);
1103     QVERIFY(animation.loops() == -1);
1104     QVERIFY(animation.alwaysRunToEnd() == true);
1105     animation.start();
1106     animation.stop();
1107     animation.start();
1108     animation.stop();
1109     QTest::qWait(500);
1110     QVERIFY(rect.x() != qreal(200));
1111     QTest::qWait(800);
1112     QTIMED_COMPARE(rect.x(), qreal(200));
1113     QCOMPARE(static_cast<QDeclarativeAbstractAnimation*>(&animation)->qtAnimation()->state(), QAbstractAnimation::Stopped);
1114 }
1115
1116 //QTBUG-20227
1117 void tst_qdeclarativeanimations::transitionAssignmentBug()
1118 {
1119     QDeclarativeEngine engine;
1120
1121     QDeclarativeComponent c(&engine, testFileUrl("transitionAssignmentBug.qml"));
1122     QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
1123     QVERIFY(rect != 0);
1124
1125     QCOMPARE(rect->property("nullObject").toBool(), false);
1126 }
1127
1128 //QTBUG-19080
1129 void tst_qdeclarativeanimations::pauseBindingBug()
1130 {
1131     QDeclarativeEngine engine;
1132
1133     QDeclarativeComponent c(&engine, testFileUrl("pauseBindingBug.qml"));
1134     QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
1135     QVERIFY(rect != 0);
1136     QDeclarativeAbstractAnimation *anim = rect->findChild<QDeclarativeAbstractAnimation*>("animation");
1137     QVERIFY(anim->qtAnimation()->state() == QAbstractAnimation::Paused);
1138
1139     delete rect;
1140 }
1141
1142 //QTBUG-13598
1143 void tst_qdeclarativeanimations::pauseBug()
1144 {
1145     QDeclarativeEngine engine;
1146
1147     QDeclarativeComponent c(&engine, testFileUrl("pauseBug.qml"));
1148     QDeclarativeAbstractAnimation *anim = qobject_cast<QDeclarativeAbstractAnimation*>(c.create());
1149     QVERIFY(anim != 0);
1150     QCOMPARE(anim->qtAnimation()->state(), QAbstractAnimation::Paused);
1151     QCOMPARE(anim->isPaused(), true);
1152     QCOMPARE(anim->isRunning(), true);
1153
1154     delete anim;
1155 }
1156
1157 QTEST_MAIN(tst_qdeclarativeanimations)
1158
1159 #include "tst_qdeclarativeanimations.moc"