| 1 | // Copyright (C) 2017 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #include <QtTest/qtest.h> |
| 5 | #include <Qt3DAnimation/qvertexblendanimation.h> |
| 6 | #include <qobject.h> |
| 7 | #include <qsignalspy.h> |
| 8 | |
| 9 | class tst_QVertexBlendAnimation : public QObject |
| 10 | { |
| 11 | Q_OBJECT |
| 12 | |
| 13 | private Q_SLOTS: |
| 14 | |
| 15 | void checkDefaultConstruction() |
| 16 | { |
| 17 | // GIVEN |
| 18 | Qt3DAnimation::QVertexBlendAnimation vertexBlendAnimation; |
| 19 | |
| 20 | // THEN |
| 21 | QCOMPARE(vertexBlendAnimation.interpolator(), 0.0f); |
| 22 | QCOMPARE(vertexBlendAnimation.target(), nullptr); |
| 23 | QCOMPARE(vertexBlendAnimation.targetName(), QString()); |
| 24 | } |
| 25 | |
| 26 | void checkPropertyChanges() |
| 27 | { |
| 28 | // GIVEN |
| 29 | Qt3DAnimation::QVertexBlendAnimation vertexBlendAnimation; |
| 30 | |
| 31 | { |
| 32 | // WHEN |
| 33 | QScopedPointer<Qt3DRender::QGeometryRenderer> gm(new Qt3DRender::QGeometryRenderer); |
| 34 | QSignalSpy spy(&vertexBlendAnimation, |
| 35 | SIGNAL(targetChanged(Qt3DRender::QGeometryRenderer*))); |
| 36 | Qt3DRender::QGeometryRenderer *newValue = gm.data(); |
| 37 | vertexBlendAnimation.setTarget(newValue); |
| 38 | |
| 39 | // THEN |
| 40 | QCOMPARE(vertexBlendAnimation.target(), newValue); |
| 41 | QCOMPARE(spy.size(), 1); |
| 42 | |
| 43 | // WHEN |
| 44 | spy.clear(); |
| 45 | vertexBlendAnimation.setTarget(newValue); |
| 46 | |
| 47 | // THEN |
| 48 | QCOMPARE(vertexBlendAnimation.target(), newValue); |
| 49 | QCOMPARE(spy.size(), 0); |
| 50 | |
| 51 | } |
| 52 | { |
| 53 | // WHEN |
| 54 | QSignalSpy spy(&vertexBlendAnimation, SIGNAL(targetNameChanged(QString))); |
| 55 | const QString newValue = QString("target"); |
| 56 | vertexBlendAnimation.setTargetName(newValue); |
| 57 | |
| 58 | // THEN |
| 59 | QCOMPARE(vertexBlendAnimation.targetName(), newValue); |
| 60 | QCOMPARE(spy.size(), 1); |
| 61 | |
| 62 | // WHEN |
| 63 | spy.clear(); |
| 64 | vertexBlendAnimation.setTargetName(newValue); |
| 65 | |
| 66 | // THEN |
| 67 | QCOMPARE(vertexBlendAnimation.targetName(), newValue); |
| 68 | QCOMPARE(spy.size(), 0); |
| 69 | |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | }; |
| 74 | |
| 75 | QTEST_APPLESS_MAIN(tst_QVertexBlendAnimation) |
| 76 | |
| 77 | #include "tst_qvertexblendanimation.moc" |