Stabilize Particles Tests
authorAlan Alpert <alan.alpert@nokia.com>
Mon, 17 Oct 2011 02:02:22 +0000 (12:02 +1000)
committerQt by Nokia <qt-info@nokia.com>
Mon, 17 Oct 2011 03:46:16 +0000 (05:46 +0200)
A couple of targeted fixes, plus enabling
QUnifiedTimer::consistentTiming.

Task-number: QTBUG-21867

Change-Id: I62acf524eb2c6491bc88fd687a0065866d7ce8aa
Reviewed-by: Martin Jones <martin.jones@nokia.com>
22 files changed:
tests/auto/particles/qsgage/tst_qsgage.cpp
tests/auto/particles/qsgangleddirection/tst_qsgangleddirection.cpp
tests/auto/particles/qsgcumulativedirection/tst_qsgcumulativedirection.cpp
tests/auto/particles/qsgcustomaffector/tst_qsgcustomaffector.cpp
tests/auto/particles/qsgcustomparticle/tst_qsgcustomparticle.cpp
tests/auto/particles/qsgellipseextruder/tst_qsgellipseextruder.cpp
tests/auto/particles/qsgfriction/tst_qsgfriction.cpp
tests/auto/particles/qsggravity/tst_qsggravity.cpp
tests/auto/particles/qsgimageparticle/tst_qsgimageparticle.cpp
tests/auto/particles/qsgitemparticle/tst_qsgitemparticle.cpp
tests/auto/particles/qsglineextruder/tst_qsglineextruder.cpp
tests/auto/particles/qsgmaskextruder/tst_qsgmaskextruder.cpp
tests/auto/particles/qsgparticlegroup/tst_qsgparticlegroup.cpp
tests/auto/particles/qsgparticlesystem/tst_qsgparticlesystem.cpp
tests/auto/particles/qsgpointattractor/tst_qsgpointattractor.cpp
tests/auto/particles/qsgpointdirection/tst_qsgpointdirection.cpp
tests/auto/particles/qsgrectangleextruder/tst_qsgrectangleextruder.cpp
tests/auto/particles/qsgtargetdirection/tst_qsgtargetdirection.cpp
tests/auto/particles/qsgtrailemitter/tst_qsgtrailemitter.cpp
tests/auto/particles/qsgturbulence/tst_qsgturbulence.cpp
tests/auto/particles/qsgwander/tst_qsgwander.cpp
tests/auto/particles/shared/particlestestsshared.h

index b58d455..54591e7 100644 (file)
@@ -42,6 +42,8 @@
 #include <QtTest/QtTest>
 #include "../shared/particlestestsshared.h"
 #include <private/qsgparticlesystem_p.h>
