Stabilize Particles tests some more
authorAlan Alpert <alan.alpert@nokia.com>
Mon, 31 Oct 2011 01:47:13 +0000 (11:47 +1000)
committerQt by Nokia <qt-info@nokia.com>
Mon, 31 Oct 2011 03:29:03 +0000 (04:29 +0100)
Odd timings can lead to slight variances in the particle groups size,
this is allowable in autotests. Also fixes incorrect use of
extremelyFuzzyCompare in tst_qquickage.

Change-Id: Ibea3a2b2a3a31ab1fe6d908c1676d865db9ba968
Reviewed-by: Martin Jones <martin.jones@nokia.com>
20 files changed:
tests/auto/particles/qquickage/tst_qquickage.cpp
tests/auto/particles/qquickangleddirection/tst_qquickangleddirection.cpp
tests/auto/particles/qquickcumulativedirection/tst_qquickcumulativedirection.cpp
tests/auto/particles/qquickcustomaffector/tst_qquickcustomaffector.cpp
tests/auto/particles/qquickcustomparticle/tst_qquickcustomparticle.cpp
tests/auto/particles/qquickellipseextruder/tst_qquickellipseextruder.cpp
tests/auto/particles/qquickfriction/tst_qquickfriction.cpp
tests/auto/particles/qquickgravity/tst_qquickgravity.cpp
tests/auto/particles/qquickimageparticle/tst_qquickimageparticle.cpp
tests/auto/particles/qquickitemparticle/tst_qquickitemparticle.cpp
tests/auto/particles/qquicklineextruder/tst_qquicklineextruder.cpp
tests/auto/particles/qquickmaskextruder/tst_qquickmaskextruder.cpp
tests/auto/particles/qquickparticlesystem/tst_qquickparticlesystem.cpp
tests/auto/particles/qquickpointattractor/tst_qquickpointattractor.cpp
tests/auto/particles/qquickpointdirection/tst_qquickpointdirection.cpp
tests/auto/particles/qquickrectangleextruder/tst_qquickrectangleextruder.cpp
tests/auto/particles/qquicktargetdirection/tst_qquicktargetdirection.cpp
tests/auto/particles/qquicktrailemitter/tst_qquicktrailemitter.cpp
tests/auto/particles/qquickturbulence/tst_qquickturbulence.cpp
tests/auto/particles/qquickwander/tst_qquickwander.cpp

index 73db409..74cd297 100644 (file)
@@ -68,7 +68,7 @@ void tst_qquickage::test_kill()
     QQuickParticleSystem* system = view->rootObject()->findChild<QQuickParticleSystem*>("system");
     ensureAnimTime(600, system->m_animation);
 
