Rename speed -> velocity in the particle system
[profile/ivi/qtdeclarative.git] / tests / auto / particles / qquickfriction / tst_qquickfriction.cpp
index aca4ea2..2beccd7 100644 (file)
@@ -1,8 +1,7 @@
 /****************************************************************************
 **
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
 **
 ** This file is part of the test suite of the Qt Toolkit.
 **
@@ -35,6 +34,7 @@
 **
 **
 **
+**
 ** $QT_END_LICENSE$
 **
 ****************************************************************************/
 #include <private/qquickparticlesystem_p.h>
 #include <private/qabstractanimation_p.h>
 
-class tst_qquickfriction : public QObject
+#include "../../shared/util.h"
+
+class tst_qquickfriction : public QQmlDataTest
 {
     Q_OBJECT
 public:
-    tst_qquickfriction();
+    tst_qquickfriction() {}
 
 private slots:
+    void initTestCase();
     void test_basic();
     void test_threshold();
 };
 
-tst_qquickfriction::tst_qquickfriction()
+void tst_qquickfriction::initTestCase()
 {
+    QQmlDataTest::initTestCase();
     QUnifiedTimer::instance()->setConsistentTiming(true);
 }
 
 void tst_qquickfriction::test_basic()
 {
-    QQuickView* view = createView(QCoreApplication::applicationDirPath() + "/data/basic.qml", 600);
+    QQuickView* view = createView(testFileUrl("basic.qml"), 600);
     QQuickParticleSystem* system = view->rootObject()->findChild<QQuickParticleSystem*>("system");
     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
@@ -101,16 +105,17 @@ void tst_qquickfriction::test_basic()
         QCOMPARE(d->endSize, 32.f);
         QVERIFY(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0)));
     }
+    delete view;
 }
 
 void tst_qquickfriction::test_threshold()
 {
-    QQuickView* view = createView(QCoreApplication::applicationDirPath() + "/data/threshold.qml", 600);
+    QQuickView* view = createView(testFileUrl("threshold.qml"), 600);
     QQuickParticleSystem* system = view->rootObject()->findChild<QQuickParticleSystem*>("system");
     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);
+    //Velocity capped at 50, but it might take a frame or two to get there
+    QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
     foreach (QQuickParticleData *d, system->groupData[0]->data) {
         if (d->t == -1.0f)
             continue; //Particle data unused
@@ -127,6 +132,7 @@ void tst_qquickfriction::test_threshold()
         QCOMPARE(d->endSize, 32.f);
         QVERIFY(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0)));
     }
+    delete view;
 }
 
 QTEST_MAIN(tst_qquickfriction);