+#include "../../../shared/util.h"
+#include <private/qabstractanimation_p.h>
 
 class tst_qsgage : public QObject
 {
@@ -58,12 +60,14 @@ private slots:
 
 tst_qsgage::tst_qsgage()
 {
+    QUnifiedTimer::instance()->setConsistentTiming(true);
 }
 
 void tst_qsgage::test_kill()
 {
     QSGView* view = createView(QCoreApplication::applicationDirPath() + "/data/kill.qml", 600);
     QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system");
+    ensureAnimTime(600, system->m_animation);
 
     QCOMPARE(system->groupData[0]->size(), 500);
     foreach (QSGParticleData *d, system->groupData[0]->data) {
@@ -87,6 +91,7 @@ void tst_qsgage::test_jump()
 {
     QSGView* view = createView(QCoreApplication::applicationDirPath() + "/data/jump.qml", 600);
     QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system");
+    ensureAnimTime(600, system->m_animation);
 
     QCOMPARE(system->groupData[0]->size(), 500);
     foreach (QSGParticleData *d, system->groupData[0]->data) {
@@ -111,6 +116,7 @@ void tst_qsgage::test_onceOff()
 {
     QSGView* view = createView(QCoreApplication::applicationDirPath() + "/data/onceoff.qml", 600);
     QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system");
+    ensureAnimTime(600, system->m_animation);
 
     QCOMPARE(system->groupData[0]->size(), 500);
     foreach (QSGParticleData *d, system->groupData[0]->data) {
@@ -134,6 +140,8 @@ void tst_qsgage::test_sustained()
 {
     QSGView* view = createView(QCoreApplication::applicationDirPath() + "/data/sustained.qml", 600);
     QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system");
+    ensureAnimTime(600, system->m_animation);
+    //TODO: Ensure some particles have lived to 0.4s point despite unified timer
 
     QCOMPARE(system->groupData[0]->size(), 500);
     foreach (QSGParticleData *d, system->groupData[0]->data) {
index ea1d4ee..dbb23ff 100644 (file)
@@ -43,6 +43,7 @@
 #include <qmath.h>
 #include "../shared/particlestestsshared.h"
 #include <private/qsgparticlesystem_p.h>
+#include <private/qabstractanimation_p.h>
 
 class tst_qsgangleddirection : public QObject
 {
@@ -56,12 +57,14 @@ private slots:
 
 tst_qsgangleddirection::tst_qsgangleddirection()
 {
+    QUnifiedTimer::instance()->setConsistentTiming(true);
 }
 
 void tst_qsgangleddirection::test_basic()
 {
     QSGView* view = createView(QCoreApplication::applicationDirPath() + "/data/basic.qml", 600);
     QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system");
+    ensureAnimTime(600, system->m_animation);
 
     QCOMPARE(system->groupData[0]->size(), 500);
     foreach (QSGParticleData *d, system->groupData[0]->data) {
@@ -80,7 +83,7 @@ void tst_qsgangleddirection::test_basic()
         QCOMPARE(d->lifeSpan, 0.5f);
         QCOMPARE(d->size, 32.f);
         QCOMPARE(d->endSize, 32.f);
-        QVERIFY(d->t <= ((qreal)system->timeInt/1000.0));
+        QVERIFY(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0)));
     }
 }
 
index 678b749..00efff5 100644 (file)
@@ -42,6 +42,7 @@
 #include <QtTest/QtTest>
 #include "../shared/particlestestsshared.h"
 #include <private/qsgparticlesystem_p.h>
+#include <private/qabstractanimation_p.h>
 
 class tst_qsgcumulativedirection : public QObject
 {
@@ -55,12 +56,14 @@ private slots:
 
 tst_qsgcumulativedirection::tst_qsgcumulativedirection()
 {
+    QUnifiedTimer::instance()->setConsistentTiming(true);
 }
 
 void tst_qsgcumulativedirection::test_basic()
 {
     QSGView* view = createView(QCoreApplication::applicationDirPath() + "/data/basic.qml", 600);
     QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system");
+    ensureAnimTime(600, system->m_animation);
 
     QCOMPARE(system->groupData[0]->size(), 500);
     foreach (QSGParticleData *d, system->groupData[0]->data) {
@@ -76,7 +79,7 @@ void tst_qsgcumulativedirection::test_basic()
         QCOMPARE(d->lifeSpan, 0.5f);
         QCOMPARE(d->size, 32.f);
         QCOMPARE(d->endSize, 32.f);
-        QVERIFY(d->t <= ((qreal)system->timeInt/1000.0));
+        QVERIFY(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0)));
     }
 }
 
index d5ae596..2b36d31 100644 (file)
@@ -42,6 +42,7 @@
 #include <QtTest/QtTest>
 #include "../shared/particlestestsshared.h"
 #include <private/qsgparticlesystem_p.h>
+#include <private/qabstractanimation_p.h>
 
 class tst_qsgcustomaffector : public QObject
 {
@@ -55,12 +56,14 @@ private slots:
 
 tst_qsgcustomaffector::tst_qsgcustomaffector()
 {
+    QUnifiedTimer::instance()->setConsistentTiming(true);
 }
 
 void tst_qsgcustomaffector::test_basic()
 {
     QSGView* view = createView(QCoreApplication::applicationDirPath() + "/data/basic.qml", 600);
     QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system");
+    ensureAnimTime(600, system->m_animation);
 
     QCOMPARE(system->groupData[0]->size(), 500);
     foreach (QSGParticleData *d, system->groupData[0]->data) {
@@ -76,7 +79,7 @@ void tst_qsgcustomaffector::test_basic()
         QCOMPARE(d->lifeSpan, 0.5f);
         QCOMPARE(d->size, 100.f);
         QCOMPARE(d->endSize, 100.f);
-        QVERIFY(d->t <= ((qreal)system->timeInt/1000.0));
+        QVERIFY(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0)));
     }
 }
 
index 239a135..92762ea 100644 (file)
@@ -42,6 +42,7 @@
 #include <QtTest/QtTest>
 #include "../shared/particlestestsshared.h"
 #include <private/qsgparticlesystem_p.h>
+#include <private/qabstractanimation_p.h>
 
 class tst_qsgcustomparticle : public QObject
 {
@@ -55,6 +56,7 @@ private slots:
 
 tst_qsgcustomparticle::tst_qsgcustomparticle()
 {
+    QUnifiedTimer::instance()->setConsistentTiming(true);
 }
 
 void tst_qsgcustomparticle::test_basic()
@@ -62,6 +64,7 @@ void tst_qsgcustomparticle::test_basic()
     QSGView* view = createView(QCoreApplication::applicationDirPath() + "/data/basic.qml", 600);
     QVERIFY(view);
     QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system");
+    ensureAnimTime(600, system->m_animation);
 
     bool oneNonZero = false;
     QCOMPARE(system->groupData[0]->size(), 500);
@@ -78,7 +81,7 @@ void tst_qsgcustomparticle::test_basic()
         QCOMPARE(d->lifeSpan, 0.5f);
         QCOMPARE(d->size, 32.f);
         QCOMPARE(d->endSize, 32.f);
-        QVERIFY(d->t <= ((qreal)system->timeInt/1000.0));
+        QVERIFY(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0)));
         QVERIFY(d->r >= 0.0 && d->r <= 1.0);
         if (d->r != 0.0 )
             oneNonZero = true;
index 02b2173..040a5e9 100644 (file)
@@ -43,6 +43,7 @@
 #include <QtTest/QtTest>
 #include "../shared/particlestestsshared.h"
 #include <private/qsgparticlesystem_p.h>
+#include <private/qabstractanimation_p.h>
 
 class tst_qsgellipseextruder : public QObject
 {
@@ -58,6 +59,7 @@ private:
 
 tst_qsgellipseextruder::tst_qsgellipseextruder()
 {
+    QUnifiedTimer::instance()->setConsistentTiming(true);
 }
 
 bool tst_qsgellipseextruder::inCircle(qreal x, qreal y, qreal r, bool borderOnly)
@@ -77,6 +79,7 @@ void tst_qsgellipseextruder::test_basic()
 {
     QSGView* view = createView(QCoreApplication::applicationDirPath() + "/data/basic.qml", 600);
     QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system");
+    ensureAnimTime(600, system->m_animation);
 
     //Filled
     QCOMPARE(system->groupData[0]->size(), 500);
@@ -92,7 +95,7 @@ void tst_qsgellipseextruder::test_basic()
         QCOMPARE(d->lifeSpan, 0.5f);
         QCOMPARE(d->size, 32.f);
         QCOMPARE(d->endSize, 32.f);
-        QVERIFY(d->t <= ((qreal)system->timeInt/1000.0));
+        QVERIFY(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0)));
     }
     //Just border
     QCOMPARE(system->groupData[1]->size(), 500);
@@ -108,7 +111,7 @@ void tst_qsgellipseextruder::test_basic()
         QCOMPARE(d->lifeSpan, 0.5f);
         QCOMPARE(d->size, 32.f);
         QCOMPARE(d->endSize, 32.f);
-        QVERIFY(d->t <= ((qreal)system->timeInt/1000.0));
+        QVERIFY(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0)));
     }
 }
 
