aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativeanimations
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2011-08-04 10:30:46 +1000
committerQt by Nokia <qt-info@nokia.com>2011-08-04 04:25:29 +0200
commit29af49fc979b888f5b5ea20616f3f6da48b009b0 (patch)
treee0f7bbe40a7960ab620ee6d69c2676e763967ba1 /tests/auto/declarative/qdeclarativeanimations
parent02a19405aab1df31a40896de3d928d8878402052 (diff)
Add enabled property to Transition.
Task-number: QTBUG-14488 Change-Id: I3619a0d26e99e2c19f50a63013dedc151b07154c Reviewed-on: http://codereview.qt.nokia.com/2591 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests/auto/declarative/qdeclarativeanimations')
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/disabledTransition.qml30
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp27
2 files changed, 57 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeanimations/data/disabledTransition.qml b/tests/auto/declarative/qdeclarativeanimations/data/disabledTransition.qml
new file mode 100644
index 0000000000..0fbafead8b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeanimations/data/disabledTransition.qml
@@ -0,0 +1,30 @@
+import QtQuick 2.0
+
+Rectangle {
+ width: 400
+ height: 400
+ Rectangle {
+ id: theRect
+ objectName: "TheRect"
+ color: "red"
+ width: 50; height: 50
+ x: 100; y: 100
+ }
+
+ states: State {
+ name: "moved"
+ PropertyChanges {
+ target: theRect
+ x: 200
+ }
+ }
+ transitions: Transition {
+ enabled: false
+ NumberAnimation { targets: theRect; properties: "x" }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: parent.state = "moved"
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
index bd9c3e0d7a..367de014b4 100644
--- a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
+++ b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
@@ -77,6 +77,7 @@ private slots:
void mixedTypes();
void properties();
void propertiesTransition();
+ void disabledTransition();
void invalidDuration();
void attached();
void propertyValueSourceDefaultStart();
@@ -576,6 +577,32 @@ void tst_qdeclarativeanimations::propertiesTransition()
}
+void tst_qdeclarativeanimations::disabledTransition()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/disabledTransition.qml"));
+ QSGRectangle *rect = qobject_cast<QSGRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QSGRectangle *myRect = rect->findChild<QSGRectangle*>("TheRect");
+ QVERIFY(myRect);
+
+ QDeclarativeTransition *trans = rect->findChild<QDeclarativeTransition*>();
+ QVERIFY(trans);
+
+ QCOMPARE(trans->enabled(), false);
+
+ QSGItemPrivate::get(rect)->setState("moved");
+ QCOMPARE(myRect->x(),qreal(200));
+
+ trans->setEnabled(true);
+
+ QSGItemPrivate::get(rect)->setState("");
+ QCOMPARE(myRect->x(),qreal(200));
+ QTest::qWait(300);
+ QTIMED_COMPARE(myRect->x(),qreal(100));
+}
+
void tst_qdeclarativeanimations::invalidDuration()
{
QDeclarativePropertyAnimation *animation = new QDeclarativePropertyAnimation;