/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** 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_END_LICENSE$
**
****************************************************************************/
#include "../../shared/util.h"
-class tst_qdeclarativeanimations : public QObject
+class tst_qdeclarativeanimations : public QDeclarativeDataTest
{
Q_OBJECT
public:
tst_qdeclarativeanimations() {}
private slots:
- void initTestCase() { QDeclarativeEngine engine; } // ensure types are registered
+ void initTestCase()
+ {
+ QDeclarativeEngine engine; // ensure types are registered
+ QDeclarativeDataTest::initTestCase();
+ }
void simpleProperty();
void simpleNumber();
QVERIFY(animation.isPaused());
animation.setCurrentTime(125);
QVERIFY(animation.currentTime() == 125);
+#if defined(UBUNTU_ONEIRIC) && defined(__x86_64__)
+ QEXPECT_FAIL("", "Fails on this platform - QTBUG-23385", Abort);
+#endif
QCOMPARE(rect.color(), QColor::fromRgbF(0.498039, 0, 0.498039, 1));
rect.setColor(QColor("green"));
{
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("pathAnimation.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("pathAnimation.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("pathAnimation2.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("pathAnimation2.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
void tst_qdeclarativeanimations::pathInterpolator()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("pathInterpolator.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("pathInterpolator.qml"));
QDeclarativePathInterpolator *interpolator = qobject_cast<QDeclarativePathInterpolator*>(c.create());
QVERIFY(interpolator);
QCOMPARE(interpolator->progress(), qreal(.5));
QCOMPARE(interpolator->x(), qreal(175));
QCOMPARE(interpolator->y(), qreal(175));
- QCOMPARE(interpolator->angle(), qreal(270));
+ QCOMPARE(interpolator->angle(), qreal(90));
interpolator->setProgress(1);
QCOMPARE(interpolator->progress(), qreal(1));
void tst_qdeclarativeanimations::pathInterpolatorBackwardJump()
{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("pathInterpolatorBack.qml")));
- QDeclarativePathInterpolator *interpolator = qobject_cast<QDeclarativePathInterpolator*>(c.create());
- QVERIFY(interpolator);
-
- QCOMPARE(interpolator->progress(), qreal(0));
- QCOMPARE(interpolator->x(), qreal(50));
- QCOMPARE(interpolator->y(), qreal(50));
- QCOMPARE(interpolator->angle(), qreal(270));
-
- interpolator->setProgress(.5);
- QCOMPARE(interpolator->progress(), qreal(.5));
- QCOMPARE(interpolator->x(), qreal(100));
- QCOMPARE(interpolator->y(), qreal(75));
- QCOMPARE(interpolator->angle(), qreal(90));
-
- interpolator->setProgress(1);
- QCOMPARE(interpolator->progress(), qreal(1));
- QCOMPARE(interpolator->x(), qreal(200));
- QCOMPARE(interpolator->y(), qreal(50));
- QCOMPARE(interpolator->angle(), qreal(0));
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, testFileUrl("pathInterpolatorBack.qml"));
+ QDeclarativePathInterpolator *interpolator = qobject_cast<QDeclarativePathInterpolator*>(c.create());
+ QVERIFY(interpolator);
+
+ QCOMPARE(interpolator->progress(), qreal(0));
+ QCOMPARE(interpolator->x(), qreal(50));
+ QCOMPARE(interpolator->y(), qreal(50));
+ QCOMPARE(interpolator->angle(), qreal(90));
+
+ interpolator->setProgress(.5);
+ QCOMPARE(interpolator->progress(), qreal(.5));
+ QCOMPARE(interpolator->x(), qreal(100));
+ QCOMPARE(interpolator->y(), qreal(75));
+ QCOMPARE(interpolator->angle(), qreal(270));
+
+ interpolator->setProgress(1);
+ QCOMPARE(interpolator->progress(), qreal(1));
+ QCOMPARE(interpolator->x(), qreal(200));
+ QCOMPARE(interpolator->y(), qreal(50));
+ QCOMPARE(interpolator->angle(), qreal(0));
+
+ //make sure we don't get caught in infinite loop here
+ interpolator->setProgress(0);
+ QCOMPARE(interpolator->progress(), qreal(0));
+ QCOMPARE(interpolator->x(), qreal(50));
+ QCOMPARE(interpolator->y(), qreal(50));
+ QCOMPARE(interpolator->angle(), qreal(90));
+ }
- //make sure we don't get caught in infinite loop here
- interpolator->setProgress(0);
- QCOMPARE(interpolator->progress(), qreal(0));
- QCOMPARE(interpolator->x(), qreal(50));
- QCOMPARE(interpolator->y(), qreal(50));
- QCOMPARE(interpolator->angle(), qreal(270));
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, testFileUrl("pathInterpolatorBack2.qml"));
+ QDeclarativePathInterpolator *interpolator = qobject_cast<QDeclarativePathInterpolator*>(c.create());
+ QVERIFY(interpolator);
+
+ QCOMPARE(interpolator->progress(), qreal(0));
+ QCOMPARE(interpolator->x(), qreal(200));
+ QCOMPARE(interpolator->y(), qreal(280));
+ QCOMPARE(interpolator->angle(), qreal(180));
+
+ interpolator->setProgress(1);
+ QCOMPARE(interpolator->progress(), qreal(1));
+ QCOMPARE(interpolator->x(), qreal(0));
+ QCOMPARE(interpolator->y(), qreal(80));
+ QCOMPARE(interpolator->angle(), qreal(180));
+
+ //make sure we don't get caught in infinite loop here
+ interpolator->setProgress(0);
+ QCOMPARE(interpolator->progress(), qreal(0));
+ QCOMPARE(interpolator->x(), qreal(200));
+ QCOMPARE(interpolator->y(), qreal(280));
+ QCOMPARE(interpolator->angle(), qreal(180));
+ }
}
void tst_qdeclarativeanimations::pathWithNoStart()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("pathAnimationNoStart.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("pathAnimationNoStart.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
//don't crash
{
QQuickView *view = new QQuickView;
- view->setSource(QUrl::fromLocalFile(TESTDATA("badtype1.qml")));
+ view->setSource(testFileUrl("badtype1.qml"));
qApp->processEvents();
//make sure we get a compiler error
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("badtype2.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("badtype2.qml"));
QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready");
c.create();
//make sure we get a compiler error
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("badtype3.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("badtype3.qml"));
QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready");
c.create();
//don't crash
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("badtype4.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("badtype4.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c1(&engine, QUrl::fromLocalFile(TESTDATA("badproperty1.qml")));
- QByteArray message = QUrl::fromLocalFile(TESTDATA("badproperty1.qml")).toString().toUtf8() + ":18:9: QML ColorAnimation: Cannot animate non-existent property \"border.colr\"";
+ QDeclarativeComponent c1(&engine, testFileUrl("badproperty1.qml"));
+ QByteArray message = testFileUrl("badproperty1.qml").toString().toUtf8() + ":18:9: QML ColorAnimation: Cannot animate non-existent property \"border.colr\"";
QTest::ignoreMessage(QtWarningMsg, message);
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c1.create());
QVERIFY(rect);
- QDeclarativeComponent c2(&engine, QUrl::fromLocalFile(TESTDATA("badproperty2.qml")));
- message = QUrl::fromLocalFile(TESTDATA("badproperty2.qml")).toString().toUtf8() + ":18:9: QML ColorAnimation: Cannot animate read-only property \"border\"";
+ QDeclarativeComponent c2(&engine, testFileUrl("badproperty2.qml"));
+ message = testFileUrl("badproperty2.qml").toString().toUtf8() + ":18:9: QML ColorAnimation: Cannot animate read-only property \"border\"";
QTest::ignoreMessage(QtWarningMsg, message);
rect = qobject_cast<QQuickRectangle*>(c2.create());
QVERIFY(rect);
//assumes border.width stays a real -- not real robust
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("mixedtype1.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("mixedtype1.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("mixedtype2.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("mixedtype2.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
//rather inexact -- is there a better way?
QVERIFY(myRect->x() > 100 && myRect->x() < 200);
+#if defined(UBUNTU_ONEIRIC) && defined(__x86_64__)
+ QEXPECT_FAIL("", "Fails on this platform - QTBUG-23385", Continue);
+#endif
QVERIFY(myRect->color() != QColor("red") && myRect->color() != QColor("blue"));
}
}
const int waitDuration = 300;
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("properties.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("properties.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("properties2.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("properties2.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("properties3.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("properties3.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("properties4.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("properties4.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("properties5.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("properties5.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
const int waitDuration = 300;
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("propertiesTransition.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("propertiesTransition2.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition2.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("propertiesTransition3.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition3.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("propertiesTransition4.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition4.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("propertiesTransition5.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition5.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
/*{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("propertiesTransition6.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition6.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("propertiesTransition7.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition7.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
void tst_qdeclarativeanimations::pathTransition()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("pathTransition.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("pathTransition.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
void tst_qdeclarativeanimations::disabledTransition()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("disabledTransition.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("disabledTransition.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("attached.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("attached.qml"));
QTest::ignoreMessage(QtDebugMsg, "off");
QTest::ignoreMessage(QtDebugMsg, "on");
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("valuesource.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("valuesource.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("valuesource2.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("valuesource2.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("dontAutoStart.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("dontAutoStart.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("dontStart.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("dontStart.qml"));
QString warning = c.url().toString() + ":14:13: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes.";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("dontStart2.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("dontStart2.qml"));
QString warning = c.url().toString() + ":15:17: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes.";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
void tst_qdeclarativeanimations::rotation()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("rotation.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("rotation.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
{
//ensure we start correctly when "running: true" is explicitly set
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("runningTrueBug.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("runningTrueBug.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
//in the case where an animation in the transition doesn't match anything (but previously did)
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("nonTransitionBug.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("nonTransitionBug.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect != 0);
QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("registrationBug.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("registrationBug.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect != 0);
QTRY_COMPARE(rect->property("value"), QVariant(int(100)));
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("doubleRegistrationBug.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("doubleRegistrationBug.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect != 0);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("transitionAssignmentBug.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("transitionAssignmentBug.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect != 0);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("pauseBindingBug.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("pauseBindingBug.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect != 0);
QDeclarativeAbstractAnimation *anim = rect->findChild<QDeclarativeAbstractAnimation*>("animation");
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("pauseBug.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("pauseBug.qml"));
QDeclarativeAbstractAnimation *anim = qobject_cast<QDeclarativeAbstractAnimation*>(c.create());
QVERIFY(anim != 0);
QCOMPARE(anim->qtAnimation()->state(), QAbstractAnimation::Paused);