index 2d835de..bc622e4 100644 (file)
@@ -42,6 +42,7 @@
 #include <QtTest/QtTest>
 #include "../shared/particlestestsshared.h"
 #include <private/qsgparticlesystem_p.h>
+#include <private/qabstractanimation_p.h>
 
 class tst_qsgfriction : public QObject
 {
@@ -55,12 +56,14 @@ private slots:
 
 tst_qsgfriction::tst_qsgfriction()
 {
+    QUnifiedTimer::instance()->setConsistentTiming(true);
 }
 
 void tst_qsgfriction::test_basic()
 {
     QSGView* view = createView(QCoreApplication::applicationDirPath() + "/data/basic.qml", 600);
     QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system");
+    ensureAnimTime(600, system->m_animation);
 
     //Default is just slowed a little
     QCOMPARE(system->groupData[0]->size(), 500);
@@ -76,7 +79,7 @@ void tst_qsgfriction::test_basic()
         QCOMPARE(d->lifeSpan, 0.5f);
         QCOMPARE(d->size, 32.f);
         QCOMPARE(d->endSize, 32.f);
-        QVERIFY(d->t <= ((qreal)system->timeInt/1000.0));
+        QVERIFY(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0)));
     }
 
     //Nondefault comes to a complete stop within the first half of its life
@@ -95,7 +98,7 @@ void tst_qsgfriction::test_basic()
         QCOMPARE(d->lifeSpan, 0.5f);
         QCOMPARE(d->size, 32.f);
         QCOMPARE(d->endSize, 32.f);
-        QVERIFY(d->t <= ((qreal)system->timeInt/1000.0));
+        QVERIFY(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0)));
     }
 }
 
index e30d261..4758094 100644 (file)
@@ -42,6 +42,7 @@
 #include <QtTest/QtTest>
 #include "../shared/particlestestsshared.h"
 #include <private/qsgparticlesystem_p.h>
+#include <private/qabstractanimation_p.h>
 
 class tst_qsggravity : public QObject
 {
@@ -55,12 +56,14 @@ private slots:
 
 tst_qsggravity::tst_qsggravity()
 {
+    QUnifiedTimer::instance()->setConsistentTiming(true);
 }
 
 void tst_qsggravity::test_basic()
 {
     QSGView* view = createView(QCoreApplication::applicationDirPath() + "/data/basic.qml", 600);
     QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system");
+    ensureAnimTime(600, system->m_animation);
 
     QCOMPARE(system->groupData[0]->size(), 500);
     foreach (QSGParticleData *d, system->groupData[0]->data) {
@@ -72,7 +75,7 @@ void tst_qsggravity::test_basic()
         QCOMPARE(d->lifeSpan, 0.5f);
         QCOMPARE(d->size, 32.f);
         QCOMPARE(d->endSize, 32.f);
-        QVERIFY(d->t <= ((qreal)system->timeInt/1000.0));
+        QVERIFY(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0)));
     }
 }
 