-    QCOMPARE(system->groupData[0]->size(), 500);
+    QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
     foreach (QQuickParticleData *d, system->groupData[0]->data) {
         if (d->t == -1)
             continue; //Particle data unused
@@ -92,14 +92,14 @@ void tst_qquickage::test_jump()
     QQuickParticleSystem* system = view->rootObject()->findChild<QQuickParticleSystem*>("system");
     ensureAnimTime(600, system->m_animation);
 
-    QCOMPARE(system->groupData[0]->size(), 500);
+    QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
     foreach (QQuickParticleData *d, system->groupData[0]->data) {
         if (d->t == -1)
             continue; //Particle data unused
 
-        //Allow for a small variance because jump is trying to simulate off wall time
-        extremelyFuzzyCompare(d->x, -100.f, 5.0f);
-        extremelyFuzzyCompare(d->y, -100.f, 5.0f);
+        //Allow for variance because jump is trying to simulate off wall time and things have emitted 'continuously' before first affect
+        QVERIFY(d->x <= -50.f);
+        QVERIFY(d->y <= -50.f);
         QCOMPARE(d->vx, 500.f);
         QCOMPARE(d->vy, 500.f);
         QCOMPARE(d->ax, 0.f);
@@ -117,7 +117,7 @@ void tst_qquickage::test_onceOff()
     QQuickParticleSystem* system = view->rootObject()->findChild<QQuickParticleSystem*>("system");
     ensureAnimTime(600, system->m_animation);
 
-    QCOMPARE(system->groupData[0]->size(), 500);
+    QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
     foreach (QQuickParticleData *d, system->groupData[0]->data) {
         if (d->t == -1)
             continue; //Particle data unused
@@ -142,7 +142,7 @@ void tst_qquickage::test_sustained()
     ensureAnimTime(600, system->m_animation);
     //TODO: Ensure some particles have lived to 0.4s point despite unified timer
 
-    QCOMPARE(system->groupData[0]->size(), 500);
+    QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
     foreach (QQuickParticleData *d, system->groupData[0]->data) {
         if (d->t == -1)
             continue; //Particle data unused
index d21753e..5310d14 100644 (file)
@@ -66,7 +66,7 @@ void tst_qquickangleddirection::test_basic()
     QQuickParticleSystem* system = view->rootObject()->findChild<QQuickParticleSystem*>("system");
     ensureAnimTime(600, system->m_animation);
 
-    QCOMPARE(system->groupData[0]->size(), 500);
+    QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
     foreach (QQuickParticleData *d, system->groupData[0]->data) {
         if (d->t == -1)
             continue; //Particle data unused
index 052578f..eeecbe4 100644 (file)
@@ -65,7 +65,7 @@ void tst_qquickcumulativedirection::test_basic()
     QQuickParticleSystem* system = view->rootObject()->findChild<QQuickParticleSystem*>("system");
     ensureAnimTime(600, system->m_animation);
 
-    QCOMPARE(system->groupData[0]->size(), 500);
+    QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
     foreach (QQuickParticleData *d, system->groupData[0]->data) {
         if (d->t == -1)
             continue; //Particle data unused
index 77b1d09..4fd23db 100644 (file)
@@ -66,7 +66,7 @@ void tst_qquickcustomaffector::test_basic()
     QQuickParticleSystem* system = view->rootObject()->findChild<QQuickParticleSystem*>("system");
     ensureAnimTime(600, system->m_animation);
 
-    QCOMPARE(system->groupData[0]->size(), 500);
+    QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
     foreach (QQuickParticleData *d, system->groupData[0]->data) {
         if (d->t == -1)
             continue; //Particle data unused
@@ -90,7 +90,7 @@ void tst_qquickcustomaffector::test_move()
     QQuickParticleSystem* system = view->rootObject()->findChild<QQuickParticleSystem*>("system");
     ensureAnimTime(600, system->m_animation);
 
-    QCOMPARE(system->groupData[0]->size(), 500);
+    QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
     foreach (QQuickParticleData *d, system->groupData[0]->data) {
         if (d->t == -1)
             continue; //Particle data unused
index 3c73fad..9333ac4 100644 (file)
@@ -67,7 +67,7 @@ void tst_qquickcustomparticle::test_basic()
     ensureAnimTime(600, system->m_animation);
 
     bool oneNonZero = false;
-    QCOMPARE(system->groupData[0]->size(), 500);
+    QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
     foreach (QQuickParticleData *d, system->groupData[0]->data) {
         if (d->t == -1)
             continue; //Particle data unused
index 7f412c8..ea2139c 100644 (file)
@@ -82,7 +82,7 @@ void tst_qquickellipseextruder::test_basic()
     ensureAnimTime(600, system->m_animation);
 
     //Filled
-    QCOMPARE(system->groupData[0]->size(), 500);
+    QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
     foreach (QQuickParticleData *d, system->groupData[0]->data) {
         if (d->t == -1)
             continue; //Particle data unused
index aca4ea2..c9070cf 100644 (file)
@@ -67,7 +67,7 @@ void tst_qquickfriction::test_basic()
     ensureAnimTime(600, system->m_animation);
 
     //Default is just slowed a little
-    QCOMPARE(system->groupData[0]->size(), 500);
+    QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
     foreach (QQuickParticleData *d, system->groupData[0]->data) {
         if (d->t == -1)
             continue; //Particle data unused
@@ -110,7 +110,7 @@ void tst_qquickfriction::test_threshold()
     ensureAnimTime(600, system->m_animation);
 
     //Speed capped at 50, but it might take a frame or two to get there
-    QCOMPARE(system->groupData[0]->size(), 500);
+    QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
     foreach (QQuickParticleData *d, system->groupData[0]->data) {
         if (d->t == -1.0f)
             continue; //Particle data unused
index 5613591..41c63de 100644 (file)
@@ -65,7 +65,7 @@ void tst_qquickgravity::test_basic()
     QQuickParticleSystem* system = view->rootObject()->findChild<QQuickParticleSystem*>("system");
     ensureAnimTime(600, system->m_animation);
 
-    QCOMPARE(system->groupData[0]->size(), 500);
+    QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
     foreach (QQuickParticleData *d, system->groupData[0]->data) {
         if (d->t == -1)
             continue; //Particle data unused
index e56de35..45f7123 100644 (file)
@@ -71,7 +71,7 @@ void tst_qquickimageparticle::test_basic()
     QQuickParticleSystem* system = view->rootObject()->findChild<QQuickParticleSystem*>("system");
     ensureAnimTime(600, system->m_animation);
 
-    QCOMPARE(system->groupData[0]->size(), 500);
+    QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
     foreach (QQuickParticleData *d, system->groupData[0]->data) {
         if (d->t == -1)
             continue; //Particle data unused
@@ -114,7 +114,7 @@ void tst_qquickimageparticle::test_colored()
     QQuickParticleSystem* system = view->rootObject()->findChild<QQuickParticleSystem*>("system");
     ensureAnimTime(600, system->m_animation);
 
-    QCOMPARE(system->groupData[0]->size(), 500);
+    QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
     foreach (QQuickParticleData *d, system->groupData[0]->data) {
         if (d->t == -1)
             continue; //Particle data unused
@@ -157,7 +157,7 @@ void tst_qquickimageparticle::test_deformed()
     QQuickParticleSystem* system = view->rootObject()->findChild<QQuickParticleSystem*>("system");
     ensureAnimTime(600, system->m_animation);
 
-    QCOMPARE(system->groupData[0]->size(), 500);
+    QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
     foreach (QQuickParticleData *d, system->groupData[0]->data) {
         if (d->t == -1)
             continue; //Particle data unused
@@ -200,7 +200,7 @@ void tst_qquickimageparticle::test_tabled()
     QQuickParticleSystem* system = view->rootObject()->findChild<QQuickParticleSystem*>("system");
     ensureAnimTime(600, system->m_animation);
 
-    QCOMPARE(system->groupData[0]->size(), 500);
+    QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
     foreach (QQuickParticleData *d, system->groupData[0]->data) {
         if (d->t == -1)
             continue; //Particle data unused
@@ -244,7 +244,7 @@ void tst_qquickimageparticle::test_sprite()
     QQuickParticleSystem* system = view->rootObject()->findChild<QQuickParticleSystem*>("system");
     ensureAnimTime(600, system->m_animation);
 
-    QCOMPARE(system->groupData[0]->size(), 500);
+    QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
     foreach (QQuickParticleData *d, system->groupData[0]->data) {
         if (d->t == -1)
             continue; //Particle data unused
index 40197ec..c681e2c 100644 (file)
@@ -66,7 +66,7 @@ void tst_qquickitemparticle::test_basic()
     QQuickParticleSystem* system = view->rootObject()->findChild<QQuickParticleSystem*>("system");
     ensureAnimTime(600, system->m_animation);
 
-    QCOMPARE(system->groupData[0]->size(), 500);
+    QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
     foreach (QQuickParticleData *d, system->groupData[0]->data) {
         if (d->t == -1)
             continue; //Particle data unused
index ff45a9e..4929d02 100644 (file)
@@ -65,7 +65,7 @@ void tst_qquicklineextruder::test_basic()
     QQuickParticleSystem* system = view->rootObject()->findChild<QQuickParticleSystem*>("system");
     ensureAnimTime(600, system->m_animation);
 
-    QCOMPARE(system->groupData[0]->size(), 500);
+    QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
     foreach (QQuickParticleData *d, system->groupData[0]->data) {
         if (d->t == -1)
             continue; //Particle data unused
index b2a178f..5d154d7 100644 (file)
@@ -65,7 +65,7 @@ void tst_qquickmaskextruder::test_basic()
     QQuickParticleSystem* system = view->rootObject()->findChild<QQuickParticleSystem*>("system");
     ensureAnimTime(600, system->m_animation);
 
-    QCOMPARE(system->groupData[0]->size(), 500);
+    QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
     foreach (QQuickParticleData *d, system->groupData[0]->data) {
         if (d->t == -1)
             continue; //Particle data unused
index b85c57d..d0e4727 100644 (file)
@@ -65,7 +65,7 @@ void tst_qquickparticlesystem::test_basic()
     QQuickParticleSystem* system = view->rootObject()->findChild<QQuickParticleSystem*>("system");
     ensureAnimTime(600, system->m_animation);
 
-    QCOMPARE(system->groupData[0]->size(), 500);
+    QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
     int stillAlive = 0;
     foreach (QQuickParticleData *d, system->groupData[0]->data) {
         if (d->t == -1)
index 6a64f91..a0c1b65 100644 (file)
@@ -65,7 +65,7 @@ void tst_qquickpointattractor::test_basic()
     QQuickParticleSystem* system = view->rootObject()->findChild<QQuickParticleSystem*>("system");
     ensureAnimTime(600, system->m_animation);
 
-    QCOMPARE(system->groupData[0]->size(), 500);
+    QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
     foreach (QQuickParticleData *d, system->groupData[0]->data) {
         if (d->t == -1)
             continue; //Particle data unused
index 19cc471..0b83a41 100644 (file)
@@ -65,7 +65,7 @@ void tst_qquickpointdirection::test_basic()
     QQuickParticleSystem* system = view->rootObject()->findChild<QQuickParticleSystem*>("system");
     ensureAnimTime(600, system->m_animation);
 
-    QCOMPARE(system->groupData[0]->size(), 500);
+    QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
     foreach (QQuickParticleData *d, system->groupData[0]->data) {
         if (d->t == -1)
             continue; //Particle data unused
index 6fb2e9c..8e92e8e 100644 (file)
@@ -65,7 +65,7 @@ void tst_qquickrectangleextruder::test_basic()
     QQuickParticleSystem* system = view->rootObject()->findChild<QQuickParticleSystem*>("system");
     ensureAnimTime(600, system->m_animation);
 
-    QCOMPARE(system->groupData[0]->size(), 500);
+    QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
     foreach (QQuickParticleData *d, system->groupData[0]->data) {
         if (d->t == -1)
             continue; //Particle data unused
index 7d83ae8..6e21aef 100644 (file)
@@ -65,7 +65,7 @@ void tst_qquicktargetdirection::test_basic()
     QQuickParticleSystem* system = view->rootObject()->findChild<QQuickParticleSystem*>("system");
     ensureAnimTime(600, system->m_animation);
 
-    QCOMPARE(system->groupData[0]->size(), 500);
+    QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
     foreach (QQuickParticleData *d, system->groupData[0]->data) {
         if (d->t == -1)
             continue; //Particle data unused
index 6325ca6..d5e01a6 100644 (file)
@@ -65,7 +65,7 @@ void tst_qquicktrailemitter::test_basic()
     QQuickParticleSystem* system = view->rootObject()->findChild<QQuickParticleSystem*>("system");
     ensureAnimTime(600, system->m_animation);
 
-    QCOMPARE(system->groupData[0]->size(), 500);
+    QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
     foreach (QQuickParticleData *d, system->groupData[0]->data) {
         if (d->t == -1)
             continue; //Particle data unused
index 29faec2..519307e 100644 (file)
@@ -67,7 +67,7 @@ void tst_qquickturbulence::test_basic()
 
     //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
-    QCOMPARE(system->groupData[0]->size(), 500);
+    QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
     foreach (QQuickParticleData *d, system->groupData[0]->data) {
         if (d->t == -1)
             continue; //Particle data unused
index 41f09d4..54aded8 100644 (file)
@@ -65,7 +65,7 @@ void tst_qquickwander::test_basic()
     QQuickParticleSystem* system = view->rootObject()->findChild<QQuickParticleSystem*>("system");
     ensureAnimTime(600, system->m_animation);
 
-    QCOMPARE(system->groupData[0]->size(), 500);
+    QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
     //Since Wander is random perturbations, the compromise between stability and actual testing is to hope that one of
     //the 500 was randomly changed from 0.0 in velocity
     bool vxChanged = false;