Debian Codegraph @

tests/auto/animation/qabstractanimation/tst_qabstractanimation.cpp

raw symbols SCIP
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.h>
5 #include <Qt3DAnimation/qabstractanimation.h>
6 #include <Qt3DAnimation/private/qabstractanimation_p.h>
7 #include <Qt3DCore/qnode.h>
8 #include <qobject.h>
9 #include <qsignalspy.h>
10
11 #include <private/qabstractanimation_p.h>
12
13 class TestAnimation : public Qt3DAnimation::QAbstractAnimation
14 {
15 public:
16 explicit TestAnimation(Qt3DCore::QNode *parent = nullptr)
17 : Qt3DAnimation::QAbstractAnimation(
18 *new Qt3DAnimation::QAbstractAnimationPrivate(
19 Qt3DAnimation::QAbstractAnimation::KeyframeAnimation), parent)
20 {
21
22 }
23 };
24
25 class tst_QAbstractAnimation : public QObject
26 {
27 Q_OBJECT
28
29 private Q_SLOTS:
30
31 void checkDefaultConstruction()
32 {
33 // GIVEN
34 TestAnimation abstractAnimation;
35
36 // THEN
37 QCOMPARE(abstractAnimation.animationName(), QString());
38 QCOMPARE(abstractAnimation.animationType(),
39 Qt3DAnimation::QAbstractAnimation::KeyframeAnimation);
40 QCOMPARE(abstractAnimation.position(), 0.0f);
41 QCOMPARE(abstractAnimation.duration(), 0.0f);
42 }
43
44 void checkPropertyChanges()
45 {
46 // GIVEN
47 TestAnimation abstractAnimation;
48
49 {
50 // WHEN
51 QSignalSpy spy(&abstractAnimation, SIGNAL(animationNameChanged(QString)));
52 const QString newValue = QString("test");
53 abstractAnimation.setAnimationName(newValue);
54
55 // THEN
56 QCOMPARE(abstractAnimation.animationName(), newValue);
57 QCOMPARE(spy.size(), 1);
58
59 // WHEN
60 spy.clear();
61 abstractAnimation.setAnimationName(newValue);
62
63 // THEN
64 QCOMPARE(abstractAnimation.animationName(), newValue);
65 QCOMPARE(spy.size(), 0);
66
67 }
68 {
69 // WHEN
70 QSignalSpy spy(&abstractAnimation, SIGNAL(positionChanged(float)));
71 const float newValue = 1.0f;
72 abstractAnimation.setPosition(newValue);
73
74 // THEN
75 QCOMPARE(abstractAnimation.position(), newValue);
76 QCOMPARE(spy.size(), 1);
77
78 // WHEN
79 spy.clear();
80 abstractAnimation.setPosition(newValue);
81
82 // THEN
83 QCOMPARE(abstractAnimation.position(), newValue);
84 QCOMPARE(spy.size(), 0);
85
86 }
87 }
88
89 };
90
91 QTEST_APPLESS_MAIN(tst_QAbstractAnimation)
92
93 #include "tst_qabstractanimation.moc"