index ee8a179..a416271 100644 (file)
@@ -42,6 +42,7 @@
 #include <QtTest/QtTest>
 #include "../shared/particlestestsshared.h"
 #include <private/qsgparticlesystem_p.h>
+#include <private/qabstractanimation_p.h>
 
 const double CONV_FACTOR = 0.017453292519943295;//Degrees to radians
 
@@ -61,12 +62,14 @@ private slots:
 
 tst_qsgimageparticle::tst_qsgimageparticle()
 {
+    QUnifiedTimer::instance()->setConsistentTiming(true);
 }
 
 void tst_qsgimageparticle::test_basic()
 {
     QSGView* view = createView(QCoreApplication::applicationDirPath() + "/data/basic.qml", 600);
     QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system");
+    ensureAnimTime(600, system->m_animation);
 
     QCOMPARE(system->groupData[0]->size(), 500);
     foreach (QSGParticleData *d, system->groupData[0]->data) {
@@ -82,7 +85,7 @@ void tst_qsgimageparticle::test_basic()
         QCOMPARE(d->lifeSpan, 0.5f);
         QCOMPARE(d->size, 32.f);
         QCOMPARE(d->endSize, 32.f);
-        QVERIFY(d->t <= ((qreal)system->timeInt/1000.0));
+        QVERIFY(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0)));
         QCOMPARE(d->color.r, (uchar)255);
         QCOMPARE(d->color.g, (uchar)255);
         QCOMPARE(d->color.b, (uchar)255);
@@ -109,6 +112,7 @@ void tst_qsgimageparticle::test_colored()
 {
     QSGView* view = createView(QCoreApplication::applicationDirPath() + "/data/colored.qml", 600);
     QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system");
+    ensureAnimTime(600, system->m_animation);
 
     QCOMPARE(system->groupData[0]->size(), 500);
     foreach (QSGParticleData *d, system->groupData[0]->data) {
@@ -124,7 +128,7 @@ void tst_qsgimageparticle::test_colored()
         QCOMPARE(d->lifeSpan, 0.5f);
         QCOMPARE(d->size, 32.f);
         QCOMPARE(d->endSize, 32.f);
-        QVERIFY(d->t <= ((qreal)system->timeInt/1000.0));
+        QVERIFY(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0)));
         QCOMPARE(d->color.r, (uchar)003);
         QCOMPARE(d->color.g, (uchar)002);
         QCOMPARE(d->color.b, (uchar)001);
@@ -151,6 +155,7 @@ void tst_qsgimageparticle::test_deformed()
 {
     QSGView* view = createView(QCoreApplication::applicationDirPath() + "/data/deformed.qml", 600);
     QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system");
+    ensureAnimTime(600, system->m_animation);
 
     QCOMPARE(system->groupData[0]->size(), 500);
     foreach (QSGParticleData *d, system->groupData[0]->data) {
@@ -166,7 +171,7 @@ void tst_qsgimageparticle::test_deformed()
         QCOMPARE(d->lifeSpan, 0.5f);
         QCOMPARE(d->size, 32.f);
         QCOMPARE(d->endSize, 32.f);
-        QVERIFY(d->t <= ((qreal)system->timeInt/1000.0));
+        QVERIFY(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0)));
         QCOMPARE(d->color.r, (uchar)255);
         QCOMPARE(d->color.g, (uchar)255);
         QCOMPARE(d->color.b, (uchar)255);
@@ -193,6 +198,7 @@ void tst_qsgimageparticle::test_tabled()
 {
     QSGView* view = createView(QCoreApplication::applicationDirPath() + "/data/tabled.qml", 600);
     QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system");
+    ensureAnimTime(600, system->m_animation);
 
     QCOMPARE(system->groupData[0]->size(), 500);
     foreach (QSGParticleData *d, system->groupData[0]->data) {
@@ -208,7 +214,7 @@ void tst_qsgimageparticle::test_tabled()
         QCOMPARE(d->lifeSpan, 0.5f);
         QCOMPARE(d->size, 32.f);
         QCOMPARE(d->endSize, 32.f);
-        QVERIFY(d->t <= ((qreal)system->timeInt/1000.0));
+        QVERIFY(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0)));
         QCOMPARE(d->color.r, (uchar)255);
         QCOMPARE(d->color.g, (uchar)255);
         QCOMPARE(d->color.b, (uchar)255);
