Debian Codegraph @

tests/auto/animation/qchannelmapper/tst_qchannelmapper.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 #include <QtTest/QTest>
5 #include <Qt3DCore/private/qnode_p.h>
6 #include <Qt3DCore/private/qscene_p.h>
7
8 #include <Qt3DAnimation/qchannelmapper.h>
9 #include <Qt3DAnimation/private/qchannelmapper_p.h>
10 #include <Qt3DAnimation/qchannelmapping.h>
11
12 #include <testarbiter.h>
13
14 class tst_QChannelmapper : public Qt3DAnimation::QChannelMapper
15 {
16 Q_OBJECT
17 public:
18 tst_QChannelmapper()
19 {
20 qRegisterMetaType<Qt3DCore::QNode *>();
21 }
22
23 private Q_SLOTS:
24
25 void checkPropertyUpdates()
26 {
27 // GIVEN
28 TestArbiter arbiter;
29 QScopedPointer<Qt3DAnimation::QChannelMapper> mapper(new Qt3DAnimation::QChannelMapper);
30 arbiter.setArbiterOnNode(mapper.data());
31
32 // WHEN
33 mapper->setEnabled(false);
34
35 // THEN
36 QCOMPARE(arbiter.dirtyNodes().size(), 1);
37 QCOMPARE(arbiter.dirtyNodes().front(), mapper.data());
38
39 arbiter.clear();
40 }
41
42 void checkMappingBookkeeping()
43 {
44 // GIVEN
45 QScopedPointer<Qt3DAnimation::QChannelMapper> mapper(new Qt3DAnimation::QChannelMapper);
46 {
47 // WHEN
48 Qt3DAnimation::QChannelMapping mapping;
49 mapper->addMapping(&mapping);
50
51 // THEN
52 QCOMPARE(mapping.parent(), mapper.data());
53 QCOMPARE(mapper->mappings().size(), 1);
54 }
55 // THEN (Should not crash and output be unset)
56 QVERIFY(mapper->mappings().empty());
57
58 {
59 // WHEN
60 Qt3DAnimation::QChannelMapper someOtherMapper;
61 QScopedPointer<Qt3DAnimation::QChannelMapping> mapping(new Qt3DAnimation::QChannelMapping(&someOtherMapper));
62 mapper->addMapping(mapping.data());
63
64 // THEN
65 QCOMPARE(mapping->parent(), &someOtherMapper);
66 QCOMPARE(mapper->mappings().size(), 1);
67
68 // WHEN
69 mapper.reset();
70 mapping.reset();
71
72 // THEN Should not crash when the output is destroyed (tests for failed removal of destruction helper)
73 }
74 }
75 };
76
77 QTEST_MAIN(tst_QChannelmapper)
78
79 #include "tst_qchannelmapper.moc"