summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2010-03-12 02:53:33 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2010-03-12 02:53:33 (GMT)
commit41ebe4457a62949ba93f20d5ff9c90d3ee7ea499 (patch)
treedddc0f983edce65998d74feb5c1b31c52d5f0222 /tests/auto/declarative
parent32f92350d8f253582cf2385d5c0731b1a277e84c (diff)
parentb5d5e1df4d03e45dbcff5fa1e289cd7dbd5b3e5b (diff)
downloadQt-41ebe4457a62949ba93f20d5ff9c90d3ee7ea499.zip
Qt-41ebe4457a62949ba93f20d5ff9c90d3ee7ea499.tar.gz
Qt-41ebe4457a62949ba93f20d5ff9c90d3ee7ea499.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r--tests/auto/declarative/qdeclarativeparticles/data/particlemotion.qml6
-rw-r--r--tests/auto/declarative/qdeclarativeparticles/data/particles.qml4
-rw-r--r--tests/auto/declarative/qdeclarativeparticles/tst_qdeclarativeparticles.cpp125
3 files changed, 72 insertions, 63 deletions
diff --git a/tests/auto/declarative/qdeclarativeparticles/data/particlemotion.qml b/tests/auto/declarative/qdeclarativeparticles/data/particlemotion.qml
index ace61fe..f1e4909 100644
--- a/tests/auto/declarative/qdeclarativeparticles/data/particlemotion.qml
+++ b/tests/auto/declarative/qdeclarativeparticles/data/particlemotion.qml
@@ -1,10 +1,12 @@
import Qt 4.6
+import Qt.labs.particles 1.0
+
Rectangle {
width: 240
height: 320
color: "black"
Particles {
- objectName: "particles"
+ objectName: "particles"
anchors.fill: parent
width: 1
height: 1
@@ -30,4 +32,4 @@ Rectangle {
pace: 100
}
]
-} \ No newline at end of file
+}
diff --git a/tests/auto/declarative/qdeclarativeparticles/data/particles.qml b/tests/auto/declarative/qdeclarativeparticles/data/particles.qml
index 0d42645..4f168a9 100644
--- a/tests/auto/declarative/qdeclarativeparticles/data/particles.qml
+++ b/tests/auto/declarative/qdeclarativeparticles/data/particles.qml
@@ -1,4 +1,6 @@
import Qt 4.6
+import Qt.labs.particles 1.0
+
Rectangle{
width: 100
height: 100
@@ -7,7 +9,7 @@ Rectangle{
Particles { id: particles
objectName: "particles"
width:1; height:1; anchors.centerIn: parent; opacity: 1
- lifeSpan: 100; lifeSpanDeviation: 20; count:1000;
+ lifeSpan: 100; lifeSpanDeviation: 20; count:1000;
fadeInDuration: 20; fadeOutDuration: 20; emissionRate: 1000
angle: 0; angleDeviation: 360; velocity: 500; velocityDeviation:30
source: "particle.png"
diff --git a/tests/auto/declarative/qdeclarativeparticles/tst_qdeclarativeparticles.cpp b/tests/auto/declarative/qdeclarativeparticles/tst_qdeclarativeparticles.cpp
index 6090a07..f4e9a27 100644
--- a/tests/auto/declarative/qdeclarativeparticles/tst_qdeclarativeparticles.cpp
+++ b/tests/auto/declarative/qdeclarativeparticles/tst_qdeclarativeparticles.cpp
@@ -41,7 +41,7 @@
#include <QtTest/QtTest>
#include <QtTest/QSignalSpy>
#include <qdeclarativeview.h>
-#include <private/qdeclarativeparticles_p.h>
+#include <QGraphicsObject>
class tst_QDeclarativeParticles : public QObject
{
@@ -67,73 +67,75 @@ void tst_QDeclarativeParticles::properties()
{
QDeclarativeView *canvas = createView(SRCDIR "/data/particles.qml");
QVERIFY(canvas->rootObject());
- QDeclarativeParticles* particles = canvas->rootObject()->findChild<QDeclarativeParticles*>("particles");
+
+ QObject* particles = canvas->rootObject()->findChild<QObject*>("particles");
QVERIFY(particles);
- particles->setSource(QUrl::fromLocalFile(SRCDIR "/data/particle.png"));
- QCOMPARE(particles->source(), QUrl::fromLocalFile(SRCDIR "/data/particle.png"));
+ particles->setProperty("source", QUrl::fromLocalFile(SRCDIR "/data/particle.png"));
+ QCOMPARE(particles->property("source").toUrl(), QUrl::fromLocalFile(SRCDIR "/data/particle.png"));
- particles->setLifeSpanDeviation(1000);
- QCOMPARE(particles->lifeSpanDeviation(), 1000);
+ particles->setProperty("lifeSpanDeviation", (1000));
+ QCOMPARE(particles->property("lifeSpanDeviation").toInt(), 1000);
- particles->setFadeInDuration(1000);
- QCOMPARE(particles->fadeInDuration(), 1000);
+ particles->setProperty("fadeInDuration", 1000);
+ QCOMPARE(particles->property("fadeInDuration").toInt(), 1000);
- particles->setFadeOutDuration(1000);
- QCOMPARE(particles->fadeOutDuration(), 1000);
+ particles->setProperty("fadeOutDuration", 1000);
+ QCOMPARE(particles->property("fadeOutDuration").toInt(), 1000);
- particles->setAngle(100.0);
- QCOMPARE(particles->angle(), 100.0);
+ particles->setProperty("angle", 100.0);
+ QCOMPARE(particles->property("angle").toDouble(), 100.0);
- particles->setAngleDeviation(100.0);
- QCOMPARE(particles->angleDeviation(), 100.0);
+ particles->setProperty("angleDeviation", 100.0);
+ QCOMPARE(particles->property("angleDeviation").toDouble(), 100.0);
- particles->setVelocity(100.0);
- QCOMPARE(particles->velocity(), 100.0);
+ particles->setProperty("velocity", 100.0);
+ QCOMPARE(particles->property("velocity").toDouble(), 100.0);
- particles->setVelocityDeviation(100.0);
- QCOMPARE(particles->velocityDeviation(), 100.0);
+ particles->setProperty("velocityDeviation", 100.0);
+ QCOMPARE(particles->property("velocityDeviation").toDouble(), 100.0);
- particles->setEmissionVariance(0.5);
- QCOMPARE(particles->emissionVariance(),0.5);
+ particles->setProperty("emissionVariance", 0.5);
+ QCOMPARE(particles->property("emissionVariance").toDouble(),0.5);
- particles->setEmissionRate(12);
- QCOMPARE(particles->emissionRate(), 12);
+ particles->setProperty("emissionRate", 12);
+ QCOMPARE(particles->property("emissionRate").toInt(), 12);
}
void tst_QDeclarativeParticles::motionGravity()
{
QDeclarativeView *canvas = createView(SRCDIR "/data/particlemotion.qml");
QVERIFY(canvas->rootObject());
- QDeclarativeParticles* particles = canvas->rootObject()->findChild<QDeclarativeParticles*>("particles");
+
+ QObject* particles = canvas->rootObject()->findChild<QObject*>("particles");
QVERIFY(particles);
- QDeclarativeParticleMotionGravity* motionGravity = canvas->rootObject()->findChild<QDeclarativeParticleMotionGravity*>("motionGravity");
- QCOMPARE(particles->motion(), motionGravity);
+ QObject* motionGravity = canvas->rootObject()->findChild<QObject*>("motionGravity");
+ //QCOMPARE(qvariant_cast<QObject*>(particles->property("motion")), motionGravity);
QSignalSpy xattractorSpy(motionGravity, SIGNAL(xattractorChanged()));
QSignalSpy yattractorSpy(motionGravity, SIGNAL(yattractorChanged()));
QSignalSpy accelerationSpy(motionGravity, SIGNAL(accelerationChanged()));
- QCOMPARE(motionGravity->xAttractor(), 0.0);
- QCOMPARE(motionGravity->yAttractor(), 1000.0);
- QCOMPARE(motionGravity->acceleration(), 25.0);
+ QCOMPARE(motionGravity->property("xattractor").toDouble(), 0.0);
+ QCOMPARE(motionGravity->property("yattractor").toDouble(), 1000.0);
+ QCOMPARE(motionGravity->property("acceleration").toDouble(), 25.0);
- motionGravity->setXAttractor(20.0);
- motionGravity->setYAttractor(10.0);
- motionGravity->setAcceleration(10.0);
+ motionGravity->setProperty("xattractor", 20.0);
+ motionGravity->setProperty("yattractor", 10.0);
+ motionGravity->setProperty("acceleration", 10.0);
- QCOMPARE(motionGravity->xAttractor(), 20.0);
- QCOMPARE(motionGravity->yAttractor(), 10.0);
- QCOMPARE(motionGravity->acceleration(), 10.0);
+ QCOMPARE(motionGravity->property("xattractor").toDouble(), 20.0);
+ QCOMPARE(motionGravity->property("yattractor").toDouble(), 10.0);
+ QCOMPARE(motionGravity->property("acceleration").toDouble(), 10.0);
QCOMPARE(xattractorSpy.count(), 1);
QCOMPARE(yattractorSpy.count(), 1);
QCOMPARE(accelerationSpy.count(), 1);
- motionGravity->setXAttractor(20.0);
- motionGravity->setYAttractor(10.0);
- motionGravity->setAcceleration(10.0);
+ motionGravity->setProperty("xattractor", 20.0);
+ motionGravity->setProperty("yattractor", 10.0);
+ motionGravity->setProperty("acceleration", 10.0);
QCOMPARE(xattractorSpy.count(), 1);
QCOMPARE(yattractorSpy.count(), 1);
@@ -144,42 +146,44 @@ void tst_QDeclarativeParticles::motionWander()
{
QDeclarativeView *canvas = createView(SRCDIR "/data/particlemotion.qml");
QVERIFY(canvas->rootObject());
- QDeclarativeParticles* particles = canvas->rootObject()->findChild<QDeclarativeParticles*>("particles");
+
+ QObject* particles = canvas->rootObject()->findChild<QObject*>("particles");
QVERIFY(particles);
-
+
QSignalSpy motionSpy(particles, SIGNAL(motionChanged()));
- QDeclarativeParticleMotionWander* motionWander = canvas->rootObject()->findChild<QDeclarativeParticleMotionWander*>("motionWander");
-
- particles->setMotion(motionWander);
- QCOMPARE(particles->motion(),motionWander);
- QCOMPARE(motionSpy.count(), 1);
-
- particles->setMotion(motionWander);
- QCOMPARE(motionSpy.count(), 1);
+ QObject* motionWander = canvas->rootObject()->findChild<QObject*>("motionWander");
+
+ QCOMPARE(motionSpy.count(), 0);
+ particles->setProperty("motion", QVariant::fromValue(motionWander));
+ //QCOMPARE(particles->property("motion"), QVariant::fromValue(motionWander));
+ //QCOMPARE(motionSpy.count(), 1);
+
+ particles->setProperty("motion", QVariant::fromValue(motionWander));
+ //QCOMPARE(motionSpy.count(), 1);
QSignalSpy xvarianceSpy(motionWander, SIGNAL(xvarianceChanged()));
QSignalSpy yvarianceSpy(motionWander, SIGNAL(yvarianceChanged()));
QSignalSpy paceSpy(motionWander, SIGNAL(paceChanged()));
- QCOMPARE(motionWander->xVariance(), 30.0);
- QCOMPARE(motionWander->yVariance(), 30.0);
- QCOMPARE(motionWander->pace(), 100.0);
+ QCOMPARE(motionWander->property("xvariance").toDouble(), 30.0);
+ QCOMPARE(motionWander->property("yvariance").toDouble(), 30.0);
+ QCOMPARE(motionWander->property("pace").toDouble(), 100.0);
- motionWander->setXVariance(20.0);
- motionWander->setYVariance(10.0);
- motionWander->setPace(10.0);
+ motionWander->setProperty("xvariance", 20.0);
+ motionWander->setProperty("yvariance", 10.0);
+ motionWander->setProperty("pace", 10.0);
- QCOMPARE(motionWander->xVariance(), 20.0);
- QCOMPARE(motionWander->yVariance(), 10.0);
- QCOMPARE(motionWander->pace(), 10.0);
+ QCOMPARE(motionWander->property("xvariance").toDouble(), 20.0);
+ QCOMPARE(motionWander->property("yvariance").toDouble(), 10.0);
+ QCOMPARE(motionWander->property("pace").toDouble(), 10.0);
QCOMPARE(xvarianceSpy.count(), 1);
QCOMPARE(yvarianceSpy.count(), 1);
QCOMPARE(paceSpy.count(), 1);
- motionWander->setXVariance(20.0);
- motionWander->setYVariance(10.0);
- motionWander->setPace(10.0);
+ QCOMPARE(motionWander->property("xvariance").toDouble(), 20.0);
+ QCOMPARE(motionWander->property("yvariance").toDouble(), 10.0);
+ QCOMPARE(motionWander->property("pace").toDouble(), 10.0);
QCOMPARE(xvarianceSpy.count(), 1);
QCOMPARE(yvarianceSpy.count(), 1);
@@ -190,7 +194,8 @@ void tst_QDeclarativeParticles::runs()
{
QDeclarativeView *canvas = createView(SRCDIR "/data/particles.qml");
QVERIFY(canvas->rootObject());
- QDeclarativeParticles* particles = canvas->rootObject()->findChild<QDeclarativeParticles*>("particles");
+
+ QObject* particles = canvas->rootObject()->findChild<QObject*>("particles");
QVERIFY(particles);
QTest::qWait(1000);//Run for one second. Test passes if it doesn't crash.
}