/****************************************************************************
**
-** 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.
**
**
**
**
+**
** $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
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
QCOMPARE(d->endSize, 32.f);
QVERIFY(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0)));
}
+ delete view;
}
QTEST_MAIN(tst_qquickfriction);