summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntti Määttä <antti.maatta@qt.io>2017-02-08 10:20:46 +0200
committerJani Heikkinen <jani.heikkinen@qt.io>2017-05-09 08:59:24 +0000
commit1178d7538bced76d1475b214cd591d86609239f3 (patch)
tree91eee0ffe71f2e911c959c52cc0fbc904e3a7271
parent540f11b0b3f1639990383e2a4c72f858b0ac01b2 (diff)
Add autotests for new animation classes
Change-Id: Id657443693009455c9307b51e862d43f41255f1d Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
-rw-r--r--tests/auto/animation/animation.pro12
-rw-r--r--tests/auto/animation/qabstractanimation/qabstractanimation.pro10
-rw-r--r--tests/auto/animation/qabstractanimation/tst_qabstractanimation.cpp117
-rw-r--r--tests/auto/animation/qanimationcontroller/qanimationcontroller.pro10
-rw-r--r--tests/auto/animation/qanimationcontroller/tst_qanimationcontroller.cpp302
-rw-r--r--tests/auto/animation/qanimationgroup/qanimationgroup.pro10
-rw-r--r--tests/auto/animation/qanimationgroup/tst_qanimationgroup.cpp100
-rw-r--r--tests/auto/animation/qkeyframeanimation/qkeyframeanimation.pro10
-rw-r--r--tests/auto/animation/qkeyframeanimation/tst_qkeyframeanimation.cpp285
-rw-r--r--tests/auto/animation/qmorphinganimation/qmorphinganimation.pro10
-rw-r--r--tests/auto/animation/qmorphinganimation/tst_qmorphinganimation.cpp309
-rw-r--r--tests/auto/animation/qmorphtarget/qmorphtarget.pro10
-rw-r--r--tests/auto/animation/qmorphtarget/tst_qmorphtarget.cpp123
-rw-r--r--tests/auto/animation/qvertexblendanimation/qvertexblendanimation.pro10
-rw-r--r--tests/auto/animation/qvertexblendanimation/tst_qvertexblendanimation.cpp102
15 files changed, 1418 insertions, 2 deletions
diff --git a/tests/auto/animation/animation.pro b/tests/auto/animation/animation.pro
index 969f477e7..d3ef37a61 100644
--- a/tests/auto/animation/animation.pro
+++ b/tests/auto/animation/animation.pro
@@ -7,7 +7,14 @@ SUBDIRS += \
qblendedclipanimator \
qchannelmapping \
qchannelmapper \
- qclipblendvalue
+ qclipblendvalue \
+ qanimationcontroller \
+ qanimationgroup \
+ qkeyframeanimation \
+ qmorphinganimation \
+ qmorphtarget \
+ qvertexblendanimation \
+ qanimationcontroller
qtConfig(private_tests) {
SUBDIRS += \
@@ -27,5 +34,6 @@ qtConfig(private_tests) {
qadditiveclipblend \
additiveclipblend \
clipblendvalue \
- animationutils
+ animationutils \
+ qabstractanimation
}
diff --git a/tests/auto/animation/qabstractanimation/qabstractanimation.pro b/tests/auto/animation/qabstractanimation/qabstractanimation.pro
new file mode 100644
index 000000000..be37677b6
--- /dev/null
+++ b/tests/auto/animation/qabstractanimation/qabstractanimation.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+
+TARGET = tst_qabstractanimation
+
+QT += 3dcore 3dcore-private 3drender 3drender-private 3danimation 3danimation-private testlib
+
+CONFIG += testcase
+
+SOURCES += tst_qabstractanimation.cpp
+
diff --git a/tests/auto/animation/qabstractanimation/tst_qabstractanimation.cpp b/tests/auto/animation/qabstractanimation/tst_qabstractanimation.cpp
new file mode 100644
index 000000000..90349fb28
--- /dev/null
+++ b/tests/auto/animation/qabstractanimation/tst_qabstractanimation.cpp
@@ -0,0 +1,117 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/qtest.h>
+#include <Qt3DAnimation/qabstractanimation.h>
+#include <Qt3DCore/qnode.h>
+#include <qobject.h>
+#include <qsignalspy.h>
+
+#include <private/qabstractanimation_p.h>
+
+class TestAnimation : public Qt3DAnimation::QAbstractAnimation
+{
+public:
+ explicit TestAnimation(Qt3DCore::QNode *parent = nullptr)
+ : Qt3DAnimation::QAbstractAnimation(
+ *new Qt3DAnimation::QAbstractAnimationPrivate(
+ Qt3DAnimation::QAbstractAnimation::KeyframeAnimation), parent)
+ {
+
+ }
+};
+
+class tst_QAbstractAnimation : public QObject
+{
+ Q_OBJECT
+
+private Q_SLOTS:
+
+ void checkDefaultConstruction()
+ {
+ // GIVEN
+ TestAnimation abstractAnimation;
+
+ // THEN
+ QCOMPARE(abstractAnimation.animationName(), QString());
+ QCOMPARE(abstractAnimation.animationType(),
+ Qt3DAnimation::QAbstractAnimation::KeyframeAnimation);
+ QCOMPARE(abstractAnimation.position(), 0.0f);
+ QCOMPARE(abstractAnimation.duration(), 0.0f);
+ }
+
+ void checkPropertyChanges()
+ {
+ // GIVEN
+ TestAnimation abstractAnimation;
+
+ {
+ // WHEN
+ QSignalSpy spy(&abstractAnimation, SIGNAL(animationNameChanged(QString)));
+ const QString newValue = QString("test");
+ abstractAnimation.setAnimationName(newValue);
+
+ // THEN
+ QCOMPARE(abstractAnimation.animationName(), newValue);
+ QCOMPARE(spy.count(), 1);
+
+ // WHEN
+ spy.clear();
+ abstractAnimation.setAnimationName(newValue);
+
+ // THEN
+ QCOMPARE(abstractAnimation.animationName(), newValue);
+ QCOMPARE(spy.count(), 0);
+
+ }
+ {
+ // WHEN
+ QSignalSpy spy(&abstractAnimation, SIGNAL(positionChanged(float)));
+ const float newValue = 1.0f;
+ abstractAnimation.setPosition(newValue);
+
+ // THEN
+ QCOMPARE(abstractAnimation.position(), newValue);
+ QCOMPARE(spy.count(), 1);
+
+ // WHEN
+ spy.clear();
+ abstractAnimation.setPosition(newValue);
+
+ // THEN
+ QCOMPARE(abstractAnimation.position(), newValue);
+ QCOMPARE(spy.count(), 0);
+
+ }
+ }
+
+};
+
+QTEST_APPLESS_MAIN(tst_QAbstractAnimation)
+
+#include "tst_qabstractanimation.moc"
diff --git a/tests/auto/animation/qanimationcontroller/qanimationcontroller.pro b/tests/auto/animation/qanimationcontroller/qanimationcontroller.pro
new file mode 100644
index 000000000..ff5348d47
--- /dev/null
+++ b/tests/auto/animation/qanimationcontroller/qanimationcontroller.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+
+TARGET = tst_qanimationcontroller
+
+QT += 3dcore 3dcore-private 3drender 3drender-private 3danimation testlib
+
+CONFIG += testcase
+
+SOURCES += tst_qanimationcontroller.cpp
+
diff --git a/tests/auto/animation/qanimationcontroller/tst_qanimationcontroller.cpp b/tests/auto/animation/qanimationcontroller/tst_qanimationcontroller.cpp
new file mode 100644
index 000000000..4774dc8ba
--- /dev/null
+++ b/tests/auto/animation/qanimationcontroller/tst_qanimationcontroller.cpp
@@ -0,0 +1,302 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/qtest.h>
+#include <Qt3DAnimation/qanimationcontroller.h>
+#include <Qt3DAnimation/qkeyframeanimation.h>
+#include <Qt3DAnimation/qmorphinganimation.h>
+#include <qobject.h>
+#include <qsignalspy.h>
+
+class tst_QAnimationController : public QObject
+{
+ Q_OBJECT
+
+private Q_SLOTS:
+
+ void checkDefaultConstruction()
+ {
+ // GIVEN
+ Qt3DAnimation::QAnimationController animationController;
+
+ // THEN
+ QCOMPARE(animationController.activeAnimationGroup(), 0);
+ QCOMPARE(animationController.position(), 0.0f);
+ QCOMPARE(animationController.positionScale(), 1.0f);
+ QCOMPARE(animationController.positionOffset(), 0.0f);
+ QCOMPARE(animationController.entity(), nullptr);
+ QCOMPARE(animationController.recursive(), true);
+ }
+
+ void checkPropertyChanges()
+ {
+ // GIVEN
+ Qt3DAnimation::QAnimationController animationController;
+
+ {
+ // WHEN
+ QSignalSpy spy(&animationController, SIGNAL(activeAnimationGroupChanged(int)));
+ const int newValue = 1;
+ animationController.setActiveAnimationGroup(newValue);
+
+ // THEN
+ QCOMPARE(animationController.activeAnimationGroup(), newValue);
+ QCOMPARE(spy.count(), 1);
+
+ // WHEN
+ spy.clear();
+ animationController.setActiveAnimationGroup(newValue);
+
+ // THEN
+ QCOMPARE(animationController.activeAnimationGroup(), newValue);
+ QCOMPARE(spy.count(), 0);
+
+ }
+ {
+ // WHEN
+ QSignalSpy spy(&animationController, SIGNAL(positionChanged(float)));
+ const float newValue = 2.0f;
+ animationController.setPosition(newValue);
+
+ // THEN
+ QCOMPARE(animationController.position(), newValue);
+ QCOMPARE(spy.count(), 1);
+
+ // WHEN
+ spy.clear();
+ animationController.setPosition(newValue);
+
+ // THEN
+ QCOMPARE(animationController.position(), newValue);
+ QCOMPARE(spy.count(), 0);
+
+ }
+ {
+ // WHEN
+ QSignalSpy spy(&animationController, SIGNAL(positionScaleChanged(float)));
+ const float newValue = 3.0f;
+ animationController.setPositionScale(newValue);
+
+ // THEN
+ QCOMPARE(animationController.positionScale(), newValue);
+ QCOMPARE(spy.count(), 1);
+
+ // WHEN
+ spy.clear();
+ animationController.setPositionScale(newValue);
+
+ // THEN
+ QCOMPARE(animationController.positionScale(), newValue);
+ QCOMPARE(spy.count(), 0);
+
+ }
+ {
+ // WHEN
+ QSignalSpy spy(&animationController, SIGNAL(positionOffsetChanged(float)));
+ const float newValue = -1.0f;
+ animationController.setPositionOffset(newValue);
+
+ // THEN
+ QCOMPARE(animationController.positionOffset(), newValue);
+ QCOMPARE(spy.count(), 1);
+
+ // WHEN
+ spy.clear();
+ animationController.setPositionOffset(newValue);
+
+ // THEN
+ QCOMPARE(animationController.positionOffset(), newValue);
+ QCOMPARE(spy.count(), 0);
+
+ }
+ {
+ // WHEN
+ QScopedPointer<Qt3DCore::QEntity> entity(new Qt3DCore::QEntity);
+ QSignalSpy spy(&animationController, SIGNAL(entityChanged(Qt3DCore::QEntity *)));
+ Qt3DCore::QEntity * newValue = entity.data();
+ animationController.setEntity(newValue);
+
+ // THEN
+ QCOMPARE(animationController.entity(), newValue);
+ QCOMPARE(spy.count(), 1);
+
+ // WHEN
+ spy.clear();
+ animationController.setEntity(newValue);
+
+ // THEN
+ QCOMPARE(animationController.entity(), newValue);
+ QCOMPARE(spy.count(), 0);
+
+ }
+ {
+ // WHEN
+ QSignalSpy spy(&animationController, SIGNAL(recursiveChanged(bool)));
+ const bool newValue = false;
+ animationController.setRecursive(newValue);
+
+ // THEN
+ QCOMPARE(animationController.recursive(), newValue);
+ QCOMPARE(spy.count(), 1);
+
+ // WHEN
+ spy.clear();
+ animationController.setRecursive(newValue);
+
+ // THEN
+ QCOMPARE(animationController.recursive(), newValue);
+ QCOMPARE(spy.count(), 0);
+
+ }
+ }
+
+ void testSetEntity()
+ {
+ // GIVEN
+ Qt3DAnimation::QAnimationController animationController;
+ Qt3DAnimation::QKeyframeAnimation *keyframeAnimation;
+ Qt3DAnimation::QKeyframeAnimation *keyframeAnimation2;
+ Qt3DAnimation::QMorphingAnimation *morphingAnimation;
+
+ QScopedPointer<Qt3DCore::QEntity> entity(new Qt3DCore::QEntity);
+ keyframeAnimation = new Qt3DAnimation::QKeyframeAnimation(entity.data());
+ keyframeAnimation2 = new Qt3DAnimation::QKeyframeAnimation(entity.data());
+ morphingAnimation = new Qt3DAnimation::QMorphingAnimation(entity.data());
+
+ const QString animName1 = QString("animation1");
+ const QString animName2 = QString("animation2");
+ morphingAnimation->setAnimationName(animName1);
+ keyframeAnimation->setAnimationName(animName1);
+ keyframeAnimation2->setAnimationName(animName2);
+
+ {
+ // WHEN
+ animationController.setEntity(entity.data());
+
+ // THEN
+ QVector<Qt3DAnimation::QAnimationGroup *> list = animationController.animationGroupList();
+ QCOMPARE(list.size(), 2);
+
+ QCOMPARE(list.at(0)->name(), animName1);
+ QCOMPARE(list.at(1)->name(), animName2);
+
+ QCOMPARE(list.at(0)->animationList().size(), 2);
+ QCOMPARE(list.at(1)->animationList().size(), 1);
+ }
+ }
+
+ void testSetEntityRecursive()
+ {
+ // GIVEN
+ Qt3DAnimation::QAnimationController animationController;
+ Qt3DAnimation::QKeyframeAnimation *keyframeAnimation;
+ Qt3DAnimation::QMorphingAnimation *morphingAnimation;
+
+ QScopedPointer<Qt3DCore::QEntity> entity(new Qt3DCore::QEntity);
+ keyframeAnimation = new Qt3DAnimation::QKeyframeAnimation(entity.data());
+ Qt3DCore::QEntity *childEntity = new Qt3DCore::QEntity(entity.data());
+ morphingAnimation = new Qt3DAnimation::QMorphingAnimation(childEntity);
+
+ const QString animName1 = QString("animation1");
+ const QString animName2 = QString("animation2");
+
+ keyframeAnimation->setAnimationName(animName1);
+ morphingAnimation->setAnimationName(animName2);
+
+ {
+ // WHEN
+ animationController.setEntity(entity.data());
+
+ // THEN
+ QVector<Qt3DAnimation::QAnimationGroup *> list = animationController.animationGroupList();
+ QCOMPARE(list.size(), 2);
+
+ QCOMPARE(list.at(0)->name(), animName1);
+ QCOMPARE(list.at(1)->name(), animName2);
+
+ QCOMPARE(list.at(0)->animationList().size(), 1);
+ QCOMPARE(list.at(1)->animationList().size(), 1);
+
+ animationController.setEntity(nullptr);
+ }
+
+ {
+ // WHEN
+ animationController.setRecursive(false);
+ animationController.setEntity(entity.data());
+
+ // THEN
+ QVector<Qt3DAnimation::QAnimationGroup *> list = animationController.animationGroupList();
+ QCOMPARE(list.size(), 1);
+
+ QCOMPARE(list.at(0)->name(), animName1);
+
+ QCOMPARE(list.at(0)->animationList().size(), 1);
+ }
+ }
+
+
+ void testPropagatePosition()
+ {
+ // GIVEN
+ Qt3DAnimation::QAnimationController animationController;
+ Qt3DAnimation::QKeyframeAnimation *keyframeAnimation;
+
+ QScopedPointer<Qt3DCore::QEntity> entity(new Qt3DCore::QEntity);
+ keyframeAnimation = new Qt3DAnimation::QKeyframeAnimation(entity.data());
+
+ const QString animName1 = QString("animation1");
+ keyframeAnimation->setAnimationName(animName1);
+
+ {
+ // WHEN
+ animationController.setEntity(entity.data());
+ animationController.setPosition(2.0f);
+
+ // THEN
+ QCOMPARE(animationController.animationGroupList().at(0)->position(), 2.0f);
+ QCOMPARE(keyframeAnimation->position(), 2.0f);
+ }
+
+ {
+ // WHEN
+ animationController.setPositionOffset(1.0);
+ animationController.setPositionScale(2.0f);
+ animationController.setPosition(2.0f);
+
+ // THEN
+ QCOMPARE(animationController.animationGroupList().at(0)->position(), 5.0f);
+ QCOMPARE(keyframeAnimation->position(), 5.0f);
+ }
+ }
+
+};
+
+QTEST_APPLESS_MAIN(tst_QAnimationController)
+
+#include "tst_qanimationcontroller.moc"
diff --git a/tests/auto/animation/qanimationgroup/qanimationgroup.pro b/tests/auto/animation/qanimationgroup/qanimationgroup.pro
new file mode 100644
index 000000000..5c39fa539
--- /dev/null
+++ b/tests/auto/animation/qanimationgroup/qanimationgroup.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+
+TARGET = tst_qanimationgroup
+
+QT += 3dcore 3dcore-private 3drender 3drender-private 3danimation testlib
+
+CONFIG += testcase
+
+SOURCES += tst_qanimationgroup.cpp
+
diff --git a/tests/auto/animation/qanimationgroup/tst_qanimationgroup.cpp b/tests/auto/animation/qanimationgroup/tst_qanimationgroup.cpp
new file mode 100644
index 000000000..0c7a66222
--- /dev/null
+++ b/tests/auto/animation/qanimationgroup/tst_qanimationgroup.cpp
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QTest>
+#include <Qt3DAnimation/qanimationgroup.h>
+#include <qobject.h>
+#include <qsignalspy.h>
+
+class tst_QAnimationGroup : public QObject
+{
+ Q_OBJECT
+
+private Q_SLOTS:
+
+ void checkDefaultConstruction()
+ {
+ // GIVEN
+ Qt3DAnimation::QAnimationGroup animationGroup;
+
+ // THEN
+ QCOMPARE(animationGroup.name(), QString());
+ QCOMPARE(animationGroup.position(), 0.0f);
+ QCOMPARE(animationGroup.duration(), 0.0f);
+ }
+
+ void checkPropertyChanges()
+ {
+ // GIVEN
+ Qt3DAnimation::QAnimationGroup animationGroup;
+
+ {
+ // WHEN
+ QSignalSpy spy(&animationGroup, SIGNAL(nameChanged(QString)));
+ const QString newValue = QString("group");
+ animationGroup.setName(newValue);
+
+ // THEN
+ QCOMPARE(animationGroup.name(), newValue);
+ QCOMPARE(spy.count(), 1);
+
+ // WHEN
+ spy.clear();
+ animationGroup.setName(newValue);
+
+ // THEN
+ QCOMPARE(animationGroup.name(), newValue);
+ QCOMPARE(spy.count(), 0);
+
+ }
+ {
+ // WHEN
+ QSignalSpy spy(&animationGroup, SIGNAL(positionChanged(float)));
+ const float newValue = 2.0f;
+ animationGroup.setPosition(newValue);
+
+ // THEN
+ QCOMPARE(animationGroup.position(), newValue);
+ QCOMPARE(spy.count(), 1);
+
+ // WHEN
+ spy.clear();
+ animationGroup.setPosition(newValue);
+
+ // THEN
+ QCOMPARE(animationGroup.position(), newValue);
+ QCOMPARE(spy.count(), 0);
+
+ }
+ }
+
+};
+
+QTEST_APPLESS_MAIN(tst_QAnimationGroup)
+
+#include "tst_qanimationgroup.moc"
diff --git a/tests/auto/animation/qkeyframeanimation/qkeyframeanimation.pro b/tests/auto/animation/qkeyframeanimation/qkeyframeanimation.pro
new file mode 100644
index 000000000..994d8d0d9
--- /dev/null
+++ b/tests/auto/animation/qkeyframeanimation/qkeyframeanimation.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+
+TARGET = tst_qkeyframeanimation
+
+QT += 3dcore 3dcore-private 3drender 3drender-private 3danimation testlib
+
+CONFIG += testcase
+
+SOURCES += tst_qkeyframeanimation.cpp
+
diff --git a/tests/auto/animation/qkeyframeanimation/tst_qkeyframeanimation.cpp b/tests/auto/animation/qkeyframeanimation/tst_qkeyframeanimation.cpp
new file mode 100644
index 000000000..33bbebc52
--- /dev/null
+++ b/tests/auto/animation/qkeyframeanimation/tst_qkeyframeanimation.cpp
@@ -0,0 +1,285 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/qtest.h>
+#include <Qt3DAnimation/qkeyframeanimation.h>
+#include <qobject.h>
+#include <qsignalspy.h>
+
+class tst_QKeyframeAnimation : public QObject
+{
+ Q_OBJECT
+
+private Q_SLOTS:
+
+ void initTestCase()
+ {
+ qRegisterMetaType<Qt3DAnimation::QKeyframeAnimation::RepeatMode>(
+ "QKeyframeAnimation::RepeatMode");
+ }
+
+ void checkDefaultConstruction()
+ {
+ // GIVEN
+ Qt3DAnimation::QKeyframeAnimation keyframeAnimation;
+
+ // THEN
+ QCOMPARE(keyframeAnimation.target(), nullptr);
+ QCOMPARE(keyframeAnimation.easing(), QEasingCurve());
+ QCOMPARE(keyframeAnimation.targetName(), QString());
+ QCOMPARE(keyframeAnimation.startMode(), Qt3DAnimation::QKeyframeAnimation::Constant);
+ QCOMPARE(keyframeAnimation.endMode(), Qt3DAnimation::QKeyframeAnimation::Constant);
+ }
+
+ void checkPropertyChanges()
+ {
+ // GIVEN
+ Qt3DAnimation::QKeyframeAnimation keyframeAnimation;
+
+ {
+ // WHEN
+ QScopedPointer<Qt3DCore::QTransform> transform(new Qt3DCore::QTransform);
+ QSignalSpy spy(&keyframeAnimation, SIGNAL(targetChanged(Qt3DCore::QTransform *)));
+ Qt3DCore::QTransform * newValue = transform.data();
+ keyframeAnimation.setTarget(newValue);
+
+ // THEN
+ QCOMPARE(keyframeAnimation.target(), newValue);
+ QCOMPARE(spy.count(), 1);
+
+ // WHEN
+ spy.clear();
+ keyframeAnimation.setTarget(newValue);
+
+ // THEN
+ QCOMPARE(keyframeAnimation.target(), newValue);
+ QCOMPARE(spy.count(), 0);
+
+ }
+ {
+ // WHEN
+ QSignalSpy spy(&keyframeAnimation, SIGNAL(easingChanged(const QEasingCurve &)));
+ const QEasingCurve newValue = QEasingCurve(QEasingCurve::CosineCurve);
+ keyframeAnimation.setEasing(newValue);
+
+ // THEN
+ QCOMPARE(keyframeAnimation.easing(), newValue);
+ QCOMPARE(spy.count(), 1);
+
+ // WHEN
+ spy.clear();
+ keyframeAnimation.setEasing(newValue);
+
+ // THEN
+ QCOMPARE(keyframeAnimation.easing(), newValue);
+ QCOMPARE(spy.count(), 0);
+
+ }
+ {
+ // WHEN
+ QSignalSpy spy(&keyframeAnimation, SIGNAL(targetNameChanged(QString)));
+ const QString newValue = QString("target");
+ keyframeAnimation.setTargetName(newValue);
+
+ // THEN
+ QCOMPARE(keyframeAnimation.targetName(), newValue);
+ QCOMPARE(spy.count(), 1);
+
+ // WHEN
+ spy.clear();
+ keyframeAnimation.setTargetName(newValue);
+
+ // THEN
+ QCOMPARE(keyframeAnimation.targetName(), newValue);
+ QCOMPARE(spy.count(), 0);
+
+ }
+ {
+ // WHEN
+ QSignalSpy spy(&keyframeAnimation,
+ SIGNAL(startModeChanged(QKeyframeAnimation::RepeatMode)));
+ const Qt3DAnimation::QKeyframeAnimation::RepeatMode newValue
+ = Qt3DAnimation::QKeyframeAnimation::Repeat;
+ keyframeAnimation.setStartMode(newValue);
+
+ // THEN
+ QCOMPARE(keyframeAnimation.startMode(), newValue);
+ QCOMPARE(spy.count(), 1);
+
+ // WHEN
+ spy.clear();
+ keyframeAnimation.setStartMode(newValue);
+
+ // THEN
+ QCOMPARE(keyframeAnimation.startMode(), newValue);
+ QCOMPARE(spy.count(), 0);
+
+ }
+ {
+ // WHEN
+ QSignalSpy spy(&keyframeAnimation,
+ SIGNAL(endModeChanged(QKeyframeAnimation::RepeatMode)));
+ const Qt3DAnimation::QKeyframeAnimation::RepeatMode newValue
+ = Qt3DAnimation::QKeyframeAnimation::Repeat;
+ keyframeAnimation.setEndMode(newValue);
+
+ // THEN
+ QCOMPARE(keyframeAnimation.endMode(), newValue);
+ QCOMPARE(spy.count(), 1);
+
+ // WHEN
+ spy.clear();
+ keyframeAnimation.setEndMode(newValue);
+
+ // THEN
+ QCOMPARE(keyframeAnimation.endMode(), newValue);
+ QCOMPARE(spy.count(), 0);
+
+ }
+ }
+
+ void testAnimating()
+ {
+ // GIVEN
+ Qt3DAnimation::QKeyframeAnimation keyframeAnimation;
+ Qt3DCore::QTransform targetTransform;
+ keyframeAnimation.setTarget(&targetTransform);
+
+ const float positions[3] = {0.0f, 1.0f, 2.0f};
+
+ Qt3DCore::QTransform keyframes[3];
+ keyframes[0].setScale(1.0f);
+ keyframes[1].setScale(2.0f);
+ keyframes[2].setScale(3.0f);
+
+ keyframes[0].setTranslation(QVector3D(0.0f, 0.0f, 0.0f));
+ keyframes[1].setTranslation(QVector3D(1.0f, 1.0f, 0.0f));
+ keyframes[2].setTranslation(QVector3D(2.0f, 0.0f, 2.0f));
+
+ keyframes[0].setRotationX(0.0f);
+ keyframes[1].setRotationY(45.0f);
+ keyframes[2].setRotationZ(90.0f);
+
+ QVector<float> framePositions;
+ framePositions.push_back(positions[0]);
+ framePositions.push_back(positions[1]);
+ framePositions.push_back(positions[2]);
+
+ QVector<Qt3DCore::QTransform*> frames;
+ frames.push_back(&keyframes[0]);
+ frames.push_back(&keyframes[1]);
+ frames.push_back(&keyframes[2]);
+
+ keyframeAnimation.setFramePositions(framePositions);
+ keyframeAnimation.setKeyframes(frames);
+
+ {
+ // WHEN
+ keyframeAnimation.setPosition(0.0f);
+
+ // THEN
+ QVERIFY(qFuzzyCompare(targetTransform.scale3D(), QVector3D(1.0f, 1.0f, 1.0f)));
+ QVERIFY(qFuzzyCompare(targetTransform.translation(), QVector3D(0.0f, 0.0f, 0.0f)));
+ QVERIFY(qFuzzyCompare(targetTransform.rotation(),
+ QQuaternion::fromEulerAngles(QVector3D(0.0f, 0.0f, 0.0f))));
+
+ // WHEN
+ keyframeAnimation.setPosition(1.0f);
+
+ // THEN
+ QVERIFY(qFuzzyCompare(targetTransform.scale3D(), QVector3D(2.0f, 2.0f, 2.0f)));
+ QVERIFY(qFuzzyCompare(targetTransform.translation(), QVector3D(1.0f, 1.0f, 0.0f)));
+ QVERIFY(qFuzzyCompare(targetTransform.rotation(),
+ QQuaternion::fromEulerAngles(QVector3D(0.0f, 45.0f, 0.0f))));
+
+ // WHEN
+ keyframeAnimation.setPosition(2.0f);
+
+ // THEN
+ QVERIFY(qFuzzyCompare(targetTransform.scale3D(), QVector3D(3.0f, 3.0f, 3.0f)));
+ QVERIFY(qFuzzyCompare(targetTransform.translation(), QVector3D(2.0f, 0.0f, 2.0f)));
+ QVERIFY(qFuzzyCompare(targetTransform.rotation(),
+ QQuaternion::fromEulerAngles(QVector3D(0.0f, 0.0f, 90.0f))));
+
+ // WHEN
+ keyframeAnimation.setPosition(3.0f);
+
+ // THEN
+ QVERIFY(qFuzzyCompare(targetTransform.scale3D(), QVector3D(3.0f, 3.0f, 3.0f)));
+ QVERIFY(qFuzzyCompare(targetTransform.translation(), QVector3D(2.0f, 0.0f, 2.0f)));
+ QVERIFY(qFuzzyCompare(targetTransform.rotation(),
+ QQuaternion::fromEulerAngles(QVector3D(0.0f, 0.0f, 90.0f))));
+
+ // WHEN
+ keyframeAnimation.setStartMode(Qt3DAnimation::QKeyframeAnimation::None);
+ keyframeAnimation.setEndMode(Qt3DAnimation::QKeyframeAnimation::None);
+ keyframeAnimation.setPosition(-1.0f);
+
+ // THEN
+ QVERIFY(qFuzzyCompare(targetTransform.scale3D(), QVector3D(3.0f, 3.0f, 3.0f)));
+ QVERIFY(qFuzzyCompare(targetTransform.translation(), QVector3D(2.0f, 0.0f, 2.0f)));
+ QVERIFY(qFuzzyCompare(targetTransform.rotation(),
+ QQuaternion::fromEulerAngles(QVector3D(0.0f, 0.0f, 90.0f))));
+
+ // WHEN
+ keyframeAnimation.setPosition(5.0f);
+
+ // THEN
+ QVERIFY(qFuzzyCompare(targetTransform.scale3D(), QVector3D(3.0f, 3.0f, 3.0f)));
+ QVERIFY(qFuzzyCompare(targetTransform.translation(), QVector3D(2.0f, 0.0f, 2.0f)));
+ QVERIFY(qFuzzyCompare(targetTransform.rotation(),
+ QQuaternion::fromEulerAngles(QVector3D(0.0f, 0.0f, 90.0f))));
+
+ // WHEN
+ keyframeAnimation.setStartMode(Qt3DAnimation::QKeyframeAnimation::Repeat);
+ keyframeAnimation.setEndMode(Qt3DAnimation::QKeyframeAnimation::Repeat);
+ keyframeAnimation.setPosition(-1.0f);
+
+ // THEN
+ QVERIFY(qFuzzyCompare(targetTransform.scale3D(), QVector3D(2.0f, 2.0f, 2.0f)));
+ QVERIFY(qFuzzyCompare(targetTransform.translation(), QVector3D(1.0f, 1.0f, 0.0f)));
+ QVERIFY(qFuzzyCompare(targetTransform.rotation(),
+ QQuaternion::fromEulerAngles(QVector3D(0.0f, 45.0f, 0.0f))));
+
+ // WHEN
+ keyframeAnimation.setStartMode(Qt3DAnimation::QKeyframeAnimation::Repeat);
+ keyframeAnimation.setEndMode(Qt3DAnimation::QKeyframeAnimation::Repeat);
+ keyframeAnimation.setPosition(4.0f);
+
+ // THEN
+ QVERIFY(qFuzzyCompare(targetTransform.scale3D(), QVector3D(1.0f, 1.0f, 1.0f)));
+ QVERIFY(qFuzzyCompare(targetTransform.translation(), QVector3D(0.0f, 0.0f, 0.0f)));
+ QVERIFY(qFuzzyCompare(targetTransform.rotation(),
+ QQuaternion::fromEulerAngles(QVector3D(0.0f, 0.0f, 0.0f))));
+ }
+ }
+};
+
+QTEST_APPLESS_MAIN(tst_QKeyframeAnimation)
+
+#include "tst_qkeyframeanimation.moc"
diff --git a/tests/auto/animation/qmorphinganimation/qmorphinganimation.pro b/tests/auto/animation/qmorphinganimation/qmorphinganimation.pro
new file mode 100644
index 000000000..aaad3b763
--- /dev/null
+++ b/tests/auto/animation/qmorphinganimation/qmorphinganimation.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+
+TARGET = tst_qmorphinganimation
+
+QT += 3dcore 3dcore-private 3drender 3drender-private 3danimation testlib
+
+CONFIG += testcase
+
+SOURCES += tst_qmorphinganimation.cpp
+
diff --git a/tests/auto/animation/qmorphinganimation/tst_qmorphinganimation.cpp b/tests/auto/animation/qmorphinganimation/tst_qmorphinganimation.cpp
new file mode 100644
index 000000000..77ff01851
--- /dev/null
+++ b/tests/auto/animation/qmorphinganimation/tst_qmorphinganimation.cpp
@@ -0,0 +1,309 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/qtest.h>
+#include <Qt3DAnimation/qmorphinganimation.h>
+#include <qobject.h>
+#include <qsignalspy.h>
+
+class tst_QMorphingAnimation : public QObject
+{
+ Q_OBJECT
+
+ bool verifyAttribute(Qt3DRender::QGeometry *geometry, QString name,
+ Qt3DRender::QAttribute *attribute)
+ {
+ const QVector<Qt3DRender::QAttribute *> attributes = geometry->attributes();
+ for (const Qt3DRender::QAttribute *attr : attributes) {
+ if (attr->name() == name) {
+ if (attr == attribute)
+ return true;
+ return false;
+ }
+ }
+ return false;
+ }
+
+private Q_SLOTS:
+
+ void initTestCase()
+ {
+ qRegisterMetaType<Qt3DAnimation::QMorphingAnimation::Method>("QMorphingAnimation::Method");
+ }
+
+ void checkDefaultConstruction()
+ {
+ // GIVEN
+ Qt3DAnimation::QMorphingAnimation morphingAnimation;
+
+ // THEN
+ QCOMPARE(morphingAnimation.interpolator(), 0.0f);
+ QCOMPARE(morphingAnimation.target(), nullptr);
+ QCOMPARE(morphingAnimation.targetName(), QString());
+ QCOMPARE(morphingAnimation.method(), Qt3DAnimation::QMorphingAnimation::Relative);
+ QCOMPARE(morphingAnimation.easing(), QEasingCurve());
+ }
+
+ void checkPropertyChanges()
+ {
+ // GIVEN
+ Qt3DAnimation::QMorphingAnimation morphingAnimation;
+
+ {
+ // WHEN
+ QScopedPointer<Qt3DRender::QGeometryRenderer> gr(new Qt3DRender::QGeometryRenderer);
+ QSignalSpy spy(&morphingAnimation,
+ SIGNAL(targetChanged(Qt3DRender::QGeometryRenderer *)));
+ Qt3DRender::QGeometryRenderer *newValue = gr.data();
+ morphingAnimation.setTarget(newValue);
+
+ // THEN
+ QCOMPARE(morphingAnimation.target(), newValue);
+ QCOMPARE(spy.count(), 1);
+
+ // WHEN
+ spy.clear();
+ morphingAnimation.setTarget(newValue);
+
+ // THEN
+ QCOMPARE(morphingAnimation.target(), newValue);
+ QCOMPARE(spy.count(), 0);
+
+ }
+ {
+ // WHEN
+ QSignalSpy spy(&morphingAnimation, SIGNAL(targetNameChanged(QString)));
+ const QString newValue = QString("target");
+ morphingAnimation.setTargetName(newValue);
+
+ // THEN
+ QCOMPARE(morphingAnimation.targetName(), newValue);
+ QCOMPARE(spy.count(), 1);
+
+ // WHEN
+ spy.clear();
+ morphingAnimation.setTargetName(newValue);
+
+ // THEN
+ QCOMPARE(morphingAnimation.targetName(), newValue);
+ QCOMPARE(spy.count(), 0);
+
+ }
+ {
+ // WHEN
+ QSignalSpy spy(&morphingAnimation, SIGNAL(methodChanged(QMorphingAnimation::Method)));
+ const Qt3DAnimation::QMorphingAnimation::Method newValue
+ = Qt3DAnimation::QMorphingAnimation::Normalized;
+ morphingAnimation.setMethod(newValue);
+
+ // THEN
+ QCOMPARE(morphingAnimation.method(), newValue);
+ QCOMPARE(spy.count(), 1);
+
+ // WHEN
+ spy.clear();
+ morphingAnimation.setMethod(newValue);
+
+ // THEN
+ QCOMPARE(morphingAnimation.method(), newValue);
+ QCOMPARE(spy.count(), 0);
+
+ }
+ {
+ // WHEN
+ QSignalSpy spy(&morphingAnimation, SIGNAL(easingChanged(QEasingCurve)));
+ const QEasingCurve newValue = QEasingCurve(QEasingCurve::InBounce);
+ morphingAnimation.setEasing(newValue);
+
+ // THEN
+ QCOMPARE(morphingAnimation.easing(), newValue);
+ QCOMPARE(spy.count(), 1);
+
+ // WHEN
+ spy.clear();
+ morphingAnimation.setEasing(newValue);
+
+ // THEN
+ QCOMPARE(morphingAnimation.easing(), newValue);
+ QCOMPARE(spy.count(), 0);
+
+ }
+ }
+
+ void testAnimation()
+ {
+ // GIVEN
+ const QString baseName("position");
+ const QString targetName("positionTarget");
+ Qt3DAnimation::QMorphingAnimation morphingAnimation;
+ Qt3DRender::QAttribute *base = new Qt3DRender::QAttribute;
+
+ Qt3DRender::QGeometry *geometry = new Qt3DRender::QGeometry;
+ Qt3DAnimation::QMorphTarget *mt1 = new Qt3DAnimation::QMorphTarget(&morphingAnimation);
+ Qt3DAnimation::QMorphTarget *mt2 = new Qt3DAnimation::QMorphTarget(&morphingAnimation);
+ Qt3DAnimation::QMorphTarget *mt3 = new Qt3DAnimation::QMorphTarget(&morphingAnimation);
+ Qt3DRender::QAttribute *a1 = new Qt3DRender::QAttribute(geometry);
+ Qt3DRender::QAttribute *a2 = new Qt3DRender::QAttribute(geometry);
+ Qt3DRender::QAttribute *a3 = new Qt3DRender::QAttribute(geometry);
+ Qt3DRender::QGeometryRenderer gr;
+
+ base->setName(baseName);
+ geometry->addAttribute(base);
+ gr.setGeometry(geometry);
+ morphingAnimation.setTarget(&gr);
+ a1->setName(baseName);
+ a2->setName(baseName);
+ a3->setName(baseName);
+ mt1->addAttribute(a1);
+ mt2->addAttribute(a2);
+ mt3->addAttribute(a3);
+ morphingAnimation.addMorphTarget(mt1);
+ morphingAnimation.addMorphTarget(mt2);
+ morphingAnimation.addMorphTarget(mt3);
+
+ QVector<float> positions;
+ QVector<float> weights;
+ positions.push_back(0.0f);
+ positions.push_back(1.0f);
+ positions.push_back(2.0f);
+ positions.push_back(3.0f);
+ positions.push_back(4.0f);
+ morphingAnimation.setTargetPositions(positions);
+
+ weights.resize(3);
+
+ weights[0] = 1.0f;
+ weights[1] = 0.0f;
+ weights[2] = 0.0f;
+ morphingAnimation.setWeights(0, weights);
+ weights[0] = 0.0f;
+ weights[1] = 0.0f;
+ weights[2] = 0.0f;
+ morphingAnimation.setWeights(1, weights);
+ weights[0] = 0.0f;
+ weights[1] = 1.0f;
+ weights[2] = 0.0f;
+ morphingAnimation.setWeights(2, weights);
+ weights[0] = 0.0f;
+ weights[1] = 0.0f;
+ weights[2] = 0.0f;
+ morphingAnimation.setWeights(3, weights);
+ weights[0] = 0.0f;
+ weights[1] = 0.0f;
+ weights[2] = 1.0f;
+ morphingAnimation.setWeights(4, weights);
+
+ morphingAnimation.setMethod(Qt3DAnimation::QMorphingAnimation::Relative);
+ {
+ // WHEN
+ morphingAnimation.setPosition(0.0f);
+
+ // THEN
+ QVERIFY(qFuzzyCompare(morphingAnimation.interpolator(), -1.0f));
+ QVERIFY(verifyAttribute(geometry, baseName, base));
+ QVERIFY(verifyAttribute(geometry, targetName, a1));
+
+ // WHEN
+ morphingAnimation.setPosition(0.5f);
+
+ // THEN
+ QVERIFY(qFuzzyCompare(morphingAnimation.interpolator(), -0.5f));
+ QVERIFY(verifyAttribute(geometry, baseName, base));
+ QVERIFY(verifyAttribute(geometry, targetName, a1));
+
+ // WHEN
+ morphingAnimation.setPosition(1.0f);
+
+ // THEN
+ QVERIFY(qFuzzyCompare(morphingAnimation.interpolator(), -0.0f));
+ QVERIFY(verifyAttribute(geometry, baseName, base));
+
+ // WHEN
+ morphingAnimation.setPosition(1.5f);
+
+ // THEN
+ QVERIFY(qFuzzyCompare(morphingAnimation.interpolator(), -0.5f));
+ QVERIFY(verifyAttribute(geometry, baseName, base));
+ QVERIFY(verifyAttribute(geometry, targetName, a2));
+
+ // WHEN
+ morphingAnimation.setPosition(4.0f);
+
+ // THEN
+ QVERIFY(qFuzzyCompare(morphingAnimation.interpolator(), -1.0f));
+ QVERIFY(verifyAttribute(geometry, baseName, base));
+ QVERIFY(verifyAttribute(geometry, targetName, a3));
+ }
+
+ morphingAnimation.setMethod(Qt3DAnimation::QMorphingAnimation::Normalized);
+ {
+ // WHEN
+ morphingAnimation.setPosition(0.0f);
+
+ // THEN
+ QVERIFY(qFuzzyCompare(morphingAnimation.interpolator(), 1.0f));
+ QVERIFY(verifyAttribute(geometry, baseName, base));
+ QVERIFY(verifyAttribute(geometry, targetName, a1));
+
+ // WHEN
+ morphingAnimation.setPosition(0.5f);
+
+ // THEN
+ QVERIFY(qFuzzyCompare(morphingAnimation.interpolator(), 0.5f));
+ QVERIFY(verifyAttribute(geometry, baseName, base));
+ QVERIFY(verifyAttribute(geometry, targetName, a1));
+
+ // WHEN
+ morphingAnimation.setPosition(1.0f);
+
+ // THEN
+ QVERIFY(qFuzzyCompare(morphingAnimation.interpolator(), 0.0f));
+ QVERIFY(verifyAttribute(geometry, baseName, base));
+
+ // WHEN
+ morphingAnimation.setPosition(1.5f);
+
+ // THEN
+ QVERIFY(qFuzzyCompare(morphingAnimation.interpolator(), 0.5f));
+ QVERIFY(verifyAttribute(geometry, baseName, base));
+ QVERIFY(verifyAttribute(geometry, targetName, a2));
+
+ // WHEN
+ morphingAnimation.setPosition(4.0f);
+
+ // THEN
+ QVERIFY(qFuzzyCompare(morphingAnimation.interpolator(), 1.0f));
+ QVERIFY(verifyAttribute(geometry, baseName, base));
+ QVERIFY(verifyAttribute(geometry, targetName, a3));
+ }
+ }
+};
+
+QTEST_APPLESS_MAIN(tst_QMorphingAnimation)
+
+#include "tst_qmorphinganimation.moc"
diff --git a/tests/auto/animation/qmorphtarget/qmorphtarget.pro b/tests/auto/animation/qmorphtarget/qmorphtarget.pro
new file mode 100644
index 000000000..bb38aad19
--- /dev/null
+++ b/tests/auto/animation/qmorphtarget/qmorphtarget.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+
+TARGET = tst_qmorphtarget
+
+QT += 3dcore 3dcore-private 3drender 3drender-private 3danimation testlib
+
+CONFIG += testcase
+
+SOURCES += tst_qmorphtarget.cpp
+
diff --git a/tests/auto/animation/qmorphtarget/tst_qmorphtarget.cpp b/tests/auto/animation/qmorphtarget/tst_qmorphtarget.cpp
new file mode 100644
index 000000000..2cba9ba2a
--- /dev/null
+++ b/tests/auto/animation/qmorphtarget/tst_qmorphtarget.cpp
@@ -0,0 +1,123 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/qtest.h>
+#include <Qt3DAnimation/qmorphtarget.h>
+#include <qobject.h>
+#include <qsignalspy.h>
+
+class tst_QMorphTarget : public QObject
+{
+ Q_OBJECT
+
+private Q_SLOTS:
+
+ void checkDefaultConstruction()
+ {
+ // GIVEN
+ Qt3DAnimation::QMorphTarget morphTarget;
+
+ // THEN
+ QCOMPARE(morphTarget.attributeNames(), QStringList());
+ }
+
+ void testSetAttributes()
+ {
+ // GIVEN
+ Qt3DAnimation::QMorphTarget morphTarget;
+ Qt3DRender::QAttribute attribute1;
+ Qt3DRender::QAttribute attribute2;
+
+ attribute1.setName(Qt3DRender::QAttribute::defaultPositionAttributeName());
+ attribute2.setName(Qt3DRender::QAttribute::defaultNormalAttributeName());
+
+ {
+ // WHEN
+ morphTarget.addAttribute(&attribute1);
+
+ // THEN
+ QStringList names = morphTarget.attributeNames();
+ QCOMPARE(names.size(), 1);
+ QCOMPARE(names.at(0), Qt3DRender::QAttribute::defaultPositionAttributeName());
+ }
+
+ {
+ // WHEN
+ morphTarget.addAttribute(&attribute2);
+
+ // THEN
+ QStringList names = morphTarget.attributeNames();
+ QCOMPARE(names.size(), 2);
+ QCOMPARE(names.at(1), Qt3DRender::QAttribute::defaultNormalAttributeName());
+ }
+ }
+
+ void testFromGeometry()
+ {
+ // GIVEN
+ Qt3DRender::QGeometry geometry;
+ Qt3DRender::QAttribute *attribute1 = new Qt3DRender::QAttribute;
+ Qt3DRender::QAttribute *attribute2 = new Qt3DRender::QAttribute;
+ attribute1->setName(Qt3DRender::QAttribute::defaultPositionAttributeName());
+ attribute2->setName(Qt3DRender::QAttribute::defaultTextureCoordinateAttributeName());
+ geometry.addAttribute(attribute1);
+ geometry.addAttribute(attribute2);
+
+ QStringList attributes;
+ attributes.push_back(Qt3DRender::QAttribute::defaultPositionAttributeName());
+
+ {
+ // WHEN
+ QScopedPointer<Qt3DAnimation::QMorphTarget> morphTarget(
+ Qt3DAnimation::QMorphTarget::fromGeometry(&geometry, attributes));
+
+ // THEN
+ QStringList names = morphTarget->attributeNames();
+ QCOMPARE(names.size(), 1);
+ QCOMPARE(names.at(0), Qt3DRender::QAttribute::defaultPositionAttributeName());
+ }
+
+ {
+ // WHEN
+ attributes.push_back(Qt3DRender::QAttribute::defaultTextureCoordinateAttributeName());
+ QScopedPointer<Qt3DAnimation::QMorphTarget> morphTarget(
+ Qt3DAnimation::QMorphTarget::fromGeometry(&geometry, attributes));
+
+ // THEN
+ QStringList names = morphTarget->attributeNames();
+ QCOMPARE(names.size(), 2);
+ QCOMPARE(names.at(0), Qt3DRender::QAttribute::defaultPositionAttributeName());
+ QCOMPARE(names.at(1), Qt3DRender::QAttribute::defaultTextureCoordinateAttributeName());
+ }
+ }
+
+};
+
+QTEST_APPLESS_MAIN(tst_QMorphTarget)
+
+#include "tst_qmorphtarget.moc"
diff --git a/tests/auto/animation/qvertexblendanimation/qvertexblendanimation.pro b/tests/auto/animation/qvertexblendanimation/qvertexblendanimation.pro
new file mode 100644
index 000000000..8079ebf15
--- /dev/null
+++ b/tests/auto/animation/qvertexblendanimation/qvertexblendanimation.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+
+TARGET = tst_qvertexblendanimation
+
+QT += 3dcore 3dcore-private 3drender 3drender-private 3danimation testlib
+
+CONFIG += testcase
+
+SOURCES += tst_qvertexblendanimation.cpp
+
diff --git a/tests/auto/animation/qvertexblendanimation/tst_qvertexblendanimation.cpp b/tests/auto/animation/qvertexblendanimation/tst_qvertexblendanimation.cpp
new file mode 100644
index 000000000..dc27e4a7e
--- /dev/null
+++ b/tests/auto/animation/qvertexblendanimation/tst_qvertexblendanimation.cpp
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/qtest.h>
+#include <Qt3DAnimation/qvertexblendanimation.h>
+#include <qobject.h>
+#include <qsignalspy.h>
+
+class tst_QVertexBlendAnimation : public QObject
+{
+ Q_OBJECT
+
+private Q_SLOTS:
+
+ void checkDefaultConstruction()
+ {
+ // GIVEN
+ Qt3DAnimation::QVertexBlendAnimation vertexBlendAnimation;
+
+ // THEN
+ QCOMPARE(vertexBlendAnimation.interpolator(), 0.0f);
+ QCOMPARE(vertexBlendAnimation.target(), nullptr);
+ QCOMPARE(vertexBlendAnimation.targetName(), QString());
+ }
+
+ void checkPropertyChanges()
+ {
+ // GIVEN
+ Qt3DAnimation::QVertexBlendAnimation vertexBlendAnimation;
+
+ {
+ // WHEN
+ QScopedPointer<Qt3DRender::QGeometryRenderer> gm(new Qt3DRender::QGeometryRenderer);
+ QSignalSpy spy(&vertexBlendAnimation,
+ SIGNAL(targetChanged(Qt3DRender::QGeometryRenderer *)));
+ Qt3DRender::QGeometryRenderer *newValue = gm.data();
+ vertexBlendAnimation.setTarget(newValue);
+
+ // THEN
+ QCOMPARE(vertexBlendAnimation.target(), newValue);
+ QCOMPARE(spy.count(), 1);
+
+ // WHEN
+ spy.clear();
+ vertexBlendAnimation.setTarget(newValue);
+
+ // THEN
+ QCOMPARE(vertexBlendAnimation.target(), newValue);
+ QCOMPARE(spy.count(), 0);
+
+ }
+ {
+ // WHEN
+ QSignalSpy spy(&vertexBlendAnimation, SIGNAL(targetNameChanged(QString)));
+ const QString newValue = QString("target");
+ vertexBlendAnimation.setTargetName(newValue);
+
+ // THEN
+ QCOMPARE(vertexBlendAnimation.targetName(), newValue);
+ QCOMPARE(spy.count(), 1);
+
+ // WHEN
+ spy.clear();
+ vertexBlendAnimation.setTargetName(newValue);
+
+ // THEN
+ QCOMPARE(vertexBlendAnimation.targetName(), newValue);
+ QCOMPARE(spy.count(), 0);
+
+ }
+ }
+
+};
+
+QTEST_APPLESS_MAIN(tst_QVertexBlendAnimation)
+
+#include "tst_qvertexblendanimation.moc"