From e59fbf997ece61b36180eb21f9c2cd6ea895b88f Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Fri, 30 Sep 2011 18:25:17 +1000 Subject: [PATCH] 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 Reviewed-by: Martin Jones --- src/declarative/particles/qsgcustomparticle.cpp | 2 +- src/declarative/particles/qsgfriction.cpp | 17 ++- src/declarative/particles/qsgparticlesystem_p.h | 6 +- src/declarative/particles/qsgrectangleextruder.cpp | 2 +- src/declarative/particles/qsgrectangleextruder_p.h | 2 +- tests/auto/particles/qsgage/data/jump.qml | 70 +++++++++ tests/auto/particles/qsgage/data/kill.qml | 66 +++++++++ tests/auto/particles/qsgage/data/onceoff.qml | 69 +++++++++ tests/auto/particles/qsgage/data/sustained.qml | 69 +++++++++ tests/auto/particles/qsgage/qsgage.pro | 11 ++ tests/auto/particles/qsgage/tst_qsgage.cpp | 150 ++++++++++++++++++++ .../particles/qsgangleddirection/data/basic.qml | 68 +++++++++ .../qsgangleddirection/qsgangleddirection.pro | 11 ++ .../qsgangleddirection/tst_qsgangleddirection.cpp | 86 +++++++++++ .../qsgcumulativedirection/data/basic.qml | 74 ++++++++++ .../qsgcumulativedirection.pro | 11 ++ .../tst_qsgcumulativedirection.cpp | 82 +++++++++++ .../particles/qsgcustomaffector/data/basic.qml | 82 +++++++++++ .../qsgcustomaffector/qsgcustomaffector.pro | 11 ++ .../qsgcustomaffector/tst_qsgcustomaffector.cpp | 82 +++++++++++ .../particles/qsgcustomparticle/data/basic.qml | 71 +++++++++ .../qsgcustomparticle/qsgcustomparticle.pro | 11 ++ .../qsgcustomparticle/tst_qsgcustomparticle.cpp | 88 ++++++++++++ .../particles/qsgellipseextruder/data/basic.qml | 77 ++++++++++ .../qsgellipseextruder/qsgellipseextruder.pro | 11 ++ .../qsgellipseextruder/tst_qsgellipseextruder.cpp | 111 +++++++++++++++ tests/auto/particles/qsgfriction/data/basic.qml | 87 +++++++++++ tests/auto/particles/qsgfriction/qsgfriction.pro | 11 ++ .../auto/particles/qsgfriction/tst_qsgfriction.cpp | 98 +++++++++++++ tests/auto/particles/qsggravity/data/basic.qml | 70 +++++++++ tests/auto/particles/qsggravity/qsggravity.pro | 11 ++ tests/auto/particles/qsggravity/tst_qsggravity.cpp | 78 ++++++++++ .../auto/particles/qsgimageparticle/data/basic.qml | 66 +++++++++ .../qsgimageparticle/qsgimageparticle.pro | 11 ++ .../qsgimageparticle/tst_qsgimageparticle.cpp | 97 +++++++++++++ .../auto/particles/qsgitemparticle/data/basic.qml | 66 +++++++++ .../particles/qsgitemparticle/qsgitemparticle.pro | 11 ++ .../qsgitemparticle/tst_qsgitemparticle.cpp | 89 ++++++++++++ .../auto/particles/qsglineextruder/data/basic.qml | 76 ++++++++++ .../particles/qsglineextruder/qsglineextruder.pro | 11 ++ .../qsglineextruder/tst_qsglineextruder.cpp | 94 ++++++++++++ .../auto/particles/qsgmaskextruder/data/basic.qml | 68 +++++++++ .../particles/qsgmaskextruder/data/smallmask.png | Bin 0 -> 719 bytes .../particles/qsgmaskextruder/qsgmaskextruder.pro | 11 ++ .../qsgmaskextruder/tst_qsgmaskextruder.cpp | 82 +++++++++++ .../auto/particles/qsgparticlegroup/data/basic.qml | 73 ++++++++++ .../qsgparticlegroup/qsgparticlegroup.pro | 11 ++ .../qsgparticlegroup/tst_qsgparticlegroup.cpp | 83 +++++++++++ .../particles/qsgparticlesystem/data/basic.qml | 66 +++++++++ .../qsgparticlesystem/qsgparticlesystem.pro | 11 ++ .../qsgparticlesystem/tst_qsgparticlesystem.cpp | 82 +++++++++++ .../particles/qsgpointattractor/data/basic.qml | 73 ++++++++++ .../qsgpointattractor/qsgpointattractor.pro | 11 ++ .../qsgpointattractor/tst_qsgpointattractor.cpp | 83 +++++++++++ .../particles/qsgpointdirection/data/basic.qml | 68 +++++++++ .../qsgpointdirection/qsgpointdirection.pro | 11 ++ .../qsgpointdirection/tst_qsgpointdirection.cpp | 84 +++++++++++ .../particles/qsgrectangleextruder/data/basic.qml | 78 ++++++++++ .../qsgrectangleextruder/qsgrectangleextruder.pro | 11 ++ .../tst_qsgrectangleextruder.cpp | 104 ++++++++++++++ .../particles/qsgtargetdirection/data/basic.qml | 67 +++++++++ .../qsgtargetdirection/qsgtargetdirection.pro | 11 ++ .../qsgtargetdirection/tst_qsgtargetdirection.cpp | 82 +++++++++++ .../auto/particles/qsgtrailemitter/data/basic.qml | 77 ++++++++++ .../particles/qsgtrailemitter/qsgtrailemitter.pro | 11 ++ .../qsgtrailemitter/tst_qsgtrailemitter.cpp | 96 +++++++++++++ tests/auto/particles/qsgturbulence/data/basic.qml | 73 ++++++++++ .../auto/particles/qsgturbulence/qsgturbulence.pro | 11 ++ .../particles/qsgturbulence/tst_qsgturbulence.cpp | 80 +++++++++++ tests/auto/particles/qsgwander/data/basic.qml | 72 ++++++++++ tests/auto/particles/qsgwander/qsgwander.pro | 11 ++ tests/auto/particles/qsgwander/tst_qsgwander.cpp | 88 ++++++++++++ tests/auto/particles/shared/particlestestsshared.h | 73 ++++++++++ tests/auto/particles/shared/star.png | Bin 0 -> 1550 bytes 74 files changed, 3970 insertions(+), 8 deletions(-) create mode 100644 tests/auto/particles/qsgage/data/jump.qml create mode 100644 tests/auto/particles/qsgage/data/kill.qml create mode 100644 tests/auto/particles/qsgage/data/onceoff.qml create mode 100644 tests/auto/particles/qsgage/data/sustained.qml create mode 100644 tests/auto/particles/qsgage/qsgage.pro create mode 100644 tests/auto/particles/qsgage/tst_qsgage.cpp create mode 100644 tests/auto/particles/qsgangleddirection/data/basic.qml create mode 100644 tests/auto/particles/qsgangleddirection/qsgangleddirection.pro create mode 100644 tests/auto/particles/qsgangleddirection/tst_qsgangleddirection.cpp create mode 100644 tests/auto/particles/qsgcumulativedirection/data/basic.qml create mode 100644 tests/auto/particles/qsgcumulativedirection/qsgcumulativedirection.pro create mode 100644 tests/auto/particles/qsgcumulativedirection/tst_qsgcumulativedirection.cpp create mode 100644 tests/auto/particles/qsgcustomaffector/data/basic.qml create mode 100644 tests/auto/particles/qsgcustomaffector/qsgcustomaffector.pro create mode 100644 tests/auto/particles/qsgcustomaffector/tst_qsgcustomaffector.cpp create mode 100644 tests/auto/particles/qsgcustomparticle/data/basic.qml create mode 100644 tests/auto/particles/qsgcustomparticle/qsgcustomparticle.pro create mode 100644 tests/auto/particles/qsgcustomparticle/tst_qsgcustomparticle.cpp create mode 100644 tests/auto/particles/qsgellipseextruder/data/basic.qml create mode 100644 tests/auto/particles/qsgellipseextruder/qsgellipseextruder.pro create mode 100644 tests/auto/particles/qsgellipseextruder/tst_qsgellipseextruder.cpp create mode 100644 tests/auto/particles/qsgfriction/data/basic.qml create mode 100644 tests/auto/particles/qsgfriction/qsgfriction.pro create mode 100644 tests/auto/particles/qsgfriction/tst_qsgfriction.cpp create mode 100644 tests/auto/particles/qsggravity/data/basic.qml create mode 100644 tests/auto/particles/qsggravity/qsggravity.pro create mode 100644 tests/auto/particles/qsggravity/tst_qsggravity.cpp create mode 100644 tests/auto/particles/qsgimageparticle/data/basic.qml create mode 100644 tests/auto/particles/qsgimageparticle/qsgimageparticle.pro create mode 100644 tests/auto/particles/qsgimageparticle/tst_qsgimageparticle.cpp create mode 100644 tests/auto/particles/qsgitemparticle/data/basic.qml create mode 100644 tests/auto/particles/qsgitemparticle/qsgitemparticle.pro create mode 100644 tests/auto/particles/qsgitemparticle/tst_qsgitemparticle.cpp create mode 100644 tests/auto/particles/qsglineextruder/data/basic.qml create mode 100644 tests/auto/particles/qsglineextruder/qsglineextruder.pro create mode 100644 tests/auto/particles/qsglineextruder/tst_qsglineextruder.cpp create mode 100644 tests/auto/particles/qsgmaskextruder/data/basic.qml create mode 100644 tests/auto/particles/qsgmaskextruder/data/smallmask.png create mode 100644 tests/auto/particles/qsgmaskextruder/qsgmaskextruder.pro create mode 100644 tests/auto/particles/qsgmaskextruder/tst_qsgmaskextruder.cpp create mode 100644 tests/auto/particles/qsgparticlegroup/data/basic.qml create mode 100644 tests/auto/particles/qsgparticlegroup/qsgparticlegroup.pro create mode 100644 tests/auto/particles/qsgparticlegroup/tst_qsgparticlegroup.cpp create mode 100644 tests/auto/particles/qsgparticlesystem/data/basic.qml create mode 100644 tests/auto/particles/qsgparticlesystem/qsgparticlesystem.pro create mode 100644 tests/auto/particles/qsgparticlesystem/tst_qsgparticlesystem.cpp create mode 100644 tests/auto/particles/qsgpointattractor/data/basic.qml create mode 100644 tests/auto/particles/qsgpointattractor/qsgpointattractor.pro create mode 100644 tests/auto/particles/qsgpointattractor/tst_qsgpointattractor.cpp create mode 100644 tests/auto/particles/qsgpointdirection/data/basic.qml create mode 100644 tests/auto/particles/qsgpointdirection/qsgpointdirection.pro create mode 100644 tests/auto/particles/qsgpointdirection/tst_qsgpointdirection.cpp create mode 100644 tests/auto/particles/qsgrectangleextruder/data/basic.qml create mode 100644 tests/auto/particles/qsgrectangleextruder/qsgrectangleextruder.pro create mode 100644 tests/auto/particles/qsgrectangleextruder/tst_qsgrectangleextruder.cpp create mode 100644 tests/auto/particles/qsgtargetdirection/data/basic.qml create mode 100644 tests/auto/particles/qsgtargetdirection/qsgtargetdirection.pro create mode 100644 tests/auto/particles/qsgtargetdirection/tst_qsgtargetdirection.cpp create mode 100644 tests/auto/particles/qsgtrailemitter/data/basic.qml create mode 100644 tests/auto/particles/qsgtrailemitter/qsgtrailemitter.pro create mode 100644 tests/auto/particles/qsgtrailemitter/tst_qsgtrailemitter.cpp create mode 100644 tests/auto/particles/qsgturbulence/data/basic.qml create mode 100644 tests/auto/particles/qsgturbulence/qsgturbulence.pro create mode 100644 tests/auto/particles/qsgturbulence/tst_qsgturbulence.cpp create mode 100644 tests/auto/particles/qsgwander/data/basic.qml create mode 100644 tests/auto/particles/qsgwander/qsgwander.pro create mode 100644 tests/auto/particles/qsgwander/tst_qsgwander.cpp create mode 100644 tests/auto/particles/shared/particlestestsshared.h create mode 100644 tests/auto/particles/shared/star.png diff --git a/src/declarative/particles/qsgcustomparticle.cpp b/src/declarative/particles/qsgcustomparticle.cpp index 5aad023..89e465b 100644 --- a/src/declarative/particles/qsgcustomparticle.cpp +++ b/src/declarative/particles/qsgcustomparticle.cpp @@ -79,7 +79,7 @@ static const char qt_particles_default_fragment_code[] = "varying highp vec2 qt_TexCoord0; \n" "uniform lowp float qt_Opacity; \n" "void main() { \n" - " gl_FragColor = texture2D(source, fTex) * qt_Opacity; \n" + " gl_FragColor = texture2D(source, qt_TexCoord0) * qt_Opacity; \n" "}"; static QSGGeometry::Attribute PlainParticle_Attributes[] = { diff --git a/src/declarative/particles/qsgfriction.cpp b/src/declarative/particles/qsgfriction.cpp index 031fc89..44b08e3 100644 --- a/src/declarative/particles/qsgfriction.cpp +++ b/src/declarative/particles/qsgfriction.cpp @@ -54,6 +54,10 @@ QT_BEGIN_NAMESPACE A drag will be applied to moving objects which is this factor of their current velocity. */ +static qreal sign(qreal a) +{ + return a >= 0 ? 1 : -1; +} QSGFrictionAffector::QSGFrictionAffector(QSGItem *parent) : QSGParticleAffector(parent), m_factor(0.0) @@ -66,8 +70,17 @@ bool QSGFrictionAffector::affectParticle(QSGParticleData *d, qreal dt) return false; qreal curVX = d->curVX(); qreal curVY = d->curVY(); - d->setInstantaneousVX(curVX + (curVX * m_factor * -1 * dt)); - d->setInstantaneousVY(curVY + (curVY * m_factor * -1 * dt)); + qreal newVX = curVX + (curVX * m_factor * -1 * dt); + qreal newVY = curVY + (curVY * m_factor * -1 * dt); + + //Since we're modelling a continuous function, it will never pass 0. + if (sign(curVX) != sign(newVX)) + newVX = 0; + if (sign(curVY) != sign(newVY)) + newVY = 0; + + d->setInstantaneousVX(newVX); + d->setInstantaneousVY(newVY); return true; } QT_END_NAMESPACE diff --git a/src/declarative/particles/qsgparticlesystem_p.h b/src/declarative/particles/qsgparticlesystem_p.h index 084409f..5dd93d2 100644 --- a/src/declarative/particles/qsgparticlesystem_p.h +++ b/src/declarative/particles/qsgparticlesystem_p.h @@ -103,7 +103,7 @@ private: QHash m_lookups; }; -class QSGParticleGroupData{ +class Q_AUTOTEST_EXPORT QSGParticleGroupData { public: QSGParticleGroupData(int id, QSGParticleSystem* sys); ~QSGParticleGroupData(); @@ -143,7 +143,7 @@ struct Color4ub { uchar a; }; -class QSGParticleData{ +class Q_AUTOTEST_EXPORT QSGParticleData { public: //TODO: QObject like memory management (without the cost, just attached to system) QSGParticleData(QSGParticleSystem* sys); @@ -225,7 +225,7 @@ private: QSGV8ParticleData* v8Datum; }; -class QSGParticleSystem : public QSGItem +class Q_AUTOTEST_EXPORT QSGParticleSystem : public QSGItem { Q_OBJECT Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged) diff --git a/src/declarative/particles/qsgrectangleextruder.cpp b/src/declarative/particles/qsgrectangleextruder.cpp index accc88f..fde227c 100644 --- a/src/declarative/particles/qsgrectangleextruder.cpp +++ b/src/declarative/particles/qsgrectangleextruder.cpp @@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE */ QSGRectangleExtruder::QSGRectangleExtruder(QObject *parent) : - QObject(parent), m_fill(true) + QSGParticleExtruder(parent), m_fill(true) { } diff --git a/src/declarative/particles/qsgrectangleextruder_p.h b/src/declarative/particles/qsgrectangleextruder_p.h index 5795375..9cc51b2 100644 --- a/src/declarative/particles/qsgrectangleextruder_p.h +++ b/src/declarative/particles/qsgrectangleextruder_p.h @@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QSGRectangleExtruder : public QObject +class QSGRectangleExtruder : public QSGParticleExtruder { Q_OBJECT Q_PROPERTY(bool fill READ fill WRITE setFill NOTIFY fillChanged) diff --git a/tests/auto/particles/qsgage/data/jump.qml b/tests/auto/particles/qsgage/data/jump.qml new file mode 100644 index 0000000..e66f9f4 --- /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 0000000..2558435 --- /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 0000000..15d0e12 --- /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 0000000..96aefec --- /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 0000000..3ca0740 --- /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 0000000..884c210 --- /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 +#include "../shared/particlestestsshared.h" +#include + +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("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("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("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("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 0000000..c2fda56 --- /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 0000000..a90b00b --- /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 0000000..0cc2c8b --- /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 +#include +#include "../shared/particlestestsshared.h" +#include + +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("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 0000000..bd46c45 --- /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 0000000..03d9ca2 --- /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 0000000..0c54ad8 --- /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 +#include "../shared/particlestestsshared.h" +#include + +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("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 0000000..7371698 --- /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 +#include "../shared/particlestestsshared.h" +#include + +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("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 0000000..244f706 --- /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 0000000..a151daf --- /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 0000000..74ef8af --- /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 +#include "../shared/particlestestsshared.h" +#include + +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("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 0000000..fa5fb36 --- /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 0000000..5315686 --- /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 0000000..f398936 --- /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 +#include +#include "../shared/particlestestsshared.h" +#include + +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("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 0000000..87a8897 --- /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 0000000..a56f4b4 --- /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 0000000..8981275 --- /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 +#include "../shared/particlestestsshared.h" +#include + +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("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 0000000..9275654 --- /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 0000000..d7a7bbd --- /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 0000000..584ec18 --- /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 +#include "../shared/particlestestsshared.h" +#include + +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("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 0000000..f5ef4c1 --- /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 0000000..d1197f0 --- /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 0000000..5e6e77c --- /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 +#include "../shared/particlestestsshared.h" +#include + +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("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 0000000..dbe16a0 --- /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 0000000..e2d2c67 --- /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 0000000..440ebaf --- /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 +#include "../shared/particlestestsshared.h" +#include +#include + +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("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(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 0000000..dbe2ec5 --- /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 0000000..ccafa70 --- /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 0000000..6a7cfe4 --- /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 +#include "../shared/particlestestsshared.h" +#include + +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("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 0000000..804df83 --- /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 new file mode 100644 index 0000000000000000000000000000000000000000..e36fb9fe55ffa985f24326b120fc3b1a359a92ae GIT binary patch literal 719 zcmeAS@N?(olHy`uVBq!ia0y~yU~~Xs4mP03*$GQm0V&P`kH})6{BHF^R|Giu3$;PB5Oz^qjE~q{`FP&t;ucLK6Ti +#include "../shared/particlestestsshared.h" +#include + +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("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 0000000..97dadd7 --- /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 0000000..40e799d --- /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 0000000..21eb52b --- /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 +#include "../shared/particlestestsshared.h" +#include + +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("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 0000000..f5ef4c1 --- /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 0000000..6ba836a --- /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 0000000..d5a0a2a --- /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 +#include "../shared/particlestestsshared.h" +#include + +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("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 0000000..86861a9 --- /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 0000000..b2acf47 --- /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 0000000..33fc670 --- /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 +#include "../shared/particlestestsshared.h" +#include + +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("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 0000000..60c2a3e --- /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 0000000..6a02503 --- /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 0000000..89d0f31 --- /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 +#include "../shared/particlestestsshared.h" +#include + +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("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 0000000..a66827e --- /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 0000000..207aa13 --- /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 0000000..1e45f81 --- /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 +#include "../shared/particlestestsshared.h" +#include + +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("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 0000000..a8caea4 --- /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 0000000..397957e --- /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 0000000..c5d84f5 --- /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 +#include "../shared/particlestestsshared.h" +#include + +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("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 0000000..538d14f --- /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 0000000..914d0e5 --- /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 0000000..a92b791 --- /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 +#include "../shared/particlestestsshared.h" +#include + +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("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 0000000..42b5cd6 --- /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 0000000..1c38cda --- /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 0000000..c7feb3c --- /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 +#include "../shared/particlestestsshared.h" +#include + +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("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 0000000..ebb4bd9 --- /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 0000000..b8bb4ae --- /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 0000000..24b718c --- /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 +#include "../shared/particlestestsshared.h" +#include + +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("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 0000000..f4c44c1 --- /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 +#include +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 new file mode 100644 index 0000000000000000000000000000000000000000..0d592cfa8752ac8a75f92614369011812be88639 GIT binary patch literal 1550 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz$r9IylHmNblJdl&R0hYC{G?O` z&)mfH)S%SFl*+=BsWuD@%u1Od5hW46K32*3xq68pHF_1f1wh>l3^w)^1&PVosU-?Y zsp*+{wo31J?^jaDOtDo8H}y5}EpSfF$n>ZxN)4{^3rViZPPR-@vbR&PsjvbXkegbP zs8ErclUHn2VXFi-*9yo63F|80+w{G(j&jGsViu#lY3g$;Hsn#lXza(AB`g+{MiW80;?2=H^aD zE=DlDF8Rr&xv6<2Fuf@Vy+%0of|5dR0nlcb)S}F?)D*X({9FaFm#s2!y2aTIr+HAl zDY)HYfK#tN&@uX;h((HMm=G}afSB-P3*^8Perg^twHE=CH6P#S^9&43O`a}}Ar-f_ zgy;5MHV`p<(R*9 ztIE23WZv_c-;e1T78`z0dT;&s--DB{7!M|$H(fbdV1aO|M#WTq5u0i`ZD!Gk;i zF6OQ5waWeYQ$jM+c6FfAU%QE&32G6^fwS(^GcDwlz3o=O=xf3$wCkU6%0^a3xunCo zO!kbOp$@_e-Ar2hq*&Cw=cFDnvyFK*t;t(Jv1j#$207JvJ45Y{?odlTYjt_QpMyPX zxWH9ejvv!EUyt~}^WKbe?F`8cYn}#GYF98Su?VHlIL`Ual<9u@m!3CaF{_I1aNJv< za^E3|C+T_<>#;YQc3W;(9rDxOyMA}@*YtzY=Wn0Wl%M#^?uVb?0%tD)9H$+}KdyP)&zjyh`u4QXV=qa6 zE$~O^p#8#UdpY8pPK56{y>aStqX3DuWnA2Kf`2|7yMM4Myx`Q@jdR~mRG7ngQXuAK zW-8n2yUqnuzt0I({>2(J*S*F0=}Kc3=Nl2vJbng6cH1yT-zehC)d>yQ=5=7A@g0`f zyvDN~SC%Yc+H&C(tH+uoC!f>=p8oZFdYAg#n0#@YbU