| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #include <QtTest/QTest> |
| 5 | #include <Qt3DAnimation/qanimationgroup.h> |
| 6 | #include <qobject.h> |
| 7 | #include <qsignalspy.h> |
| 8 | |
| 9 | class tst_QAnimationGroup : public QObject |
| 10 | { |
| 11 | Q_OBJECT |
| 12 | |
| 13 | private Q_SLOTS: |
| 14 | |
| 15 | void checkDefaultConstruction() |
| 16 | { |
| 17 | // GIVEN |
| 18 | Qt3DAnimation::QAnimationGroup animationGroup; |
| 19 | |
| 20 | // THEN |
| 21 | QCOMPARE(animationGroup.name(), QString()); |
| 22 | QCOMPARE(animationGroup.position(), 0.0f); |
| 23 | QCOMPARE(animationGroup.duration(), 0.0f); |
| 24 | } |
| 25 | |
| 26 | void checkPropertyChanges() |
| 27 | { |
| 28 | // GIVEN |
| 29 | Qt3DAnimation::QAnimationGroup animationGroup; |
| 30 | |
| 31 | { |
| 32 | // WHEN |
| 33 | QSignalSpy spy(&animationGroup, SIGNAL(nameChanged(QString))); |
| 34 | const QString newValue = QString("group"); |
| 35 | animationGroup.setName(newValue); |
| 36 | |
| 37 | // THEN |
| 38 | QCOMPARE(animationGroup.name(), newValue); |
| 39 | QCOMPARE(spy.size(), 1); |
| 40 | |
| 41 | // WHEN |
| 42 | spy.clear(); |
| 43 | animationGroup.setName(newValue); |
| 44 | |
| 45 | // THEN |
| 46 | QCOMPARE(animationGroup.name(), newValue); |
| 47 | QCOMPARE(spy.size(), 0); |
| 48 | |
| 49 | } |
| 50 | { |
| 51 | // WHEN |
| 52 | QSignalSpy spy(&animationGroup, SIGNAL(positionChanged(float))); |
| 53 | const float newValue = 2.0f; |
| 54 | animationGroup.setPosition(newValue); |
| 55 | |
| 56 | // THEN |
| 57 | QCOMPARE(animationGroup.position(), newValue); |
| 58 | QCOMPARE(spy.size(), 1); |
| 59 | |
| 60 | // WHEN |
| 61 | spy.clear(); |
| 62 | animationGroup.setPosition(newValue); |
| 63 | |
| 64 | // THEN |
| 65 | QCOMPARE(animationGroup.position(), newValue); |
| 66 | QCOMPARE(spy.size(), 0); |
| 67 | |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | }; |
| 72 | |
| 73 | QTEST_APPLESS_MAIN(tst_QAnimationGroup) |
| 74 | |
| 75 | #include "tst_qanimationgroup.moc" |