diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2011-09-30 18:25:17 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-10-03 04:53:54 +0200 |
commit | e59fbf997ece61b36180eb21f9c2cd6ea895b88f (patch) | |
tree | c4d206ea4eadaf33b1ed0cbe1a9c5baae6fbd33f /tests/auto/particles | |
parent | 69e925444ecebd352462f742d894b326d4cc9a72 (diff) |
Initial commit of particle system autotests
Just some basic autotests for most of the elements.
Change-Id: I2d289f38f362a38c69e03ff92154c98db3c4c486
Reviewed-on: http://codereview.qt-project.org/5844
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests/auto/particles')
69 files changed, 3949 insertions, 0 deletions
diff --git a/tests/auto/particles/qsgage/data/jump.qml b/tests/auto/particles/qsgage/data/jump.qml new file mode 100644 index 0000000000..e66f9f4950 --- /dev/null +++ b/tests/auto/particles/qsgage/data/jump.qml @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + color: "black" + width: 320 + height: 320 + + ParticleSystem { + id: sys + objectName: "system" + anchors.fill: parent + + Age { + once: true + advancePosition: false + lifeLeft: 100 + } + + ImageParticle { source: "../../shared/star.png" } + Emitter { + //0,0 position + size: 32 + emitRate: 1000 + lifeSpan: 500 + speed: PointDirection{ x: 500; y: 500 } + } + } +} diff --git a/tests/auto/particles/qsgage/data/kill.qml b/tests/auto/particles/qsgage/data/kill.qml new file mode 100644 index 0000000000..2558435e60 --- /dev/null +++ b/tests/auto/particles/qsgage/data/kill.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + color: "black" + width: 320 + height: 320 + + ParticleSystem { + id: sys + objectName: "system" + anchors.fill: parent + + Age {} + + ImageParticle { source: "../../shared/star.png" } + Emitter{ + //0,0 position + size: 32 + emitRate: 1000 + lifeSpan: 500 + speed: PointDirection{ x: 1000; y: 1000 } + } + } +} diff --git a/tests/auto/particles/qsgage/data/onceoff.qml b/tests/auto/particles/qsgage/data/onceoff.qml new file mode 100644 index 0000000000..15d0e123b4 --- /dev/null +++ b/tests/auto/particles/qsgage/data/onceoff.qml @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + color: "black" + width: 320 + height: 320 + + ParticleSystem { + id: sys + objectName: "system" + anchors.fill: parent + + Age { + once: true + lifeLeft: 100 + } + + ImageParticle { source: "../../shared/star.png" } + Emitter{ + //0,0 position + size: 32 + emitRate: 1000 + lifeSpan: 500 + speed: PointDirection{ x: 500; y: 500 } + } + } +} diff --git a/tests/auto/particles/qsgage/data/sustained.qml b/tests/auto/particles/qsgage/data/sustained.qml new file mode 100644 index 0000000000..96aefec3dc --- /dev/null +++ b/tests/auto/particles/qsgage/data/sustained.qml @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + color: "black" + width: 320 + height: 320 + + ParticleSystem { + id: sys + objectName: "system" + anchors.fill: parent + + Age { + once: false + lifeLeft: 100 + } + + ImageParticle { source: "../../shared/star.png" } + Emitter{ + //0,0 position + size: 32 + emitRate: 1000 + lifeSpan: 500 + speed: PointDirection{ x: 500; y: 500 } + } + } +} diff --git a/tests/auto/particles/qsgage/qsgage.pro b/tests/auto/particles/qsgage/qsgage.pro new file mode 100644 index 0000000000..3ca07403fe --- /dev/null +++ b/tests/auto/particles/qsgage/qsgage.pro @@ -0,0 +1,11 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +SOURCES += tst_qsgage.cpp +macx:CONFIG -= app_bundle + +DEFINES += SRCDIR=\\\"$$PWD\\\" + +CONFIG += parallel_test + +QT += core-private gui-private v8-private declarative-private opengl-private + diff --git a/tests/auto/particles/qsgage/tst_qsgage.cpp b/tests/auto/particles/qsgage/tst_qsgage.cpp new file mode 100644 index 0000000000..884c210455 --- /dev/null +++ b/tests/auto/particles/qsgage/tst_qsgage.cpp @@ -0,0 +1,150 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include "../shared/particlestestsshared.h" +#include <private/qsgparticlesystem_p.h> + +class tst_qsgage : public QObject +{ + Q_OBJECT +public: + tst_qsgage(); + +private slots: + void test_kill(); + void test_jump(); + void test_onceOff(); + void test_sustained(); +}; + +tst_qsgage::tst_qsgage() +{ +} + +void tst_qsgage::test_kill() +{ + QSGView* view = createView(SRCDIR "/data/kill.qml", 600); + QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system"); + + QCOMPARE(system->groupData[0]->size(), 500); + foreach (QSGParticleData *d, system->groupData[0]->data) { + QCOMPARE(d->x, 0.f); + QCOMPARE(d->y, 0.f); + QCOMPARE(d->vx, 1000.f); + QCOMPARE(d->vy, 1000.f); + QCOMPARE(d->ax, 0.f); + QCOMPARE(d->ay, 0.f); + QCOMPARE(d->lifeSpan, 0.5f); + QCOMPARE(d->size, 32.f); + QCOMPARE(d->endSize, 32.f); + QVERIFY(d->t <= ((qreal)system->timeInt/1000.0) - 0.5f + EPSILON); + } +} + +void tst_qsgage::test_jump() +{ + QSGView* view = createView(SRCDIR "/data/jump.qml", 600); + QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system"); + + QCOMPARE(system->groupData[0]->size(), 500); + foreach (QSGParticleData *d, system->groupData[0]->data) { + //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); + QCOMPARE(d->vx, 500.f); + QCOMPARE(d->vy, 500.f); + QCOMPARE(d->ax, 0.f); + QCOMPARE(d->ay, 0.f); + QCOMPARE(d->lifeSpan, 0.5f); + QCOMPARE(d->size, 32.f); + QCOMPARE(d->endSize, 32.f); + QVERIFY(d->t <= ((qreal)system->timeInt/1000.0) - 0.4f + EPSILON); + } +} + +void tst_qsgage::test_onceOff() +{ + QSGView* view = createView(SRCDIR "/data/onceoff.qml", 600); + QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system"); + + QCOMPARE(system->groupData[0]->size(), 500); + foreach (QSGParticleData *d, system->groupData[0]->data) { + if (d->t == -1) + continue; //Recycling process means not all initialized/used + QCOMPARE(d->x, 0.f); + QCOMPARE(d->y, 0.f); + QCOMPARE(d->vx, 500.f); + QCOMPARE(d->vy, 500.f); + QCOMPARE(d->ax, 0.f); + QCOMPARE(d->ay, 0.f); + QCOMPARE(d->lifeSpan, 0.5f); + QCOMPARE(d->size, 32.f); + QCOMPARE(d->endSize, 32.f); + QVERIFY(d->t <= ((qreal)system->timeInt/1000.0) - 0.4f + EPSILON); + } +} + +void tst_qsgage::test_sustained() +{ + QSGView* view = createView(SRCDIR "/data/sustained.qml", 600); + QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system"); + + QCOMPARE(system->groupData[0]->size(), 500); + foreach (QSGParticleData *d, system->groupData[0]->data) { + if (d->t == -1) + continue; //Recycling process means not all initialized/used + QCOMPARE(d->x, 0.f); + QCOMPARE(d->y, 0.f); + QCOMPARE(d->vx, 500.f); + QCOMPARE(d->vy, 500.f); + QCOMPARE(d->ax, 0.f); + QCOMPARE(d->ay, 0.f); + QCOMPARE(d->lifeSpan, 0.5f); + QCOMPARE(d->size, 32.f); + QCOMPARE(d->endSize, 32.f); + QVERIFY(myFuzzyCompare(d->t, ((qreal)system->timeInt/1000.0) - 0.4f)); + } +} + +QTEST_MAIN(tst_qsgage); + +#include "tst_qsgage.moc" diff --git a/tests/auto/particles/qsgangleddirection/data/basic.qml b/tests/auto/particles/qsgangleddirection/data/basic.qml new file mode 100644 index 0000000000..c2fda56561 --- /dev/null +++ b/tests/auto/particles/qsgangleddirection/data/basic.qml @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + color: "black" + width: 320 + height: 320 + + ParticleSystem { + id: sys + objectName: "system" + anchors.fill: parent + + ImageParticle { + source: "../../shared/star.png" + } + + Emitter{ + //0,0 position + size: 32 + emitRate: 1000 + lifeSpan: 500 + speed: AngleDirection { angle: 45; magnitude: 500 } + acceleration: AngleDirection { angle: 45; angleVariation: 22; magnitude: 250; magnitudeVariation: 249} + } + } +} diff --git a/tests/auto/particles/qsgangleddirection/qsgangleddirection.pro b/tests/auto/particles/qsgangleddirection/qsgangleddirection.pro new file mode 100644 index 0000000000..a90b00bc57 --- /dev/null +++ b/tests/auto/particles/qsgangleddirection/qsgangleddirection.pro @@ -0,0 +1,11 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +SOURCES += tst_qsgangleddirection.cpp +macx:CONFIG -= app_bundle + +DEFINES += SRCDIR=\\\"$$PWD\\\" + +CONFIG += parallel_test + +QT += core-private gui-private v8-private declarative-private opengl-private + diff --git a/tests/auto/particles/qsgangleddirection/tst_qsgangleddirection.cpp b/tests/auto/particles/qsgangleddirection/tst_qsgangleddirection.cpp new file mode 100644 index 0000000000..0cc2c8b56b --- /dev/null +++ b/tests/auto/particles/qsgangleddirection/tst_qsgangleddirection.cpp @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include <qmath.h> +#include "../shared/particlestestsshared.h" +#include <private/qsgparticlesystem_p.h> + +class tst_qsgangleddirection : public QObject +{ + Q_OBJECT +public: + tst_qsgangleddirection(); + +private slots: + void test_basic(); +}; + +tst_qsgangleddirection::tst_qsgangleddirection() +{ +} + +void tst_qsgangleddirection::test_basic() +{ + QSGView* view = createView(SRCDIR "/data/basic.qml", 600); + QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system"); + + QCOMPARE(system->groupData[0]->size(), 500); + foreach (QSGParticleData *d, system->groupData[0]->data) { + QCOMPARE(d->x, 0.f); + QCOMPARE(d->y, 0.f); + QVERIFY(qFuzzyCompare(d->vx, 353.55339f)); + QVERIFY(qFuzzyCompare(d->vy, 353.55339f)); + QVERIFY(d->ax > 0.f); + QVERIFY(d->ax < 500.f); + QVERIFY(d->ay > 0.f); + QVERIFY(d->ay < 500.f); + QVERIFY(qSqrt(d->ax*d->ax + d->ay*d->ay) < 500.f); + QCOMPARE(d->lifeSpan, 0.5f); + QCOMPARE(d->size, 32.f); + QCOMPARE(d->endSize, 32.f); + QVERIFY(d->t <= ((qreal)system->timeInt/1000.0)); + } +} + +QTEST_MAIN(tst_qsgangleddirection); + +#include "tst_qsgangleddirection.moc" diff --git a/tests/auto/particles/qsgcumulativedirection/data/basic.qml b/tests/auto/particles/qsgcumulativedirection/data/basic.qml new file mode 100644 index 0000000000..bd46c4556f --- /dev/null +++ b/tests/auto/particles/qsgcumulativedirection/data/basic.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + color: "black" + width: 320 + height: 320 + + ParticleSystem { + id: sys + objectName: "system" + anchors.fill: parent + + ImageParticle { + source: "../../shared/star.png" + } + + Emitter{ + //0,0 position + size: 32 + emitRate: 1000 + lifeSpan: 500 + speed: CumulativeDirection { + PointDirection { x: 100; y: -100 } + PointDirection { x: -100; y: 100 } + } + acceleration: CumulativeDirection { + AngleDirection { angle: 0; magnitude: 100 } + AngleDirection { angle: 180; magnitude: 100 } + } + } + } +} diff --git a/tests/auto/particles/qsgcumulativedirection/qsgcumulativedirection.pro b/tests/auto/particles/qsgcumulativedirection/qsgcumulativedirection.pro new file mode 100644 index 0000000000..03d9ca21e6 --- /dev/null +++ b/tests/auto/particles/qsgcumulativedirection/qsgcumulativedirection.pro @@ -0,0 +1,11 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +SOURCES += tst_qsgcumulativedirection.cpp +macx:CONFIG -= app_bundle + +DEFINES += SRCDIR=\\\"$$PWD\\\" + +CONFIG += parallel_test + +QT += core-private gui-private v8-private declarative-private opengl-private + diff --git a/tests/auto/particles/qsgcumulativedirection/tst_qsgcumulativedirection.cpp b/tests/auto/particles/qsgcumulativedirection/tst_qsgcumulativedirection.cpp new file mode 100644 index 0000000000..0c54ad8490 --- /dev/null +++ b/tests/auto/particles/qsgcumulativedirection/tst_qsgcumulativedirection.cpp @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include "../shared/particlestestsshared.h" +#include <private/qsgparticlesystem_p.h> + +class tst_qsgcumulativedirection : public QObject +{ + Q_OBJECT +public: + tst_qsgcumulativedirection(); + +private slots: + void test_basic(); +}; + +tst_qsgcumulativedirection::tst_qsgcumulativedirection() +{ +} + +void tst_qsgcumulativedirection::test_basic() +{ + QSGView* view = createView(SRCDIR "/data/basic.qml", 600); + QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system"); + + QCOMPARE(system->groupData[0]->size(), 500); + foreach (QSGParticleData *d, system->groupData[0]->data) { + QVERIFY(myFuzzyCompare(d->x, 0.0f)); + QVERIFY(myFuzzyCompare(d->y, 0.0f)); + QVERIFY(myFuzzyCompare(d->vx, 0.0f)); + QVERIFY(myFuzzyCompare(d->vy, 0.0f)); + QVERIFY(myFuzzyCompare(d->ax, 0.0f)); + QVERIFY(myFuzzyCompare(d->ay, 0.0f)); + QCOMPARE(d->lifeSpan, 0.5f); + QCOMPARE(d->size, 32.f); + QCOMPARE(d->endSize, 32.f); + QVERIFY(d->t <= ((qreal)system->timeInt/1000.0)); + } +} + +QTEST_MAIN(tst_qsgcumulativedirection); + +#include "tst_qsgcumulativedirection.moc" diff --git a/tests/auto/particles/qsgcustomaffector/data/basic.qml b/tests/auto/particles/qsgcustomaffector/data/basic.qml new file mode 100644 index 0000000000..7371698026 --- /dev/null +++ b/tests/auto/particles/qsgcustomaffector/data/basic.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + color: "black" + width: 320 + height: 320 + + ParticleSystem { + id: sys + objectName: "system" + anchors.fill: parent + + ImageParticle { + source: "../../shared/star.png" + } + + Emitter{ + //0,0 position + size: 32 + emitRate: 1000 + lifeSpan: 500 + } + + Affector { + once: true + onAffectParticles: { + for (var i=0; i<particles.length; i++) { + particles[i].initialX = 100; + particles[i].initialY = 100; + particles[i].initialVX = 100; + particles[i].initialVY = 100; + particles[i].initialAX = 100; + particles[i].initialAY = 100; + particles[i].startSize = 100; + particles[i].endSize = 100; + } + } + } + } +} diff --git a/tests/auto/particles/qsgcustomaffector/qsgcustomaffector.pro b/tests/auto/particles/qsgcustomaffector/qsgcustomaffector.pro new file mode 100644 index 0000000000..1484491e43 --- /dev/null +++ b/tests/auto/particles/qsgcustomaffector/qsgcustomaffector.pro @@ -0,0 +1,11 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +SOURCES += tst_qsgcustomaffector.cpp +macx:CONFIG -= app_bundle + +DEFINES += SRCDIR=\\\"$$PWD\\\" + +CONFIG += parallel_test + +QT += core-private gui-private v8-private declarative-private opengl-private + diff --git a/tests/auto/particles/qsgcustomaffector/tst_qsgcustomaffector.cpp b/tests/auto/particles/qsgcustomaffector/tst_qsgcustomaffector.cpp new file mode 100644 index 0000000000..6ae2aa5f06 --- /dev/null +++ b/tests/auto/particles/qsgcustomaffector/tst_qsgcustomaffector.cpp @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include "../shared/particlestestsshared.h" +#include <private/qsgparticlesystem_p.h> + +class tst_qsgcustomaffector : public QObject +{ + Q_OBJECT +public: + tst_qsgcustomaffector(); + +private slots: + void test_basic(); +}; + +tst_qsgcustomaffector::tst_qsgcustomaffector() +{ +} + +void tst_qsgcustomaffector::test_basic() +{ + QSGView* view = createView(SRCDIR "/data/basic.qml", 600); + QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system"); + + QCOMPARE(system->groupData[0]->size(), 500); + foreach (QSGParticleData *d, system->groupData[0]->data) { + QCOMPARE(d->x, 100.f); + QCOMPARE(d->y, 100.f); + QCOMPARE(d->vx, 100.f); + QCOMPARE(d->vy, 100.f); + QCOMPARE(d->ax, 100.f); + QCOMPARE(d->ay, 100.f); + QCOMPARE(d->lifeSpan, 0.5f); + QCOMPARE(d->size, 100.f); + QCOMPARE(d->endSize, 100.f); + QVERIFY(d->t <= ((qreal)system->timeInt/1000.0)); + } +} + +QTEST_MAIN(tst_qsgcustomaffector); + +#include "tst_qsgcustomaffector.moc" diff --git a/tests/auto/particles/qsgcustomparticle/data/basic.qml b/tests/auto/particles/qsgcustomparticle/data/basic.qml new file mode 100644 index 0000000000..244f706b99 --- /dev/null +++ b/tests/auto/particles/qsgcustomparticle/data/basic.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + color: "black" + width: 320 + height: 320 + + ParticleSystem { + id: sys + objectName: "system" + anchors.fill: parent + + CustomParticle { + property variant source: ShaderEffectSource { + hideSource: true + sourceItem: Image { + source: "../../shared/star.png" + } + } + } + + Emitter{ + //0,0 position + size: 32 + emitRate: 1000 + lifeSpan: 500 + } + } +} diff --git a/tests/auto/particles/qsgcustomparticle/qsgcustomparticle.pro b/tests/auto/particles/qsgcustomparticle/qsgcustomparticle.pro new file mode 100644 index 0000000000..a151daf54b --- /dev/null +++ b/tests/auto/particles/qsgcustomparticle/qsgcustomparticle.pro @@ -0,0 +1,11 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +SOURCES += tst_qsgcustomparticle.cpp +macx:CONFIG -= app_bundle + +DEFINES += SRCDIR=\\\"$$PWD\\\" + +CONFIG += parallel_test + +QT += core-private gui-private v8-private declarative-private opengl-private + diff --git a/tests/auto/particles/qsgcustomparticle/tst_qsgcustomparticle.cpp b/tests/auto/particles/qsgcustomparticle/tst_qsgcustomparticle.cpp new file mode 100644 index 0000000000..74ef8af909 --- /dev/null +++ b/tests/auto/particles/qsgcustomparticle/tst_qsgcustomparticle.cpp @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include "../shared/particlestestsshared.h" +#include <private/qsgparticlesystem_p.h> + +class tst_qsgcustomparticle : public QObject +{ + Q_OBJECT +public: + tst_qsgcustomparticle(); + +private slots: + void test_basic(); +}; + +tst_qsgcustomparticle::tst_qsgcustomparticle() +{ +} + +void tst_qsgcustomparticle::test_basic() +{ + QSGView* view = createView(SRCDIR "/data/basic.qml", 600); + QVERIFY(view); + QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system"); + + bool oneNonZero = false; + QCOMPARE(system->groupData[0]->size(), 500); + foreach (QSGParticleData *d, system->groupData[0]->data) { + QCOMPARE(d->x, 0.f); + QCOMPARE(d->y, 0.f); + QCOMPARE(d->vx, 0.f); + QCOMPARE(d->vy, 0.f); + QCOMPARE(d->ax, 0.f); + QCOMPARE(d->ay, 0.f); + QCOMPARE(d->lifeSpan, 0.5f); + QCOMPARE(d->size, 32.f); + QCOMPARE(d->endSize, 32.f); + QVERIFY(d->t <= ((qreal)system->timeInt/1000.0)); + QVERIFY(d->r >= 0.0 && d->r <= 1.0); + if (d->r != 0.0 ) + oneNonZero = true; + } + QVERIFY(oneNonZero);//Zero is a valid value, but it also needs to be set to a random number +} + +QTEST_MAIN(tst_qsgcustomparticle); + +#include "tst_qsgcustomparticle.moc" diff --git a/tests/auto/particles/qsgellipseextruder/data/basic.qml b/tests/auto/particles/qsgellipseextruder/data/basic.qml new file mode 100644 index 0000000000..fa5fb3686a --- /dev/null +++ b/tests/auto/particles/qsgellipseextruder/data/basic.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + color: "black" + width: 320 + height: 320 + + ParticleSystem { + id: sys + objectName: "system" + anchors.fill: parent + + ImageParticle { + groups: ["", "nondefault"] + source: "../../shared/star.png" + } + + Emitter{ + anchors.fill: parent + shape: EllipseShape{} + size: 32 + emitRate: 1000 + lifeSpan: 500 + } + + Emitter{ + group: "nondefault" + anchors.fill: parent + shape: EllipseShape{ fill: false } + size: 32 + emitRate: 1000 + lifeSpan: 500 + } + } +} diff --git a/tests/auto/particles/qsgellipseextruder/qsgellipseextruder.pro b/tests/auto/particles/qsgellipseextruder/qsgellipseextruder.pro new file mode 100644 index 0000000000..5315686935 --- /dev/null +++ b/tests/auto/particles/qsgellipseextruder/qsgellipseextruder.pro @@ -0,0 +1,11 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +SOURCES += tst_qsgellipseextruder.cpp +macx:CONFIG -= app_bundle + +DEFINES += SRCDIR=\\\"$$PWD\\\" + +CONFIG += parallel_test + +QT += core-private gui-private v8-private declarative-private opengl-private + diff --git a/tests/auto/particles/qsgellipseextruder/tst_qsgellipseextruder.cpp b/tests/auto/particles/qsgellipseextruder/tst_qsgellipseextruder.cpp new file mode 100644 index 0000000000..f398936b3f --- /dev/null +++ b/tests/auto/particles/qsgellipseextruder/tst_qsgellipseextruder.cpp @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <qmath.h> +#include <QtTest/QtTest> +#include "../shared/particlestestsshared.h" +#include <private/qsgparticlesystem_p.h> + +class tst_qsgellipseextruder : public QObject +{ + Q_OBJECT +public: + tst_qsgellipseextruder(); + +private slots: + void test_basic(); +private: + bool inCircle(qreal x, qreal y, qreal r, bool borderOnly=false); +}; + +tst_qsgellipseextruder::tst_qsgellipseextruder() +{ +} + +bool tst_qsgellipseextruder::inCircle(qreal x, qreal y, qreal r, bool borderOnly) +{ + x -= r; + y -= r; + if (myFuzzyCompare(x,0) && myFuzzyCompare(y,0)) + return !borderOnly; + qreal mag = qSqrt(x*x + y*y); + if (borderOnly) + return myFuzzyCompare(mag, r); //Need myFuzzyCompare for smaller Epsilon than qFuzzyCompare + else + return mag - EPSILON < r; +} + +void tst_qsgellipseextruder::test_basic() +{ + QSGView* view = createView(SRCDIR "/data/basic.qml", 600); + QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system"); + + //Filled + QCOMPARE(system->groupData[0]->size(), 500); + foreach (QSGParticleData *d, system->groupData[0]->data) { + QVERIFY(inCircle(d->x, d->y, 160, false)); + QCOMPARE(d->vx, 0.f); + QCOMPARE(d->vy, 0.f); + QCOMPARE(d->ax, 0.f); + QCOMPARE(d->ay, 0.f); + QCOMPARE(d->lifeSpan, 0.5f); + QCOMPARE(d->size, 32.f); + QCOMPARE(d->endSize, 32.f); + QVERIFY(d->t <= ((qreal)system->timeInt/1000.0)); + } + //Just border + QCOMPARE(system->groupData[1]->size(), 500); + foreach (QSGParticleData *d, system->groupData[1]->data) { + QVERIFY(inCircle(d->x, d->y, 160, true)); + QCOMPARE(d->vx, 0.f); + QCOMPARE(d->vy, 0.f); + QCOMPARE(d->ax, 0.f); + QCOMPARE(d->ay, 0.f); + QCOMPARE(d->lifeSpan, 0.5f); + QCOMPARE(d->size, 32.f); + QCOMPARE(d->endSize, 32.f); + QVERIFY(d->t <= ((qreal)system->timeInt/1000.0)); + } +} + +QTEST_MAIN(tst_qsgellipseextruder); + +#include "tst_qsgellipseextruder.moc" diff --git a/tests/auto/particles/qsgfriction/data/basic.qml b/tests/auto/particles/qsgfriction/data/basic.qml new file mode 100644 index 0000000000..87a8897914 --- /dev/null +++ b/tests/auto/particles/qsgfriction/data/basic.qml @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + color: "black" + width: 320 + height: 320 + + ParticleSystem { + id: sys + objectName: "system" + anchors.fill: parent + + ImageParticle { + groups: ["","notdefault"] + source: "../../shared/star.png" + } + + Friction { + factor: 0.2 + } + + Emitter{ + //0,0 position + speed: PointDirection{x:100} + size: 32 + emitRate: 1000 + lifeSpan: 500 + } + + Friction { + groups: ["notdefault"] + factor: 1000.0 + } + + Emitter{ + //0,0 position + group: "notdefault" + y:200 + speed: PointDirection{x:100} + size: 32 + emitRate: 1000 + lifeSpan: 500 + } + } +} diff --git a/tests/auto/particles/qsgfriction/qsgfriction.pro b/tests/auto/particles/qsgfriction/qsgfriction.pro new file mode 100644 index 0000000000..a56f4b417a --- /dev/null +++ b/tests/auto/particles/qsgfriction/qsgfriction.pro @@ -0,0 +1,11 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +SOURCES += tst_qsgfriction.cpp +macx:CONFIG -= app_bundle + +DEFINES += SRCDIR=\\\"$$PWD\\\" + +CONFIG += parallel_test + +QT += core-private gui-private v8-private declarative-private opengl-private + diff --git a/tests/auto/particles/qsgfriction/tst_qsgfriction.cpp b/tests/auto/particles/qsgfriction/tst_qsgfriction.cpp new file mode 100644 index 0000000000..8981275717 --- /dev/null +++ b/tests/auto/particles/qsgfriction/tst_qsgfriction.cpp @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include "../shared/particlestestsshared.h" +#include <private/qsgparticlesystem_p.h> + +class tst_qsgfriction : public QObject +{ + Q_OBJECT +public: + tst_qsgfriction(); + +private slots: + void test_basic(); +}; + +tst_qsgfriction::tst_qsgfriction() +{ +} + +void tst_qsgfriction::test_basic() +{ + QSGView* view = createView(SRCDIR "/data/basic.qml", 600); + QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system"); + + //Default is just slowed a little + QCOMPARE(system->groupData[0]->size(), 500); + foreach (QSGParticleData *d, system->groupData[0]->data) { + QVERIFY(d->vx < 100.f); + QCOMPARE(d->y, 0.f); + QCOMPARE(d->vy, 0.f); + QCOMPARE(d->ax, 0.f); + QCOMPARE(d->ay, 0.f); + QCOMPARE(d->lifeSpan, 0.5f); + QCOMPARE(d->size, 32.f); + QCOMPARE(d->endSize, 32.f); + QVERIFY(d->t <= ((qreal)system->timeInt/1000.0)); + } + + //Nondefault comes to a complete stop within the first half of its life + QCOMPARE(system->groupData[1]->size(), 500); + foreach (QSGParticleData *d, system->groupData[1]->data) { + if (d->t > ((qreal)system->timeInt/1000.0) - 0.25) + continue; + QVERIFY(myFuzzyCompare(d->vx, 0.f)); + QCOMPARE(d->y, 200.f); + QCOMPARE(d->vy, 0.f); + QCOMPARE(d->ax, 0.f); + QCOMPARE(d->ay, 0.f); + QCOMPARE(d->lifeSpan, 0.5f); + QCOMPARE(d->size, 32.f); + QCOMPARE(d->endSize, 32.f); + QVERIFY(d->t <= ((qreal)system->timeInt/1000.0)); + } +} + +QTEST_MAIN(tst_qsgfriction); + +#include "tst_qsgfriction.moc" diff --git a/tests/auto/particles/qsggravity/data/basic.qml b/tests/auto/particles/qsggravity/data/basic.qml new file mode 100644 index 0000000000..9275654297 --- /dev/null +++ b/tests/auto/particles/qsggravity/data/basic.qml @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + color: "black" + width: 320 + height: 320 + + ParticleSystem { + id: sys + objectName: "system" + anchors.fill: parent + + ImageParticle { + source: "../../shared/star.png" + } + + Gravity { + acceleration: 1000 + angle: 45 + } + Emitter{ + //0,0 position + size: 32 + emitRate: 1000 + lifeSpan: 500 + } + } +} diff --git a/tests/auto/particles/qsggravity/qsggravity.pro b/tests/auto/particles/qsggravity/qsggravity.pro new file mode 100644 index 0000000000..d7a7bbd4a3 --- /dev/null +++ b/tests/auto/particles/qsggravity/qsggravity.pro @@ -0,0 +1,11 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +SOURCES += tst_qsggravity.cpp +macx:CONFIG -= app_bundle + +DEFINES += SRCDIR=\\\"$$PWD\\\" + +CONFIG += parallel_test + +QT += core-private gui-private v8-private declarative-private opengl-private + diff --git a/tests/auto/particles/qsggravity/tst_qsggravity.cpp b/tests/auto/particles/qsggravity/tst_qsggravity.cpp new file mode 100644 index 0000000000..584ec18d52 --- /dev/null +++ b/tests/auto/particles/qsggravity/tst_qsggravity.cpp @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include "../shared/particlestestsshared.h" +#include <private/qsgparticlesystem_p.h> + +class tst_qsggravity : public QObject +{ + Q_OBJECT +public: + tst_qsggravity(); + +private slots: + void test_basic(); +}; + +tst_qsggravity::tst_qsggravity() +{ +} + +void tst_qsggravity::test_basic() +{ + QSGView* view = createView(SRCDIR "/data/basic.qml", 600); + QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system"); + + QCOMPARE(system->groupData[0]->size(), 500); + foreach (QSGParticleData *d, system->groupData[0]->data) { + QCOMPARE(d->ax, 707.10678f); + QCOMPARE(d->ay, 707.10678f); + QCOMPARE(d->lifeSpan, 0.5f); + QCOMPARE(d->size, 32.f); + QCOMPARE(d->endSize, 32.f); + QVERIFY(d->t <= ((qreal)system->timeInt/1000.0)); + } +} + +QTEST_MAIN(tst_qsggravity); + +#include "tst_qsggravity.moc" diff --git a/tests/auto/particles/qsgimageparticle/data/basic.qml b/tests/auto/particles/qsgimageparticle/data/basic.qml new file mode 100644 index 0000000000..f5ef4c16c0 --- /dev/null +++ b/tests/auto/particles/qsgimageparticle/data/basic.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + color: "black" + width: 320 + height: 320 + + ParticleSystem { + id: sys + objectName: "system" + anchors.fill: parent + + ImageParticle { + source: "../../shared/star.png" + } + + Emitter{ + //0,0 position + size: 32 + emitRate: 1000 + lifeSpan: 500 + } + } +} diff --git a/tests/auto/particles/qsgimageparticle/qsgimageparticle.pro b/tests/auto/particles/qsgimageparticle/qsgimageparticle.pro new file mode 100644 index 0000000000..d1197f0c98 --- /dev/null +++ b/tests/auto/particles/qsgimageparticle/qsgimageparticle.pro @@ -0,0 +1,11 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +SOURCES += tst_qsgimageparticle.cpp +macx:CONFIG -= app_bundle + +DEFINES += SRCDIR=\\\"$$PWD\\\" + +CONFIG += parallel_test + +QT += core-private gui-private v8-private declarative-private opengl-private + diff --git a/tests/auto/particles/qsgimageparticle/tst_qsgimageparticle.cpp b/tests/auto/particles/qsgimageparticle/tst_qsgimageparticle.cpp new file mode 100644 index 0000000000..5e6e77cc03 --- /dev/null +++ b/tests/auto/particles/qsgimageparticle/tst_qsgimageparticle.cpp @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include "../shared/particlestestsshared.h" +#include <private/qsgparticlesystem_p.h> + +class tst_qsgimageparticle : public QObject +{ + Q_OBJECT +public: + tst_qsgimageparticle(); + +private slots: + void test_basic(); +}; + +tst_qsgimageparticle::tst_qsgimageparticle() +{ +} + +void tst_qsgimageparticle::test_basic() +{ + QSGView* view = createView(SRCDIR "/data/basic.qml", 600); + QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system"); + + QCOMPARE(system->groupData[0]->size(), 500); + foreach (QSGParticleData *d, system->groupData[0]->data) { + QCOMPARE(d->x, 0.f); + QCOMPARE(d->y, 0.f); + QCOMPARE(d->vx, 0.f); + QCOMPARE(d->vy, 0.f); + QCOMPARE(d->ax, 0.f); + QCOMPARE(d->ay, 0.f); + QCOMPARE(d->lifeSpan, 0.5f); + QCOMPARE(d->size, 32.f); + QCOMPARE(d->endSize, 32.f); + QVERIFY(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); + QCOMPARE(d->color.a, (uchar)255); + QCOMPARE(d->xx, 1.0f); + QCOMPARE(d->xy, 0.0f); + QCOMPARE(d->yy, 1.0f); + QCOMPARE(d->yx, 0.0f); + QCOMPARE(d->rotation, 0.0f); + QCOMPARE(d->rotationSpeed, 0.0f); + QCOMPARE(d->autoRotate, 0.0f); + QCOMPARE(d->animIdx, 0.0f); + QCOMPARE(d->frameDuration, 1.0f); + QCOMPARE(d->frameCount, 1.0f); + QCOMPARE(d->animT, -1.0f); + } +} + +QTEST_MAIN(tst_qsgimageparticle); + +#include "tst_qsgimageparticle.moc" diff --git a/tests/auto/particles/qsgitemparticle/data/basic.qml b/tests/auto/particles/qsgitemparticle/data/basic.qml new file mode 100644 index 0000000000..dbe16a0b4e --- /dev/null +++ b/tests/auto/particles/qsgitemparticle/data/basic.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + color: "black" + width: 320 + height: 320 + + ParticleSystem { + id: sys + objectName: "system" + anchors.fill: parent + + ItemParticle { + delegate: Image{ source: "../../shared/star.png" } + } + + Emitter{ + //0,0 position + size: 32 + emitRate: 1000 + lifeSpan: 500 + } + } +} diff --git a/tests/auto/particles/qsgitemparticle/qsgitemparticle.pro b/tests/auto/particles/qsgitemparticle/qsgitemparticle.pro new file mode 100644 index 0000000000..e2d2c67431 --- /dev/null +++ b/tests/auto/particles/qsgitemparticle/qsgitemparticle.pro @@ -0,0 +1,11 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +SOURCES += tst_qsgitemparticle.cpp +macx:CONFIG -= app_bundle + +DEFINES += SRCDIR=\\\"$$PWD\\\" + +CONFIG += parallel_test + +QT += core-private gui-private v8-private declarative-private opengl-private + diff --git a/tests/auto/particles/qsgitemparticle/tst_qsgitemparticle.cpp b/tests/auto/particles/qsgitemparticle/tst_qsgitemparticle.cpp new file mode 100644 index 0000000000..440ebafdb8 --- /dev/null +++ b/tests/auto/particles/qsgitemparticle/tst_qsgitemparticle.cpp @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include "../shared/particlestestsshared.h" +#include <private/qsgparticlesystem_p.h> +#include <private/qsgimage_p.h> + +class tst_qsgitemparticle : public QObject +{ + Q_OBJECT +public: + tst_qsgitemparticle(); + +private slots: + void test_basic(); +}; + +tst_qsgitemparticle::tst_qsgitemparticle() +{ +} + +void tst_qsgitemparticle::test_basic() +{ + QSGView* view = createView(SRCDIR "/data/basic.qml", 600); + QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system"); + + QCOMPARE(system->groupData[0]->size(), 500); + foreach (QSGParticleData *d, system->groupData[0]->data) { + QCOMPARE(d->x, 0.f); + QCOMPARE(d->y, 0.f); + QCOMPARE(d->vx, 0.f); + QCOMPARE(d->vy, 0.f); + QCOMPARE(d->ax, 0.f); + QCOMPARE(d->ay, 0.f); + QCOMPARE(d->lifeSpan, 0.5f); + QCOMPARE(d->size, 32.f); + QCOMPARE(d->endSize, 32.f); + QVERIFY(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 + continue; + QVERIFY(d->delegate); + QVERIFY(qobject_cast<QSGImage*>(d->delegate)); + } +} + +QTEST_MAIN(tst_qsgitemparticle); + +#include "tst_qsgitemparticle.moc" diff --git a/tests/auto/particles/qsglineextruder/data/basic.qml b/tests/auto/particles/qsglineextruder/data/basic.qml new file mode 100644 index 0000000000..dbe2ec5c7d --- /dev/null +++ b/tests/auto/particles/qsglineextruder/data/basic.qml @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + color: "black" + width: 320 + height: 320 + + ParticleSystem { + id: sys + objectName: "system" + anchors.fill: parent + + ImageParticle { + groups: ["", "notdefault"] + source: "../../shared/star.png" + } + + Emitter{ + anchors.fill: parent + shape: LineShape{} + size: 32 + emitRate: 1000 + lifeSpan: 500 + } + Emitter{ + anchors.fill: parent + group: "notdefault" + shape: LineShape{mirrored: true} + size: 32 + emitRate: 1000 + lifeSpan: 500 + } + } +} diff --git a/tests/auto/particles/qsglineextruder/qsglineextruder.pro b/tests/auto/particles/qsglineextruder/qsglineextruder.pro new file mode 100644 index 0000000000..ccafa70e98 --- /dev/null +++ b/tests/auto/particles/qsglineextruder/qsglineextruder.pro @@ -0,0 +1,11 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +SOURCES += tst_qsglineextruder.cpp +macx:CONFIG -= app_bundle + +DEFINES += SRCDIR=\\\"$$PWD\\\" + +CONFIG += parallel_test + +QT += core-private gui-private v8-private declarative-private opengl-private + diff --git a/tests/auto/particles/qsglineextruder/tst_qsglineextruder.cpp b/tests/auto/particles/qsglineextruder/tst_qsglineextruder.cpp new file mode 100644 index 0000000000..6a7cfe426d --- /dev/null +++ b/tests/auto/particles/qsglineextruder/tst_qsglineextruder.cpp @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include "../shared/particlestestsshared.h" +#include <private/qsgparticlesystem_p.h> + +class tst_qsglineextruder : public QObject +{ + Q_OBJECT +public: + tst_qsglineextruder(); + +private slots: + void test_basic(); +}; + +tst_qsglineextruder::tst_qsglineextruder() +{ +} + +void tst_qsglineextruder::test_basic() +{ + QSGView* view = createView(SRCDIR "/data/basic.qml", 600); + QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system"); + + QCOMPARE(system->groupData[0]->size(), 500); + foreach (QSGParticleData *d, system->groupData[0]->data) { + QCOMPARE(d->x, d->y); + QCOMPARE(d->vx, 0.f); + QCOMPARE(d->vy, 0.f); + QCOMPARE(d->ax, 0.f); + QCOMPARE(d->ay, 0.f); + QCOMPARE(d->lifeSpan, 0.5f); + QCOMPARE(d->size, 32.f); + QCOMPARE(d->endSize, 32.f); + QVERIFY(d->t <= ((qreal)system->timeInt/1000.0)); + } + + QCOMPARE(system->groupData[1]->size(), 500); + foreach (QSGParticleData *d, system->groupData[1]->data) { + QCOMPARE(d->x + d->y, 320.0f); + QCOMPARE(d->vx, 0.f); + QCOMPARE(d->vy, 0.f); + QCOMPARE(d->ax, 0.f); + QCOMPARE(d->ay, 0.f); + QCOMPARE(d->lifeSpan, 0.5f); + QCOMPARE(d->size, 32.f); + QCOMPARE(d->endSize, 32.f); + QVERIFY(d->t <= ((qreal)system->timeInt/1000.0)); + } +} + +QTEST_MAIN(tst_qsglineextruder); + +#include "tst_qsglineextruder.moc" diff --git a/tests/auto/particles/qsgmaskextruder/data/basic.qml b/tests/auto/particles/qsgmaskextruder/data/basic.qml new file mode 100644 index 0000000000..804df83de8 --- /dev/null +++ b/tests/auto/particles/qsgmaskextruder/data/basic.qml @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + color: "black" + width: 320 + height: 320 + + ParticleSystem { + id: sys + objectName: "system" + anchors.fill: parent + + ImageParticle { + source: "../../shared/star.png" + } + + Emitter{ + //100,100 rect at 100,100 + anchors.fill: parent + shape: MaskShape{source: "smallmask.png"} + size: 32 + emitRate: 1000 + lifeSpan: 500 + } + } +} diff --git a/tests/auto/particles/qsgmaskextruder/data/smallmask.png b/tests/auto/particles/qsgmaskextruder/data/smallmask.png Binary files differnew file mode 100644 index 0000000000..e36fb9fe55 --- /dev/null +++ b/tests/auto/particles/qsgmaskextruder/data/smallmask.png diff --git a/tests/auto/particles/qsgmaskextruder/qsgmaskextruder.pro b/tests/auto/particles/qsgmaskextruder/qsgmaskextruder.pro new file mode 100644 index 0000000000..8cd5302436 --- /dev/null +++ b/tests/auto/particles/qsgmaskextruder/qsgmaskextruder.pro @@ -0,0 +1,11 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +SOURCES += tst_qsgmaskextruder.cpp +macx:CONFIG -= app_bundle + +DEFINES += SRCDIR=\\\"$$PWD\\\" + +CONFIG += parallel_test + +QT += core-private gui-private v8-private declarative-private opengl-private + diff --git a/tests/auto/particles/qsgmaskextruder/tst_qsgmaskextruder.cpp b/tests/auto/particles/qsgmaskextruder/tst_qsgmaskextruder.cpp new file mode 100644 index 0000000000..1ac33a0fb7 --- /dev/null +++ b/tests/auto/particles/qsgmaskextruder/tst_qsgmaskextruder.cpp @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include "../shared/particlestestsshared.h" +#include <private/qsgparticlesystem_p.h> + +class tst_qsgmaskextruder : public QObject +{ + Q_OBJECT +public: + tst_qsgmaskextruder(); + +private slots: + void test_basic(); +}; + +tst_qsgmaskextruder::tst_qsgmaskextruder() +{ +} + +void tst_qsgmaskextruder::test_basic() +{ + QSGView* view = createView(SRCDIR "/data/basic.qml", 600); + QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system"); + + QCOMPARE(system->groupData[0]->size(), 500); + foreach (QSGParticleData *d, system->groupData[0]->data) { + QVERIFY(d->x >= 100.0f && d->x <= 200.0f); + QVERIFY(d->y >= 100.0f && d->y <= 200.0f); + QCOMPARE(d->vx, 0.f); + QCOMPARE(d->vy, 0.f); + QCOMPARE(d->ax, 0.f); + QCOMPARE(d->ay, 0.f); + QCOMPARE(d->lifeSpan, 0.5f); + QCOMPARE(d->size, 32.f); + QCOMPARE(d->endSize, 32.f); + QVERIFY(d->t <= ((qreal)system->timeInt/1000.0)); + } +} + +QTEST_MAIN(tst_qsgmaskextruder); + +#include "tst_qsgmaskextruder.moc" diff --git a/tests/auto/particles/qsgparticlegroup/data/basic.qml b/tests/auto/particles/qsgparticlegroup/data/basic.qml new file mode 100644 index 0000000000..97dadd7461 --- /dev/null +++ b/tests/auto/particles/qsgparticlegroup/data/basic.qml @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + color: "black" + width: 320 + height: 320 + + ParticleSystem { + id: sys + objectName: "system" + anchors.fill: parent + + ImageParticle { + source: "../../shared/star.png" + } + + ParticleGroup { + name: "notdefault" + duration: 0 + to: {"":1} + } + + Emitter{ + //0,0 position + group: "notdefault" + size: 32 + emitRate: 1000 + lifeSpan: 500 + } + } +} diff --git a/tests/auto/particles/qsgparticlegroup/qsgparticlegroup.pro b/tests/auto/particles/qsgparticlegroup/qsgparticlegroup.pro new file mode 100644 index 0000000000..40e799dd79 --- /dev/null +++ b/tests/auto/particles/qsgparticlegroup/qsgparticlegroup.pro @@ -0,0 +1,11 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +SOURCES += tst_qsgparticlegroup.cpp +macx:CONFIG -= app_bundle + +DEFINES += SRCDIR=\\\"$$PWD\\\" + +CONFIG += parallel_test + +QT += core-private gui-private v8-private declarative-private opengl-private + diff --git a/tests/auto/particles/qsgparticlegroup/tst_qsgparticlegroup.cpp b/tests/auto/particles/qsgparticlegroup/tst_qsgparticlegroup.cpp new file mode 100644 index 0000000000..21eb52b4ca --- /dev/null +++ b/tests/auto/particles/qsgparticlegroup/tst_qsgparticlegroup.cpp @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include "../shared/particlestestsshared.h" +#include <private/qsgparticlesystem_p.h> + +class tst_qsgparticlegroup : public QObject +{ + Q_OBJECT +public: + tst_qsgparticlegroup(); + +private slots: + void test_instantTransition(); +}; + +tst_qsgparticlegroup::tst_qsgparticlegroup() +{ +} + +void tst_qsgparticlegroup::test_instantTransition() +{ + QSGView* view = createView(SRCDIR "/data/basic.qml", 600); + QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system"); + + //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); + foreach (QSGParticleData *d, system->groupData[0]->data) { + QCOMPARE(d->x, 0.f); + QCOMPARE(d->y, 0.f); + QCOMPARE(d->vx, 0.f); + QCOMPARE(d->vy, 0.f); + QCOMPARE(d->ax, 0.f); + QCOMPARE(d->ay, 0.f); + QCOMPARE(d->lifeSpan, 0.5f); + QCOMPARE(d->size, 32.f); + QCOMPARE(d->endSize, 32.f); + QVERIFY(d->t <= ((qreal)system->timeInt/1000.0)); + } +} + +QTEST_MAIN(tst_qsgparticlegroup); + +#include "tst_qsgparticlegroup.moc" diff --git a/tests/auto/particles/qsgparticlesystem/data/basic.qml b/tests/auto/particles/qsgparticlesystem/data/basic.qml new file mode 100644 index 0000000000..f5ef4c16c0 --- /dev/null +++ b/tests/auto/particles/qsgparticlesystem/data/basic.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + color: "black" + width: 320 + height: 320 + + ParticleSystem { + id: sys + objectName: "system" + anchors.fill: parent + + ImageParticle { + source: "../../shared/star.png" + } + + Emitter{ + //0,0 position + size: 32 + emitRate: 1000 + lifeSpan: 500 + } + } +} diff --git a/tests/auto/particles/qsgparticlesystem/qsgparticlesystem.pro b/tests/auto/particles/qsgparticlesystem/qsgparticlesystem.pro new file mode 100644 index 0000000000..6ba836ad06 --- /dev/null +++ b/tests/auto/particles/qsgparticlesystem/qsgparticlesystem.pro @@ -0,0 +1,11 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +SOURCES += tst_qsgparticlesystem.cpp +macx:CONFIG -= app_bundle + +DEFINES += SRCDIR=\\\"$$PWD\\\" + +CONFIG += parallel_test + +QT += core-private gui-private v8-private declarative-private opengl-private + diff --git a/tests/auto/particles/qsgparticlesystem/tst_qsgparticlesystem.cpp b/tests/auto/particles/qsgparticlesystem/tst_qsgparticlesystem.cpp new file mode 100644 index 0000000000..d5a0a2adfa --- /dev/null +++ b/tests/auto/particles/qsgparticlesystem/tst_qsgparticlesystem.cpp @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include "../shared/particlestestsshared.h" +#include <private/qsgparticlesystem_p.h> + +class tst_qsgparticlesystem : public QObject +{ + Q_OBJECT +public: + tst_qsgparticlesystem(); + +private slots: + void test_basic(); +}; + +tst_qsgparticlesystem::tst_qsgparticlesystem() +{ +} + +void tst_qsgparticlesystem::test_basic() +{ + QSGView* view = createView(SRCDIR "/data/basic.qml", 600); + QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system"); + + QCOMPARE(system->groupData[0]->size(), 500); + foreach (QSGParticleData *d, system->groupData[0]->data) { + QCOMPARE(d->x, 0.f); + QCOMPARE(d->y, 0.f); + QCOMPARE(d->vx, 0.f); + QCOMPARE(d->vy, 0.f); + QCOMPARE(d->ax, 0.f); + QCOMPARE(d->ay, 0.f); + QCOMPARE(d->lifeSpan, 0.5f); + QCOMPARE(d->size, 32.f); + QCOMPARE(d->endSize, 32.f); + QVERIFY(d->t <= ((qreal)system->timeInt/1000.0)); + } +} + +QTEST_MAIN(tst_qsgparticlesystem); + +#include "tst_qsgparticlesystem.moc" diff --git a/tests/auto/particles/qsgpointattractor/data/basic.qml b/tests/auto/particles/qsgpointattractor/data/basic.qml new file mode 100644 index 0000000000..86861a9cf2 --- /dev/null +++ b/tests/auto/particles/qsgpointattractor/data/basic.qml @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + color: "black" + width: 320 + height: 320 + + ParticleSystem { + id: sys + objectName: "system" + anchors.fill: parent + + ImageParticle { + source: "../../shared/star.png" + } + + Attractor { + anchors.centerIn: parent + proportionalToDistance: Attractor.Constant + affectedParameter: Attractor.Position + strength: 100 + } + + Emitter{ + //0,0 position + size: 32 + emitRate: 1000 + lifeSpan: 500 + } + } +} diff --git a/tests/auto/particles/qsgpointattractor/qsgpointattractor.pro b/tests/auto/particles/qsgpointattractor/qsgpointattractor.pro new file mode 100644 index 0000000000..b2acf47644 --- /dev/null +++ b/tests/auto/particles/qsgpointattractor/qsgpointattractor.pro @@ -0,0 +1,11 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +SOURCES += tst_qsgpointattractor.cpp +macx:CONFIG -= app_bundle + +DEFINES += SRCDIR=\\\"$$PWD\\\" + +CONFIG += parallel_test + +QT += core-private gui-private v8-private declarative-private opengl-private + diff --git a/tests/auto/particles/qsgpointattractor/tst_qsgpointattractor.cpp b/tests/auto/particles/qsgpointattractor/tst_qsgpointattractor.cpp new file mode 100644 index 0000000000..33fc670322 --- /dev/null +++ b/tests/auto/particles/qsgpointattractor/tst_qsgpointattractor.cpp @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include "../shared/particlestestsshared.h" +#include <private/qsgparticlesystem_p.h> + +class tst_qsgpointattractor : public QObject +{ + Q_OBJECT +public: + tst_qsgpointattractor(); + +private slots: + void test_basic(); +}; + +tst_qsgpointattractor::tst_qsgpointattractor() +{ +} + +void tst_qsgpointattractor::test_basic() +{ + QSGView* view = createView(SRCDIR "/data/basic.qml", 600); + QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system"); + + QCOMPARE(system->groupData[0]->size(), 500); + foreach (QSGParticleData *d, system->groupData[0]->data) { + QVERIFY(d->x != 0.f); + QVERIFY(d->y != 0.f); + QVERIFY(d->x == d->y); + QCOMPARE(d->vx, 0.f); + QCOMPARE(d->vy, 0.f); + QCOMPARE(d->ax, 0.f); + QCOMPARE(d->ay, 0.f); + QCOMPARE(d->lifeSpan, 0.5f); + QCOMPARE(d->size, 32.f); + QCOMPARE(d->endSize, 32.f); + QVERIFY(d->t <= ((qreal)system->timeInt/1000.0)); + } +} + +QTEST_MAIN(tst_qsgpointattractor); + +#include "tst_qsgpointattractor.moc" diff --git a/tests/auto/particles/qsgpointdirection/data/basic.qml b/tests/auto/particles/qsgpointdirection/data/basic.qml new file mode 100644 index 0000000000..60c2a3e37b --- /dev/null +++ b/tests/auto/particles/qsgpointdirection/data/basic.qml @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + color: "black" + width: 320 + height: 320 + + ParticleSystem { + id: sys + objectName: "system" + anchors.fill: parent + + ImageParticle { + source: "../../shared/star.png" + } + + Emitter{ + //0,0 position + size: 32 + speed: PointDirection{ x: 100; y: 100 } + acceleration: PointDirection{ x: 100; xVariation: 100; y: 100; yVariation: 100 } + emitRate: 1000 + lifeSpan: 500 + } + } +} diff --git a/tests/auto/particles/qsgpointdirection/qsgpointdirection.pro b/tests/auto/particles/qsgpointdirection/qsgpointdirection.pro new file mode 100644 index 0000000000..6a0250386c --- /dev/null +++ b/tests/auto/particles/qsgpointdirection/qsgpointdirection.pro @@ -0,0 +1,11 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +SOURCES += tst_qsgpointdirection.cpp +macx:CONFIG -= app_bundle + +DEFINES += SRCDIR=\\\"$$PWD\\\" + +CONFIG += parallel_test + +QT += core-private gui-private v8-private declarative-private opengl-private + diff --git a/tests/auto/particles/qsgpointdirection/tst_qsgpointdirection.cpp b/tests/auto/particles/qsgpointdirection/tst_qsgpointdirection.cpp new file mode 100644 index 0000000000..89d0f316c5 --- /dev/null +++ b/tests/auto/particles/qsgpointdirection/tst_qsgpointdirection.cpp @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include "../shared/particlestestsshared.h" +#include <private/qsgparticlesystem_p.h> + +class tst_qsgpointdirection : public QObject +{ + Q_OBJECT +public: + tst_qsgpointdirection(); + +private slots: + void test_basic(); +}; + +tst_qsgpointdirection::tst_qsgpointdirection() +{ +} + +void tst_qsgpointdirection::test_basic() +{ + QSGView* view = createView(SRCDIR "/data/basic.qml", 600); + QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system"); + + QCOMPARE(system->groupData[0]->size(), 500); + foreach (QSGParticleData *d, system->groupData[0]->data) { + QCOMPARE(d->x, 0.f); + QCOMPARE(d->y, 0.f); + QCOMPARE(d->vx, 100.f); + QCOMPARE(d->vy, 100.f); + QVERIFY(d->ax >= 0.f); + QVERIFY(d->ax <= 200.f); + QVERIFY(d->ay >= 0.f); + QVERIFY(d->ay <= 200.f); + QCOMPARE(d->lifeSpan, 0.5f); + QCOMPARE(d->size, 32.f); + QCOMPARE(d->endSize, 32.f); + QVERIFY(d->t <= ((qreal)system->timeInt/1000.0)); + } +} + +QTEST_MAIN(tst_qsgpointdirection); + +#include "tst_qsgpointdirection.moc" diff --git a/tests/auto/particles/qsgrectangleextruder/data/basic.qml b/tests/auto/particles/qsgrectangleextruder/data/basic.qml new file mode 100644 index 0000000000..a66827ed90 --- /dev/null +++ b/tests/auto/particles/qsgrectangleextruder/data/basic.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + color: "black" + width: 320 + height: 320 + + ParticleSystem { + id: sys + objectName: "system" + anchors.fill: parent + + ImageParticle { + groups: ["", "notdefault"] + source: "../../shared/star.png" + } + + Emitter{ + width: 100 + height: 100 + size: 32 + shape: RectangleShape{} + emitRate: 1000 + lifeSpan: 500 + } + Emitter{ + width: 100 + height: 100 + group: "notdefault" + size: 32 + shape: RectangleShape{fill: false} + emitRate: 1000 + lifeSpan: 500 + } + } +} diff --git a/tests/auto/particles/qsgrectangleextruder/qsgrectangleextruder.pro b/tests/auto/particles/qsgrectangleextruder/qsgrectangleextruder.pro new file mode 100644 index 0000000000..207aa13004 --- /dev/null +++ b/tests/auto/particles/qsgrectangleextruder/qsgrectangleextruder.pro @@ -0,0 +1,11 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +SOURCES += tst_qsgrectangleextruder.cpp +macx:CONFIG -= app_bundle + +DEFINES += SRCDIR=\\\"$$PWD\\\" + +CONFIG += parallel_test + +QT += core-private gui-private v8-private declarative-private opengl-private + diff --git a/tests/auto/particles/qsgrectangleextruder/tst_qsgrectangleextruder.cpp b/tests/auto/particles/qsgrectangleextruder/tst_qsgrectangleextruder.cpp new file mode 100644 index 0000000000..1e45f81ee1 --- /dev/null +++ b/tests/auto/particles/qsgrectangleextruder/tst_qsgrectangleextruder.cpp @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include "../shared/particlestestsshared.h" +#include <private/qsgparticlesystem_p.h> + +class tst_qsgrectangleextruder : public QObject +{ + Q_OBJECT +public: + tst_qsgrectangleextruder(); + +private slots: + void test_basic(); +}; + +tst_qsgrectangleextruder::tst_qsgrectangleextruder() +{ +} + +void tst_qsgrectangleextruder::test_basic() +{ + QSGView* view = createView(SRCDIR "/data/basic.qml", 600); + QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system"); + + QCOMPARE(system->groupData[0]->size(), 500); + foreach (QSGParticleData *d, system->groupData[0]->data) { + QVERIFY(d->x >= 0.f); + QVERIFY(d->x <= 100.f); + QVERIFY(d->y >= 0.f); + QVERIFY(d->y <= 100.f); + QCOMPARE(d->vx, 0.f); + QCOMPARE(d->vy, 0.f); + QCOMPARE(d->ax, 0.f); + QCOMPARE(d->ay, 0.f); + QCOMPARE(d->lifeSpan, 0.5f); + QCOMPARE(d->size, 32.f); + QCOMPARE(d->endSize, 32.f); + QVERIFY(d->t <= ((qreal)system->timeInt/1000.0)); + } + + QCOMPARE(system->groupData[1]->size(), 500); + foreach (QSGParticleData *d, system->groupData[1]->data) { + if (!myFuzzyCompare(d->x, 0.f) && !myFuzzyCompare(d->x, 100.f)){ + QVERIFY(d->x >= 0.f); + QVERIFY(d->x <= 100.f); + QVERIFY(myFuzzyCompare(d->y, 0.f) || myFuzzyCompare(d->y, 100.f)); + } else { + QVERIFY(d->y >= 0.f); + QVERIFY(d->y <= 100.f); + } + QCOMPARE(d->vx, 0.f); + QCOMPARE(d->vy, 0.f); + QCOMPARE(d->ax, 0.f); + QCOMPARE(d->ay, 0.f); + QCOMPARE(d->lifeSpan, 0.5f); + QCOMPARE(d->size, 32.f); + QCOMPARE(d->endSize, 32.f); + QVERIFY(d->t <= ((qreal)system->timeInt/1000.0)); + } +} + +QTEST_MAIN(tst_qsgrectangleextruder); + +#include "tst_qsgrectangleextruder.moc" diff --git a/tests/auto/particles/qsgtargetdirection/data/basic.qml b/tests/auto/particles/qsgtargetdirection/data/basic.qml new file mode 100644 index 0000000000..a8caea4641 --- /dev/null +++ b/tests/auto/particles/qsgtargetdirection/data/basic.qml @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + color: "black" + width: 320 + height: 320 + + ParticleSystem { + id: sys + objectName: "system" + anchors.fill: parent + + ImageParticle { + source: "../../shared/star.png" + } + + Emitter{ + //0,0 position + speed: TargetDirection{ targetItem: sys; proportionalMagnitude: true; magnitude: 1 } + size: 32 + emitRate: 1000 + lifeSpan: 500 + } + } +} diff --git a/tests/auto/particles/qsgtargetdirection/qsgtargetdirection.pro b/tests/auto/particles/qsgtargetdirection/qsgtargetdirection.pro new file mode 100644 index 0000000000..397957e768 --- /dev/null +++ b/tests/auto/particles/qsgtargetdirection/qsgtargetdirection.pro @@ -0,0 +1,11 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +SOURCES += tst_qsgtargetdirection.cpp +macx:CONFIG -= app_bundle + +DEFINES += SRCDIR=\\\"$$PWD\\\" + +CONFIG += parallel_test + +QT += core-private gui-private v8-private declarative-private opengl-private + diff --git a/tests/auto/particles/qsgtargetdirection/tst_qsgtargetdirection.cpp b/tests/auto/particles/qsgtargetdirection/tst_qsgtargetdirection.cpp new file mode 100644 index 0000000000..c5d84f5e17 --- /dev/null +++ b/tests/auto/particles/qsgtargetdirection/tst_qsgtargetdirection.cpp @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include "../shared/particlestestsshared.h" +#include <private/qsgparticlesystem_p.h> + +class tst_qsgtargetdirection : public QObject +{ + Q_OBJECT +public: + tst_qsgtargetdirection(); + +private slots: + void test_basic(); +}; + +tst_qsgtargetdirection::tst_qsgtargetdirection() +{ +} + +void tst_qsgtargetdirection::test_basic() +{ + QSGView* view = createView(SRCDIR "/data/basic.qml", 600); + QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system"); + + QCOMPARE(system->groupData[0]->size(), 500); + foreach (QSGParticleData *d, system->groupData[0]->data) { + QCOMPARE(d->x, 0.f); + QCOMPARE(d->y, 0.f); + QCOMPARE(d->vx, 160.f); + QCOMPARE(d->vy, 160.f); + QCOMPARE(d->ax, 0.f); + QCOMPARE(d->ay, 0.f); + QCOMPARE(d->lifeSpan, 0.5f); + QCOMPARE(d->size, 32.f); + QCOMPARE(d->endSize, 32.f); + QVERIFY(d->t <= ((qreal)system->timeInt/1000.0)); + } +} + +QTEST_MAIN(tst_qsgtargetdirection); + +#include "tst_qsgtargetdirection.moc" diff --git a/tests/auto/particles/qsgtrailemitter/data/basic.qml b/tests/auto/particles/qsgtrailemitter/data/basic.qml new file mode 100644 index 0000000000..538d14f1d5 --- /dev/null +++ b/tests/auto/particles/qsgtrailemitter/data/basic.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + color: "black" + width: 320 + height: 320 + + ParticleSystem { + id: sys + objectName: "system" + anchors.fill: parent + + ImageParticle { + groups: ["","notdefault"] + source: "../../shared/star.png" + } + + + TrailEmitter { + group: "notdefault" + follow: "" + size: 32 + emitRatePerParticle: 2 + lifeSpan: 500 + speed: PointDirection{ x: 500; y: 500 } + } + Emitter{ + x: 4 + y: 4 + size: 32 + emitRate: 1000 + lifeSpan: 500 + } + } +} diff --git a/tests/auto/particles/qsgtrailemitter/qsgtrailemitter.pro b/tests/auto/particles/qsgtrailemitter/qsgtrailemitter.pro new file mode 100644 index 0000000000..914d0e5b9d --- /dev/null +++ b/tests/auto/particles/qsgtrailemitter/qsgtrailemitter.pro @@ -0,0 +1,11 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +SOURCES += tst_qsgtrailemitter.cpp +macx:CONFIG -= app_bundle + +DEFINES += SRCDIR=\\\"$$PWD\\\" + +CONFIG += parallel_test + +QT += core-private gui-private v8-private declarative-private opengl-private + diff --git a/tests/auto/particles/qsgtrailemitter/tst_qsgtrailemitter.cpp b/tests/auto/particles/qsgtrailemitter/tst_qsgtrailemitter.cpp new file mode 100644 index 0000000000..a92b7911a4 --- /dev/null +++ b/tests/auto/particles/qsgtrailemitter/tst_qsgtrailemitter.cpp @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include "../shared/particlestestsshared.h" +#include <private/qsgparticlesystem_p.h> + +class tst_qsgtrailemitter : public QObject +{ + Q_OBJECT +public: + tst_qsgtrailemitter(); + +private slots: + void test_basic(); +}; + +tst_qsgtrailemitter::tst_qsgtrailemitter() +{ +} + +void tst_qsgtrailemitter::test_basic() +{ + QSGView* view = createView(SRCDIR "/data/basic.qml", 600); + QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system"); + + QCOMPARE(system->groupData[0]->size(), 500); + foreach (QSGParticleData *d, system->groupData[0]->data) { + QCOMPARE(d->x, 4.f); + QCOMPARE(d->y, 4.f); + QCOMPARE(d->vx, 0.f); + QCOMPARE(d->vy, 0.f); + QCOMPARE(d->ax, 0.f); + QCOMPARE(d->ay, 0.f); + QCOMPARE(d->lifeSpan, 0.5f); + QCOMPARE(d->size, 32.f); + QCOMPARE(d->endSize, 32.f); + QVERIFY(d->t <= ((qreal)system->timeInt/1000.0)); + } + + QCOMPARE(system->groupData[1]->size(), 500); + foreach (QSGParticleData *d, system->groupData[1]->data) { + QCOMPARE(d->x, 4.f); + QCOMPARE(d->y, 4.f); + QCOMPARE(d->vx, 500.f); + QCOMPARE(d->vy, 500.f); + QCOMPARE(d->ax, 0.f); + QCOMPARE(d->ay, 0.f); + QCOMPARE(d->lifeSpan, 0.5f); + QCOMPARE(d->size, 32.f); + QCOMPARE(d->endSize, 32.f); + QVERIFY(d->t <= ((qreal)system->timeInt/1000.0)); + } +} + +QTEST_MAIN(tst_qsgtrailemitter); + +#include "tst_qsgtrailemitter.moc" diff --git a/tests/auto/particles/qsgturbulence/data/basic.qml b/tests/auto/particles/qsgturbulence/data/basic.qml new file mode 100644 index 0000000000..42b5cd6a97 --- /dev/null +++ b/tests/auto/particles/qsgturbulence/data/basic.qml @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + color: "black" + width: 320 + height: 320 + + ParticleSystem { + id: sys + objectName: "system" + anchors.fill: parent + + ImageParticle { + source: "../../shared/star.png" + } + + Turbulence { + anchors.fill: parent + strength: 1000 + } + + Emitter{ + //100,100 position + x: 100 + y: 100 + size: 32 + emitRate: 1000 + lifeSpan: 500 + } + } +} diff --git a/tests/auto/particles/qsgturbulence/qsgturbulence.pro b/tests/auto/particles/qsgturbulence/qsgturbulence.pro new file mode 100644 index 0000000000..1c38cda566 --- /dev/null +++ b/tests/auto/particles/qsgturbulence/qsgturbulence.pro @@ -0,0 +1,11 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +SOURCES += tst_qsgturbulence.cpp +macx:CONFIG -= app_bundle + +DEFINES += SRCDIR=\\\"$$PWD\\\" + +CONFIG += parallel_test + +QT += core-private gui-private v8-private declarative-private opengl-private + diff --git a/tests/auto/particles/qsgturbulence/tst_qsgturbulence.cpp b/tests/auto/particles/qsgturbulence/tst_qsgturbulence.cpp new file mode 100644 index 0000000000..c7feb3c438 --- /dev/null +++ b/tests/auto/particles/qsgturbulence/tst_qsgturbulence.cpp @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include "../shared/particlestestsshared.h" +#include <private/qsgparticlesystem_p.h> + +class tst_qsgturbulence : public QObject +{ + Q_OBJECT +public: + tst_qsgturbulence(); + +private slots: + void test_basic(); +}; + +tst_qsgturbulence::tst_qsgturbulence() +{ +} + +void tst_qsgturbulence::test_basic() +{ + QSGView* view = createView(SRCDIR "/data/basic.qml", 600); + QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system"); + + //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); + foreach (QSGParticleData *d, system->groupData[0]->data) { + QVERIFY(d->vx != 0.f); + QVERIFY(d->vy != 0.f); + QCOMPARE(d->lifeSpan, 0.5f); + QCOMPARE(d->size, 32.f); + QCOMPARE(d->endSize, 32.f); + QVERIFY(d->t <= ((qreal)system->timeInt/1000.0)); + } +} + +QTEST_MAIN(tst_qsgturbulence); + +#include "tst_qsgturbulence.moc" diff --git a/tests/auto/particles/qsgwander/data/basic.qml b/tests/auto/particles/qsgwander/data/basic.qml new file mode 100644 index 0000000000..ebb4bd963a --- /dev/null +++ b/tests/auto/particles/qsgwander/data/basic.qml @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + color: "black" + width: 320 + height: 320 + + ParticleSystem { + id: sys + objectName: "system" + anchors.fill: parent + + ImageParticle { + source: "../../shared/star.png" + } + + Wander { + pace: 400 + xVariance: 100 + yVariance: 100 + } + + Emitter{ + //0,0 position + size: 32 + emitRate: 1000 + lifeSpan: 500 + } + } +} diff --git a/tests/auto/particles/qsgwander/qsgwander.pro b/tests/auto/particles/qsgwander/qsgwander.pro new file mode 100644 index 0000000000..b8bb4aed13 --- /dev/null +++ b/tests/auto/particles/qsgwander/qsgwander.pro @@ -0,0 +1,11 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +SOURCES += tst_qsgwander.cpp +macx:CONFIG -= app_bundle + +DEFINES += SRCDIR=\\\"$$PWD\\\" + +CONFIG += parallel_test + +QT += core-private gui-private v8-private declarative-private opengl-private + diff --git a/tests/auto/particles/qsgwander/tst_qsgwander.cpp b/tests/auto/particles/qsgwander/tst_qsgwander.cpp new file mode 100644 index 0000000000..24b718c8bf --- /dev/null +++ b/tests/auto/particles/qsgwander/tst_qsgwander.cpp @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include "../shared/particlestestsshared.h" +#include <private/qsgparticlesystem_p.h> + +class tst_qsgwander : public QObject +{ + Q_OBJECT +public: + tst_qsgwander(); + +private slots: + void test_basic(); +}; + +tst_qsgwander::tst_qsgwander() +{ +} + +void tst_qsgwander::test_basic() +{ + QSGView* view = createView(SRCDIR "/data/basic.qml", 600); + QSGParticleSystem* system = view->rootObject()->findChild<QSGParticleSystem*>("system"); + + QCOMPARE(system->groupData[0]->size(), 500); + //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; + bool vyChanged = false; + foreach (QSGParticleData *d, system->groupData[0]->data) { + QCOMPARE(d->ax, 0.f); + QCOMPARE(d->ay, 0.f); + QCOMPARE(d->lifeSpan, 0.5f); + QCOMPARE(d->size, 32.f); + QCOMPARE(d->endSize, 32.f); + QVERIFY(d->t <= ((qreal)system->timeInt/1000.0)); + if (d->vx != 0.0f) + vxChanged = true; + if (d->vy != 0.0f) + vyChanged = true; + } + QVERIFY(vxChanged); + QVERIFY(vyChanged); +} + +QTEST_MAIN(tst_qsgwander); + +#include "tst_qsgwander.moc" diff --git a/tests/auto/particles/shared/particlestestsshared.h b/tests/auto/particles/shared/particlestestsshared.h new file mode 100644 index 0000000000..f4c44c1ace --- /dev/null +++ b/tests/auto/particles/shared/particlestestsshared.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef PARTICLES_TESTS_SHARED +#define PARTICLES_TESTS_SHARED +#include <QSGView> +#include <QtTest> +const qreal EPSILON = 0.0001; + +bool extremelyFuzzyCompare(qreal a, qreal b, qreal e)//For cases which can have larger variances +{ + return (a + e > b) && (a - e < b); +} + +bool myFuzzyCompare(qreal a, qreal b)//For cases which might be near 0 so qFuzzyCompare fails +{ + return (a + EPSILON > b) && (a - EPSILON < b); +} + +QSGView* createView(const QString &filename, int additionalWait) +{ + QSGView *canvas = new QSGView(0); + + canvas->setSource(QUrl::fromLocalFile(filename)); + if (canvas->status() != QSGView::Ready) + return 0; + canvas->show(); + QTest::qWaitForWindowShown(canvas); + if (additionalWait) + QTest::qWait(additionalWait); + + return canvas; +} + +#endif diff --git a/tests/auto/particles/shared/star.png b/tests/auto/particles/shared/star.png Binary files differnew file mode 100644 index 0000000000..0d592cfa87 --- /dev/null +++ b/tests/auto/particles/shared/star.png |