@@ -236,6 +242,7 @@ void tst_qsgimageparticle::test_sprite()
 {
     QSGView* view = createView(QCoreApplication::applicationDirPath() + "/data/sprite.qml", 600);
     QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system");
+    ensureAnimTime(600, system->m_animation);
 
     QCOMPARE(system->groupData[0]->size(), 500);
     foreach (QSGParticleData *d, system->groupData[0]->data) {
@@ -251,7 +258,7 @@ void tst_qsgimageparticle::test_sprite()
         QCOMPARE(d->lifeSpan, 0.5f);
         QCOMPARE(d->size, 32.f);
         QCOMPARE(d->endSize, 32.f);
-        QVERIFY(d->t <= ((qreal)system->timeInt/1000.0));
+        QVERIFY(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0)));
         QCOMPARE(d->color.r, (uchar)255);
         QCOMPARE(d->color.g, (uchar)255);
         QCOMPARE(d->color.b, (uchar)255);
index f2307ed..e58ab83 100644 (file)
@@ -43,6 +43,7 @@
 #include "../shared/particlestestsshared.h"
 #include <private/qsgparticlesystem_p.h>
 #include <private/qsgimage_p.h>
+#include <private/qabstractanimation_p.h>
 
 class tst_qsgitemparticle : public QObject
 {
@@ -56,12 +57,14 @@ private slots:
 
 tst_qsgitemparticle::tst_qsgitemparticle()
 {
+    QUnifiedTimer::instance()->setConsistentTiming(true);
 }
 
 void tst_qsgitemparticle::test_basic()
 {
     QSGView* view = createView(QCoreApplication::applicationDirPath() + "/data/basic.qml", 600);
     QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system");
+    ensureAnimTime(600, system->m_animation);
 
     QCOMPARE(system->groupData[0]->size(), 500);
     foreach (QSGParticleData *d, system->groupData[0]->data) {
@@ -77,10 +80,10 @@ void tst_qsgitemparticle::test_basic()
         QCOMPARE(d->lifeSpan, 0.5f);
         QCOMPARE(d->size, 32.f);
         QCOMPARE(d->endSize, 32.f);
-        QVERIFY(d->t <= ((qreal)system->timeInt/1000.0));
+        QVERIFY(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0)));
         if (d->t > ((qreal)system->timeInt/1000.0) - 0.05)//Delegates appear between frames, may miss the first couple
             continue;
-        if (d->t < ((qreal)system->timeInt/1000.0) - 0.5)//Delegates cleared on death
+        if (d->t < ((qreal)system->timeInt/1000.0) - 0.45)//Delegates cleared on death
             continue;
         QVERIFY(d->delegate);
         QVERIFY(qobject_cast<QSGImage*>(d->delegate));
index 2d43f7b..0f25f50 100644 (file)
@@ -42,6 +42,7 @@
 #include <QtTest/QtTest>
 #include "../shared/particlestestsshared.h"
 #include <private/qsgparticlesystem_p.h>
+#include <private/qabstractanimation_p.h>
 
 class tst_qsglineextruder : public QObject
 {
@@ -55,12 +56,14 @@ private slots:
 
 tst_qsglineextruder::tst_qsglineextruder()
 {
+    QUnifiedTimer::instance()->setConsistentTiming(true);
 }
 
 void tst_qsglineextruder::test_basic()
 {
     QSGView* view = createView(QCoreApplication::applicationDirPath() + "/data/basic.qml", 600);
     QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system");
+    ensureAnimTime(600, system->m_animation);
 
     QCOMPARE(system->groupData[0]->size(), 500);
     foreach (QSGParticleData *d, system->groupData[0]->data) {
@@ -75,7 +78,7 @@ void tst_qsglineextruder::test_basic()
         QCOMPARE(d->lifeSpan, 0.5f);
         QCOMPARE(d->size, 32.f);
         QCOMPARE(d->endSize, 32.f);
-        QVERIFY(d->t <= ((qreal)system->timeInt/1000.0));
+        QVERIFY(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0)));
     }
 
     QCOMPARE(system->groupData[1]->size(), 500);
@@ -91,7 +94,7 @@ void tst_qsglineextruder::test_basic()
         QCOMPARE(d->lifeSpan, 0.5f);
         QCOMPARE(d->size, 32.f);
         QCOMPARE(d->endSize, 32.f);
-        QVERIFY(d->t <= ((qreal)system->timeInt/1000.0));
+        QVERIFY(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0)));
     }
 }
 
index cdd5808..03070d8 100644 (file)
@@ -42,6 +42,7 @@
 #include <QtTest/QtTest>
 #include "../shared/particlestestsshared.h"
 #include <private/qsgparticlesystem_p.h>
