aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquicksmoothedanimation
diff options
context:
space:
mode:
authorMatthew Vogt <matthew.vogt@nokia.com>2012-02-16 14:43:03 +1000
committerQt by Nokia <qt-info@nokia.com>2012-02-24 04:51:31 +0100
commitb855240b782395f94315f43ea3e7e182299fac48 (patch)
treebc594c04449be8cd14cd0ab0bb72dafc2be0ffb2 /tests/auto/quick/qquicksmoothedanimation
parent6a42a6e0a9a1abdda0d07a5a20b4ac7e45348684 (diff)
Rename QDeclarative symbols to QQuick and QQml
Symbols beginning with QDeclarative are already exported by the quick1 module. Users can apply the bin/rename-qtdeclarative-symbols.sh script to modify client code using the previous names of the renamed symbols. Task-number: QTBUG-23737 Change-Id: Ifaa482663767634931e8711a8e9bf6e404859e66 Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests/auto/quick/qquicksmoothedanimation')
-rw-r--r--tests/auto/quick/qquicksmoothedanimation/data/deleteOnUpdate.qml27
-rw-r--r--tests/auto/quick/qquicksmoothedanimation/data/simpleanimation.qml12
-rw-r--r--tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation1.qml3
-rw-r--r--tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation2.qml5
-rw-r--r--tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation3.qml6
-rw-r--r--tests/auto/quick/qquicksmoothedanimation/data/smoothedanimationBehavior.qml24
-rw-r--r--tests/auto/quick/qquicksmoothedanimation/data/smoothedanimationValueSource.qml13
-rw-r--r--tests/auto/quick/qquicksmoothedanimation/qquicksmoothedanimation.pro15
-rw-r--r--tests/auto/quick/qquicksmoothedanimation/tst_qquicksmoothedanimation.cpp242
9 files changed, 347 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicksmoothedanimation/data/deleteOnUpdate.qml b/tests/auto/quick/qquicksmoothedanimation/data/deleteOnUpdate.qml
new file mode 100644
index 0000000000..ff8dfaa846
--- /dev/null
+++ b/tests/auto/quick/qquicksmoothedanimation/data/deleteOnUpdate.qml
@@ -0,0 +1,27 @@
+import QtQuick 2.0
+
+Rectangle {
+ width: 300; height: 300;
+
+ Rectangle {
+ color: "red"
+ width: 60; height: 60;
+ x: 100; y: 100;
+
+ property real prevX: 100
+ onXChanged: {
+ if (x - prevX > 10) {
+ anim.to += 5
+ anim.restart(); //this can cause deletion of backend animation classes
+ prevX = x;
+ }
+ }
+
+ SmoothedAnimation on x {
+ id: anim
+ objectName: "anim"
+ velocity: 100
+ to: 150
+ }
+ }
+}
diff --git a/tests/auto/quick/qquicksmoothedanimation/data/simpleanimation.qml b/tests/auto/quick/qquicksmoothedanimation/data/simpleanimation.qml
new file mode 100644
index 0000000000..b2be63ec94
--- /dev/null
+++ b/tests/auto/quick/qquicksmoothedanimation/data/simpleanimation.qml
@@ -0,0 +1,12 @@
+import QtQuick 2.0
+
+Rectangle {
+ width: 300; height: 300;
+ Rectangle {
+ objectName: "rect"
+ color: "red"
+ width: 60; height: 60;
+ x: 100; y: 100;
+ }
+ SmoothedAnimation { objectName: "anim"}
+} \ No newline at end of file
diff --git a/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation1.qml b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation1.qml
new file mode 100644
index 0000000000..3631f971f0
--- /dev/null
+++ b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation1.qml
@@ -0,0 +1,3 @@
+import QtQuick 2.0
+
+SmoothedAnimation {}
diff --git a/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation2.qml b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation2.qml
new file mode 100644
index 0000000000..b07120234a
--- /dev/null
+++ b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation2.qml
@@ -0,0 +1,5 @@
+import QtQuick 2.0
+
+SmoothedAnimation {
+ to: 10; duration: 300; reversingMode: SmoothedAnimation.Immediate
+}
diff --git a/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation3.qml b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation3.qml
new file mode 100644
index 0000000000..8d5dc4a92b
--- /dev/null
+++ b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation3.qml
@@ -0,0 +1,6 @@
+import QtQuick 2.0
+
+SmoothedAnimation {
+ to: 10; velocity: 250; reversingMode: SmoothedAnimation.Sync
+ maximumEasingTime: 150
+}
diff --git a/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimationBehavior.qml b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimationBehavior.qml
new file mode 100644
index 0000000000..81d36bf015
--- /dev/null
+++ b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimationBehavior.qml
@@ -0,0 +1,24 @@
+import QtQuick 2.0
+
+Rectangle {
+ width: 400; height: 400; color: "blue"
+
+ Rectangle {
+ id: rect1
+ color: "red"
+ width: 60; height: 60;
+ x: 100; y: 100;
+ SmoothedAnimation on x { to: 200; velocity: 500 }
+ SmoothedAnimation on y { to: 200; velocity: 500 }
+ }
+
+ Rectangle {
+ objectName: "theRect"
+ color: "green"
+ width: 60; height: 60;
+ x: rect1.x; y: rect1.y;
+ // id are needed for SmoothedAnimation in order to avoid deferred creation
+ Behavior on x { SmoothedAnimation { id: anim1; objectName: "easeX"; velocity: 400 } }
+ Behavior on y { SmoothedAnimation { id: anim2; objectName: "easeY"; velocity: 400 } }
+ }
+ }
diff --git a/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimationValueSource.qml b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimationValueSource.qml
new file mode 100644
index 0000000000..e136df84f6
--- /dev/null
+++ b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimationValueSource.qml
@@ -0,0 +1,13 @@
+import QtQuick 2.0
+
+Rectangle {
+ width: 300; height: 300;
+ Rectangle {
+ objectName: "theRect"
+ color: "red"
+ width: 60; height: 60;
+ x: 100; y: 100;
+ SmoothedAnimation on x { objectName: "easeX"; to: 200; velocity: 500 }
+ SmoothedAnimation on y { objectName: "easeY"; to: 200; duration: 250; velocity: 500 }
+ }
+}
diff --git a/tests/auto/quick/qquicksmoothedanimation/qquicksmoothedanimation.pro b/tests/auto/quick/qquicksmoothedanimation/qquicksmoothedanimation.pro
new file mode 100644
index 0000000000..0d5567da8d
--- /dev/null
+++ b/tests/auto/quick/qquicksmoothedanimation/qquicksmoothedanimation.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquicksmoothedanimation
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquicksmoothedanimation.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private quick-private testlib
diff --git a/tests/auto/quick/qquicksmoothedanimation/tst_qquicksmoothedanimation.cpp b/tests/auto/quick/qquicksmoothedanimation/tst_qquicksmoothedanimation.cpp
new file mode 100644
index 0000000000..a3e0e46f97
--- /dev/null
+++ b/tests/auto/quick/qquicksmoothedanimation/tst_qquicksmoothedanimation.cpp
@@ -0,0 +1,242 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 <qtest.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQuick/private/qquicksmoothedanimation_p.h>
+#include <QtQuick/private/qquickrectangle_p.h>
+#include <private/qqmlvaluetype_p.h>
+#include "../../shared/util.h"
+
+class tst_qquicksmoothedanimation : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquicksmoothedanimation();
+
+private slots:
+ void defaultValues();
+ void values();
+ void disabled();
+ void simpleAnimation();
+ void valueSource();
+ void behavior();
+ void deleteOnUpdate();
+
+private:
+ QQmlEngine engine;
+};
+
+tst_qquicksmoothedanimation::tst_qquicksmoothedanimation()
+{
+}
+
+void tst_qquicksmoothedanimation::defaultValues()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("smoothedanimation1.qml"));
+ QQuickSmoothedAnimation *obj = qobject_cast<QQuickSmoothedAnimation*>(c.create());
+
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->to(), 0.);
+ QCOMPARE(obj->velocity(), 200.);
+ QCOMPARE(obj->duration(), -1);
+ QCOMPARE(obj->maximumEasingTime(), -1);
+ QCOMPARE(obj->reversingMode(), QQuickSmoothedAnimation::Eased);
+
+ delete obj;
+}
+
+void tst_qquicksmoothedanimation::values()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("smoothedanimation2.qml"));
+ QQuickSmoothedAnimation *obj = qobject_cast<QQuickSmoothedAnimation*>(c.create());
+
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->to(), 10.);
+ QCOMPARE(obj->velocity(), 200.);
+ QCOMPARE(obj->duration(), 300);
+ QCOMPARE(obj->maximumEasingTime(), -1);
+ QCOMPARE(obj->reversingMode(), QQuickSmoothedAnimation::Immediate);
+
+ delete obj;
+}
+
+void tst_qquicksmoothedanimation::disabled()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("smoothedanimation3.qml"));
+ QQuickSmoothedAnimation *obj = qobject_cast<QQuickSmoothedAnimation*>(c.create());
+
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->to(), 10.);
+ QCOMPARE(obj->velocity(), 250.);
+ QCOMPARE(obj->maximumEasingTime(), 150);
+ QCOMPARE(obj->reversingMode(), QQuickSmoothedAnimation::Sync);
+
+ delete obj;
+}
+
+void tst_qquicksmoothedanimation::simpleAnimation()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("simpleanimation.qml"));
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QQuickRectangle *rect = obj->findChild<QQuickRectangle*>("rect");
+ QVERIFY(rect);
+
+ QQuickSmoothedAnimation *animation = obj->findChild<QQuickSmoothedAnimation*>("anim");
+ QVERIFY(animation);
+
+ animation->setTargetObject(rect);
+ animation->setProperty("x");
+ animation->setTo(200);
+ animation->setDuration(250);
+ QVERIFY(animation->target() == rect);
+ QVERIFY(animation->property() == "x");
+ QVERIFY(animation->to() == 200);
+ animation->start();
+ QVERIFY(animation->isRunning());
+ QTest::qWait(animation->duration());
+ QTRY_COMPARE(rect->x(), qreal(200));
+ QTest::qWait(100); //smoothed animation doesn't report stopped until delayed timer fires
+
+ QVERIFY(!animation->isRunning());
+ rect->setX(0);
+ animation->start();
+ QVERIFY(animation->isRunning());
+ animation->pause();
+ QVERIFY(animation->isRunning());
+ QVERIFY(animation->isPaused());
+ animation->setCurrentTime(125);
+ QVERIFY(animation->currentTime() == 125);
+ QCOMPARE(rect->x(), qreal(100));
+}
+
+void tst_qquicksmoothedanimation::valueSource()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("smoothedanimationValueSource.qml"));
+
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *theRect = rect->findChild<QQuickRectangle*>("theRect");
+ QVERIFY(theRect);
+
+ QQuickSmoothedAnimation *easeX = rect->findChild<QQuickSmoothedAnimation*>("easeX");
+ QVERIFY(easeX);
+ QVERIFY(easeX->isRunning());
+
+ QQuickSmoothedAnimation *easeY = rect->findChild<QQuickSmoothedAnimation*>("easeY");
+ QVERIFY(easeY);
+ QVERIFY(easeY->isRunning());
+
+ // XXX get the proper duration
+ QTest::qWait(100);
+
+ QTRY_VERIFY(!easeX->isRunning());
+ QTRY_VERIFY(!easeY->isRunning());
+
+ QTRY_COMPARE(theRect->x(), qreal(200));
+ QTRY_COMPARE(theRect->y(), qreal(200));
+
+ delete rect;
+}
+
+void tst_qquicksmoothedanimation::behavior()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("smoothedanimationBehavior.qml"));
+
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *theRect = rect->findChild<QQuickRectangle*>("theRect");
+ QVERIFY(theRect);
+
+ QQuickSmoothedAnimation *easeX = rect->findChild<QQuickSmoothedAnimation*>("easeX");
+ QVERIFY(easeX);
+
+ QQuickSmoothedAnimation *easeY = rect->findChild<QQuickSmoothedAnimation*>("easeY");
+ QVERIFY(easeY);
+
+ // XXX get the proper duration
+ QTest::qWait(400);
+
+ QTRY_VERIFY(!easeX->isRunning());
+ QTRY_VERIFY(!easeY->isRunning());
+
+ QTRY_COMPARE(theRect->x(), qreal(200));
+ QTRY_COMPARE(theRect->y(), qreal(200));
+
+ delete rect;
+}
+
+void tst_qquicksmoothedanimation::deleteOnUpdate()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("deleteOnUpdate.qml"));
+
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickSmoothedAnimation *anim = rect->findChild<QQuickSmoothedAnimation*>("anim");
+ QVERIFY(anim);
+
+ //don't crash
+ QTest::qWait(500);
+
+ delete rect;
+}
+
+QTEST_MAIN(tst_qquicksmoothedanimation)
+
+#include "tst_qquicksmoothedanimation.moc"