summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2017-05-20 14:57:26 +0100
committerSean Harmer <sean.harmer@kdab.com>2017-05-20 14:57:53 +0100
commitcd9059a22604307f483764db134d51b15c540758 (patch)
tree9ceea8edf2b41e55f17a49552d9cf37fcdedc9b2 /tests
parent1d024678ba16dd979a8c7023b35cdc76db357d37 (diff)
parent9bf4daddeb62ec6a40e2d90587a7327acbb3780f (diff)
Merge branch '5.9.0' into 5.9
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/animation/animation.pro11
-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
-rw-r--r--tests/auto/core/nodes/tst_nodes.cpp63
-rw-r--r--tests/auto/core/qchangearbiter/tst_qchangearbiter.cpp4
-rw-r--r--tests/auto/core/qscene/tst_qscene.cpp3
-rw-r--r--tests/auto/render/qscene2d/tst_qscene2d.cpp64
-rw-r--r--tests/auto/render/scene2d/tst_scene2d.cpp36
-rw-r--r--tests/manual/custom-mesh-update-data-qml/main.qml6
-rw-r--r--tests/manual/dynamic-model-loader-qml/CuboidEntity.qml2
-rw-r--r--tests/manual/gltf/main.qml2
-rw-r--r--tests/manual/loader-qml/CuboidEntity.qml2
-rw-r--r--tests/manual/render-qml-to-texture-qml/main.qml3
-rw-r--r--tests/manual/render-qml-to-texture/main.cpp8
26 files changed, 1549 insertions, 63 deletions
diff --git a/tests/auto/animation/animation.pro b/tests/auto/animation/animation.pro
index 969f477e7..b48fd347b 100644
--- a/tests/auto/animation/animation.pro
+++ b/tests/auto/animation/animation.pro
@@ -7,7 +7,13 @@ SUBDIRS += \
qblendedclipanimator \
qchannelmapping \
qchannelmapper \
- qclipblendvalue
+ qclipblendvalue \
+ qanimationcontroller \
+ qanimationgroup \
+ qkeyframeanimation \
+ qmorphinganimation \
+ qmorphtarget \
+ qvertexblendanimation
qtConfig(private_tests) {
SUBDIRS += \
@@ -27,5 +33,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"
diff --git a/tests/auto/core/nodes/tst_nodes.cpp b/tests/auto/core/nodes/tst_nodes.cpp
index 89d396931..25c2a6dba 100644
--- a/tests/auto/core/nodes/tst_nodes.cpp
+++ b/tests/auto/core/nodes/tst_nodes.cpp
@@ -79,6 +79,8 @@ private slots:
void appendingChildEntitiesToNode();
void removingChildEntitiesFromNode();
+ void checkConstructionSetParentMix(); // QTBUG-60612
+
void appendingComponentToEntity();
void appendingParentlessComponentToEntity();
void removingComponentFromEntity();
@@ -204,6 +206,11 @@ public:
Qt3DCore::QNodePrivate::get(this)->setArbiter(arbiter);
}
+ void setSimulateBackendCreated(bool created)
+ {
+ Qt3DCore::QNodePrivate::get(this)->m_hasBackendNode = created;
+ }
+
signals:
void customPropertyChanged();
@@ -232,6 +239,11 @@ public:
Qt3DCore::QNodePrivate::get(this)->setScene(scene);
Qt3DCore::QNodePrivate::get(this)->setArbiter(arbiter);
}
+
+ void setSimulateBackendCreated(bool created)
+ {
+ Qt3DCore::QNodePrivate::get(this)->m_hasBackendNode = created;
+ }
};
class MyQComponent : public Qt3DCore::QComponent
@@ -389,6 +401,8 @@ void tst_Nodes::appendSingleChildNodeToNodeSceneExplicitParenting()
QScopedPointer<MyQNode> node(new MyQNode());
// WHEN
node->setArbiterAndScene(&spy, &scene);
+ node->setSimulateBackendCreated(true);
+
// THEN
QVERIFY(Qt3DCore::QNodePrivate::get(node.data())->scene() != nullptr);
@@ -405,7 +419,7 @@ void tst_Nodes::appendSingleChildNodeToNodeSceneExplicitParenting()
// THEN
QVERIFY(child->parent() == node.data());
QVERIFY(child->parentNode() == node.data());
- QCOMPARE(spy.events.size(), 2);
+ QCOMPARE(spy.events.size(), 2); // Created + Child Added
QCOMPARE(node->children().count(), 1);
QVERIFY(Qt3DCore::QNodePrivate::get(child.data())->scene() != nullptr);
@@ -482,6 +496,7 @@ void tst_Nodes::appendMultipleChildNodesToNodeScene()
// WHEN
node->setArbiterAndScene(&spy, &scene);
+ node->setSimulateBackendCreated(true);
// THEN
QVERIFY(Qt3DCore::QNodePrivate::get(node.data())->scene() != nullptr);
@@ -664,6 +679,7 @@ void tst_Nodes::removingSingleChildNodeFromNode()
// WHEN
root->setArbiterAndScene(&spy, &scene);
+ root->setSimulateBackendCreated(true);
child->setParent(root.data());
// Clear any creation event
@@ -790,6 +806,47 @@ void tst_Nodes::removingChildEntitiesFromNode()
QVERIFY(childEntity->parent() == nullptr);
}
+void tst_Nodes::checkConstructionSetParentMix()
+{
+ // GIVEN
+ ObserverSpy spy;
+ Qt3DCore::QScene scene;
+ QScopedPointer<MyQNode> root(new MyQNode());
+
+ // WHEN
+ root->setArbiterAndScene(&spy, &scene);
+ root->setSimulateBackendCreated(true);
+
+ // THEN
+ QVERIFY(Qt3DCore::QNodePrivate::get(root.data())->scene() != nullptr);
+
+ // WHEN
+ Qt3DCore::QEntity *subTreeRoot = new Qt3DCore::QEntity(root.data());
+
+ for (int i = 0; i < 100; ++i) {
+ Qt3DCore::QEntity *child = new Qt3DCore::QEntity();
+ child->setParent(subTreeRoot);
+ }
+
+ // THEN
+ QCoreApplication::processEvents();
+ QCOMPARE(root->children().count(), 1);
+ QCOMPARE(subTreeRoot->children().count(), 100);
+ QCOMPARE(spy.events.size(), 102); // 1 subTreeRoot creation change, 100 child creation, 1 child added (subTree to root)
+
+ // Ensure first event is subTreeRoot
+ const Qt3DCore::QNodeCreatedChangeBasePtr firstEvent = spy.events.takeFirst().change().dynamicCast<Qt3DCore::QNodeCreatedChangeBase>();
+ QVERIFY(!firstEvent.isNull());
+ QCOMPARE(firstEvent->subjectId(), subTreeRoot->id());
+ QCOMPARE(firstEvent->parentId(), root->id());
+
+ const Qt3DCore::QPropertyNodeAddedChangePtr lastEvent = spy.events.takeLast().change().dynamicCast<Qt3DCore::QPropertyNodeAddedChange>();
+ QVERIFY(!lastEvent.isNull());
+ QCOMPARE(lastEvent->subjectId(), root->id());
+ QCOMPARE(lastEvent->propertyName(), "children");
+ QCOMPARE(lastEvent->addedNodeId(), subTreeRoot->id());
+}
+
void tst_Nodes::appendingParentlessComponentToEntity()
{
// GIVEN
@@ -798,6 +855,8 @@ void tst_Nodes::appendingParentlessComponentToEntity()
{
QScopedPointer<MyQEntity> entity(new MyQEntity());
entity->setArbiterAndScene(&entitySpy);
+ entity->setSimulateBackendCreated(true);
+
MyQComponent *comp = new MyQComponent();
comp->setArbiter(&componentSpy);
@@ -816,7 +875,7 @@ void tst_Nodes::appendingParentlessComponentToEntity()
QVERIFY(comp->parentNode() == entity.data());
QCOMPARE(entitySpy.events.size(), 1);
QVERIFY(entitySpy.events.first().wasLocked());
- QCOMPARE(componentSpy.events.size(), 2); // first event is parent being set
+ QCOMPARE(componentSpy.events.size(), 1);
// Note: since QEntity has no scene in this test case, we only have the
// ComponentAdded event In theory we should also get the NodeCreated event
diff --git a/tests/auto/core/qchangearbiter/tst_qchangearbiter.cpp b/tests/auto/core/qchangearbiter/tst_qchangearbiter.cpp
index 061de06fa..faccb6d34 100644
--- a/tests/auto/core/qchangearbiter/tst_qchangearbiter.cpp
+++ b/tests/auto/core/qchangearbiter/tst_qchangearbiter.cpp
@@ -442,6 +442,7 @@ void tst_QChangeArbiter::registerSceneObserver()
tst_Node *root = new tst_Node();
Qt3DCore::QNode *child = new tst_Node();
Qt3DCore::QNodePrivate::get(root)->setScene(scene.data());
+ Qt3DCore::QNodePrivate::get(root)->m_hasBackendNode = true;
scene->addObservable(root);
QList<tst_SimpleObserver *> observers;
@@ -573,6 +574,7 @@ void tst_QChangeArbiter::unregisterSceneObservers()
tst_Node *root = new tst_Node();
Qt3DCore::QNode *child = new tst_Node();
Qt3DCore::QNodePrivate::get(root)->setScene(scene.data());
+ Qt3DCore::QNodePrivate::get(root)->m_hasBackendNode = true;
scene->addObservable(root);
QList<tst_SimpleObserver *> observers;
@@ -796,6 +798,7 @@ void tst_QChangeArbiter::distributePropertyChanges()
// WHEN
PropertyTestNode *root = new PropertyTestNode();
Qt3DCore::QNodePrivate::get(root)->setScene(scene.data());
+ Qt3DCore::QNodePrivate::get(root)->m_hasBackendNode = true;
scene->addObservable(root);
tst_SimpleObserver *rootObserver = new tst_SimpleObserver();
@@ -890,6 +893,7 @@ void tst_QChangeArbiter::distributeBackendChanges()
// WHEN
tst_Node *root = new tst_Node();
Qt3DCore::QNodePrivate::get(root)->setScene(scene.data());
+ Qt3DCore::QNodePrivate::get(root)->m_hasBackendNode = true;
scene->addObservable(root);
tst_BackendObserverObservable *backenObserverObservable = new tst_BackendObserverObservable();
diff --git a/tests/auto/core/qscene/tst_qscene.cpp b/tests/auto/core/qscene/tst_qscene.cpp
index f4b04362d..78f17e8fa 100644
--- a/tests/auto/core/qscene/tst_qscene.cpp
+++ b/tests/auto/core/qscene/tst_qscene.cpp
@@ -297,6 +297,8 @@ void tst_QScene::deleteChildNode()
Qt3DCore::QNode *root2 = new tst_Node();
Qt3DCore::QNodePrivate::get(root1)->setScene(scene);
Qt3DCore::QNodePrivate::get(root2)->setScene(scene);
+ Qt3DCore::QNodePrivate::get(root1)->m_hasBackendNode = true;
+ Qt3DCore::QNodePrivate::get(root2)->m_hasBackendNode = true;
// WHEN
scene->addObservable(root1);
@@ -358,6 +360,7 @@ void tst_QScene::removeChildNode()
Qt3DCore::QNode *root = new tst_Node;
Qt3DCore::QNodePrivate::get(root)->setScene(scene);
+ Qt3DCore::QNodePrivate::get(root)->m_hasBackendNode = true;
scene->addObservable(root);
// WHEN
diff --git a/tests/auto/render/qscene2d/tst_qscene2d.cpp b/tests/auto/render/qscene2d/tst_qscene2d.cpp
index f0ff2db1e..846207456 100644
--- a/tests/auto/render/qscene2d/tst_qscene2d.cpp
+++ b/tests/auto/render/qscene2d/tst_qscene2d.cpp
@@ -58,10 +58,9 @@ private Q_SLOTS:
// THEN
QCOMPARE(scene2d.output(), nullptr);
- QCOMPARE(scene2d.source(), QUrl(QStringLiteral("")));
QCOMPARE(scene2d.renderPolicy(), QScene2D::Continuous);
- QCOMPARE(scene2d.loaded(), false);
QCOMPARE(scene2d.item(), nullptr);
+ QCOMPARE(scene2d.isMouseEnabled(), true);
}
void checkPropertyChanges()
@@ -92,59 +91,60 @@ private Q_SLOTS:
}
{
// WHEN
- QSignalSpy spy(&scene2d, SIGNAL(sourceChanged(QUrl)));
- const QUrl newValue = QUrl(QStringLiteral("qrc://source.qml"));
- scene2d.setSource(newValue);
+ QSignalSpy spy(&scene2d, SIGNAL(renderPolicyChanged(QScene2D::RenderPolicy)));
+ const QScene2D::RenderPolicy newValue = QScene2D::SingleShot;
+ scene2d.setRenderPolicy(newValue);
// THEN
QVERIFY(spy.isValid());
- QCOMPARE(scene2d.source(), newValue);
+ QCOMPARE(scene2d.renderPolicy(), newValue);
QCOMPARE(spy.count(), 1);
// WHEN
spy.clear();
- scene2d.setSource(newValue);
+ scene2d.setRenderPolicy(newValue);
// THEN
- QCOMPARE(scene2d.source(), newValue);
+ QCOMPARE(scene2d.renderPolicy(), newValue);
QCOMPARE(spy.count(), 0);
}
{
// WHEN
- QSignalSpy spy(&scene2d, SIGNAL(renderPolicyChanged(QScene2D::RenderPolicy)));
- const QScene2D::RenderPolicy newValue = QScene2D::SingleShot;
- scene2d.setRenderPolicy(newValue);
+ QSignalSpy spy(&scene2d, SIGNAL(itemChanged(QQuickItem*)));
+ QQuickItem *newValue = item.data();
+ scene2d.setItem(newValue);
// THEN
QVERIFY(spy.isValid());
- QCOMPARE(scene2d.renderPolicy(), newValue);
+ QCOMPARE(scene2d.item(), newValue);
QCOMPARE(spy.count(), 1);
// WHEN
spy.clear();
- scene2d.setRenderPolicy(newValue);
+ scene2d.setItem(newValue);
// THEN
- QCOMPARE(scene2d.renderPolicy(), newValue);
+ QCOMPARE(scene2d.item(), newValue);
QCOMPARE(spy.count(), 0);
}
+
{
// WHEN
- QSignalSpy spy(&scene2d, SIGNAL(itemChanged(QQuickItem*)));
- QQuickItem *newValue = item.data();
- scene2d.setItem(newValue);
+ QSignalSpy spy(&scene2d, SIGNAL(mouseEnabledChanged(bool)));
+ bool newValue = false;
+ scene2d.setMouseEnabled(newValue);
// THEN
QVERIFY(spy.isValid());
- QCOMPARE(scene2d.item(), newValue);
+ QCOMPARE(scene2d.isMouseEnabled(), newValue);
QCOMPARE(spy.count(), 1);
// WHEN
spy.clear();
- scene2d.setItem(newValue);
+ scene2d.setMouseEnabled(newValue);
// THEN
- QCOMPARE(scene2d.item(), newValue);
+ QCOMPARE(scene2d.isMouseEnabled(), newValue);
QCOMPARE(spy.count(), 0);
}
}
@@ -156,7 +156,6 @@ private Q_SLOTS:
QScopedPointer<Qt3DRender::QRenderTargetOutput> output(new Qt3DRender::QRenderTargetOutput());
scene2d.setOutput(output.data());
- scene2d.setSource(QUrl(QStringLiteral("qrc://source.qml")));
scene2d.setRenderPolicy(QScene2D::SingleShot);
// WHEN
@@ -181,6 +180,7 @@ private Q_SLOTS:
QCOMPARE(scene2d.isEnabled(), true);
QCOMPARE(scene2d.isEnabled(), creationChangeData->isNodeEnabled());
QCOMPARE(scene2d.metaObject(), creationChangeData->metaObject());
+ QCOMPARE(scene2d.isMouseEnabled(), cloneData.mouseEnabled);
}
// WHEN
@@ -242,7 +242,7 @@ private Q_SLOTS:
}
- void checkSourceUpdate()
+ void checkRenderPolicyUpdate()
{
// GIVEN
TestArbiter arbiter;
@@ -251,14 +251,15 @@ private Q_SLOTS:
{
// WHEN
- scene2d.setSource(QUrl(QStringLiteral("qrc://source.qml")));
+ scene2d.setRenderPolicy(QScene2D::SingleShot);
QCoreApplication::processEvents();
// THEN
QCOMPARE(arbiter.events.size(), 1);
auto change = arbiter.events.first().staticCast<Qt3DCore::QPropertyUpdatedChange>();
- QCOMPARE(change->propertyName(), "source");
- QCOMPARE(change->value().value<QUrl>(), scene2d.source());
+ QCOMPARE(change->propertyName(), "renderPolicy");
+ QCOMPARE(change->value().value<Qt3DRender::Quick::QScene2D::RenderPolicy>(),
+ scene2d.renderPolicy());
QCOMPARE(change->type(), Qt3DCore::PropertyUpdated);
arbiter.events.clear();
@@ -266,7 +267,7 @@ private Q_SLOTS:
{
// WHEN
- scene2d.setSource(QUrl(QStringLiteral("qrc://source.qml")));
+ scene2d.setRenderPolicy(QScene2D::SingleShot);
QCoreApplication::processEvents();
// THEN
@@ -275,7 +276,7 @@ private Q_SLOTS:
}
- void checkRenderPolicyUpdate()
+ void checkMouseEnabledUpdate()
{
// GIVEN
TestArbiter arbiter;
@@ -284,15 +285,14 @@ private Q_SLOTS:
{
// WHEN
- scene2d.setRenderPolicy(QScene2D::SingleShot);
+ scene2d.setMouseEnabled(false);
QCoreApplication::processEvents();
// THEN
QCOMPARE(arbiter.events.size(), 1);
auto change = arbiter.events.first().staticCast<Qt3DCore::QPropertyUpdatedChange>();
- QCOMPARE(change->propertyName(), "renderPolicy");
- QCOMPARE(change->value().value<Qt3DRender::Quick::QScene2D::RenderPolicy>(),
- scene2d.renderPolicy());
+ QCOMPARE(change->propertyName(), "mouseEnabled");
+ QCOMPARE(change->value().toBool(), scene2d.isMouseEnabled());
QCOMPARE(change->type(), Qt3DCore::PropertyUpdated);
arbiter.events.clear();
@@ -300,7 +300,7 @@ private Q_SLOTS:
{
// WHEN
- scene2d.setRenderPolicy(QScene2D::SingleShot);
+ scene2d.setMouseEnabled(false);
QCoreApplication::processEvents();
// THEN
diff --git a/tests/auto/render/scene2d/tst_scene2d.cpp b/tests/auto/render/scene2d/tst_scene2d.cpp
index d0bd5ca9d..a78ed0ab1 100644
--- a/tests/auto/render/scene2d/tst_scene2d.cpp
+++ b/tests/auto/render/scene2d/tst_scene2d.cpp
@@ -114,6 +114,7 @@ private Q_SLOTS:
QCOMPARE(backendScene2d.m_initialized, false);
QCOMPARE(backendScene2d.m_renderInitialized, false);
QCOMPARE(backendScene2d.m_renderPolicy, QScene2D::Continuous);
+ QCOMPARE(backendScene2d.m_mouseEnabled, true);
backendScene2d.cleanup();
}
@@ -135,6 +136,7 @@ private Q_SLOTS:
QCOMPARE(backendScene2d->m_outputId, Qt3DCore::QNodeId());
QVERIFY(backendScene2d->m_sharedObject.data() != nullptr);
QCOMPARE(backendScene2d->m_renderPolicy, QScene2D::Continuous);
+ QCOMPARE(backendScene2d->m_mouseEnabled, true);
backendScene2d->cleanup();
}
{
@@ -183,28 +185,25 @@ private Q_SLOTS:
}
{
// WHEN
- const QSharedPointer<Qt3DRender::Quick::Scene2DSharedObject> newValue
- = QSharedPointer<Qt3DRender::Quick::Scene2DSharedObject>(
- new Qt3DRender::Quick::Scene2DSharedObject(nullptr));
+ const QScene2D::RenderPolicy newValue = QScene2D::SingleShot;
const auto change = Qt3DCore::QPropertyUpdatedChangePtr::create(Qt3DCore::QNodeId());
- change->setPropertyName("sharedObject");
+ change->setPropertyName("renderPolicy");
change->setValue(QVariant::fromValue(newValue));
backendScene2d->sceneChangeEvent(change);
// THEN
- QCOMPARE(backendScene2d->m_sharedObject, newValue);
- QCOMPARE(backendScene2d->m_sharedObject.data(), newValue.data());
+ QCOMPARE(backendScene2d->m_renderPolicy, newValue);
}
{
// WHEN
- const QScene2D::RenderPolicy newValue = QScene2D::SingleShot;
+ const bool newValue = false;
const auto change = Qt3DCore::QPropertyUpdatedChangePtr::create(Qt3DCore::QNodeId());
- change->setPropertyName("renderPolicy");
- change->setValue(QVariant::fromValue(newValue));
+ change->setPropertyName("mouseEnabled");
+ change->setValue(newValue);
backendScene2d->sceneChangeEvent(change);
// THEN
- QCOMPARE(backendScene2d->m_renderPolicy, newValue);
+ QCOMPARE(backendScene2d->isEnabled(), newValue);
}
backendScene2d->cleanup();
@@ -228,6 +227,7 @@ private Q_SLOTS:
TestRenderer renderer;
renderer.setNodeManagers(nodeManagers.data());
scene2d->setRenderer(&renderer);
+ scene2d->setEnabled(true);
sharedObject->m_quickWindow = testWindow.data();
scene2d->setSharedObject(sharedObject);
testWindow->setGeometry(0,0,1024,1024);
@@ -341,7 +341,7 @@ private Q_SLOTS:
QCoreApplication::processEvents();
// THEN
- QVERIFY(testWindow->verifyEventPos(0, QEvent::MouseButtonPress, QPointF(0,0)));
+ QVERIFY(testWindow->verifyEventPos(0, QEvent::MouseButtonPress, QPointF(0,1024)));
testWindow->clear();
}
@@ -355,7 +355,7 @@ private Q_SLOTS:
QCoreApplication::processEvents();
// THEN
- QVERIFY(testWindow->verifyEventPos(0, QEvent::MouseButtonPress, QPointF(1024,0)));
+ QVERIFY(testWindow->verifyEventPos(0, QEvent::MouseButtonPress, QPointF(1024,1024)));
testWindow->clear();
}
@@ -369,7 +369,7 @@ private Q_SLOTS:
QCoreApplication::processEvents();
// THEN
- QVERIFY(testWindow->verifyEventPos(0, QEvent::MouseButtonPress, QPointF(1024,1024)));
+ QVERIFY(testWindow->verifyEventPos(0, QEvent::MouseButtonPress, QPointF(1024,0)));
testWindow->clear();
}
@@ -383,7 +383,7 @@ private Q_SLOTS:
QCoreApplication::processEvents();
// THEN
- QVERIFY(testWindow->verifyEventPos(0, QEvent::MouseButtonPress, QPointF(0,0)));
+ QVERIFY(testWindow->verifyEventPos(0, QEvent::MouseButtonPress, QPointF(0,1024)));
testWindow->clear();
}
@@ -397,7 +397,7 @@ private Q_SLOTS:
QCoreApplication::processEvents();
// THEN
- QVERIFY(testWindow->verifyEventPos(0, QEvent::MouseButtonPress, QPointF(1024,1024)));
+ QVERIFY(testWindow->verifyEventPos(0, QEvent::MouseButtonPress, QPointF(1024,0)));
testWindow->clear();
}
@@ -411,7 +411,7 @@ private Q_SLOTS:
QCoreApplication::processEvents();
// THEN
- QVERIFY(testWindow->verifyEventPos(0, QEvent::MouseButtonPress, QPointF(0,1024)));
+ QVERIFY(testWindow->verifyEventPos(0, QEvent::MouseButtonPress, QPointF(0,0)));
testWindow->clear();
}
@@ -425,7 +425,7 @@ private Q_SLOTS:
QCoreApplication::processEvents();
// THEN
- QVERIFY(testWindow->verifyEventPos(0, QEvent::MouseButtonPress, QPointF(512.0f, 256.0f)));
+ QVERIFY(testWindow->verifyEventPos(0, QEvent::MouseButtonPress, QPointF(512.0f, 768.0f)));
testWindow->clear();
}
@@ -439,7 +439,7 @@ private Q_SLOTS:
QCoreApplication::processEvents();
// THEN
- QVERIFY(testWindow->verifyEventPos(0, QEvent::MouseButtonPress, QPointF(96.0f, 128.0f)));
+ QVERIFY(testWindow->verifyEventPos(0, QEvent::MouseButtonPress, QPointF(96.0f, 896.0f)));
testWindow->clear();
}
}
diff --git a/tests/manual/custom-mesh-update-data-qml/main.qml b/tests/manual/custom-mesh-update-data-qml/main.qml
index e95c05a26..909dbf9ca 100644
--- a/tests/manual/custom-mesh-update-data-qml/main.qml
+++ b/tests/manual/custom-mesh-update-data-qml/main.qml
@@ -224,7 +224,7 @@ Entity {
byteOffset: 0
byteStride: 9 * 4
count: 4
- name: defaultPositionAttributeName()
+ name: defaultPositionAttributeName
buffer: vertexBuffer
}
@@ -235,7 +235,7 @@ Entity {
byteOffset: 3 * 4
byteStride: 9 * 4
count: 4
- name: defaultNormalAttributeName()
+ name: defaultNormalAttributeName
buffer: vertexBuffer
}
@@ -246,7 +246,7 @@ Entity {
byteOffset: 6 * 4
byteStride: 9 * 4
count: 4
- name: defaultColorAttributeName()
+ name: defaultColorAttributeName
buffer: vertexBuffer
}
diff --git a/tests/manual/dynamic-model-loader-qml/CuboidEntity.qml b/tests/manual/dynamic-model-loader-qml/CuboidEntity.qml
index 8555b6903..d9b33c511 100644
--- a/tests/manual/dynamic-model-loader-qml/CuboidEntity.qml
+++ b/tests/manual/dynamic-model-loader-qml/CuboidEntity.qml
@@ -76,7 +76,7 @@ Entity {
QQ2.ColorAnimation {
target: phongMaterial
- property: "warmColor"
+ property: "warm"
from: "red"
to: "blue"
duration: 2500
diff --git a/tests/manual/gltf/main.qml b/tests/manual/gltf/main.qml
index 1afb8c48e..39fbb9acf 100644
--- a/tests/manual/gltf/main.qml
+++ b/tests/manual/gltf/main.qml
@@ -79,7 +79,7 @@ Entity {
buffers : ClearBuffers.ColorDepthBuffer
clearColor: "black"
SortPolicy {
- sortTypes: [ SortType.BackToFront ]
+ sortTypes: [ SortPolicy.BackToFront ]
}
}
}
diff --git a/tests/manual/loader-qml/CuboidEntity.qml b/tests/manual/loader-qml/CuboidEntity.qml
index 8555b6903..d9b33c511 100644
--- a/tests/manual/loader-qml/CuboidEntity.qml
+++ b/tests/manual/loader-qml/CuboidEntity.qml
@@ -76,7 +76,7 @@ Entity {
QQ2.ColorAnimation {
target: phongMaterial
- property: "warmColor"
+ property: "warm"
from: "red"
to: "blue"
duration: 2500
diff --git a/tests/manual/render-qml-to-texture-qml/main.qml b/tests/manual/render-qml-to-texture-qml/main.qml
index 748e14f6e..65a0a8783 100644
--- a/tests/manual/render-qml-to-texture-qml/main.qml
+++ b/tests/manual/render-qml-to-texture-qml/main.qml
@@ -91,7 +91,8 @@ QQ2.Item {
}
entities: [plane1]
- grabMouse: plane1.picker.pressed
+
+ mouseEnabled: plane1.picker.pressed
InteractiveGui {
diff --git a/tests/manual/render-qml-to-texture/main.cpp b/tests/manual/render-qml-to-texture/main.cpp
index a2fc6ed09..2420c8560 100644
--- a/tests/manual/render-qml-to-texture/main.cpp
+++ b/tests/manual/render-qml-to-texture/main.cpp
@@ -37,6 +37,8 @@
#include <QGuiApplication>
#include <QAnimationDriver>
#include <QPropertyAnimation>
+#include <QQmlComponent>
+#include <QQmlEngine>
#include <Qt3DCore/QEntity>
#include <Qt3DCore/QAspectEngine>
@@ -87,7 +89,7 @@ int main(int argc, char *argv[])
while (frameGraphNode->childNodes().size() > 0)
frameGraphNode = (Qt3DRender::QFrameGraphNode*)frameGraphNode->childNodes().at(0);
view.defaultFrameGraph()->setClearColor(QColor::fromRgbF(1.0f, 1.0f, 1.0f));
- Qt3DRender::Quick::QScene2D* qmlTextureRenderer = new Qt3DRender::Quick::QScene2D(frameGraphNode);
+ Qt3DRender::Quick::QScene2D *qmlTextureRenderer = new Qt3DRender::Quick::QScene2D(frameGraphNode);
Qt3DRender::QTexture2D* offscreenTexture = new Qt3DRender::QTexture2D(qmlTextureRenderer);
offscreenTexture->setSize(1024, 1024);
@@ -102,7 +104,9 @@ int main(int argc, char *argv[])
output->setTexture(offscreenTexture);
qmlTextureRenderer->setOutput(output);
- qmlTextureRenderer->setSource(QUrl(QStringLiteral("qrc:/OffscreenGui.qml")));
+ QQmlEngine engine;
+ QQmlComponent component(&engine, QUrl(QStringLiteral("qrc:/OffscreenGui.qml")));
+ qmlTextureRenderer->setItem(static_cast<QQuickItem *>(component.create()));
Qt3DCore::QEntity* planeEntity = new Qt3DCore::QEntity(sceneRoot);
Qt3DExtras::QPlaneMesh* planeMesh = new Qt3DExtras::QPlaneMesh(planeEntity);