+#include <private/qabstractanimation_p.h>
 
 class tst_qsgmaskextruder : public QObject
 {
@@ -55,12 +56,14 @@ private slots:
 
 tst_qsgmaskextruder::tst_qsgmaskextruder()
 {
+    QUnifiedTimer::instance()->setConsistentTiming(true);
 }
 
 void tst_qsgmaskextruder::test_basic()
 {
     QSGView* view = createView(QCoreApplication::applicationDirPath() + "/data/basic.qml", 600);
     QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system");
+    ensureAnimTime(600, system->m_animation);
 
     QCOMPARE(system->groupData[0]->size(), 500);
     foreach (QSGParticleData *d, system->groupData[0]->data) {
@@ -76,7 +79,7 @@ void tst_qsgmaskextruder::test_basic()
         QCOMPARE(d->lifeSpan, 0.5f);
         QCOMPARE(d->size, 32.f);
         QCOMPARE(d->endSize, 32.f);
-        QVERIFY(d->t <= ((qreal)system->timeInt/1000.0));
+        QVERIFY(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0)));
     }
 }
 
index fd1709b..49dc197 100644 (file)
@@ -42,6 +42,7 @@
 #include <QtTest/QtTest>
 #include "../shared/particlestestsshared.h"
 #include <private/qsgparticlesystem_p.h>
+#include <private/qabstractanimation_p.h>
 
 class tst_qsgparticlegroup : public QObject
 {
@@ -55,12 +56,14 @@ private slots:
 
 tst_qsgparticlegroup::tst_qsgparticlegroup()
 {
+    QUnifiedTimer::instance()->setConsistentTiming(true);
 }
 
 void tst_qsgparticlegroup::test_instantTransition()
 {
     QSGView* view = createView(QCoreApplication::applicationDirPath() + "/data/basic.qml", 600);
     QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system");
+    ensureAnimTime(600, system->m_animation);
 
     //A frame or two worth of particles will be missed, the transition doesn't take effect on the frame it's spawned (QTBUG-21781)
     QVERIFY(system->groupData[0]->size() <= 500 && system->groupData[0]->size() >= 450);
@@ -77,7 +80,7 @@ void tst_qsgparticlegroup::test_instantTransition()
         QCOMPARE(d->lifeSpan, 0.5f);
         QCOMPARE(d->size, 32.f);
         QCOMPARE(d->endSize, 32.f);
-        QVERIFY(d->t <= ((qreal)system->timeInt/1000.0));
+        QVERIFY(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0)));
     }
 }
 
index ade9ca9..9c6f299 100644 (file)
@@ -42,6 +42,7 @@
 #include <QtTest/QtTest>
 #include "../shared/particlestestsshared.h"
 #include <private/qsgparticlesystem_p.h>
+#include <private/qabstractanimation_p.h>
 
 class tst_qsgparticlesystem : public QObject
 {
@@ -55,12 +56,14 @@ private slots:
 
 tst_qsgparticlesystem::tst_qsgparticlesystem()
 {
+    QUnifiedTimer::instance()->setConsistentTiming(true);
 }
 
 void tst_qsgparticlesystem::test_basic()
 {
     QSGView* view = createView(QCoreApplication::applicationDirPath() + "/data/basic.qml", 600);
     QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system");
+    ensureAnimTime(600, system->m_animation);
 
     QCOMPARE(system->groupData[0]->size(), 500);
     int stillAlive = 0;
@@ -79,7 +82,7 @@ void tst_qsgparticlesystem::test_basic()
         QCOMPARE(d->lifeSpan, 0.5f);
         QCOMPARE(d->size, 32.f);
         QCOMPARE(d->endSize, 32.f);
-        QVERIFY(d->t <= ((qreal)system->timeInt/1000.0));
+        QVERIFY(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0)));
     }
     QVERIFY(extremelyFuzzyCompare(stillAlive, 500, 5));//Small simulation variance is permissible.
 }
index ef3b06a..9e4ff32 100644 (file)
@@ -42,6 +42,7 @@
 #include <QtTest/QtTest>
 #include "../shared/particlestestsshared.h"
 #include <private/qsgparticlesystem_p.h>
+#include <private/qabstractanimation_p.h>
 
 class tst_qsgpointattractor : public QObject
 {
@@ -55,12 +56,14 @@ private slots:
 
 tst_qsgpointattractor::tst_qsgpointattractor()
 {
+    QUnifiedTimer::instance()->setConsistentTiming(true);
 }
 
 void tst_qsgpointattractor::test_basic()
 {
     QSGView* view = createView(QCoreApplication::applicationDirPath() + "/data/basic.qml", 600);
     QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system");
+    ensureAnimTime(600, system->m_animation);
 
     QCOMPARE(system->groupData[0]->size(), 500);
     foreach (QSGParticleData *d, system->groupData[0]->data) {
@@ -77,7 +80,7 @@ void tst_qsgpointattractor::test_basic()
         QCOMPARE(d->lifeSpan, 0.5f);
         QCOMPARE(d->size, 32.f);
         QCOMPARE(d->endSize, 32.f);
-        QVERIFY(d->t <= ((qreal)system->timeInt/1000.0));
+        QVERIFY(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0)));
     }
 }
 
