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/QSurface3DSeries>
33
34using namespace QtDataVisualization;
35
36class tst_series: public QObject
37{
38 Q_OBJECT
39
40private 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
52private:
53 QSurface3DSeries *m_series;
54};
55
56void tst_series::initTestCase()
57{
58}
59
60void tst_series::cleanupTestCase()
61{
62}
63
64void tst_series::init()
65{
66 m_series = new QSurface3DSeries();
67}
68
69void tst_series::cleanup()
70{
71 delete m_series;
72}
73
74void tst_series::construct()
75{
76 QSurface3DSeries *series = new QSurface3DSeries();
77 QVERIFY(series);
78 delete series;
79
80 QSurfaceDataProxy *proxy = new QSurfaceDataProxy();
81
82 series = new QSurface3DSeries(proxy);
83 QVERIFY(series);
84 QCOMPARE(series->dataProxy(), proxy);
85 delete series;
86}
87
88void tst_series::initialProperties()
89{
90 QVERIFY(m_series);
91
92 QVERIFY(m_series->dataProxy());
93 QCOMPARE(m_series->drawMode(), QSurface3DSeries::DrawSurfaceAndWireframe);
94 QCOMPARE(m_series->isFlatShadingEnabled(), true);
95 QCOMPARE(m_series->isFlatShadingSupported(), true);
96 QCOMPARE(m_series->selectedPoint(), m_series->invalidSelectionPosition());
97
98 // Common properties. The ones identical between different series are tested in QBar3DSeries tests
99 QCOMPARE(m_series->itemLabelFormat(), QString("@xLabel, @yLabel, @zLabel"));
100 QCOMPARE(m_series->mesh(), QAbstract3DSeries::MeshSphere);
101 QCOMPARE(m_series->type(), QAbstract3DSeries::SeriesTypeSurface);
102}
103
104void tst_series::initializeProperties()
105{
106 QVERIFY(m_series);
107
108 m_series->setDataProxy(new QSurfaceDataProxy());
109 m_series->setDrawMode(QSurface3DSeries::DrawWireframe);
110 m_series->setFlatShadingEnabled(false);
111 m_series->setSelectedPoint(QPoint(0, 0));
112
113 QCOMPARE(m_series->drawMode(), QSurface3DSeries::DrawWireframe);
114 QCOMPARE(m_series->isFlatShadingEnabled(), false);
115 QCOMPARE(m_series->selectedPoint(), QPoint(0, 0));
116
117 // Common properties. The ones identical between different series are tested in QBar3DSeries tests
118 m_series->setMesh(QAbstract3DSeries::MeshPyramid);
119
120 QCOMPARE(m_series->mesh(), QAbstract3DSeries::MeshPyramid);
121}
122
123void tst_series::invalidProperties()
124{
125 m_series->setMesh(QAbstract3DSeries::MeshPoint);
126
127 QCOMPARE(m_series->mesh(), QAbstract3DSeries::MeshSphere);
128}
129
130QTEST_MAIN(tst_series)
131#include "tst_series.moc"
132

source code of qtdatavis3d/tests/auto/cpptest/q3dsurface-series/tst_series.cpp