summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-11-03 06:10:53 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-11-03 06:11:37 (GMT)
commit0cf756891d94bcfef52c7c18ce4e3e3f7e64e2d7 (patch)
treee51cb0704156651830a4dc78a744543d608339c6 /tests/auto
parent36420993cb7572fa630ac88cdd6afefa2ab1c660 (diff)
downloadQt-0cf756891d94bcfef52c7c18ce4e3e3f7e64e2d7.zip
Qt-0cf756891d94bcfef52c7c18ce4e3e3f7e64e2d7.tar.gz
Qt-0cf756891d94bcfef52c7c18ce4e3e3f7e64e2d7.tar.bz2
Add more Behavior autotests.
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/declarative/behaviors/data/simple.qml5
-rw-r--r--tests/auto/declarative/behaviors/tst_behaviors.cpp43
2 files changed, 47 insertions, 1 deletions
diff --git a/tests/auto/declarative/behaviors/data/simple.qml b/tests/auto/declarative/behaviors/data/simple.qml
index a715f7b..37c3915 100644
--- a/tests/auto/declarative/behaviors/data/simple.qml
+++ b/tests/auto/declarative/behaviors/data/simple.qml
@@ -6,7 +6,10 @@ Rectangle {
id: rect
objectName: "MyRect"
width: 100; height: 100; color: "green"
- x: Behavior { NumberAnimation { duration: 200; } }
+ x: Behavior {
+ objectName: "MyBehavior";
+ NumberAnimation { duration: 200; }
+ }
}
MouseRegion {
id: clicker
diff --git a/tests/auto/declarative/behaviors/tst_behaviors.cpp b/tests/auto/declarative/behaviors/tst_behaviors.cpp
index 9803a9d..7bdc82e 100644
--- a/tests/auto/declarative/behaviors/tst_behaviors.cpp
+++ b/tests/auto/declarative/behaviors/tst_behaviors.cpp
@@ -43,6 +43,7 @@
#include <QtDeclarative/qmlcomponent.h>
#include <QtDeclarative/qmlview.h>
#include <private/qmlgraphicsrectangle_p.h>
+#include <private/qmlbehavior_p.h>
#include <private/qmlanimation_p.h>
class tst_behaviors : public QObject
@@ -60,6 +61,9 @@ private slots:
void replaceBinding();
//void transitionOverrides();
void group();
+ void emptyBehavior();
+ void nonSelectingBehavior();
+ void reassignedAnimation();
};
void tst_behaviors::simpleBehavior()
@@ -68,6 +72,7 @@ void tst_behaviors::simpleBehavior()
QmlComponent c(&engine, QUrl("file://" SRCDIR "/data/simple.qml"));
QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
QVERIFY(rect);
+ QVERIFY(qobject_cast<QmlBehavior*>(rect->findChild<QmlBehavior*>("MyBehavior"))->animation());
rect->setState("moved");
QTest::qWait(100);
@@ -189,6 +194,44 @@ void tst_behaviors::group()
}
}
+void tst_behaviors::emptyBehavior()
+{
+ QmlEngine engine;
+ QmlComponent c(&engine, QUrl("file://" SRCDIR "/data/empty.qml"));
+ QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
+ QVERIFY(rect);
+
+ rect->setState("moved");
+ qreal x = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"))->x();
+ QCOMPARE(x, qreal(200)); //should change immediately
+}
+
+void tst_behaviors::nonSelectingBehavior()
+{
+ QmlEngine engine;
+ QmlComponent c(&engine, QUrl("file://" SRCDIR "/data/nonSelecting.qml"));
+ QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
+ QVERIFY(rect);
+
+ rect->setState("moved");
+ qreal x = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"))->x();
+ QCOMPARE(x, qreal(200)); //should change immediately
+}
+
+void tst_behaviors::reassignedAnimation()
+{
+ QmlEngine engine;
+ QmlComponent c(&engine, QUrl("file://" SRCDIR "/data/reassignedAnimation.qml"));
+ QTest::ignoreMessage(QtWarningMsg, "QML QmlBehavior (file://" SRCDIR "/data/reassignedAnimation.qml:9:12) Can't change the animation assigned to a Behavior.");
+ QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
+ QVERIFY(rect);
+
+ rect->setState("moved");
+ QTest::qWait(200 + 100);
+ qreal x = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"))->x();
+ QVERIFY(x > 0 && x < 200); //i.e. the right behavior has been triggered
+}
+
QTEST_MAIN(tst_behaviors)
#include "tst_behaviors.moc"