Debian Codegraph @

tests/auto/animation/qanimationcliploader/tst_qanimationcliploader.cpp

raw symbols SCIP
1 // Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB).
2 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4
5 #include <QtTest/QTest>
6 #include <Qt3DAnimation/qanimationcliploader.h>
7 #include <Qt3DAnimation/private/qanimationcliploader_p.h>
8 #include <QObject>
9 #include <QSignalSpy>
10 #include <testarbiter.h>
11
12 class tst_QAnimationClipLoader : public Qt3DAnimation::QAnimationClipLoader
13 {
14 Q_OBJECT
15
16 private Q_SLOTS:
17 void checkDefaultConstruction()
18 {
19 // GIVEN
20 Qt3DAnimation::QAnimationClipLoader clip;
21
22 // THEN
23 QCOMPARE(clip.source(), QUrl());
24 QCOMPARE(clip.duration(), 0.0f);
25 QCOMPARE(clip.status(), Qt3DAnimation::QAnimationClipLoader::NotReady);
26 }
27
28 void checkPropertyChanges()
29 {
30 // GIVEN
31 Qt3DAnimation::QAnimationClipLoader clip;
32
33 {
34 // WHEN
35 QSignalSpy spy(&clip, SIGNAL(sourceChanged(QUrl)));
36 const QUrl newValue(QStringLiteral("qrc:/walk.qlip"));
37 clip.setSource(newValue);
38
39 // THEN
40 QVERIFY(spy.isValid());
41 QCOMPARE(clip.source(), newValue);
42 QCOMPARE(spy.size(), 1);
43
44 // WHEN
45 spy.clear();
46 clip.setSource(newValue);
47
48 // THEN
49 QCOMPARE(clip.source(), newValue);
50 QCOMPARE(spy.size(), 0);
51 }
52 }
53
54 void checkSourceUpdate()
55 {
56 // GIVEN
57 TestArbiter arbiter;
58 Qt3DAnimation::QAnimationClipLoader clip;
59 arbiter.setArbiterOnNode(&clip);
60
61 {
62 // WHEN
63 clip.setSource(QUrl(QStringLiteral("qrc:/toyplane.qlip")));
64
65 // THEN
66 QCOMPARE(arbiter.dirtyNodes().size(), 1);
67 QCOMPARE(arbiter.dirtyNodes().front(), &clip);
68
69 arbiter.clear();
70 }
71
72 {
73 // WHEN
74 clip.setSource(QStringLiteral("qrc:/toyplane.qlip"));
75
76 // THEN
77 QCOMPARE(arbiter.dirtyNodes().size(), 0);
78 }
79
80 }
81 };
82
83 QTEST_MAIN(tst_QAnimationClipLoader)
84
85 #include "tst_qanimationcliploader.moc"