diff options
author | Sean Harmer <sean.harmer@kdab.com> | 2017-05-21 08:26:29 +0100 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2017-05-21 08:26:29 +0100 |
commit | 9f8fc3717508a6b8045f65e6c820692fb67dc450 (patch) | |
tree | ad426afcaa91f61ecd669fbc416838f108554771 /tests/auto | |
parent | a830a9365832fd52c1849768543a64c55e4cee0a (diff) | |
parent | cd9059a22604307f483764db134d51b15c540758 (diff) |
Merge branch '5.9' into dev
Conflicts:
.qmake.conf
src/core/qscene.cpp
src/plugins/sceneparsers/gltf/gltfimporter.cpp
src/plugins/sceneparsers/gltfexport/gltfexporter.cpp
src/render/texture/gltexture.cpp
Change-Id: I7bde0fc0177eae252fef01cc43725fcf69c13a80
Diffstat (limited to 'tests/auto')
33 files changed, 1764 insertions, 209 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/buffer/tst_buffer.cpp b/tests/auto/render/buffer/tst_buffer.cpp index 7f7c0adb9..8049aaf37 100644 --- a/tests/auto/render/buffer/tst_buffer.cpp +++ b/tests/auto/render/buffer/tst_buffer.cpp @@ -89,6 +89,8 @@ private Q_SLOTS: QCOMPARE(renderBuffer.data(), buffer.data()); QCOMPARE(renderBuffer.dataGenerator(), buffer.dataGenerator()); QVERIFY(*renderBuffer.dataGenerator() == *buffer.dataGenerator()); + QCOMPARE(renderBuffer.pendingBufferUpdates().size(), 1); + QCOMPARE(renderBuffer.pendingBufferUpdates().first().offset, -1); } void checkInitialAndCleanedUpState() @@ -195,7 +197,10 @@ private Q_SLOTS: // THEN QCOMPARE(renderBuffer.data(), QByteArrayLiteral("LS9")); QVERIFY(renderBuffer.isDirty()); + QCOMPARE(renderBuffer.pendingBufferUpdates().size(), 1); + QCOMPARE(renderBuffer.pendingBufferUpdates().first().offset, -1); + renderBuffer.pendingBufferUpdates().clear(); renderBuffer.unsetDirty(); QVERIFY(!renderBuffer.isDirty()); @@ -233,8 +238,11 @@ private Q_SLOTS: Qt3DCore::QPropertyUpdatedChangePtr change = arbiter.events.first().staticCast<Qt3DCore::QPropertyUpdatedChange>(); QCOMPARE(change->propertyName(), "data"); QCOMPARE(change->value().toByteArray(), QByteArrayLiteral("454")); + QCOMPARE(renderBuffer.pendingBufferUpdates().size(), 1); + QCOMPARE(renderBuffer.pendingBufferUpdates().first().offset, -1); arbiter.events.clear(); + renderBuffer.pendingBufferUpdates().clear(); // WHEN updateChange.reset(new Qt3DCore::QPropertyUpdatedChange(Qt3DCore::QNodeId())); @@ -247,6 +255,7 @@ private Q_SLOTS: // THEN QVERIFY(!renderBuffer.pendingBufferUpdates().empty()); + QCOMPARE(renderBuffer.pendingBufferUpdates().first().offset, 2); QVERIFY(renderBuffer.isDirty()); renderBuffer.unsetDirty(); diff --git a/tests/auto/render/framegraphvisitor/framegraphvisitor.pro b/tests/auto/render/framegraphvisitor/framegraphvisitor.pro new file mode 100644 index 000000000..2c9a0028e --- /dev/null +++ b/tests/auto/render/framegraphvisitor/framegraphvisitor.pro @@ -0,0 +1,13 @@ +TEMPLATE = app + +TARGET = tst_framegraphvisitor + +QT += core-private 3dcore 3dcore-private 3drender 3drender-private testlib + +CONFIG += testcase + +SOURCES += tst_framegraphvisitor.cpp + +CONFIG += useCommonTestAspect + +include(../commons/commons.pri) diff --git a/tests/auto/render/framegraphvisitor/tst_framegraphvisitor.cpp b/tests/auto/render/framegraphvisitor/tst_framegraphvisitor.cpp new file mode 100644 index 000000000..5344d7eb3 --- /dev/null +++ b/tests/auto/render/framegraphvisitor/tst_framegraphvisitor.cpp @@ -0,0 +1,174 @@ +/**************************************************************************** +** +** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** 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-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include <QtTest/QTest> +#include <Qt3DCore/qentity.h> + +#include <Qt3DRender/private/nodemanagers_p.h> +#include <Qt3DRender/private/managers_p.h> +#include <Qt3DRender/private/entity_p.h> + +#include <Qt3DRender/private/framegraphnode_p.h> +#include <Qt3DRender/private/framegraphvisitor_p.h> + +#include <Qt3DRender/qtechniquefilter.h> +#include <Qt3DRender/qnodraw.h> +#include <Qt3DRender/qfrustumculling.h> +#include <Qt3DRender/qviewport.h> + +#include "testaspect.h" + +namespace { + + + +} // anonymous + +using FGIdType = QPair<Qt3DCore::QNodeId, Qt3DRender::Render::FrameGraphNode::FrameGraphNodeType>; +using BranchIdsAndTypes = QVector<FGIdType>; + +Q_DECLARE_METATYPE(QVector<BranchIdsAndTypes>) + +class tst_FrameGraphVisitor : public QObject +{ + Q_OBJECT +private Q_SLOTS: + + void visitFGTree_data() + { + QTest::addColumn<Qt3DCore::QEntity *>("rootEntity"); + QTest::addColumn<Qt3DRender::QFrameGraphNode *>("fgRoot"); + QTest::addColumn<QVector<BranchIdsAndTypes>>("fgNodeIdsPerBranch"); + + { + Qt3DCore::QEntity *entity = new Qt3DCore::QEntity(); + Qt3DRender::QTechniqueFilter *techniqueFilter = new Qt3DRender::QTechniqueFilter(entity); + + QTest::newRow("singleNode") << entity + << static_cast<Qt3DRender::QFrameGraphNode *>(techniqueFilter) + << (QVector<BranchIdsAndTypes>() + << (BranchIdsAndTypes() << FGIdType(techniqueFilter->id(), Qt3DRender::Render::FrameGraphNode::TechniqueFilter)) + ); + } + + { + Qt3DCore::QEntity *entity = new Qt3DCore::QEntity(); + Qt3DRender::QTechniqueFilter *techniqueFilter = new Qt3DRender::QTechniqueFilter(entity); + Qt3DRender::QFrustumCulling *frustumCulling = new Qt3DRender::QFrustumCulling(techniqueFilter); + Qt3DRender::QNoDraw *noDraw = new Qt3DRender::QNoDraw(frustumCulling); + + QTest::newRow("singleBranch") << entity + << static_cast<Qt3DRender::QFrameGraphNode *>(techniqueFilter) + << (QVector<BranchIdsAndTypes>() + << (BranchIdsAndTypes() + << FGIdType(noDraw->id(), Qt3DRender::Render::FrameGraphNode::NoDraw) + << FGIdType(frustumCulling->id(), Qt3DRender::Render::FrameGraphNode::FrustumCulling) + << FGIdType(techniqueFilter->id(), Qt3DRender::Render::FrameGraphNode::TechniqueFilter) + ) + ); + } + { + Qt3DCore::QEntity *entity = new Qt3DCore::QEntity(); + Qt3DRender::QTechniqueFilter *techniqueFilter = new Qt3DRender::QTechniqueFilter(entity); + Qt3DRender::QFrustumCulling *frustumCulling = new Qt3DRender::QFrustumCulling(techniqueFilter); + Qt3DRender::QNoDraw *noDraw = new Qt3DRender::QNoDraw(frustumCulling); + Qt3DRender::QViewport *viewPort = new Qt3DRender::QViewport(frustumCulling); + + QTest::newRow("dualBranch") << entity + << static_cast<Qt3DRender::QFrameGraphNode *>(techniqueFilter) + << (QVector<BranchIdsAndTypes>() + << (BranchIdsAndTypes() + << FGIdType(noDraw->id(), Qt3DRender::Render::FrameGraphNode::NoDraw) + << FGIdType(frustumCulling->id(), Qt3DRender::Render::FrameGraphNode::FrustumCulling) + << FGIdType(techniqueFilter->id(), Qt3DRender::Render::FrameGraphNode::TechniqueFilter) + ) + << (BranchIdsAndTypes() + << FGIdType(viewPort->id(), Qt3DRender::Render::FrameGraphNode::Viewport) + << FGIdType(frustumCulling->id(), Qt3DRender::Render::FrameGraphNode::FrustumCulling) + << FGIdType(techniqueFilter->id(), Qt3DRender::Render::FrameGraphNode::TechniqueFilter) + ) + ); + } + + } + + void visitFGTree() + { + // GIVEN + QFETCH(Qt3DCore::QEntity *, rootEntity); + QFETCH(Qt3DRender::QFrameGraphNode *, fgRoot); + QFETCH(QVector<BranchIdsAndTypes>, fgNodeIdsPerBranch); + QScopedPointer<Qt3DRender::TestAspect> aspect(new Qt3DRender::TestAspect(rootEntity)); + + // THEN + Qt3DRender::Render::FrameGraphManager *fgManager = aspect->nodeManagers()->frameGraphManager(); + Qt3DRender::Render::FrameGraphNode *backendFGRoot = fgManager->lookupNode(fgRoot->id()); + QVERIFY(backendFGRoot != nullptr); + + + // WHEN + Qt3DRender::Render::FrameGraphVisitor visitor(fgManager); + const QVector<Qt3DRender::Render::FrameGraphNode *> fgNodes = visitor.traverse(backendFGRoot); + + // THEN + QCOMPARE(fgNodeIdsPerBranch.size(), fgNodes.size()); + + for (int i = 0; i < fgNodeIdsPerBranch.size(); ++i) { + const BranchIdsAndTypes brandIdsAndTypes = fgNodeIdsPerBranch.at(i); + + Qt3DRender::Render::FrameGraphNode *fgNode = fgNodes.at(i); + for (int j = 0; j < brandIdsAndTypes.size(); ++j) { + const FGIdType idAndType = brandIdsAndTypes.at(j); + QVERIFY(fgNode != nullptr); + QCOMPARE(fgNode->peerId(), idAndType.first); + QCOMPARE(fgNode->nodeType(), idAndType.second); + fgNode = fgNode->parent(); + } + + QVERIFY(fgNode == nullptr); + } + + delete rootEntity; + } +}; + +QTEST_MAIN(tst_FrameGraphVisitor) + +#include "tst_framegraphvisitor.moc" diff --git a/tests/auto/render/graphicshelpergl2/tst_graphicshelpergl2.cpp b/tests/auto/render/graphicshelpergl2/tst_graphicshelpergl2.cpp index 58e2373f5..473e43d09 100644 --- a/tests/auto/render/graphicshelpergl2/tst_graphicshelpergl2.cpp +++ b/tests/auto/render/graphicshelpergl2/tst_graphicshelpergl2.cpp @@ -124,7 +124,7 @@ class tst_GraphicsHelperGL2 : public QObject Q_OBJECT private Q_SLOTS: - void initTestCase() + void init() { m_window.reset(new QWindow); m_window->setSurfaceType(QWindow::OpenGLSurface); @@ -160,7 +160,7 @@ private Q_SLOTS: } } - void cleanupTestCase() + void cleanup() { m_glContext.doneCurrent(); } diff --git a/tests/auto/render/graphicshelpergl3_2/BLACKLIST b/tests/auto/render/graphicshelpergl3_2/BLACKLIST deleted file mode 100644 index 1d6233cd7..000000000 --- a/tests/auto/render/graphicshelpergl3_2/BLACKLIST +++ /dev/null @@ -1,2 +0,0 @@ -[blitFramebuffer] -ubuntu-16.04 diff --git a/tests/auto/render/graphicshelpergl3_2/tst_graphicshelpergl3_2.cpp b/tests/auto/render/graphicshelpergl3_2/tst_graphicshelpergl3_2.cpp index fb0265427..b66192835 100644 --- a/tests/auto/render/graphicshelpergl3_2/tst_graphicshelpergl3_2.cpp +++ b/tests/auto/render/graphicshelpergl3_2/tst_graphicshelpergl3_2.cpp @@ -177,7 +177,7 @@ class tst_GraphicsHelperGL3_2 : public QObject Q_OBJECT private Q_SLOTS: - void initTestCase() + void init() { m_window.reset(new QWindow); m_window->setSurfaceType(QWindow::OpenGLSurface); @@ -209,7 +209,7 @@ private Q_SLOTS: } } - void cleanupTestCase() + void cleanup() { m_glContext.doneCurrent(); } @@ -1867,6 +1867,11 @@ private Q_SLOTS: if (!m_initializationSuccessful) QSKIP("Initialization failed, OpenGL 3.2 Core functions not supported"); + GLint maxSamples; + m_func->glGetIntegerv(GL_MAX_SAMPLES, &maxSamples); + if (maxSamples < 1) + QSKIP("This test requires an implementation that supports multisampled textures"); + // GIVEN GLuint fbos[2]; GLuint fboTextures[2]; @@ -1875,7 +1880,7 @@ private Q_SLOTS: m_func->glGenTextures(2, fboTextures); m_func->glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, fboTextures[0]); - m_func->glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 4, GL_RGBA8, 10, 10, true); + m_func->glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, maxSamples, GL_RGBA8, 10, 10, true); m_func->glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0); m_func->glBindTexture(GL_TEXTURE_2D, fboTextures[1]); diff --git a/tests/auto/render/graphicshelpergl3_3/BLACKLIST b/tests/auto/render/graphicshelpergl3_3/BLACKLIST deleted file mode 100644 index 1d6233cd7..000000000 --- a/tests/auto/render/graphicshelpergl3_3/BLACKLIST +++ /dev/null @@ -1,2 +0,0 @@ -[blitFramebuffer] -ubuntu-16.04 diff --git a/tests/auto/render/graphicshelpergl3_3/tst_graphicshelpergl3_3.cpp b/tests/auto/render/graphicshelpergl3_3/tst_graphicshelpergl3_3.cpp index 293750dbf..b7cc1cdac 100644 --- a/tests/auto/render/graphicshelpergl3_3/tst_graphicshelpergl3_3.cpp +++ b/tests/auto/render/graphicshelpergl3_3/tst_graphicshelpergl3_3.cpp @@ -176,7 +176,7 @@ class tst_GraphicsHelperGL3_3 : public QObject Q_OBJECT private Q_SLOTS: - void initTestCase() + void init() { m_window.reset(new QWindow); m_window->setSurfaceType(QWindow::OpenGLSurface); @@ -209,7 +209,7 @@ private Q_SLOTS: } } - void cleanupTestCase() + void cleanup() { m_glContext.doneCurrent(); } @@ -1967,6 +1967,11 @@ private Q_SLOTS: if (!m_initializationSuccessful) QSKIP("Initialization failed, OpenGL 3.3 Core functions not supported"); + GLint maxSamples; + m_func->glGetIntegerv(GL_MAX_SAMPLES, &maxSamples); + if (maxSamples < 1) + QSKIP("This test requires an implementation that supports multisampled textures"); + // GIVEN GLuint fbos[2]; GLuint fboTextures[2]; @@ -1975,7 +1980,7 @@ private Q_SLOTS: m_func->glGenTextures(2, fboTextures); m_func->glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, fboTextures[0]); - m_func->glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 4, GL_RGBA8, 10, 10, true); + m_func->glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, maxSamples, GL_RGBA8, 10, 10, true); m_func->glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0); m_func->glBindTexture(GL_TEXTURE_2D, fboTextures[1]); @@ -1986,13 +1991,13 @@ private Q_SLOTS: m_func->glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, fboTextures[1], 0); GLenum status = m_func->glCheckFramebufferStatus(GL_FRAMEBUFFER); - QVERIFY(status == GL_FRAMEBUFFER_COMPLETE); + QCOMPARE(status, GLenum(GL_FRAMEBUFFER_COMPLETE)); m_func->glBindFramebuffer(GL_FRAMEBUFFER, fbos[0]); m_func->glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, fboTextures[0], 0); status = m_func->glCheckFramebufferStatus(GL_FRAMEBUFFER); - QVERIFY(status == GL_FRAMEBUFFER_COMPLETE); + QCOMPARE(status, GLenum(GL_FRAMEBUFFER_COMPLETE)); m_func->glEnable(GL_MULTISAMPLE); m_func->glClearColor(0.2f, 0.2f, 0.2f, 0.2f); diff --git a/tests/auto/render/graphicshelpergl4/tst_graphicshelpergl4.cpp b/tests/auto/render/graphicshelpergl4/tst_graphicshelpergl4.cpp index c6a306910..0ee14841c 100644 --- a/tests/auto/render/graphicshelpergl4/tst_graphicshelpergl4.cpp +++ b/tests/auto/render/graphicshelpergl4/tst_graphicshelpergl4.cpp @@ -201,7 +201,7 @@ class tst_GraphicsHelperGL4 : public QObject { Q_OBJECT private Q_SLOTS: - void initTestCase() + void init() { m_window.reset(new QWindow); m_window->setSurfaceType(QWindow::OpenGLSurface); @@ -234,7 +234,7 @@ private Q_SLOTS: } } - void cleanupTestCase() + void cleanup() { m_glContext.doneCurrent(); } diff --git a/tests/auto/render/pickboundingvolumejob/tst_pickboundingvolumejob.cpp b/tests/auto/render/pickboundingvolumejob/tst_pickboundingvolumejob.cpp index 07055d810..1d391101e 100644 --- a/tests/auto/render/pickboundingvolumejob/tst_pickboundingvolumejob.cpp +++ b/tests/auto/render/pickboundingvolumejob/tst_pickboundingvolumejob.cpp @@ -1145,7 +1145,10 @@ private Q_SLOTS: change = arbiter1.events.first().staticCast<Qt3DCore::QPropertyUpdatedChange>(); QCOMPARE(change->propertyName(), "moved"); } else { + QVERIFY(arbiter2.events.size() > 1); change = arbiter2.events.first().staticCast<Qt3DCore::QPropertyUpdatedChange>(); + QCOMPARE(change->propertyName(), "moved"); + change = arbiter2.events.at(1).staticCast<Qt3DCore::QPropertyUpdatedChange>(); QCOMPARE(change->propertyName(), "entered"); } 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/qsortcriterion/tst_qsortcriterion.cpp b/tests/auto/render/qsortcriterion/tst_qsortcriterion.cpp deleted file mode 100644 index bac9fb3e8..000000000 --- a/tests/auto/render/qsortcriterion/tst_qsortcriterion.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the S 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 <Qt3DCore/private/qnode_p.h> -#include <Qt3DCore/private/qscene_p.h> -#include <Qt3DCore/private/qnodecreatedchangegenerator_p.h> - -#include <Qt3DRender/qsortcriterion.h> -#include <Qt3DRender/private/qsortcriterion_p.h> - -#include "testpostmanarbiter.h" - -class tst_QSortCriterion: public QObject -{ - Q_OBJECT - -private Q_SLOTS: - - void checkCloning_data() - { - QTest::addColumn<Qt3DRender::QSortCriterion *>("sortCriterion"); - QTest::addColumn<Qt3DRender::QSortCriterion::SortType>("sortType"); - - Qt3DRender::QSortCriterion *defaultConstructed = new Qt3DRender::QSortCriterion(); - QTest::newRow("defaultConstructed") << defaultConstructed << Qt3DRender::QSortCriterion::StateChangeCost; - - Qt3DRender::QSortCriterion *backToFrontSort = new Qt3DRender::QSortCriterion(); - backToFrontSort->setSort(Qt3DRender::QSortCriterion::BackToFront); - QTest::newRow("backToFrontSort") << backToFrontSort << Qt3DRender::QSortCriterion::BackToFront; - - Qt3DRender::QSortCriterion *materialSort = new Qt3DRender::QSortCriterion(); - materialSort->setSort(Qt3DRender::QSortCriterion::Material); - QTest::newRow("materialSort") << materialSort << Qt3DRender::QSortCriterion::Material; - } - - void checkCloning() - { - // GIVEN - QFETCH(Qt3DRender::QSortCriterion *, sortCriterion); - QFETCH(Qt3DRender::QSortCriterion::SortType, sortType); - - // THEN - QCOMPARE(sortCriterion->sort(), sortType); - -// TO DO: Add creation change -// // WHEN -// Qt3DCore::QNodeCreatedChangeGenerator creationChangeGenerator(sortCriterion); -// QVector<Qt3DCore::QNodeCreatedChangeBasePtr> creationChanges = creationChangeGenerator.creationChanges(); - -// // THEN -// QCOMPARE(creationChanges.size(), 1); - -// const Qt3DCore::QNodeCreatedChangePtr<Qt3DRender::QCameraSelectorData> creationChangeData = -// qSharedPointerCast<Qt3DCore::QNodeCreatedChange<Qt3DRender::QSortCriterion>>(creationChanges.first()); -// const Qt3DRender::QCameraSelectorData &cloneData = creationChangeData->data; - - -// // THEN -// QCOMPARE(sortCriterion->id(), creationChangeData->subjectId()); -// QCOMPARE(sortCriterion->isEnabled(), creationChangeData->isNodeEnabled()); -// QCOMPARE(sortCriterion->metaObject(), creationChangeData->metaObject()); -// QCOMPARE(sortCriterion->sort(), cloneData.sort); - - delete sortCriterion; - } - - void checkPropertyUpdates() - { - // GIVEN - QScopedPointer<Qt3DRender::QSortCriterion> sortCriterion(new Qt3DRender::QSortCriterion()); - TestArbiter arbiter(sortCriterion.data()); - - // WHEN - sortCriterion->setSort(Qt3DRender::QSortCriterion::BackToFront); - QCoreApplication::processEvents(); - - // THEN - QCOMPARE(arbiter.events.size(), 1); - Qt3DCore::QNodePropertyChangePtr change = arbiter.events.first().staticCast<Qt3DCore::QNodePropertyChange>(); - QCOMPARE(change->propertyName(), "sort"); - QCOMPARE(change->subjectId(), sortCriterion->id()); - QCOMPARE(change->value().value<Qt3DRender::QSortCriterion::SortType>(), Qt3DRender::QSortCriterion::BackToFront); - QCOMPARE(change->type(), Qt3DCore::NodeUpdated); - - arbiter.events.clear(); - - // WHEN - sortCriterion->setSort(Qt3DRender::QSortCriterion::BackToFront); - QCoreApplication::processEvents(); - - // THEN - QCOMPARE(arbiter.events.size(), 0); - - // WHEN - sortCriterion->setSort(Qt3DRender::QSortCriterion::Material); - QCoreApplication::processEvents(); - - // THEN - QCOMPARE(arbiter.events.size(), 1); - change = arbiter.events.first().staticCast<Qt3DCore::QNodePropertyChange>(); - QCOMPARE(change->propertyName(), "sort"); - QCOMPARE(change->subjectId(), sortCriterion->id()); - QCOMPARE(change->value().value<Qt3DRender::QSortCriterion::SortType>(), Qt3DRender::QSortCriterion::Material); - QCOMPARE(change->type(), Qt3DCore::NodeUpdated); - - arbiter.events.clear(); - } -}; - -QTEST_MAIN(tst_QSortCriterion) - -#include "tst_qsortcriterion.moc" diff --git a/tests/auto/render/render.pro b/tests/auto/render/render.pro index bf464cf6b..8eea3d032 100644 --- a/tests/auto/render/render.pro +++ b/tests/auto/render/render.pro @@ -106,7 +106,8 @@ qtConfig(private_tests) { qshaderprogram \ qscene2d \ scene2d \ - coordinatereader + coordinatereader \ + framegraphvisitor !macos: SUBDIRS += graphicshelpergl4 } diff --git a/tests/auto/render/renderqueue/tst_renderqueue.cpp b/tests/auto/render/renderqueue/tst_renderqueue.cpp index 2d25cbe57..163a699c1 100644 --- a/tests/auto/render/renderqueue/tst_renderqueue.cpp +++ b/tests/auto/render/renderqueue/tst_renderqueue.cpp @@ -55,10 +55,14 @@ void tst_RenderQueue::setRenderViewCount() // GIVEN Qt3DRender::Render::RenderQueue renderQueue; + // THEN + QCOMPARE(renderQueue.wasReset(), true); + // WHEN renderQueue.setTargetRenderViewCount(7); // THEN + QCOMPARE(renderQueue.wasReset(), false); QVERIFY(renderQueue.targetRenderViewCount() == 7); QVERIFY(renderQueue.currentRenderViewCount()== 0); } @@ -214,6 +218,7 @@ void tst_RenderQueue::resetQueue() // WHEN renderQueue.setTargetRenderViewCount(5); // THEN + QCOMPARE(renderQueue.wasReset(), false); QVERIFY(renderQueue.currentRenderViewCount() == 0); // WHEN @@ -227,6 +232,7 @@ void tst_RenderQueue::resetQueue() // WHEN renderQueue.reset(); + QCOMPARE(renderQueue.wasReset(), true); // THEN QVERIFY(renderQueue.currentRenderViewCount() == 0); } 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(); } } |