summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2009-11-04 04:16:57 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2009-11-04 04:16:57 (GMT)
commit120134ec588a6edf572df8d1fae40013753d233e (patch)
tree3cd78f46a5ffb72408c9fc4e3267095ccec1957a /tests/auto
parente042014961636d459dc84df93ad2cca96049e2d1 (diff)
parent684fe7af0b6d8133973132fd5b6b01cc16957a10 (diff)
downloadQt-120134ec588a6edf572df8d1fae40013753d233e.zip
Qt-120134ec588a6edf572df8d1fae40013753d233e.tar.gz
Qt-120134ec588a6edf572df8d1fae40013753d233e.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/declarative/behaviors/data/empty.qml23
-rw-r--r--tests/auto/declarative/behaviors/data/nonSelecting.qml26
-rw-r--r--tests/auto/declarative/behaviors/data/reassignedAnimation.qml27
-rw-r--r--tests/auto/declarative/datetimeformatter/tst_datetimeformatter.cpp10
-rw-r--r--tests/auto/declarative/declarative.pro1
-rw-r--r--tests/auto/declarative/listview/tst_listview.cpp20
-rw-r--r--tests/auto/declarative/qmlgraphicsborderimage/data/colors-round.sci7
-rw-r--r--tests/auto/declarative/qmlgraphicsborderimage/data/colors.pngbin0 -> 1655 bytes
-rw-r--r--tests/auto/declarative/qmlgraphicsborderimage/qmlgraphicsborderimage.pro8
-rw-r--r--tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp162
-rw-r--r--tests/auto/declarative/qmlgraphicsparticles/data/particle.pngbin0 -> 262 bytes
-rw-r--r--tests/auto/declarative/qmlgraphicsparticles/data/particles.qml15
-rw-r--r--tests/auto/declarative/qmlgraphicsparticles/qmlgraphicsparticles.pro8
-rw-r--r--tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp122
-rw-r--r--tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp8
-rw-r--r--tests/auto/declarative/qmlqt/data/closestangle.qml12
-rw-r--r--tests/auto/declarative/qmlqt/tst_qmlqt.cpp18
-rw-r--r--tests/auto/declarative/states/data/anchorChanges.qml22
-rw-r--r--tests/auto/declarative/states/data/anchorChanges2.qml21
-rw-r--r--tests/auto/declarative/states/data/parentChange.qml36
-rw-r--r--tests/auto/declarative/states/data/parentChange2.qml31
-rw-r--r--tests/auto/declarative/states/data/parentChange3.qml42
-rw-r--r--tests/auto/declarative/states/data/script.qml10
-rw-r--r--tests/auto/declarative/states/tst_states.cpp113
24 files changed, 738 insertions, 4 deletions
diff --git a/tests/auto/declarative/behaviors/data/empty.qml b/tests/auto/declarative/behaviors/data/empty.qml
new file mode 100644
index 0000000..412e26c
--- /dev/null
+++ b/tests/auto/declarative/behaviors/data/empty.qml
@@ -0,0 +1,23 @@
+import Qt 4.6
+Rectangle {
+ width: 400
+ height: 400
+ Rectangle {
+ id: rect
+ objectName: "MyRect"
+ width: 100; height: 100; color: "green"
+ x: Behavior {}
+ }
+ MouseRegion {
+ id: clicker
+ anchors.fill: parent
+ }
+ states: State {
+ name: "moved"
+ when: clicker.pressed
+ PropertyChanges {
+ target: rect
+ x: 200
+ }
+ }
+}
diff --git a/tests/auto/declarative/behaviors/data/nonSelecting.qml b/tests/auto/declarative/behaviors/data/nonSelecting.qml
new file mode 100644
index 0000000..ae9a9f5
--- /dev/null
+++ b/tests/auto/declarative/behaviors/data/nonSelecting.qml
@@ -0,0 +1,26 @@
+import Qt 4.6
+Rectangle {
+ width: 400
+ height: 400
+ Rectangle {
+ id: rect
+ objectName: "MyRect"
+ width: 100; height: 100; color: "green"
+ x: Behavior {
+ objectName: "MyBehavior";
+ NumberAnimation { target: rect; property: "y"; duration: 200; }
+ }
+ }
+ MouseRegion {
+ id: clicker
+ anchors.fill: parent
+ }
+ states: State {
+ name: "moved"
+ when: clicker.pressed
+ PropertyChanges {
+ target: rect
+ x: 200
+ }
+ }
+}
diff --git a/tests/auto/declarative/behaviors/data/reassignedAnimation.qml b/tests/auto/declarative/behaviors/data/reassignedAnimation.qml
new file mode 100644
index 0000000..693a595
--- /dev/null
+++ b/tests/auto/declarative/behaviors/data/reassignedAnimation.qml
@@ -0,0 +1,27 @@
+import Qt 4.6
+Rectangle {
+ width: 400
+ height: 400
+ Rectangle {
+ id: rect
+ objectName: "MyRect"
+ width: 100; height: 100; color: "green"
+ x: Behavior {
+ objectName: "MyBehavior"
+ NumberAnimation { duration: 200 }
+ NumberAnimation { duration: 1000 }
+ }
+ }
+ MouseRegion {
+ id: clicker
+ anchors.fill: parent
+ }
+ states: State {
+ name: "moved"
+ when: clicker.pressed
+ PropertyChanges {
+ target: rect
+ x: 200
+ }
+ }
+}
diff --git a/tests/auto/declarative/datetimeformatter/tst_datetimeformatter.cpp b/tests/auto/declarative/datetimeformatter/tst_datetimeformatter.cpp
index 1712b86..5899d8d 100644
--- a/tests/auto/declarative/datetimeformatter/tst_datetimeformatter.cpp
+++ b/tests/auto/declarative/datetimeformatter/tst_datetimeformatter.cpp
@@ -67,12 +67,16 @@ void tst_datetimeformatter::date()
QVERIFY(formatter != 0);
QDate date(2008,12,24);
+ QCOMPARE(formatter->date(), date);
+ QCOMPARE(formatter->dateTime().date(), date);
QCOMPARE(formatter->dateText(),date.toString(Qt::SystemLocaleShortDate));
formatter->setLongStyle(true);
+ QVERIFY(formatter->longStyle());
QCOMPARE(formatter->dateText(),date.toString(Qt::SystemLocaleLongDate));
formatter->setDateFormat("ddd MMMM d yy");
+ QCOMPARE(formatter->dateFormat(), QLatin1String("ddd MMMM d yy"));
QCOMPARE(formatter->dateText(),date.toString("ddd MMMM d yy"));
QVERIFY(formatter->timeText().isEmpty());
@@ -91,6 +95,7 @@ void tst_datetimeformatter::time()
QTime time(14,15,38,200);
QCOMPARE(formatter->time(),time);
+ QCOMPARE(formatter->dateTime().time(),time);
QCOMPARE(formatter->timeText(),time.toString(Qt::SystemLocaleShortDate));
@@ -98,6 +103,7 @@ void tst_datetimeformatter::time()
QCOMPARE(formatter->timeText(),time.toString(Qt::SystemLocaleLongDate));
formatter->setTimeFormat("H:m:s a");
+ QCOMPARE(formatter->timeFormat(), QLatin1String("H:m:s a"));
QCOMPARE(formatter->timeText(),time.toString("H:m:s a"));
formatter->setTimeFormat("hh:mm:ss.zzz");
@@ -117,12 +123,16 @@ void tst_datetimeformatter::dateTime()
QVERIFY(formatter != 0);
QDateTime dateTime(QDate(1978,03,04),QTime(9,13,54));
+ QCOMPARE(formatter->dateTime(),dateTime);
+ QCOMPARE(formatter->date(),dateTime.date());
+ QCOMPARE(formatter->time(),dateTime.time());
QCOMPARE(formatter->dateTimeText(),dateTime.toString(Qt::SystemLocaleShortDate));
formatter->setLongStyle(true);
QCOMPARE(formatter->dateTimeText(),dateTime.toString(Qt::SystemLocaleLongDate));
formatter->setDateTimeFormat("M/d/yy H:m:s a");
+ QCOMPARE(formatter->dateTimeFormat(), QLatin1String("M/d/yy H:m:s a"));
QCOMPARE(formatter->dateTimeText(),dateTime.toString("M/d/yy H:m:s a"));
}
diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro
index 86cf175..321e91b 100644
--- a/tests/auto/declarative/declarative.pro
+++ b/tests/auto/declarative/declarative.pro
@@ -19,6 +19,7 @@ SUBDIRS += anchors \
qmldom \
qmlecmascript \
qmlgraphicstext \
+ qmlgraphicsborderimage \
qmlfontloader \
qmllanguage \
qmllist \
diff --git a/tests/auto/declarative/listview/tst_listview.cpp b/tests/auto/declarative/listview/tst_listview.cpp
index 441138b..e61dd55 100644
--- a/tests/auto/declarative/listview/tst_listview.cpp
+++ b/tests/auto/declarative/listview/tst_listview.cpp
@@ -356,6 +356,26 @@ void tst_QmlGraphicsListView::inserted()
QVERIFY(item->y() == i*20);
}
+ for (int i = model.count(); i < 30; ++i)
+ model.insertItem(i, "Hello", QString::number(i));
+ QTest::qWait(1000);
+
+ listview->setViewportY(80);
+ QTest::qWait(1000);
+
+ // Insert item outside visible area
+ model.insertItem(1, "Hello", "1324");
+ QTest::qWait(1000);
+
+ QVERIFY(listview->viewportY() == 80);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count() - 1;
+ for (int i = 5; i < 5+itemCount; ++i) {
+ QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
+ QVERIFY(item->y() == i*20 - 20);
+ }
+
delete canvas;
}
diff --git a/tests/auto/declarative/qmlgraphicsborderimage/data/colors-round.sci b/tests/auto/declarative/qmlgraphicsborderimage/data/colors-round.sci
new file mode 100644
index 0000000..5d2f49f
--- /dev/null
+++ b/tests/auto/declarative/qmlgraphicsborderimage/data/colors-round.sci
@@ -0,0 +1,7 @@
+border.left:10
+border.top:20
+border.right:30
+border.bottom:40
+horizontalTileRule:Round
+verticalTileRule:Repeat
+source:colors.png
diff --git a/tests/auto/declarative/qmlgraphicsborderimage/data/colors.png b/tests/auto/declarative/qmlgraphicsborderimage/data/colors.png
new file mode 100644
index 0000000..dfb62f3
--- /dev/null
+++ b/tests/auto/declarative/qmlgraphicsborderimage/data/colors.png
Binary files differ
diff --git a/tests/auto/declarative/qmlgraphicsborderimage/qmlgraphicsborderimage.pro b/tests/auto/declarative/qmlgraphicsborderimage/qmlgraphicsborderimage.pro
new file mode 100644
index 0000000..82da769
--- /dev/null
+++ b/tests/auto/declarative/qmlgraphicsborderimage/qmlgraphicsborderimage.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qmlgraphicsborderimage.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp b/tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp
new file mode 100644
index 0000000..4174ccf
--- /dev/null
+++ b/tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp
@@ -0,0 +1,162 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 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$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QTextDocument>
+#include <QtDeclarative/qmlengine.h>
+#include <QtDeclarative/qmlcomponent.h>
+#include <private/qmlgraphicsborderimage_p.h>
+#include <private/qmlgraphicsimagebase_p.h>
+#include <private/qmlgraphicsscalegrid_p_p.h>
+
+class tst_qmlgraphicsborderimage : public QObject
+
+{
+ Q_OBJECT
+public:
+ tst_qmlgraphicsborderimage();
+
+private slots:
+ void simple();
+ void resized();
+ void smooth();
+ void tileModes();
+ void sciFile();
+
+private:
+ QmlEngine engine;
+};
+
+tst_qmlgraphicsborderimage::tst_qmlgraphicsborderimage()
+{
+}
+
+void tst_qmlgraphicsborderimage::simple()
+{
+ QString componentStr = "import Qt 4.6\nBorderImage { source: \"" SRCDIR "/data/colors.png\" }";
+ QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://"));
+ QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QVERIFY(obj->width() == 120);
+ QVERIFY(obj->height() == 120);
+ QVERIFY(obj->horizontalTileMode() == QmlGraphicsBorderImage::Stretch);
+ QVERIFY(obj->verticalTileMode() == QmlGraphicsBorderImage::Stretch);
+
+ delete obj;
+}
+
+void tst_qmlgraphicsborderimage::resized()
+{
+ QString componentStr = "import Qt 4.6\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; width: 300; height: 300 }";
+ QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://"));
+ QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QVERIFY(obj->width() == 300);
+ QVERIFY(obj->height() == 300);
+ QVERIFY(obj->horizontalTileMode() == QmlGraphicsBorderImage::Stretch);
+ QVERIFY(obj->verticalTileMode() == QmlGraphicsBorderImage::Stretch);
+
+ delete obj;
+}
+
+void tst_qmlgraphicsborderimage::smooth()
+{
+ QString componentStr = "import Qt 4.6\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; smooth: true; width: 300; height: 300 }";
+ QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://"));
+ QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QVERIFY(obj->width() == 300);
+ QVERIFY(obj->height() == 300);
+ QVERIFY(obj->smooth() == true);
+ QVERIFY(obj->horizontalTileMode() == QmlGraphicsBorderImage::Stretch);
+ QVERIFY(obj->verticalTileMode() == QmlGraphicsBorderImage::Stretch);
+
+ delete obj;
+}
+
+void tst_qmlgraphicsborderimage::tileModes()
+{
+ {
+ QString componentStr = "import Qt 4.6\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; width: 100; height: 300; horizontalTileMode: BorderImage.Repeat; verticalTileMode: BorderImage.Repeat }";
+ QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://"));
+ QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QVERIFY(obj->width() == 100);
+ QVERIFY(obj->height() == 300);
+ QVERIFY(obj->horizontalTileMode() == QmlGraphicsBorderImage::Repeat);
+ QVERIFY(obj->verticalTileMode() == QmlGraphicsBorderImage::Repeat);
+
+ delete obj;
+ }
+ {
+ QString componentStr = "import Qt 4.6\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; width: 300; height: 150; horizontalTileMode: BorderImage.Round; verticalTileMode: BorderImage.Round }";
+ QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://"));
+ QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QVERIFY(obj->width() == 300);
+ QVERIFY(obj->height() == 150);
+ QVERIFY(obj->horizontalTileMode() == QmlGraphicsBorderImage::Round);
+ QVERIFY(obj->verticalTileMode() == QmlGraphicsBorderImage::Round);
+
+ delete obj;
+ }
+}
+
+void tst_qmlgraphicsborderimage::sciFile()
+{
+ QString componentStr = "import Qt 4.6\nBorderImage { source: \"" SRCDIR "/data/colors-round.sci\"; width: 300; height: 300 }";
+ QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://"));
+ QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QVERIFY(obj->width() == 300);
+ QVERIFY(obj->height() == 300);
+ QVERIFY(obj->border()->left() == 10);
+ QVERIFY(obj->border()->top() == 20);
+ QVERIFY(obj->border()->right() == 30);
+ QVERIFY(obj->border()->bottom() == 40);
+ QVERIFY(obj->horizontalTileMode() == QmlGraphicsBorderImage::Round);
+ QVERIFY(obj->verticalTileMode() == QmlGraphicsBorderImage::Repeat);
+
+ delete obj;
+}
+
+QTEST_MAIN(tst_qmlgraphicsborderimage)
+
+#include "tst_qmlgraphicsborderimage.moc"
diff --git a/tests/auto/declarative/qmlgraphicsparticles/data/particle.png b/tests/auto/declarative/qmlgraphicsparticles/data/particle.png
new file mode 100644
index 0000000..defbde5
--- /dev/null
+++ b/tests/auto/declarative/qmlgraphicsparticles/data/particle.png
Binary files differ
diff --git a/tests/auto/declarative/qmlgraphicsparticles/data/particles.qml b/tests/auto/declarative/qmlgraphicsparticles/data/particles.qml
new file mode 100644
index 0000000..dccd2c7
--- /dev/null
+++ b/tests/auto/declarative/qmlgraphicsparticles/data/particles.qml
@@ -0,0 +1,15 @@
+import Qt 4.6
+Rectangle{
+ width: 100
+ height: 100
+ color: "black"
+ objectName: "rect"
+ Particles { id: particles
+ objectName: "particles"
+ width:1; height:1; anchors.centerIn: parent; opacity: 1
+ lifeSpan: 100; lifeSpanDeviation: 20; count:1000;
+ fadeInDuration: 20; fadeOutDuration: 20;
+ angle: 0; angleDeviation: 360; velocity: 500; velocityDeviation:30
+ source: "particle.png"
+ }
+}
diff --git a/tests/auto/declarative/qmlgraphicsparticles/qmlgraphicsparticles.pro b/tests/auto/declarative/qmlgraphicsparticles/qmlgraphicsparticles.pro
new file mode 100644
index 0000000..94eeb4e
--- /dev/null
+++ b/tests/auto/declarative/qmlgraphicsparticles/qmlgraphicsparticles.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qmlgraphicsparticles.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp b/tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp
new file mode 100644
index 0000000..e50437a
--- /dev/null
+++ b/tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 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$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtTest/QtTest>
+#include <qmlview.h>
+#include <private/qmlgraphicsparticles_p.h>
+
+class tst_QmlGraphicsParticles : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QmlGraphicsParticles();
+
+private slots:
+ void properties();
+ void runs();
+private:
+ QmlView *createView(const QString &filename);
+
+};
+
+tst_QmlGraphicsParticles::tst_QmlGraphicsParticles()
+{
+}
+
+void tst_QmlGraphicsParticles::properties()
+{
+ QmlView *canvas = createView(SRCDIR "/data/particles.qml");
+ QVERIFY(canvas->root());
+ QmlGraphicsParticles* particles = canvas->root()->findChild<QmlGraphicsParticles*>("particles");
+ QVERIFY(particles);
+
+ particles->setSource(QUrl("file://" SRCDIR "/data/particle.png"));
+ QCOMPARE(particles->source(), QUrl("file://" SRCDIR "/data/particle.png"));
+
+ particles->setLifeSpanDeviation(1000);
+ QCOMPARE(particles->lifeSpanDeviation(), 1000);
+
+ particles->setFadeInDuration(1000);
+ QCOMPARE(particles->fadeInDuration(), 1000);
+
+ particles->setFadeOutDuration(1000);
+ QCOMPARE(particles->fadeOutDuration(), 1000);
+
+ particles->setAngle(100.0);
+ QCOMPARE(particles->angle(), 100.0);
+
+ particles->setAngleDeviation(100.0);
+ QCOMPARE(particles->angleDeviation(), 100.0);
+
+ particles->setVelocity(100.0);
+ QCOMPARE(particles->velocity(), 100.0);
+
+ particles->setVelocityDeviation(100.0);
+ QCOMPARE(particles->velocityDeviation(), 100.0);
+
+ particles->setEmitting(false);
+ QCOMPARE(particles->emitting(), false);
+}
+
+void tst_QmlGraphicsParticles::runs()
+{
+ QmlView *canvas = createView(SRCDIR "/data/particles.qml");
+ QVERIFY(canvas->root());
+ QmlGraphicsParticles* particles = canvas->root()->findChild<QmlGraphicsParticles*>("particles");
+ QVERIFY(particles);
+ QTest::qWait(1000);//Run for one second. Test passes if it doesn't crash.
+}
+
+QmlView *tst_QmlGraphicsParticles::createView(const QString &filename)
+{
+ QmlView *canvas = new QmlView(0);
+ canvas->setFixedSize(240,320);
+
+ QFile file(filename);
+ file.open(QFile::ReadOnly);
+ QString qml = file.readAll();
+ canvas->setQml(qml, filename);
+ canvas->execute();
+
+ return canvas;
+}
+QTEST_MAIN(tst_QmlGraphicsParticles)
+
+#include "tst_qmlgraphicsparticles.moc"
diff --git a/tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp b/tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp
index b9c12ee..1a90575 100644
--- a/tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp
+++ b/tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp
@@ -502,13 +502,13 @@ void tst_qmlgraphicstext::smooth()
QString componentStr = "import Qt 4.6\nText { smooth: true; text: \"" + standard.at(i) + "\" }";
QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
- QCOMPARE(textObject->smoothTransform(), true);
+ QCOMPARE(textObject->smooth(), true);
}
{
QString componentStr = "import Qt 4.6\nText { text: \"" + standard.at(i) + "\" }";
QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
- QCOMPARE(textObject->smoothTransform(), false);
+ QCOMPARE(textObject->smooth(), false);
}
}
for (int i = 0; i < richText.size(); i++)
@@ -517,13 +517,13 @@ void tst_qmlgraphicstext::smooth()
QString componentStr = "import Qt 4.6\nText { smooth: true; text: \"" + richText.at(i) + "\" }";
QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
- QCOMPARE(textObject->smoothTransform(), true);
+ QCOMPARE(textObject->smooth(), true);
}
{
QString componentStr = "import Qt 4.6\nText { text: \"" + richText.at(i) + "\" }";
QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
- QCOMPARE(textObject->smoothTransform(), false);
+ QCOMPARE(textObject->smooth(), false);
}
}
}
diff --git a/tests/auto/declarative/qmlqt/data/closestangle.qml b/tests/auto/declarative/qmlqt/data/closestangle.qml
new file mode 100644
index 0000000..8f999e3
--- /dev/null
+++ b/tests/auto/declarative/qmlqt/data/closestangle.qml
@@ -0,0 +1,12 @@
+import Qt 4.6
+
+Object {
+ property var testSame: Qt.closestAngle(0,1)
+ property var testLess: Qt.closestAngle(0,-359)
+ property var testMore: Qt.closestAngle(0,361)
+ property var testFail: Qt.closestAngle(0)
+ property var test5: Qt.closestAngle(0,1,2)
+ property var test6: Qt.closestAngle(123.45465768,1.11)
+ property var test7: Qt.closestAngle(-3.1415,1.11)
+}
+
diff --git a/tests/auto/declarative/qmlqt/tst_qmlqt.cpp b/tests/auto/declarative/qmlqt/tst_qmlqt.cpp
index 10402ae..cc9b94d 100644
--- a/tests/auto/declarative/qmlqt/tst_qmlqt.cpp
+++ b/tests/auto/declarative/qmlqt/tst_qmlqt.cpp
@@ -64,6 +64,7 @@ private slots:
void lighter();
void darker();
void tint();
+ void closestAngle();
void playSound();
void openUrlExternally();
@@ -249,6 +250,23 @@ void tst_qmlqt::tint()
delete object;
}
+void tst_qmlqt::closestAngle()
+{
+ QmlComponent component(&engine, TEST_FILE("closestangle.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<qreal>(object->property("testSame")), 1.0);
+ QCOMPARE(qvariant_cast<qreal>(object->property("testLess")), 1.0);
+ QCOMPARE(qvariant_cast<qreal>(object->property("testMore")), 1.0);
+ QCOMPARE(qvariant_cast<qreal>(object->property("testFail")), 0.0);
+ QCOMPARE(qvariant_cast<qreal>(object->property("test5")), 1.0);
+ QCOMPARE(qvariant_cast<qreal>(object->property("test6")), 1.11);
+ QCOMPARE(qvariant_cast<qreal>(object->property("test7")), 1.11);
+
+ delete object;
+}
+
void tst_qmlqt::playSound()
{
QEXPECT_FAIL("", "How do we test this?", Abort);
diff --git a/tests/auto/declarative/states/data/anchorChanges.qml b/tests/auto/declarative/states/data/anchorChanges.qml
new file mode 100644
index 0000000..bb17840
--- /dev/null
+++ b/tests/auto/declarative/states/data/anchorChanges.qml
@@ -0,0 +1,22 @@
+import Qt 4.6
+
+Rectangle {
+ id: container
+ width: 200; height: 200
+ Rectangle {
+ id: myRect
+ objectName: "MyRect"
+ width: 50; height: 50
+ color: "green";
+ anchors.left: parent.left
+ anchors.leftMargin: 5
+ }
+ states: State {
+ name: "right"
+ AnchorChanges {
+ target: myRect;
+ reset: "left"
+ right: container.right
+ }
+ }
+}
diff --git a/tests/auto/declarative/states/data/anchorChanges2.qml b/tests/auto/declarative/states/data/anchorChanges2.qml
new file mode 100644
index 0000000..545345e
--- /dev/null
+++ b/tests/auto/declarative/states/data/anchorChanges2.qml
@@ -0,0 +1,21 @@
+import Qt 4.6
+
+Rectangle {
+ width: 200; height: 200
+ Rectangle {
+ id: myRect
+ objectName: "MyRect"
+ width: 50; height: 50
+ color: "green";
+ anchors.left: parent.left
+ anchors.leftMargin: 5
+ }
+ states: State {
+ name: "right"
+ AnchorChanges {
+ target: myRect;
+ reset: "left"
+ right: parent.right
+ }
+ }
+}
diff --git a/tests/auto/declarative/states/data/parentChange.qml b/tests/auto/declarative/states/data/parentChange.qml
new file mode 100644
index 0000000..94fbd69
--- /dev/null
+++ b/tests/auto/declarative/states/data/parentChange.qml
@@ -0,0 +1,36 @@
+import Qt 4.6
+
+Rectangle {
+ width: 400; height: 400
+ Item {
+ x: 10; y: 10
+ Rectangle {
+ id: myRect
+ objectName: "MyRect"
+ x: 5
+ width: 100; height: 100
+ color: "red"
+ }
+ }
+ MouseRegion {
+ id: Clickable
+ anchors.fill: parent
+ }
+
+ Item {
+ x: -100; y: -50
+ Item {
+ id: newParent
+ x: 248; y: 360
+ }
+ }
+
+ states: State {
+ name: "reparented"
+ when: Clickable.pressed
+ ParentChange {
+ target: myRect
+ parent: newParent
+ }
+ }
+}
diff --git a/tests/auto/declarative/states/data/parentChange2.qml b/tests/auto/declarative/states/data/parentChange2.qml
new file mode 100644
index 0000000..d1c6d6a
--- /dev/null
+++ b/tests/auto/declarative/states/data/parentChange2.qml
@@ -0,0 +1,31 @@
+import Qt 4.6
+
+Rectangle {
+ id: newParent
+ width: 400; height: 400
+ Item {
+ scale: .5
+ rotation: 15
+ x: 10; y: 10
+ Rectangle {
+ id: myRect
+ objectName: "MyRect"
+ x: 5
+ width: 100; height: 100
+ color: "red"
+ }
+ }
+ MouseRegion {
+ id: Clickable
+ anchors.fill: parent
+ }
+
+ states: State {
+ name: "reparented"
+ when: Clickable.pressed
+ ParentChange {
+ target: myRect
+ parent: newParent
+ }
+ }
+}
diff --git a/tests/auto/declarative/states/data/parentChange3.qml b/tests/auto/declarative/states/data/parentChange3.qml
new file mode 100644
index 0000000..c7b7bee
--- /dev/null
+++ b/tests/auto/declarative/states/data/parentChange3.qml
@@ -0,0 +1,42 @@
+import Qt 4.6
+
+Rectangle {
+ width: 400; height: 400
+ Item {
+ scale: .5
+ rotation: 15
+ transformOrigin: "Center"
+ x: 10; y: 10
+ Rectangle {
+ id: myRect
+ objectName: "MyRect"
+ x: 5
+ width: 100; height: 100
+ transformOrigin: "BottomLeft"
+ color: "red"
+ }
+ }
+ MouseRegion {
+ id: Clickable
+ anchors.fill: parent
+ }
+
+ Item {
+ x: 200; y: 200
+ rotation: 52;
+ scale: 2
+ Item {
+ id: newParent
+ x: 100; y: 100
+ }
+ }
+
+ states: State {
+ name: "reparented"
+ when: Clickable.pressed
+ ParentChange {
+ target: myRect
+ parent: newParent
+ }
+ }
+}
diff --git a/tests/auto/declarative/states/data/script.qml b/tests/auto/declarative/states/data/script.qml
new file mode 100644
index 0000000..6983419
--- /dev/null
+++ b/tests/auto/declarative/states/data/script.qml
@@ -0,0 +1,10 @@
+import Qt 4.6
+Rectangle {
+ id: MyRectangle
+ width: 100; height: 100
+ color: "red"
+ states: State {
+ name: "blue"
+ StateChangeScript { script: MyRectangle.color = "blue"; }
+ }
+}
diff --git a/tests/auto/declarative/states/tst_states.cpp b/tests/auto/declarative/states/tst_states.cpp
index 89e755e..a215ed8 100644
--- a/tests/auto/declarative/states/tst_states.cpp
+++ b/tests/auto/declarative/states/tst_states.cpp
@@ -54,6 +54,9 @@ private slots:
void basicExtension();
void basicBinding();
void signalOverride();
+ void parentChange();
+ void anchorChanges();
+ void script();
};
void tst_states::basicChanges()
@@ -353,6 +356,116 @@ void tst_states::signalOverride()
}
}
+void tst_states::parentChange()
+{
+ QmlEngine engine;
+
+ {
+ QmlComponent rectComponent(&engine, SRCDIR "/data/parentChange.qml");
+ QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ rect->setState("reparented");
+ QCOMPARE(innerRect->rotation(), qreal(0));
+ QCOMPARE(innerRect->scale(), qreal(1));
+ QCOMPARE(innerRect->x(), qreal(-133));
+ QCOMPARE(innerRect->y(), qreal(-300));
+ }
+
+ {
+ QmlComponent rectComponent(&engine, SRCDIR "/data/parentChange2.qml");
+ QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ rect->setState("reparented");
+ QCOMPARE(innerRect->rotation(), qreal(15));
+ QCOMPARE(innerRect->scale(), qreal(.5));
+ QCOMPARE(QString("%1").arg(innerRect->x()), QString("%1").arg(12.4148145657));
+ QCOMPARE(QString("%1").arg(innerRect->y()), QString("%1").arg(10.6470476128));
+ }
+
+ {
+ QmlComponent rectComponent(&engine, SRCDIR "/data/parentChange3.qml");
+ QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ rect->setState("reparented");
+ QCOMPARE(innerRect->rotation(), qreal(-37));
+ QCOMPARE(innerRect->scale(), qreal(.25));
+ QCOMPARE(QString("%1").arg(innerRect->x()), QString("%1").arg(-217.305));
+ QCOMPARE(QString("%1").arg(innerRect->y()), QString("%1").arg(-164.413));
+
+ rect->setState("");
+ QCOMPARE(innerRect->rotation(), qreal(0));
+ QCOMPARE(innerRect->scale(), qreal(1));
+ QCOMPARE(innerRect->x(), qreal(5));
+ QCOMPARE(innerRect->y(), qreal(0));
+ }
+}
+
+void tst_states::anchorChanges()
+{
+ QmlEngine engine;
+
+ {
+ QmlComponent rectComponent(&engine, SRCDIR "/data/anchorChanges.qml");
+ QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ rect->setState("right");
+ QCOMPARE(innerRect->x(), qreal(150));
+
+ rect->setState("");
+ QCOMPARE(innerRect->x(), qreal(5));
+ }
+
+ {
+ QmlComponent rectComponent(&engine, SRCDIR "/data/anchorChanges2.qml");
+ QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ rect->setState("right");
+ QCOMPARE(innerRect->x(), qreal(150));
+
+ rect->setState("");
+ QCOMPARE(innerRect->x(), qreal(5));
+ }
+}
+
+void tst_states::script()
+{
+ QmlEngine engine;
+
+ {
+ QmlComponent rectComponent(&engine, SRCDIR "/data/script.qml");
+ QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("blue")); // a script isn't reverted
+ }
+}
+
QTEST_MAIN(tst_states)
#include "tst_states.moc"