index 4752f1c..c6a3a2c 100644 (file)
@@ -42,6 +42,7 @@
 #include <QtTest/QtTest>
 #include "../shared/particlestestsshared.h"
 #include <private/qsgparticlesystem_p.h>
+#include <private/qabstractanimation_p.h>
 
 class tst_qsgpointdirection : public QObject
 {
@@ -55,12 +56,14 @@ private slots:
 
 tst_qsgpointdirection::tst_qsgpointdirection()
 {
+    QUnifiedTimer::instance()->setConsistentTiming(true);
 }
 
 void tst_qsgpointdirection::test_basic()
 {
     QSGView* view = createView(QCoreApplication::applicationDirPath() + "/data/basic.qml", 600);
     QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system");
+    ensureAnimTime(600, system->m_animation);
 
     QCOMPARE(system->groupData[0]->size(), 500);
     foreach (QSGParticleData *d, system->groupData[0]->data) {
@@ -78,7 +81,7 @@ void tst_qsgpointdirection::test_basic()
         QCOMPARE(d->lifeSpan, 0.5f);
         QCOMPARE(d->size, 32.f);
         QCOMPARE(d->endSize, 32.f);
-        QVERIFY(d->t <= ((qreal)system->timeInt/1000.0));
+        QVERIFY(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0)));
     }
 }
 
index b8cda61..e8c27aa 100644 (file)
@@ -42,6 +42,7 @@
 #include <QtTest/QtTest>
 #include "../shared/particlestestsshared.h"
 #include <private/qsgparticlesystem_p.h>
+#include <private/qabstractanimation_p.h>
 
 class tst_qsgrectangleextruder : public QObject
 {
@@ -55,12 +56,14 @@ private slots:
 
 tst_qsgrectangleextruder::tst_qsgrectangleextruder()
 {
+    QUnifiedTimer::instance()->setConsistentTiming(true);
 }
 
 void tst_qsgrectangleextruder::test_basic()
 {
     QSGView* view = createView(QCoreApplication::applicationDirPath() + "/data/basic.qml", 600);
     QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system");
+    ensureAnimTime(600, system->m_animation);
 
     QCOMPARE(system->groupData[0]->size(), 500);
     foreach (QSGParticleData *d, system->groupData[0]->data) {
@@ -78,7 +81,7 @@ void tst_qsgrectangleextruder::test_basic()
         QCOMPARE(d->lifeSpan, 0.5f);
         QCOMPARE(d->size, 32.f);
         QCOMPARE(d->endSize, 32.f);
-        QVERIFY(d->t <= ((qreal)system->timeInt/1000.0));
+        QVERIFY(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0)));
     }
 
     QCOMPARE(system->groupData[1]->size(), 500);
@@ -101,7 +104,7 @@ void tst_qsgrectangleextruder::test_basic()
         QCOMPARE(d->lifeSpan, 0.5f);
         QCOMPARE(d->size, 32.f);
         QCOMPARE(d->endSize, 32.f);
-        QVERIFY(d->t <= ((qreal)system->timeInt/1000.0));
+        QVERIFY(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0)));
     }
 }
 
index 0f37fc0..decc961 100644 (file)
@@ -42,6 +42,7 @@
 #include <QtTest/QtTest>
 #include "../shared/particlestestsshared.h"
 #include <private/qsgparticlesystem_p.h>
+#include <private/qabstractanimation_p.h>
 
 class tst_qsgtargetdirection : public QObject
 {
@@ -55,12 +56,14 @@ private slots:
 
 tst_qsgtargetdirection::tst_qsgtargetdirection()
 {
+    QUnifiedTimer::instance()->setConsistentTiming(true);
 }
 
 void tst_qsgtargetdirection::test_basic()
 {
     QSGView* view = createView(QCoreApplication::applicationDirPath() + "/data/basic.qml", 600);
     QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system");
+    ensureAnimTime(600, system->m_animation);
 
     QCOMPARE(system->groupData[0]->size(), 500);
     foreach (QSGParticleData *d, system->groupData[0]->data) {
@@ -76,7 +79,7 @@ void tst_qsgtargetdirection::test_basic()
         QCOMPARE(d->lifeSpan, 0.5f);
         QCOMPARE(d->size, 32.f);
         QCOMPARE(d->endSize, 32.f);
-        QVERIFY(d->t <= ((qreal)system->timeInt/1000.0));
+        QVERIFY(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0)));
     }
 }
 
index 29e9d90..e24c63c 100644 (file)
@@ -42,6 +42,7 @@
 #include <QtTest/QtTest>
 #include "../shared/particlestestsshared.h"
 #include <private/qsgparticlesystem_p.h>
