1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the Qt Data Visualization module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU |
19 | ** General Public License version 3 or (at your option) any later version |
20 | ** approved by the KDE Free Qt Foundation. The licenses are as published by |
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 |
22 | ** included in the packaging of this file. Please review the following |
23 | ** information to ensure the GNU General Public License requirements will |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
25 | ** |
26 | ** $QT_END_LICENSE$ |
27 | ** |
28 | ****************************************************************************/ |
29 | |
30 | #include <QtTest/QtTest> |
31 | |
32 | #include <QtDataVisualization/QCustom3DItem> |
33 | |
34 | using namespace QtDataVisualization; |
35 | |
36 | class tst_custom: public QObject |
37 | { |
38 | Q_OBJECT |
39 | |
40 | private slots: |
41 | void initTestCase(); |
42 | void cleanupTestCase(); |
43 | void init(); |
44 | void cleanup(); |
45 | |
46 | void construct(); |
47 | |
48 | void initialProperties(); |
49 | void initializeProperties(); |
50 | |
51 | private: |
52 | QCustom3DItem *m_custom; |
53 | }; |
54 | |
55 | void tst_custom::initTestCase() |
56 | { |
57 | } |
58 | |
59 | void tst_custom::cleanupTestCase() |
60 | { |
61 | } |
62 | |
63 | void tst_custom::init() |
64 | { |
65 | m_custom = new QCustom3DItem(); |
66 | } |
67 | |
68 | void tst_custom::cleanup() |
69 | { |
70 | delete m_custom; |
71 | } |
72 | |
73 | void tst_custom::construct() |
74 | { |
75 | QCustom3DItem *custom = new QCustom3DItem(); |
76 | QVERIFY(custom); |
77 | delete custom; |
78 | |
79 | custom = new QCustom3DItem(":/customitem.obj" , QVector3D(1.0, 1.0, 1.0), |
80 | QVector3D(1.0, 1.0, 1.0), QQuaternion(1.0, 1.0, 10.0, 100.0), |
81 | QImage(":/customtexture.jpg" )); |
82 | QVERIFY(custom); |
83 | QCOMPARE(custom->meshFile(), QString(":/customitem.obj" )); |
84 | QCOMPARE(custom->position(), QVector3D(1.0, 1.0, 1.0)); |
85 | QCOMPARE(custom->isPositionAbsolute(), false); |
86 | QCOMPARE(custom->rotation(), QQuaternion(1.0, 1.0, 10.0, 100.0)); |
87 | QCOMPARE(custom->scaling(), QVector3D(1.0, 1.0, 1.0)); |
88 | QCOMPARE(custom->isScalingAbsolute(), true); |
89 | QCOMPARE(custom->isShadowCasting(), true); |
90 | QCOMPARE(custom->textureFile(), QString()); |
91 | QCOMPARE(custom->isVisible(), true); |
92 | delete custom; |
93 | } |
94 | |
95 | void tst_custom::initialProperties() |
96 | { |
97 | QVERIFY(m_custom); |
98 | |
99 | QCOMPARE(m_custom->meshFile(), QString()); |
100 | QCOMPARE(m_custom->position(), QVector3D()); |
101 | QCOMPARE(m_custom->isPositionAbsolute(), false); |
102 | QCOMPARE(m_custom->rotation(), QQuaternion()); |
103 | QCOMPARE(m_custom->scaling(), QVector3D(0.1f, 0.1f, 0.1f)); |
104 | QCOMPARE(m_custom->isScalingAbsolute(), true); |
105 | QCOMPARE(m_custom->isShadowCasting(), true); |
106 | QCOMPARE(m_custom->textureFile(), QString()); |
107 | QCOMPARE(m_custom->isVisible(), true); |
108 | } |
109 | |
110 | void tst_custom::initializeProperties() |
111 | { |
112 | QVERIFY(m_custom); |
113 | |
114 | m_custom->setMeshFile(":/customitem.obj" ); |
115 | m_custom->setPosition(QVector3D(1.0, 1.0, 1.0)); |
116 | m_custom->setPositionAbsolute(true); |
117 | m_custom->setRotation(QQuaternion(1.0, 1.0, 10.0, 100.0)); |
118 | m_custom->setScaling(QVector3D(1.0, 1.0, 1.0)); |
119 | m_custom->setScalingAbsolute(false); |
120 | m_custom->setShadowCasting(false); |
121 | m_custom->setTextureFile(":/customtexture.jpg" ); |
122 | m_custom->setVisible(false); |
123 | |
124 | QCOMPARE(m_custom->meshFile(), QString(":/customitem.obj" )); |
125 | QCOMPARE(m_custom->position(), QVector3D(1.0, 1.0, 1.0)); |
126 | QCOMPARE(m_custom->isPositionAbsolute(), true); |
127 | QCOMPARE(m_custom->rotation(), QQuaternion(1.0, 1.0, 10.0, 100.0)); |
128 | QCOMPARE(m_custom->scaling(), QVector3D(1.0, 1.0, 1.0)); |
129 | QCOMPARE(m_custom->isScalingAbsolute(), false); |
130 | QCOMPARE(m_custom->isShadowCasting(), false); |
131 | QCOMPARE(m_custom->textureFile(), QString(":/customtexture.jpg" )); |
132 | QCOMPARE(m_custom->isVisible(), false); |
133 | |
134 | m_custom->setTextureImage(QImage(QSize(10, 10), QImage::Format_ARGB32)); |
135 | QCOMPARE(m_custom->textureFile(), QString()); |
136 | } |
137 | |
138 | QTEST_MAIN(tst_custom) |
139 | #include "tst_custom.moc" |
140 | |