##// END OF EJS Templates
Adds spline scatter unit tests
Michal Klocek -
r1266:f91c26ab5181
parent child
Show More
@@ -0,0 +1,6
1 !include( ../auto.pri ):error( "Couldn't find the auto.pri file!" )
2
3 HEADERS += ../qxyseries/tst_qxyseries.h
4 SOURCES += tst_qscatterseries.cpp ../qxyseries/tst_qxyseries.cpp
5
6 !system_build:mac:QMAKE_POST_LINK += "$$MAC_POST_LINK_PREFIX $$MAC_AUTOTESTS_BIN_DIR"
@@ -0,0 +1,100
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 #include "../qxyseries/tst_qxyseries.h"
22 #include <qscatterseries.h>
23
24 Q_DECLARE_METATYPE(QList<QPointF>)
25
26 class tst_QScatterSeries : public tst_QXYSeries
27 {
28 Q_OBJECT
29
30 public slots:
31 void initTestCase();
32 void cleanupTestCase();
33 void init();
34 void cleanup();
35 private slots:
36 void qscatterseries_data();
37 void qscatterseries();
38 protected:
39 void pointsVisible_data();
40 };
41
42 void tst_QScatterSeries::initTestCase()
43 {
44 }
45
46 void tst_QScatterSeries::cleanupTestCase()
47 {
48 }
49
50 void tst_QScatterSeries::init()
51 {
52 tst_QXYSeries::init();
53 m_series = new QScatterSeries();
54 }
55
56 void tst_QScatterSeries::cleanup()
57 {
58 delete m_series;
59 tst_QXYSeries::cleanup();
60 }
61
62 void tst_QScatterSeries::qscatterseries_data()
63 {
64
65 }
66
67 void tst_QScatterSeries::qscatterseries()
68 {
69 QScatterSeries series;
70
71 QCOMPARE(series.count(),0);
72 QCOMPARE(series.brush(), QBrush());
73 QCOMPARE(series.points(), QList<QPointF>());
74 QCOMPARE(series.pen(), QPen());
75 QCOMPARE(series.pointsVisible(), false);
76
77 series.append(QList<QPointF>());
78 series.append(0.0,0.0);
79 series.append(QPointF());
80
81 series.remove(0.0,0.0);
82 series.remove(QPointF());
83 series.removeAll();
84
85 series.replace(QPointF(),QPointF());
86 series.replace(0,0,0,0);
87 series.setBrush(QBrush());
88
89 series.setPen(QPen());
90 series.setPointsVisible(false);
91
92 m_chart->addSeries(&series);
93 m_view->show();
94 QTest::qWaitForWindowShown(m_view);
95 }
96
97 QTEST_MAIN(tst_QScatterSeries)
98
99 #include "tst_qscatterseries.moc"
100
@@ -0,0 +1,7
1 !include( ../auto.pri ) {
2 error( "Couldn't find the auto.pri file!" )
3 }
4 HEADERS += ../qxyseries/tst_qxyseries.h
5 SOURCES += tst_qsplineseries.cpp ../qxyseries/tst_qxyseries.cpp
6
7 !system_build:mac: QMAKE_POST_LINK += "$$MAC_POST_LINK_PREFIX $$MAC_AUTOTESTS_BIN_DIR"
@@ -0,0 +1,100
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 #include "../qxyseries/tst_qxyseries.h"
22 #include <qsplineseries.h>
23
24 Q_DECLARE_METATYPE(QList<QPointF>)
25
26 class tst_QSplineSeries : public tst_QXYSeries
27 {
28 Q_OBJECT
29
30 public slots:
31 void initTestCase();
32 void cleanupTestCase();
33 void init();
34 void cleanup();
35 private slots:
36 void qsplineseries_data();
37 void qsplineseries();
38 protected:
39 void pointsVisible_data();
40 };
41
42 void tst_QSplineSeries::initTestCase()
43 {
44 }
45
46 void tst_QSplineSeries::cleanupTestCase()
47 {
48 }
49
50 void tst_QSplineSeries::init()
51 {
52 tst_QXYSeries::init();
53 m_series = new QSplineSeries();
54 }
55
56 void tst_QSplineSeries::cleanup()
57 {
58 delete m_series;
59 tst_QXYSeries::cleanup();
60 }
61
62 void tst_QSplineSeries::qsplineseries_data()
63 {
64
65 }
66
67 void tst_QSplineSeries::qsplineseries()
68 {
69 QSplineSeries series;
70
71 QCOMPARE(series.count(),0);
72 QCOMPARE(series.brush(), QBrush());
73 QCOMPARE(series.points(), QList<QPointF>());
74 QCOMPARE(series.pen(), QPen());
75 QCOMPARE(series.pointsVisible(), false);
76
77 series.append(QList<QPointF>());
78 series.append(0.0,0.0);
79 series.append(QPointF());
80
81 series.remove(0.0,0.0);
82 series.remove(QPointF());
83 series.removeAll();
84
85 series.replace(QPointF(),QPointF());
86 series.replace(0,0,0,0);
87 series.setBrush(QBrush());
88
89 series.setPen(QPen());
90 series.setPointsVisible(false);
91
92 m_chart->addSeries(&series);
93 m_view->show();
94 QTest::qWaitForWindowShown(m_view);
95 }
96
97 QTEST_MAIN(tst_QSplineSeries)
98
99 #include "tst_qsplineseries.moc"
100
@@ -0,0 +1,6
1 !include( ../auto.pri ) {
2 error( "Couldn't find the auto.pri file!" )
3 }
4 SOURCES += tst_qlineseries.cpp
5
6 !system_build:mac: QMAKE_POST_LINK += "$$MAC_POST_LINK_PREFIX $$MAC_AUTOTESTS_BIN_DIR"
@@ -0,0 +1,347
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 #include "tst_qxyseries.h"
22
23 Q_DECLARE_METATYPE(QList<QPointF>)
24
25 void tst_QXYSeries::initTestCase()
26 {
27 }
28
29 void tst_QXYSeries::cleanupTestCase()
30 {
31 }
32
33 void tst_QXYSeries::init()
34 {
35 m_view = new QChartView(new QChart());
36 m_chart = m_view->chart();
37 }
38
39 void tst_QXYSeries::cleanup()
40 {
41 delete m_view;
42 m_view = 0;
43 m_chart = 0;
44 m_series = 0;
45 }
46
47 void tst_QXYSeries::append_data()
48 {
49 QTest::addColumn< QList<QPointF> >("points");
50 QTest::newRow("0,0 1,1 2,2 3,3") << (QList<QPointF>() << QPointF(0,0) << QPointF(1,1) << QPointF(2,2) << QPointF(3,3));
51 QTest::newRow("0,0 -1,-1 -2,-2 -3,-3") << (QList<QPointF>() << QPointF(0,0) << QPointF(-1,-1) << QPointF(-2,-2) << QPointF(-3,-3));
52 }
53
54
55 void tst_QXYSeries::append_raw_data()
56 {
57 append_data();
58 }
59
60 void tst_QXYSeries::append_raw()
61 {
62 QFETCH(QList<QPointF>, points);
63 QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&)));
64 m_series->append(points);
65 TRY_COMPARE(spy0.count(), 0);
66 QCOMPARE(m_series->points(), points);
67 }
68
69 void tst_QXYSeries::chart_append_data()
70 {
71 append_data();
72 }
73
74 void tst_QXYSeries::chart_append()
75 {
76 append_raw();
77 m_chart->addSeries(m_series);
78 m_view->show();
79 QTest::qWaitForWindowShown(m_view);
80 }
81
82 void tst_QXYSeries::append_chart_data()
83 {
84 append_data();
85 }
86
87 void tst_QXYSeries::append_chart()
88 {
89 m_view->show();
90 m_chart->addSeries(m_series);
91 QTest::qWaitForWindowShown(m_view);
92 append_raw();
93
94 }
95
96 void tst_QXYSeries::append_chart_animation_data()
97 {
98 append_data();
99 }
100
101 void tst_QXYSeries::append_chart_animation()
102 {
103 m_chart->setAnimationOptions(QChart::AllAnimations);
104 append_chart();
105 }
106
107 void tst_QXYSeries::count_data()
108 {
109 QTest::addColumn<int>("count");
110 QTest::newRow("0") << 0;
111 QTest::newRow("5") << 5;
112 QTest::newRow("10") << 5;
113 }
114
115 void tst_QXYSeries::count_raw_data()
116 {
117 count_data();
118 }
119
120 void tst_QXYSeries::count_raw()
121 {
122 QFETCH(int, count);
123
124 QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&)));
125
126 for(int i=0 ; i< count; ++i)
127 m_series->append(i,i);
128
129 TRY_COMPARE(spy0.count(), 0);
130 QCOMPARE(m_series->count(), count);
131 }
132
133 void tst_QXYSeries::remove_raw_data()
134 {
135 append_data();
136 }
137
138 void tst_QXYSeries::remove_raw()
139 {
140 QFETCH(QList<QPointF>, points);
141 QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&)));
142 m_series->append(points);
143 TRY_COMPARE(spy0.count(), 0);
144 QCOMPARE(m_series->points(), points);
145
146 foreach(const QPointF& point,points)
147 m_series->remove(point);
148
149 QCOMPARE(m_series->points().count(), 0);
150 TRY_COMPARE(spy0.count(), 0);
151
152 m_series->append(points);
153 QCOMPARE(m_series->points(), points);
154
155 //reverse order
156 for(int i = points.count()-1 ; i>=0; i--){
157 m_series->remove(points[i]);
158 }
159 QCOMPARE(m_series->points().count(), 0);
160 }
161
162 void tst_QXYSeries::remove_chart_data()
163 {
164 append_data();
165 }
166
167 void tst_QXYSeries::remove_chart()
168 {
169 m_view->show();
170 m_chart->addSeries(m_series);
171 QTest::qWaitForWindowShown(m_view);
172 remove_raw();
173 }
174
175 void tst_QXYSeries::remove_chart_animation_data()
176 {
177 append_data();
178 }
179
180 void tst_QXYSeries::remove_chart_animation()
181 {
182 m_chart->setAnimationOptions(QChart::AllAnimations);
183 remove_chart();
184 }
185
186
187 void tst_QXYSeries::removeAll_raw_data()
188 {
189 append_data();
190 }
191
192 void tst_QXYSeries::removeAll_raw()
193 {
194 QFETCH(QList<QPointF>, points);
195 QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&)));
196 m_series->append(points);
197 TRY_COMPARE(spy0.count(), 0);
198 QCOMPARE(m_series->points(), points);
199 m_series->removeAll();
200 TRY_COMPARE(spy0.count(), 0);
201 QCOMPARE(m_series->points().count(), 0);
202 }
203
204 void tst_QXYSeries::removeAll_chart_data()
205 {
206 append_data();
207 }
208
209 void tst_QXYSeries::removeAll_chart()
210 {
211 m_view->show();
212 m_chart->addSeries(m_series);
213 QTest::qWaitForWindowShown(m_view);
214 removeAll_raw();
215 }
216
217 void tst_QXYSeries::removeAll_chart_animation_data()
218 {
219 append_data();
220 }
221
222 void tst_QXYSeries::removeAll_chart_animation()
223 {
224 m_chart->setAnimationOptions(QChart::AllAnimations);
225 removeAll_chart();
226 }
227
228 void tst_QXYSeries::replace_raw_data()
229 {
230 append_data();
231 }
232
233 void tst_QXYSeries::replace_raw()
234 {
235 QFETCH(QList<QPointF>, points);
236 QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&)));
237 m_series->append(points);
238 TRY_COMPARE(spy0.count(), 0);
239 QCOMPARE(m_series->points(), points);
240
241 foreach(const QPointF& point,points)
242 m_series->replace(point.x(),point.y(),point.x(),0);
243
244 QList<QPointF> newPoints = m_series->points();
245
246 QCOMPARE(newPoints.count(), points.count());
247
248 for(int i =0 ; i<points.count() ; ++i) {
249 QCOMPARE(points[i].x(), newPoints[i].x());
250 QCOMPARE(newPoints[i].y(), 0.0);
251 }
252 }
253
254
255 void tst_QXYSeries::replace_chart_data()
256 {
257 append_data();
258 }
259
260 void tst_QXYSeries::replace_chart()
261 {
262 m_view->show();
263 m_chart->addSeries(m_series);
264 QTest::qWaitForWindowShown(m_view);
265 replace_raw();
266 }
267
268 void tst_QXYSeries::replace_chart_animation_data()
269 {
270 append_data();
271 }
272
273 void tst_QXYSeries::replace_chart_animation()
274 {
275 m_chart->setAnimationOptions(QChart::AllAnimations);
276 replace_chart();
277 }
278
279 void tst_QXYSeries::oper_data()
280 {
281 append_data();
282 }
283
284 void tst_QXYSeries::oper()
285 {
286 QFETCH(QList<QPointF>, points);
287
288 QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&)));
289
290 foreach(const QPointF& point,points)
291 {
292 *m_series<<point;
293 }
294
295 QCOMPARE(m_series->points(), points);
296 TRY_COMPARE(spy0.count(), 0);
297 }
298
299
300 void tst_QXYSeries::pen_data()
301 {
302 QTest::addColumn<QPen>("pen");
303 QTest::newRow("null") << QPen();
304 QTest::newRow("blue") << QPen(Qt::blue);
305 QTest::newRow("black") << QPen(Qt::black);
306 QTest::newRow("red") << QPen(Qt::red);
307 }
308
309 void tst_QXYSeries::pen()
310 {
311 QFETCH(QPen, pen);
312
313 QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&)));
314 m_series->setPen(pen);
315
316 TRY_COMPARE(spy0.count(), 0);
317 QCOMPARE(m_series->pen(), pen);
318
319 m_chart->addSeries(m_series);
320
321 if(pen!=QPen()) QCOMPARE(m_series->pen(), pen);
322
323 m_chart->setTheme(QChart::ChartThemeDark);
324
325 if(pen!=QPen()) QCOMPARE(m_series->pen(), pen);
326 }
327
328 void tst_QXYSeries::pointsVisible_data()
329 {
330 QTest::addColumn<bool>("pointsVisible");
331 QTest::newRow("true") << true;
332 QTest::newRow("false") << false;
333 }
334
335 void tst_QXYSeries::pointsVisible_raw_data()
336 {
337 pointsVisible_data();
338 }
339
340 void tst_QXYSeries::pointsVisible_raw()
341 {
342 QFETCH(bool, pointsVisible);
343 QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&)));
344 m_series->setPointsVisible(pointsVisible);
345 TRY_COMPARE(spy0.count(), 0);
346 QCOMPARE(m_series->pointsVisible(), pointsVisible);
347 }
@@ -0,0 +1,88
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 #ifndef TST_QXYSERIES_H
22 #define TST_QXYSERIES_H
23
24 #include <QtTest/QtTest>
25 #include <qxyseries.h>
26 #include <qchartview.h>
27 #include <QStandardItemModel>
28 #include <tst_definitions.h>
29
30 QTCOMMERCIALCHART_USE_NAMESPACE
31
32 class tst_QXYSeries : public QObject
33 {
34 Q_OBJECT
35
36 public slots:
37 virtual void initTestCase();
38 virtual void cleanupTestCase();
39 virtual void init();
40 virtual void cleanup();
41
42 private slots:
43 void oper_data();
44 void oper();
45 void pen_data();
46 void pen();
47 void pointsVisible_raw_data();
48 void pointsVisible_raw();
49 void append_raw_data();
50 void append_raw();
51 void append_chart_data();
52 void append_chart();
53 void append_chart_animation_data();
54 void append_chart_animation();
55 void chart_append_data();
56 void chart_append();
57 void count_raw_data();
58 void count_raw();
59 void remove_raw_data();
60 void remove_raw();
61 void remove_chart_data();
62 void remove_chart();
63 void remove_chart_animation_data();
64 void remove_chart_animation();
65 void removeAll_raw_data();
66 void removeAll_raw();
67 void removeAll_chart_data();
68 void removeAll_chart();
69 void removeAll_chart_animation_data();
70 void removeAll_chart_animation();
71 void replace_raw_data();
72 void replace_raw();
73 void replace_chart_data();
74 void replace_chart();
75 void replace_chart_animation_data();
76 void replace_chart_animation();
77 protected:
78 void append_data();
79 void count_data();
80 void pointsVisible_data();
81
82 protected:
83 QChartView* m_view;
84 QChart* m_chart;
85 QXYSeries* m_series;
86 };
87
88 #endif
@@ -3,7 +3,7
3 }
3 }
4
4
5 TEMPLATE = subdirs
5 TEMPLATE = subdirs
6 SUBDIRS += qchartview qchart qlineseries qbarset qbarseries qstackedbarseries qpercentbarseries qgroupedbarseries qpieslice qpieseries qpiemodelmapper
6 SUBDIRS += qchartview qchart qlineseries qbarset qbarseries qstackedbarseries qpercentbarseries qgroupedbarseries qpieslice qpieseries qpiemodelmapper qsplineseries qscatterseries
7
7
8 test_private:{
8 test_private:{
9 SUBDIRS += chartdataset domain
9 SUBDIRS += chartdataset domain
@@ -1,6 +1,7
1 !include( ../auto.pri ) {
1 !include( ../auto.pri ) {
2 error( "Couldn't find the auto.pri file!" )
2 error( "Couldn't find the auto.pri file!" )
3 }
3 }
4 SOURCES += tst_qlineseries.cpp
4 HEADERS += ../qxyseries/tst_qxyseries.h
5 SOURCES += tst_qlineseries.cpp ../qxyseries/tst_qxyseries.cpp
5
6
6 !system_build:mac: QMAKE_POST_LINK += "$$MAC_POST_LINK_PREFIX $$MAC_AUTOTESTS_BIN_DIR"
7 !system_build:mac: QMAKE_POST_LINK += "$$MAC_POST_LINK_PREFIX $$MAC_AUTOTESTS_BIN_DIR"
@@ -18,73 +18,26
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include <QtTest/QtTest>
21 #include "../qxyseries/tst_qxyseries.h"
22 #include <qlineseries.h>
22 #include <qlineseries.h>
23 #include <qxymodelmapper.h>
24 #include <qchartview.h>
25 #include <QStandardItemModel>
26 #include <tst_definitions.h>
27
23
28 Q_DECLARE_METATYPE(QList<QPointF>)
29
24
30 QTCOMMERCIALCHART_USE_NAMESPACE
25 Q_DECLARE_METATYPE(QList<QPointF>)
31
26
32 class tst_QLineSeries : public QObject
27 class tst_QLineSeries : public tst_QXYSeries
33 {
28 {
34 Q_OBJECT
29 Q_OBJECT
35
30
36 public slots:
31 public slots:
37 void initTestCase();
32 void initTestCase();
38 void cleanupTestCase();
33 void cleanupTestCase();
39 void init();
34 void init();
40 void cleanup();
35 void cleanup();
41
36 private slots:
42 private slots:
43 void qlineseries_data();
37 void qlineseries_data();
44 void qlineseries();
38 void qlineseries();
45 void append_raw_data();
39 protected:
46 void append_raw();
47 void append_chart_data();
48 void append_chart();
49 void append_chart_animation_data();
50 void append_chart_animation();
51 void chart_append_data();
52 void chart_append();
53 void count_raw_data();
54 void count_raw();
55 void oper_data();
56 void oper();
57 void pen_data();
58 void pen();
59 void pointsVisible_raw_data();
60 void pointsVisible_raw();
61 void remove_raw_data();
62 void remove_raw();
63 void remove_chart_data();
64 void remove_chart();
65 void remove_chart_animation_data();
66 void remove_chart_animation();
67 void removeAll_raw_data();
68 void removeAll_raw();
69 void removeAll_chart_data();
70 void removeAll_chart();
71 void removeAll_chart_animation_data();
72 void removeAll_chart_animation();
73 void replace_raw_data();
74 void replace_raw();
75 void replace_chart_data();
76 void replace_chart();
77 void replace_chart_animation_data();
78 void replace_chart_animation();
79 private:
80 void append_data();
81 void count_data();
82 void pointsVisible_data();
40 void pointsVisible_data();
83
84 private:
85 QChartView* m_view;
86 QChart* m_chart;
87 QLineSeries* m_series;
88 };
41 };
89
42
90 void tst_QLineSeries::initTestCase()
43 void tst_QLineSeries::initTestCase()
@@ -97,18 +50,14 void tst_QLineSeries::cleanupTestCase()
97
50
98 void tst_QLineSeries::init()
51 void tst_QLineSeries::init()
99 {
52 {
100 m_view = new QChartView(new QChart());
53 tst_QXYSeries::init();
101 m_chart = m_view->chart();
102 m_series = new QLineSeries();
54 m_series = new QLineSeries();
103 }
55 }
104
56
105 void tst_QLineSeries::cleanup()
57 void tst_QLineSeries::cleanup()
106 {
58 {
107 delete m_series;
59 delete m_series;
108 delete m_view;
60 tst_QXYSeries::cleanup();
109 m_view = 0;
110 m_chart = 0;
111 m_series = 0;
112 }
61 }
113
62
114 void tst_QLineSeries::qlineseries_data()
63 void tst_QLineSeries::qlineseries_data()
@@ -138,10 +87,6 void tst_QLineSeries::qlineseries()
138 series.replace(0,0,0,0);
87 series.replace(0,0,0,0);
139 series.setBrush(QBrush());
88 series.setBrush(QBrush());
140
89
141 // QCOMPARE(series.setModel((QAbstractItemModel*)0), false);
142
143 // series.setModelMapping(-1, -1, Qt::Orientation(0));
144
145 series.setPen(QPen());
90 series.setPen(QPen());
146 series.setPointsVisible(false);
91 series.setPointsVisible(false);
147
92
@@ -150,301 +95,6 void tst_QLineSeries::qlineseries()
150 QTest::qWaitForWindowShown(m_view);
95 QTest::qWaitForWindowShown(m_view);
151 }
96 }
152
97
153 void tst_QLineSeries::append_data()
154 {
155 QTest::addColumn< QList<QPointF> >("points");
156 QTest::newRow("0,0 1,1 2,2 3,3") << (QList<QPointF>() << QPointF(0,0) << QPointF(1,1) << QPointF(2,2) << QPointF(3,3));
157 QTest::newRow("0,0 -1,-1 -2,-2 -3,-3") << (QList<QPointF>() << QPointF(0,0) << QPointF(-1,-1) << QPointF(-2,-2) << QPointF(-3,-3));
158 }
159
160
161 void tst_QLineSeries::append_raw_data()
162 {
163 append_data();
164 }
165
166 void tst_QLineSeries::append_raw()
167 {
168 QFETCH(QList<QPointF>, points);
169 QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&)));
170 m_series->append(points);
171 TRY_COMPARE(spy0.count(), 0);
172 QCOMPARE(m_series->points(), points);
173 }
174
175 void tst_QLineSeries::chart_append_data()
176 {
177 append_data();
178 }
179
180 void tst_QLineSeries::chart_append()
181 {
182 append_raw();
183 m_chart->addSeries(m_series);
184 m_view->show();
185 QTest::qWaitForWindowShown(m_view);
186 }
187
188 void tst_QLineSeries::append_chart_data()
189 {
190 append_data();
191 }
192
193 void tst_QLineSeries::append_chart()
194 {
195 m_view->show();
196 m_chart->addSeries(m_series);
197 QTest::qWaitForWindowShown(m_view);
198 append_raw();
199
200 }
201
202 void tst_QLineSeries::append_chart_animation_data()
203 {
204 append_data();
205 }
206
207 void tst_QLineSeries::append_chart_animation()
208 {
209 m_chart->setAnimationOptions(QChart::AllAnimations);
210 append_chart();
211 }
212
213 void tst_QLineSeries::count_data()
214 {
215 QTest::addColumn<int>("count");
216 QTest::newRow("0") << 0;
217 QTest::newRow("5") << 5;
218 QTest::newRow("10") << 5;
219 }
220
221 void tst_QLineSeries::count_raw_data()
222 {
223 count_data();
224 }
225
226 void tst_QLineSeries::count_raw()
227 {
228 QFETCH(int, count);
229
230 QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&)));
231
232 for(int i=0 ; i< count; ++i)
233 m_series->append(i,i);
234
235 TRY_COMPARE(spy0.count(), 0);
236 QCOMPARE(m_series->count(), count);
237 }
238
239 void tst_QLineSeries::oper_data()
240 {
241 append_data();
242 }
243
244 void tst_QLineSeries::oper()
245 {
246 QFETCH(QList<QPointF>, points);
247 QLineSeries series;
248
249 QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&)));
250
251 foreach(const QPointF& point,points)
252 {
253 series<<point;
254 }
255
256 QCOMPARE(series.points(), points);
257 TRY_COMPARE(spy0.count(), 0);
258 }
259
260
261 void tst_QLineSeries::pen_data()
262 {
263 QTest::addColumn<QPen>("pen");
264 QTest::newRow("null") << QPen();
265 QTest::newRow("blue") << QPen(Qt::blue);
266 QTest::newRow("black") << QPen(Qt::black);
267 QTest::newRow("red") << QPen(Qt::red);
268 }
269
270 void tst_QLineSeries::pen()
271 {
272 QFETCH(QPen, pen);
273 QLineSeries series;
274
275 QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&)));
276 series.setPen(pen);
277
278 TRY_COMPARE(spy0.count(), 0);
279 QCOMPARE(series.pen(), pen);
280
281 m_chart->addSeries(&series);
282
283 if(pen!=QPen()) QCOMPARE(series.pen(), pen);
284
285 m_chart->setTheme(QChart::ChartThemeDark);
286
287 QVERIFY(series.pen() != pen);
288 }
289
290 void tst_QLineSeries::pointsVisible_data()
291 {
292 QTest::addColumn<bool>("pointsVisible");
293 QTest::newRow("true") << true;
294 QTest::newRow("false") << false;
295 }
296
297 void tst_QLineSeries::pointsVisible_raw_data()
298 {
299 pointsVisible_data();
300 }
301
302 void tst_QLineSeries::pointsVisible_raw()
303 {
304 QFETCH(bool, pointsVisible);
305 QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&)));
306 m_series->setPointsVisible(pointsVisible);
307 TRY_COMPARE(spy0.count(), 0);
308 QCOMPARE(m_series->pointsVisible(), pointsVisible);
309 }
310
311 void tst_QLineSeries::remove_raw_data()
312 {
313 append_data();
314 }
315
316 void tst_QLineSeries::remove_raw()
317 {
318 QFETCH(QList<QPointF>, points);
319 QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&)));
320 m_series->append(points);
321 TRY_COMPARE(spy0.count(), 0);
322 QCOMPARE(m_series->points(), points);
323
324 foreach(const QPointF& point,points)
325 m_series->remove(point);
326
327 TRY_COMPARE(spy0.count(), 0);
328 QCOMPARE(m_series->points().count(), 0);
329 }
330
331 void tst_QLineSeries::remove_chart_data()
332 {
333 append_data();
334 }
335
336 void tst_QLineSeries::remove_chart()
337 {
338 m_view->show();
339 m_chart->addSeries(m_series);
340 QTest::qWaitForWindowShown(m_view);
341 remove_raw();
342 }
343
344 void tst_QLineSeries::remove_chart_animation_data()
345 {
346 append_data();
347 }
348
349 void tst_QLineSeries::remove_chart_animation()
350 {
351 m_chart->setAnimationOptions(QChart::AllAnimations);
352 remove_chart();
353 }
354
355
356 void tst_QLineSeries::removeAll_raw_data()
357 {
358 append_data();
359 }
360
361 void tst_QLineSeries::removeAll_raw()
362 {
363 QFETCH(QList<QPointF>, points);
364 QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&)));
365 m_series->append(points);
366 TRY_COMPARE(spy0.count(), 0);
367 QCOMPARE(m_series->points(), points);
368 m_series->removeAll();
369 TRY_COMPARE(spy0.count(), 0);
370 QCOMPARE(m_series->points().count(), 0);
371 }
372
373 void tst_QLineSeries::removeAll_chart_data()
374 {
375 append_data();
376 }
377
378 void tst_QLineSeries::removeAll_chart()
379 {
380 m_view->show();
381 m_chart->addSeries(m_series);
382 QTest::qWaitForWindowShown(m_view);
383 removeAll_raw();
384 }
385
386 void tst_QLineSeries::removeAll_chart_animation_data()
387 {
388 append_data();
389 }
390
391 void tst_QLineSeries::removeAll_chart_animation()
392 {
393 m_chart->setAnimationOptions(QChart::AllAnimations);
394 removeAll_chart();
395 }
396
397 void tst_QLineSeries::replace_raw_data()
398 {
399 append_data();
400 }
401
402 void tst_QLineSeries::replace_raw()
403 {
404 QFETCH(QList<QPointF>, points);
405 QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&)));
406 m_series->append(points);
407 TRY_COMPARE(spy0.count(), 0);
408 QCOMPARE(m_series->points(), points);
409
410 foreach(const QPointF& point,points)
411 m_series->replace(point.x(),point.y(),point.x(),0);
412
413 QList<QPointF> newPoints = m_series->points();
414
415 QCOMPARE(newPoints.count(), points.count());
416
417 for(int i =0 ; i<points.count() ; ++i) {
418 QCOMPARE(points[i].x(), newPoints[i].x());
419 QCOMPARE(newPoints[i].y(), 0.0);
420 }
421 }
422
423
424 void tst_QLineSeries::replace_chart_data()
425 {
426 append_data();
427 }
428
429 void tst_QLineSeries::replace_chart()
430 {
431 m_view->show();
432 m_chart->addSeries(m_series);
433 QTest::qWaitForWindowShown(m_view);
434 replace_raw();
435 }
436
437 void tst_QLineSeries::replace_chart_animation_data()
438 {
439 append_data();
440 }
441
442 void tst_QLineSeries::replace_chart_animation()
443 {
444 m_chart->setAnimationOptions(QChart::AllAnimations);
445 replace_chart();
446 }
447
448 QTEST_MAIN(tst_QLineSeries)
98 QTEST_MAIN(tst_QLineSeries)
449
99
450 #include "tst_qlineseries.moc"
100 #include "tst_qlineseries.moc"
General Comments 0
You need to be logged in to leave comments. Login now