+#include <private/qabstractanimation_p.h>
 
 class tst_qsgtrailemitter : public QObject
 {
@@ -55,12 +56,14 @@ private slots:
 
 tst_qsgtrailemitter::tst_qsgtrailemitter()
 {
+    QUnifiedTimer::instance()->setConsistentTiming(true);
 }
 
 void tst_qsgtrailemitter::test_basic()
 {
     QSGView* view = createView(QCoreApplication::applicationDirPath() + "/data/basic.qml", 600);
     QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system");
+    ensureAnimTime(600, system->m_animation);
 
     QCOMPARE(system->groupData[0]->size(), 500);
     foreach (QSGParticleData *d, system->groupData[0]->data) {
@@ -76,7 +79,7 @@ void tst_qsgtrailemitter::test_basic()
         QCOMPARE(d->lifeSpan, 0.5f);
         QCOMPARE(d->size, 32.f);
         QCOMPARE(d->endSize, 32.f);
-        QVERIFY(d->t <= ((qreal)system->timeInt/1000.0));
+        QVERIFY(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0)));
     }
 
     QCOMPARE(system->groupData[1]->size(), 500);
@@ -93,7 +96,7 @@ void tst_qsgtrailemitter::test_basic()
         QCOMPARE(d->lifeSpan, 0.5f);
         QCOMPARE(d->size, 32.f);
         QCOMPARE(d->endSize, 32.f);
-        QVERIFY(d->t <= ((qreal)system->timeInt/1000.0));
+        QVERIFY(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0)));
     }
 }
 
index 155b109..4230bc5 100644 (file)
@@ -42,6 +42,7 @@
 #include <QtTest/QtTest>
 #include "../shared/particlestestsshared.h"
 #include <private/qsgparticlesystem_p.h>
+#include <private/qabstractanimation_p.h>
 
 class tst_qsgturbulence : public QObject
 {
@@ -55,12 +56,14 @@ private slots:
 
 tst_qsgturbulence::tst_qsgturbulence()
 {
+    QUnifiedTimer::instance()->setConsistentTiming(true);
 }
 
 void tst_qsgturbulence::test_basic()
 {
     QSGView* view = createView(QCoreApplication::applicationDirPath() + "/data/basic.qml", 600);
     QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system");
+    ensureAnimTime(600, system->m_animation);
 
     //Note that the noise image built-in provides the 'randomness', so this test should be stable so long as it and the size
     //of the Turbulence item remain the same
@@ -74,7 +77,7 @@ void tst_qsgturbulence::test_basic()
         QCOMPARE(d->lifeSpan, 0.5f);
         QCOMPARE(d->size, 32.f);
         QCOMPARE(d->endSize, 32.f);
-        QVERIFY(d->t <= ((qreal)system->timeInt/1000.0));
+        QVERIFY(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0)));
     }
 }
 
index 0a73248..b200b6f 100644 (file)
@@ -42,6 +42,7 @@
 #include <QtTest/QtTest>
 #include "../shared/particlestestsshared.h"
 #include <private/qsgparticlesystem_p.h>
+#include <private/qabstractanimation_p.h>
 
 class tst_qsgwander : public QObject
 {
@@ -55,12 +56,14 @@ private slots:
 
 tst_qsgwander::tst_qsgwander()
 {
+    QUnifiedTimer::instance()->setConsistentTiming(true);
 }
 
 void tst_qsgwander::test_basic()
 {
     QSGView* view = createView(QCoreApplication::applicationDirPath() + "/data/basic.qml", 600);
     QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system");
+    ensureAnimTime(600, system->m_animation);
 
     QCOMPARE(system->groupData[0]->size(), 500);
     //Since Wander is random perturbations, the compromise between stability and actual testing is to hope that one of
@@ -76,7 +79,7 @@ void tst_qsgwander::test_basic()
         QCOMPARE(d->lifeSpan, 0.5f);
         QCOMPARE(d->size, 32.f);
         QCOMPARE(d->endSize, 32.f);
-        QVERIFY(d->t <= ((qreal)system->timeInt/1000.0));
+        QVERIFY(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0)));
         if (d->vx != 0.0f)
             vxChanged = true;
         if (d->vy != 0.0f)
index 66e880f..ed483ba 100644 (file)
@@ -43,6 +43,7 @@
 #define PARTICLES_TESTS_SHARED
 #include <QSGView>
 #include <QtTest>
+#include <QAbstractAnimation>
 const qreal EPSILON = 0.0001;
 
 bool extremelyFuzzyCompare(qreal a, qreal b, qreal e)//For cases which can have larger variances
@@ -80,4 +81,10 @@ QSGView* createView(const QString &filename, int additionalWait=0)
     return canvas;
 }
 
+void ensureAnimTime(int requiredTime, QAbstractAnimation* anim)//With consistentTiming, who knows how long an animation really takes...
+{
+    while (anim->currentTime() < requiredTime)
+        QTest::qWait(100);
+}
+
 #endif