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/QBar3DSeries> |
33 | |
34 | using namespace QtDataVisualization; |
35 | |
36 | class tst_series: 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 | void invalidProperties(); |
51 | |
52 | private: |
53 | QBar3DSeries *m_series; |
54 | }; |
55 | |
56 | void tst_series::initTestCase() |
57 | { |
58 | } |
59 | |
60 | void tst_series::cleanupTestCase() |
61 | { |
62 | } |
63 | |
64 | void tst_series::init() |
65 | { |
66 | m_series = new QBar3DSeries(); |
67 | } |
68 | |
69 | void tst_series::cleanup() |
70 | { |
71 | delete m_series; |
72 | } |
73 | |
74 | void tst_series::construct() |
75 | { |
76 | QBar3DSeries *series = new QBar3DSeries(); |
77 | QVERIFY(series); |
78 | delete series; |
79 | |
80 | QBarDataProxy *proxy = new QBarDataProxy(); |
81 | |
82 | series = new QBar3DSeries(proxy); |
83 | QVERIFY(series); |
84 | QCOMPARE(series->dataProxy(), proxy); |
85 | delete series; |
86 | } |
87 | |
88 | void tst_series::initialProperties() |
89 | { |
90 | QVERIFY(m_series); |
91 | |
92 | QVERIFY(m_series->dataProxy()); |
93 | QCOMPARE(m_series->meshAngle(), 0.0f); |
94 | QCOMPARE(m_series->selectedBar(), m_series->invalidSelectionPosition()); |
95 | |
96 | // Common properties |
97 | QCOMPARE(m_series->baseColor(), QColor(Qt::black)); |
98 | QCOMPARE(m_series->baseGradient(), QLinearGradient()); |
99 | QCOMPARE(m_series->colorStyle(), Q3DTheme::ColorStyleUniform); |
100 | QCOMPARE(m_series->itemLabel(), QString("" )); |
101 | QCOMPARE(m_series->itemLabelFormat(), QString("@valueLabel" )); |
102 | QCOMPARE(m_series->isItemLabelVisible(), true); |
103 | QCOMPARE(m_series->mesh(), QAbstract3DSeries::MeshBevelBar); |
104 | QCOMPARE(m_series->meshRotation(), QQuaternion(1, 0, 0, 0)); |
105 | QCOMPARE(m_series->isMeshSmooth(), false); |
106 | QCOMPARE(m_series->multiHighlightColor(), QColor(Qt::black)); |
107 | QCOMPARE(m_series->multiHighlightGradient(), QLinearGradient()); |
108 | QCOMPARE(m_series->name(), QString("" )); |
109 | QCOMPARE(m_series->singleHighlightColor(), QColor(Qt::black)); |
110 | QCOMPARE(m_series->singleHighlightGradient(), QLinearGradient()); |
111 | QCOMPARE(m_series->type(), QAbstract3DSeries::SeriesTypeBar); |
112 | QCOMPARE(m_series->userDefinedMesh(), QString("" )); |
113 | QCOMPARE(m_series->isVisible(), true); |
114 | } |
115 | |
116 | void tst_series::initializeProperties() |
117 | { |
118 | QVERIFY(m_series); |
119 | |
120 | m_series->setDataProxy(new QBarDataProxy()); |
121 | m_series->setMeshAngle(15.0f); |
122 | m_series->setSelectedBar(QPoint(0, 0)); |
123 | |
124 | QCOMPARE(m_series->meshAngle(), 15.0f); |
125 | QCOMPARE(m_series->selectedBar(), QPoint(0, 0)); |
126 | |
127 | QLinearGradient gradient1; |
128 | gradient1.setColorAt(pos: 0.0, color: Qt::red); |
129 | gradient1.setColorAt(pos: 1.0, color: Qt::blue); |
130 | QLinearGradient gradient2; |
131 | gradient2.setColorAt(pos: 0.0, color: Qt::yellow); |
132 | gradient2.setColorAt(pos: 1.0, color: Qt::green); |
133 | QLinearGradient gradient3; |
134 | gradient3.setColorAt(pos: 0.0, color: Qt::white); |
135 | gradient3.setColorAt(pos: 1.0, color: Qt::gray); |
136 | |
137 | // Common properties |
138 | m_series->setBaseColor(QColor(Qt::blue)); |
139 | m_series->setBaseGradient(gradient1); |
140 | m_series->setColorStyle(Q3DTheme::ColorStyleRangeGradient); |
141 | m_series->setItemLabelFormat("%f" ); |
142 | m_series->setItemLabelVisible(false); |
143 | m_series->setMesh(QAbstract3DSeries::MeshCone); |
144 | m_series->setMeshSmooth(true); |
145 | m_series->setMultiHighlightColor(QColor(Qt::green)); |
146 | m_series->setMultiHighlightGradient(gradient2); |
147 | m_series->setName("name" ); |
148 | m_series->setSingleHighlightColor(QColor(Qt::red)); |
149 | m_series->setSingleHighlightGradient(gradient3); |
150 | m_series->setUserDefinedMesh(":/customitem.obj" ); |
151 | m_series->setVisible(false); |
152 | |
153 | QCOMPARE(m_series->baseColor(), QColor(Qt::blue)); |
154 | QCOMPARE(m_series->baseGradient(), gradient1); |
155 | QCOMPARE(m_series->baseGradient().stops().at(0).second, QColor(Qt::red)); |
156 | QCOMPARE(m_series->colorStyle(), Q3DTheme::ColorStyleRangeGradient); |
157 | QCOMPARE(m_series->itemLabelFormat(), QString("%f" )); |
158 | QCOMPARE(m_series->isItemLabelVisible(), false); |
159 | QCOMPARE(m_series->mesh(), QAbstract3DSeries::MeshCone); |
160 | QCOMPARE(m_series->isMeshSmooth(), true); |
161 | QCOMPARE(m_series->multiHighlightColor(), QColor(Qt::green)); |
162 | QCOMPARE(m_series->multiHighlightGradient(), gradient2); |
163 | QCOMPARE(m_series->multiHighlightGradient().stops().at(0).second, QColor(Qt::yellow)); |
164 | QCOMPARE(m_series->name(), QString("name" )); |
165 | QCOMPARE(m_series->singleHighlightColor(), QColor(Qt::red)); |
166 | QCOMPARE(m_series->singleHighlightGradient(), gradient3); |
167 | QCOMPARE(m_series->singleHighlightGradient().stops().at(0).second, QColor(Qt::white)); |
168 | QCOMPARE(m_series->userDefinedMesh(), QString(":/customitem.obj" )); |
169 | QCOMPARE(m_series->isVisible(), false); |
170 | } |
171 | |
172 | void tst_series::invalidProperties() |
173 | { |
174 | m_series->setMesh(QAbstract3DSeries::MeshMinimal); |
175 | |
176 | QCOMPARE(m_series->mesh(), QAbstract3DSeries::MeshBevelBar); |
177 | } |
178 | |
179 | QTEST_MAIN(tst_series) |
180 | #include "tst_series.moc" |
181 | |