Debian Codegraph @

tests/auto/render/qfilterkey/tst_qfilterkey.cpp

raw symbols SCIP
1 // Copyright (C) 2016 Paul Lemire <[email protected]>
2 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4
5 #include <QtTest/QTest>
6 #include <Qt3DRender/qfilterkey.h>
7 #include <Qt3DRender/private/qfilterkey_p.h>
8 #include <QObject>
9 #include <QSignalSpy>
10 #include "testarbiter.h"
11
12 class tst_QFilterKey : public QObject
13 {
14 Q_OBJECT
15
16 private Q_SLOTS:
17
18 void checkDefaultConstruction()
19 {
20 // GIVEN
21 Qt3DRender::QFilterKey filterKey;
22
23 // THEN
24 QCOMPARE(filterKey.value(), QVariant());
25 QCOMPARE(filterKey.name(), QString());
26 }
27
28 void checkPropertyChanges()
29 {
30 // GIVEN
31 Qt3DRender::QFilterKey filterKey;
32
33 {
34 // WHEN
35 QSignalSpy spy(&filterKey, SIGNAL(valueChanged(QVariant)));
36 const QVariant newValue = QVariant("Tim");
37 filterKey.setValue(newValue);
38
39 // THEN
40 QVERIFY(spy.isValid());
41 QCOMPARE(filterKey.value(), newValue);
42 QCOMPARE(spy.size(), 1);
43
44 // WHEN
45 spy.clear();
46 filterKey.setValue(newValue);
47
48 // THEN
49 QCOMPARE(filterKey.value(), newValue);
50 QCOMPARE(spy.size(), 0);
51 }
52 {
53 // WHEN
54 QSignalSpy spy(&filterKey, SIGNAL(nameChanged(QString)));
55 const QString newValue = QStringLiteral("Darius");
56 filterKey.setName(newValue);
57
58 // THEN
59 QVERIFY(spy.isValid());
60 QCOMPARE(filterKey.name(), newValue);
61 QCOMPARE(spy.size(), 1);
62
63 // WHEN
64 spy.clear();
65 filterKey.setName(newValue);
66
67 // THEN
68 QCOMPARE(filterKey.name(), newValue);
69 QCOMPARE(spy.size(), 0);
70 }
71 }
72
73 void checkValueUpdate()
74 {
75 // GIVEN
76 TestArbiter arbiter;
77 Qt3DRender::QFilterKey filterKey;
78 arbiter.setArbiterOnNode(&filterKey);
79
80 {
81 // WHEN
82 filterKey.setValue(QVariant(427));
83 QCoreApplication::processEvents();
84
85 // THEN
86 QCOMPARE(arbiter.dirtyNodes().size(), 1);
87 QCOMPARE(arbiter.dirtyNodes().front(), &filterKey);
88
89 arbiter.clear();
90 }
91
92 {
93 // WHEN
94 filterKey.setValue(QVariant(427));
95 QCoreApplication::processEvents();
96
97 // THEN
98 QCOMPARE(arbiter.dirtyNodes().size(), 0);
99 }
100
101 }
102
103 void checkNameUpdate()
104 {
105 // GIVEN
106 TestArbiter arbiter;
107 Qt3DRender::QFilterKey filterKey;
108 arbiter.setArbiterOnNode(&filterKey);
109
110 {
111 // WHEN
112 filterKey.setName(QStringLiteral("Easton"));
113 QCoreApplication::processEvents();
114
115 // THEN
116 QCOMPARE(arbiter.dirtyNodes().size(), 1);
117 QCOMPARE(arbiter.dirtyNodes().front(), &filterKey);
118
119 arbiter.clear();
120 }
121
122 {
123 // WHEN
124 filterKey.setName(QStringLiteral("Easton"));
125 QCoreApplication::processEvents();
126
127 // THEN
128 QCOMPARE(arbiter.dirtyNodes().size(), 0);
129 }
130
131 }
132
133 };
134
135 QTEST_MAIN(tst_QFilterKey)
136
137 #include "tst_qfilterkey.moc"