@@ -0,0 +1,4 | |||
|
1 | !include( ../../test.pri ) { | |
|
2 | error( "Couldn't find the test.pri file!" ) | |
|
3 | } | |
|
4 | SOURCES += tst_qchart.cpp No newline at end of file |
This diff has been collapsed as it changes many lines, (775 lines changed) Show them Hide them | |||
@@ -0,0 +1,775 | |||
|
1 | #include <QtTest/QtTest> | |
|
2 | #include <qchartview.h> | |
|
3 | #include <qlineseries.h> | |
|
4 | #include <qareaseries.h> | |
|
5 | #include <qscatterseries.h> | |
|
6 | #include <qsplineseries.h> | |
|
7 | #include <qpieseries.h> | |
|
8 | #include <qbarseries.h> | |
|
9 | #include <qpercentbarseries.h> | |
|
10 | #include <qstackedbarseries.h> | |
|
11 | ||
|
12 | QTCOMMERCIALCHART_USE_NAMESPACE | |
|
13 | ||
|
14 | Q_DECLARE_METATYPE(QChartAxis*) | |
|
15 | Q_DECLARE_METATYPE(QSeries*) | |
|
16 | ||
|
17 | class tst_QChart : public QObject | |
|
18 | { | |
|
19 | Q_OBJECT | |
|
20 | ||
|
21 | public slots: | |
|
22 | void initTestCase(); | |
|
23 | void cleanupTestCase(); | |
|
24 | void init(); | |
|
25 | void cleanup(); | |
|
26 | ||
|
27 | private slots: | |
|
28 | void qchart_data(); | |
|
29 | void qchart(); | |
|
30 | ||
|
31 | void addSeries_data(); | |
|
32 | void addSeries(); | |
|
33 | void animationOptions_data(); | |
|
34 | void animationOptions(); | |
|
35 | void axisX_data(); | |
|
36 | void axisX(); | |
|
37 | void axisY_data(); | |
|
38 | void axisY(); | |
|
39 | void backgroundBrush_data(); | |
|
40 | void backgroundBrush(); | |
|
41 | void backgroundPen_data(); | |
|
42 | void backgroundPen(); | |
|
43 | void isBackgroundVisible_data(); | |
|
44 | void isBackgroundVisible(); | |
|
45 | void legend_data(); | |
|
46 | void legend(); | |
|
47 | void margins_data(); | |
|
48 | void margins(); | |
|
49 | void removeAllSeries_data(); | |
|
50 | void removeAllSeries(); | |
|
51 | void removeSeries_data(); | |
|
52 | void removeSeries(); | |
|
53 | void scrollDown_data(); | |
|
54 | void scrollDown(); | |
|
55 | void scrollLeft_data(); | |
|
56 | void scrollLeft(); | |
|
57 | void scrollRight_data(); | |
|
58 | void scrollRight(); | |
|
59 | void scrollUp_data(); | |
|
60 | void scrollUp(); | |
|
61 | void setAnimationOptions_data(); | |
|
62 | void setAnimationOptions(); | |
|
63 | void setBackgroundBrush_data(); | |
|
64 | void setBackgroundBrush(); | |
|
65 | void setBackgroundPen_data(); | |
|
66 | void setBackgroundPen(); | |
|
67 | void setBackgroundVisible_data(); | |
|
68 | void setBackgroundVisible(); | |
|
69 | void setTheme_data(); | |
|
70 | void setTheme(); | |
|
71 | void setTitle_data(); | |
|
72 | void setTitle(); | |
|
73 | void setTitleBrush_data(); | |
|
74 | void setTitleBrush(); | |
|
75 | void setTitleFont_data(); | |
|
76 | void setTitleFont(); | |
|
77 | void theme_data(); | |
|
78 | void theme(); | |
|
79 | void title_data(); | |
|
80 | void title(); | |
|
81 | void titleBrush_data(); | |
|
82 | void titleBrush(); | |
|
83 | void titleFont_data(); | |
|
84 | void titleFont(); | |
|
85 | void zoomIn_data(); | |
|
86 | void zoomIn(); | |
|
87 | void zoomOut_data(); | |
|
88 | void zoomOut(); | |
|
89 | ||
|
90 | private: | |
|
91 | QChartView* m_view; | |
|
92 | QChart* m_chart; | |
|
93 | }; | |
|
94 | ||
|
95 | void tst_QChart::initTestCase() | |
|
96 | { | |
|
97 | ||
|
98 | } | |
|
99 | ||
|
100 | void tst_QChart::cleanupTestCase() | |
|
101 | { | |
|
102 | ||
|
103 | } | |
|
104 | ||
|
105 | void tst_QChart::init() | |
|
106 | { | |
|
107 | m_view = new QChartView(new QChart()); | |
|
108 | m_chart = m_view->chart(); | |
|
109 | ||
|
110 | } | |
|
111 | ||
|
112 | void tst_QChart::cleanup() | |
|
113 | { | |
|
114 | delete m_view; | |
|
115 | m_view = 0; | |
|
116 | m_chart = 0; | |
|
117 | } | |
|
118 | ||
|
119 | void tst_QChart::qchart_data() | |
|
120 | { | |
|
121 | } | |
|
122 | ||
|
123 | void tst_QChart::qchart() | |
|
124 | { | |
|
125 | QVERIFY(m_chart); | |
|
126 | QVERIFY(m_chart->legend()); | |
|
127 | QVERIFY(!m_chart->legend()->isVisible()); | |
|
128 | ||
|
129 | QCOMPARE(m_chart->animationOptions(), QChart::NoAnimation); | |
|
130 | QVERIFY(m_chart->axisX()); | |
|
131 | QVERIFY(m_chart->axisY()); | |
|
132 | QVERIFY(m_chart->backgroundBrush()!=QBrush()); | |
|
133 | QVERIFY(m_chart->backgroundPen()!=QPen()); | |
|
134 | QCOMPARE(m_chart->isBackgroundVisible(), true); | |
|
135 | ||
|
136 | QVERIFY(m_chart->margins().top()>0); | |
|
137 | QVERIFY(m_chart->margins().left()>0); | |
|
138 | QVERIFY(m_chart->margins().right()>0); | |
|
139 | QVERIFY(m_chart->margins().bottom()>0); | |
|
140 | m_chart->removeAllSeries(); | |
|
141 | m_chart->scrollDown(); | |
|
142 | m_chart->scrollLeft(); | |
|
143 | m_chart->scrollRight(); | |
|
144 | m_chart->scrollUp(); | |
|
145 | QCOMPARE(m_chart->theme(), QChart::ChartThemeLight); | |
|
146 | QCOMPARE(m_chart->title(), QString()); | |
|
147 | QCOMPARE(m_chart->titleBrush(),QBrush()); | |
|
148 | QCOMPARE(m_chart->titleFont(),QFont()); | |
|
149 | m_chart->zoomIn(); | |
|
150 | m_chart->zoomIn(QRectF()); | |
|
151 | m_chart->zoomOut(); | |
|
152 | } | |
|
153 | ||
|
154 | void tst_QChart::addSeries_data() | |
|
155 | { | |
|
156 | QTest::addColumn<QSeries*>("series"); | |
|
157 | QTest::addColumn<QChartAxis*>("axis"); | |
|
158 | ||
|
159 | QSeries* series0 = new QLineSeries(this); | |
|
160 | QSeries* series1 = new QAreaSeries(static_cast<QLineSeries*>(series0)); | |
|
161 | QSeries* series2 = new QScatterSeries(this); | |
|
162 | QSeries* series3 = new QSplineSeries(this); | |
|
163 | QSeries* series4 = new QPieSeries(this); | |
|
164 | QSeries* series5 = new QBarSeries(QBarCategories(),this); | |
|
165 | QSeries* series6 = new QPercentBarSeries(QBarCategories(),this); | |
|
166 | QSeries* series7 = new QStackedBarSeries(QBarCategories(),this); | |
|
167 | ||
|
168 | QChartAxis* axis = new QChartAxis(this); | |
|
169 | ||
|
170 | QTest::newRow("default axis: lineSeries") << series0 << (QChartAxis*) 0; | |
|
171 | QTest::newRow("axis0: lineSeries") << series0 << axis; | |
|
172 | QTest::newRow("default axis: areaSeries") << series1 << (QChartAxis*) 0; | |
|
173 | QTest::newRow("axis: areaSeries") << series1 << axis; | |
|
174 | QTest::newRow("default axis: scatterSeries") << series2 << (QChartAxis*) 0; | |
|
175 | QTest::newRow("axis1: scatterSeries") << series2 << axis; | |
|
176 | QTest::newRow("default axis: splineSeries") << series3 << (QChartAxis*) 0; | |
|
177 | QTest::newRow("axis: splineSeries") << series3 << axis; | |
|
178 | QTest::newRow("default axis: pieSeries") << series4 << (QChartAxis*) 0; | |
|
179 | QTest::newRow("axis: pieSeries") << series4 << axis; | |
|
180 | QTest::newRow("default axis: barSeries") << series5 << (QChartAxis*) 0; | |
|
181 | QTest::newRow("axis: barSeries") << series5 << axis; | |
|
182 | QTest::newRow("default axis: percentBarSeries") << series6 << (QChartAxis*) 0; | |
|
183 | QTest::newRow("axis: barSeries") << series6 << axis; | |
|
184 | QTest::newRow("default axis: stackedBarSeries") << series7 << (QChartAxis*) 0; | |
|
185 | QTest::newRow("axis: barSeries") << series7 << axis; | |
|
186 | ||
|
187 | } | |
|
188 | ||
|
189 | void tst_QChart::addSeries() | |
|
190 | { | |
|
191 | QFETCH(QSeries*, series); | |
|
192 | QFETCH(QChartAxis*, axis); | |
|
193 | if(!axis) axis = m_chart->axisY(); | |
|
194 | m_chart->addSeries(series,axis); | |
|
195 | QCOMPARE(m_chart->axisY(series),axis); | |
|
196 | } | |
|
197 | ||
|
198 | Q_DECLARE_METATYPE(QChart::AnimationOptions) | |
|
199 | void tst_QChart::animationOptions_data() | |
|
200 | { | |
|
201 | #if 0 | |
|
202 | QTest::addColumn<QChart::AnimationOptions>("animationOptions"); | |
|
203 | QTest::newRow("null") << QChart::AnimationOptions(); | |
|
204 | #endif | |
|
205 | } | |
|
206 | ||
|
207 | // public QChart::AnimationOptions animationOptions() const | |
|
208 | void tst_QChart::animationOptions() | |
|
209 | { | |
|
210 | #if 0 | |
|
211 | QFETCH(QChart::AnimationOptions, animationOptions); | |
|
212 | ||
|
213 | SubQChart chart; | |
|
214 | ||
|
215 | QCOMPARE(chart.animationOptions(), animationOptions); | |
|
216 | #endif | |
|
217 | QSKIP("Test is not implemented.", SkipAll); | |
|
218 | } | |
|
219 | ||
|
220 | void tst_QChart::axisX_data() | |
|
221 | { | |
|
222 | #if 0 | |
|
223 | QTest::addColumn<QChartAxis*>("axisX"); | |
|
224 | QTest::newRow("null") << QChartAxis*(); | |
|
225 | #endif | |
|
226 | } | |
|
227 | ||
|
228 | // public QChartAxis* axisX() const | |
|
229 | void tst_QChart::axisX() | |
|
230 | { | |
|
231 | #if 0 | |
|
232 | QFETCH(QChartAxis*, axisX); | |
|
233 | ||
|
234 | SubQChart chart; | |
|
235 | ||
|
236 | QCOMPARE(chart.axisX(), axisX); | |
|
237 | #endif | |
|
238 | QSKIP("Test is not implemented.", SkipAll); | |
|
239 | } | |
|
240 | ||
|
241 | void tst_QChart::axisY_data() | |
|
242 | { | |
|
243 | #if 0 | |
|
244 | QTest::addColumn<QChartAxis*>("axisY"); | |
|
245 | QTest::newRow("null") << QChartAxis*(); | |
|
246 | #endif | |
|
247 | } | |
|
248 | ||
|
249 | // public QChartAxis* axisY() const | |
|
250 | void tst_QChart::axisY() | |
|
251 | { | |
|
252 | #if 0 | |
|
253 | QFETCH(QChartAxis*, axisY); | |
|
254 | ||
|
255 | SubQChart chart; | |
|
256 | ||
|
257 | QCOMPARE(chart.axisY(), axisY); | |
|
258 | #endif | |
|
259 | QSKIP("Test is not implemented.", SkipAll); | |
|
260 | } | |
|
261 | ||
|
262 | Q_DECLARE_METATYPE(QBrush) | |
|
263 | void tst_QChart::backgroundBrush_data() | |
|
264 | { | |
|
265 | #if 0 | |
|
266 | QTest::addColumn<QBrush>("backgroundBrush"); | |
|
267 | QTest::newRow("null") << QBrush(); | |
|
268 | #endif | |
|
269 | } | |
|
270 | ||
|
271 | // public QBrush backgroundBrush() const | |
|
272 | void tst_QChart::backgroundBrush() | |
|
273 | { | |
|
274 | #if 0 | |
|
275 | QFETCH(QBrush, backgroundBrush); | |
|
276 | ||
|
277 | SubQChart chart; | |
|
278 | ||
|
279 | QCOMPARE(chart.backgroundBrush(), backgroundBrush); | |
|
280 | #endif | |
|
281 | QSKIP("Test is not implemented.", SkipAll); | |
|
282 | } | |
|
283 | ||
|
284 | Q_DECLARE_METATYPE(QPen) | |
|
285 | void tst_QChart::backgroundPen_data() | |
|
286 | { | |
|
287 | #if 0 | |
|
288 | QTest::addColumn<QPen>("backgroundPen"); | |
|
289 | QTest::newRow("null") << QPen(); | |
|
290 | #endif | |
|
291 | } | |
|
292 | ||
|
293 | // public QPen backgroundPen() const | |
|
294 | void tst_QChart::backgroundPen() | |
|
295 | { | |
|
296 | #if 0 | |
|
297 | QFETCH(QPen, backgroundPen); | |
|
298 | ||
|
299 | SubQChart chart; | |
|
300 | ||
|
301 | QCOMPARE(chart.backgroundPen(), backgroundPen); | |
|
302 | #endif | |
|
303 | QSKIP("Test is not implemented.", SkipAll); | |
|
304 | } | |
|
305 | ||
|
306 | void tst_QChart::isBackgroundVisible_data() | |
|
307 | { | |
|
308 | QTest::addColumn<bool>("isBackgroundVisible"); | |
|
309 | QTest::newRow("true") << true; | |
|
310 | QTest::newRow("false") << false; | |
|
311 | } | |
|
312 | ||
|
313 | // public bool isBackgroundVisible() const | |
|
314 | void tst_QChart::isBackgroundVisible() | |
|
315 | { | |
|
316 | #if 0 | |
|
317 | QFETCH(bool, isBackgroundVisible); | |
|
318 | ||
|
319 | SubQChart chart; | |
|
320 | ||
|
321 | QCOMPARE(chart.isBackgroundVisible(), isBackgroundVisible); | |
|
322 | #endif | |
|
323 | QSKIP("Test is not implemented.", SkipAll); | |
|
324 | } | |
|
325 | ||
|
326 | Q_DECLARE_METATYPE(QLegend*) | |
|
327 | void tst_QChart::legend_data() | |
|
328 | { | |
|
329 | #if 0 | |
|
330 | QTest::addColumn<QLegend*>("legend"); | |
|
331 | QTest::newRow("null") << QLegend*(); | |
|
332 | #endif | |
|
333 | } | |
|
334 | ||
|
335 | // public QLegend* legend() const | |
|
336 | void tst_QChart::legend() | |
|
337 | { | |
|
338 | #if 0 | |
|
339 | QFETCH(QLegend*, legend); | |
|
340 | ||
|
341 | SubQChart chart; | |
|
342 | ||
|
343 | QCOMPARE(chart.legend(), legend); | |
|
344 | #endif | |
|
345 | QSKIP("Test is not implemented.", SkipAll); | |
|
346 | } | |
|
347 | ||
|
348 | void tst_QChart::margins_data() | |
|
349 | { | |
|
350 | QTest::addColumn<QRectF>("margins"); | |
|
351 | QTest::newRow("null") << QRectF(); | |
|
352 | } | |
|
353 | ||
|
354 | // public QRectF margins() const | |
|
355 | void tst_QChart::margins() | |
|
356 | { | |
|
357 | #if 0 | |
|
358 | QFETCH(QRectF, margins); | |
|
359 | ||
|
360 | SubQChart chart; | |
|
361 | ||
|
362 | QCOMPARE(chart.margins(), margins); | |
|
363 | #endif | |
|
364 | QSKIP("Test is not implemented.", SkipAll); | |
|
365 | } | |
|
366 | ||
|
367 | void tst_QChart::removeAllSeries_data() | |
|
368 | { | |
|
369 | QTest::addColumn<int>("foo"); | |
|
370 | QTest::newRow("0") << 0; | |
|
371 | QTest::newRow("-1") << -1; | |
|
372 | } | |
|
373 | ||
|
374 | // public void removeAllSeries() | |
|
375 | void tst_QChart::removeAllSeries() | |
|
376 | { | |
|
377 | #if 0 | |
|
378 | QFETCH(int, foo); | |
|
379 | ||
|
380 | SubQChart chart; | |
|
381 | ||
|
382 | chart.removeAllSeries(); | |
|
383 | #endif | |
|
384 | QSKIP("Test is not implemented.", SkipAll); | |
|
385 | } | |
|
386 | ||
|
387 | void tst_QChart::removeSeries_data() | |
|
388 | { | |
|
389 | QTest::addColumn<int>("seriesCount"); | |
|
390 | QTest::newRow("0") << 0; | |
|
391 | QTest::newRow("-1") << -1; | |
|
392 | } | |
|
393 | ||
|
394 | // public void removeSeries(QSeries* series) | |
|
395 | void tst_QChart::removeSeries() | |
|
396 | { | |
|
397 | #if 0 | |
|
398 | QFETCH(int, seriesCount); | |
|
399 | ||
|
400 | SubQChart chart; | |
|
401 | ||
|
402 | chart.removeSeries(series); | |
|
403 | #endif | |
|
404 | QSKIP("Test is not implemented.", SkipAll); | |
|
405 | } | |
|
406 | ||
|
407 | void tst_QChart::scrollDown_data() | |
|
408 | { | |
|
409 | QTest::addColumn<int>("foo"); | |
|
410 | QTest::newRow("0") << 0; | |
|
411 | QTest::newRow("-1") << -1; | |
|
412 | } | |
|
413 | ||
|
414 | // public void scrollDown() | |
|
415 | void tst_QChart::scrollDown() | |
|
416 | { | |
|
417 | #if 0 | |
|
418 | QFETCH(int, foo); | |
|
419 | ||
|
420 | SubQChart chart; | |
|
421 | ||
|
422 | chart.scrollDown(); | |
|
423 | #endif | |
|
424 | QSKIP("Test is not implemented.", SkipAll); | |
|
425 | } | |
|
426 | ||
|
427 | void tst_QChart::scrollLeft_data() | |
|
428 | { | |
|
429 | QTest::addColumn<int>("foo"); | |
|
430 | QTest::newRow("0") << 0; | |
|
431 | QTest::newRow("-1") << -1; | |
|
432 | } | |
|
433 | ||
|
434 | // public void scrollLeft() | |
|
435 | void tst_QChart::scrollLeft() | |
|
436 | { | |
|
437 | #if 0 | |
|
438 | QFETCH(int, foo); | |
|
439 | ||
|
440 | SubQChart chart; | |
|
441 | ||
|
442 | chart.scrollLeft(); | |
|
443 | #endif | |
|
444 | QSKIP("Test is not implemented.", SkipAll); | |
|
445 | } | |
|
446 | ||
|
447 | void tst_QChart::scrollRight_data() | |
|
448 | { | |
|
449 | QTest::addColumn<int>("foo"); | |
|
450 | QTest::newRow("0") << 0; | |
|
451 | QTest::newRow("-1") << -1; | |
|
452 | } | |
|
453 | ||
|
454 | // public void scrollRight() | |
|
455 | void tst_QChart::scrollRight() | |
|
456 | { | |
|
457 | #if 0 | |
|
458 | QFETCH(int, foo); | |
|
459 | ||
|
460 | SubQChart chart; | |
|
461 | ||
|
462 | chart.scrollRight(); | |
|
463 | #endif | |
|
464 | QSKIP("Test is not implemented.", SkipAll); | |
|
465 | } | |
|
466 | ||
|
467 | void tst_QChart::scrollUp_data() | |
|
468 | { | |
|
469 | QTest::addColumn<int>("foo"); | |
|
470 | QTest::newRow("0") << 0; | |
|
471 | QTest::newRow("-1") << -1; | |
|
472 | } | |
|
473 | ||
|
474 | // public void scrollUp() | |
|
475 | void tst_QChart::scrollUp() | |
|
476 | { | |
|
477 | #if 0 | |
|
478 | QFETCH(int, foo); | |
|
479 | ||
|
480 | SubQChart chart; | |
|
481 | ||
|
482 | chart.scrollUp(); | |
|
483 | #endif | |
|
484 | QSKIP("Test is not implemented.", SkipAll); | |
|
485 | } | |
|
486 | ||
|
487 | void tst_QChart::setAnimationOptions_data() | |
|
488 | { | |
|
489 | #if 0 | |
|
490 | QTest::addColumn<QChart::AnimationOptions>("options"); | |
|
491 | QTest::newRow("null") << QChart::AnimationOptions(); | |
|
492 | #endif | |
|
493 | } | |
|
494 | ||
|
495 | // public void setAnimationOptions(QChart::AnimationOptions options) | |
|
496 | void tst_QChart::setAnimationOptions() | |
|
497 | { | |
|
498 | #if 0 | |
|
499 | QFETCH(QChart::AnimationOptions, options); | |
|
500 | ||
|
501 | SubQChart chart; | |
|
502 | ||
|
503 | chart.setAnimationOptions(options); | |
|
504 | #endif | |
|
505 | QSKIP("Test is not implemented.", SkipAll); | |
|
506 | } | |
|
507 | ||
|
508 | void tst_QChart::setBackgroundBrush_data() | |
|
509 | { | |
|
510 | #if 0 | |
|
511 | QTest::addColumn<QBrush>("brush"); | |
|
512 | QTest::newRow("null") << QBrush(); | |
|
513 | #endif | |
|
514 | } | |
|
515 | ||
|
516 | // public void setBackgroundBrush(QBrush const& brush) | |
|
517 | void tst_QChart::setBackgroundBrush() | |
|
518 | { | |
|
519 | #if 0 | |
|
520 | QFETCH(QBrush, brush); | |
|
521 | ||
|
522 | SubQChart chart; | |
|
523 | ||
|
524 | chart.setBackgroundBrush(brush); | |
|
525 | #endif | |
|
526 | QSKIP("Test is not implemented.", SkipAll); | |
|
527 | } | |
|
528 | ||
|
529 | void tst_QChart::setBackgroundPen_data() | |
|
530 | { | |
|
531 | #if 0 | |
|
532 | QTest::addColumn<QPen>("pen"); | |
|
533 | QTest::newRow("null") << QPen(); | |
|
534 | #endif | |
|
535 | } | |
|
536 | ||
|
537 | // public void setBackgroundPen(QPen const& pen) | |
|
538 | void tst_QChart::setBackgroundPen() | |
|
539 | { | |
|
540 | #if 0 | |
|
541 | QFETCH(QPen, pen); | |
|
542 | ||
|
543 | SubQChart chart; | |
|
544 | ||
|
545 | chart.setBackgroundPen(pen); | |
|
546 | #endif | |
|
547 | QSKIP("Test is not implemented.", SkipAll); | |
|
548 | } | |
|
549 | ||
|
550 | void tst_QChart::setBackgroundVisible_data() | |
|
551 | { | |
|
552 | QTest::addColumn<bool>("visible"); | |
|
553 | QTest::newRow("true") << true; | |
|
554 | QTest::newRow("false") << false; | |
|
555 | } | |
|
556 | ||
|
557 | // public void setBackgroundVisible(bool visible) | |
|
558 | void tst_QChart::setBackgroundVisible() | |
|
559 | { | |
|
560 | #if 0 | |
|
561 | QFETCH(bool, visible); | |
|
562 | ||
|
563 | SubQChart chart; | |
|
564 | ||
|
565 | chart.setBackgroundVisible(visible); | |
|
566 | #endif | |
|
567 | QSKIP("Test is not implemented.", SkipAll); | |
|
568 | } | |
|
569 | ||
|
570 | Q_DECLARE_METATYPE(QChart::ChartTheme) | |
|
571 | void tst_QChart::setTheme_data() | |
|
572 | { | |
|
573 | #if 0 | |
|
574 | QTest::addColumn<QChart::ChartTheme>("theme"); | |
|
575 | QTest::newRow("null") << QChart::ChartTheme(); | |
|
576 | #endif | |
|
577 | } | |
|
578 | ||
|
579 | // public void setTheme(QChart::ChartTheme theme) | |
|
580 | void tst_QChart::setTheme() | |
|
581 | { | |
|
582 | #if 0 | |
|
583 | QFETCH(QChart::ChartTheme, theme); | |
|
584 | ||
|
585 | SubQChart chart; | |
|
586 | ||
|
587 | chart.setTheme(theme); | |
|
588 | #endif | |
|
589 | QSKIP("Test is not implemented.", SkipAll); | |
|
590 | } | |
|
591 | ||
|
592 | void tst_QChart::setTitle_data() | |
|
593 | { | |
|
594 | QTest::addColumn<QString>("title"); | |
|
595 | QTest::newRow("null") << QString(); | |
|
596 | QTest::newRow("foo") << QString("foo"); | |
|
597 | } | |
|
598 | ||
|
599 | // public void setTitle(QString const& title) | |
|
600 | void tst_QChart::setTitle() | |
|
601 | { | |
|
602 | #if 0 | |
|
603 | QFETCH(QString, title); | |
|
604 | ||
|
605 | SubQChart chart; | |
|
606 | ||
|
607 | chart.setTitle(title); | |
|
608 | #endif | |
|
609 | QSKIP("Test is not implemented.", SkipAll); | |
|
610 | } | |
|
611 | ||
|
612 | void tst_QChart::setTitleBrush_data() | |
|
613 | { | |
|
614 | #if 0 | |
|
615 | QTest::addColumn<QBrush>("brush"); | |
|
616 | QTest::newRow("null") << QBrush(); | |
|
617 | #endif | |
|
618 | } | |
|
619 | ||
|
620 | // public void setTitleBrush(QBrush const& brush) | |
|
621 | void tst_QChart::setTitleBrush() | |
|
622 | { | |
|
623 | #if 0 | |
|
624 | QFETCH(QBrush, brush); | |
|
625 | ||
|
626 | SubQChart chart; | |
|
627 | ||
|
628 | chart.setTitleBrush(brush); | |
|
629 | #endif | |
|
630 | QSKIP("Test is not implemented.", SkipAll); | |
|
631 | } | |
|
632 | ||
|
633 | void tst_QChart::setTitleFont_data() | |
|
634 | { | |
|
635 | QTest::addColumn<QFont>("font"); | |
|
636 | QTest::newRow("null") << QFont(); | |
|
637 | } | |
|
638 | ||
|
639 | // public void setTitleFont(QFont const& font) | |
|
640 | void tst_QChart::setTitleFont() | |
|
641 | { | |
|
642 | #if 0 | |
|
643 | QFETCH(QFont, font); | |
|
644 | ||
|
645 | SubQChart chart; | |
|
646 | ||
|
647 | chart.setTitleFont(font); | |
|
648 | #endif | |
|
649 | QSKIP("Test is not implemented.", SkipAll); | |
|
650 | } | |
|
651 | ||
|
652 | void tst_QChart::theme_data() | |
|
653 | { | |
|
654 | #if 0 | |
|
655 | QTest::addColumn<QChart::ChartTheme>("theme"); | |
|
656 | QTest::newRow("null") << QChart::ChartTheme(); | |
|
657 | #endif | |
|
658 | } | |
|
659 | ||
|
660 | // public QChart::ChartTheme theme() const | |
|
661 | void tst_QChart::theme() | |
|
662 | { | |
|
663 | #if 0 | |
|
664 | QFETCH(QChart::ChartTheme, theme); | |
|
665 | ||
|
666 | SubQChart chart; | |
|
667 | ||
|
668 | QCOMPARE(chart.theme(), theme); | |
|
669 | #endif | |
|
670 | QSKIP("Test is not implemented.", SkipAll); | |
|
671 | } | |
|
672 | ||
|
673 | void tst_QChart::title_data() | |
|
674 | { | |
|
675 | QTest::addColumn<QString>("title"); | |
|
676 | QTest::newRow("null") << QString(); | |
|
677 | QTest::newRow("foo") << QString("foo"); | |
|
678 | } | |
|
679 | ||
|
680 | // public QString title() const | |
|
681 | void tst_QChart::title() | |
|
682 | { | |
|
683 | #if 0 | |
|
684 | QFETCH(QString, title); | |
|
685 | ||
|
686 | SubQChart chart; | |
|
687 | ||
|
688 | QCOMPARE(chart.title(), title); | |
|
689 | #endif | |
|
690 | QSKIP("Test is not implemented.", SkipAll); | |
|
691 | } | |
|
692 | ||
|
693 | void tst_QChart::titleBrush_data() | |
|
694 | { | |
|
695 | #if 0 | |
|
696 | QTest::addColumn<QBrush>("titleBrush"); | |
|
697 | QTest::newRow("null") << QBrush(); | |
|
698 | #endif | |
|
699 | } | |
|
700 | ||
|
701 | // public QBrush titleBrush() const | |
|
702 | void tst_QChart::titleBrush() | |
|
703 | { | |
|
704 | #if 0 | |
|
705 | QFETCH(QBrush, titleBrush); | |
|
706 | ||
|
707 | SubQChart chart; | |
|
708 | ||
|
709 | QCOMPARE(chart.titleBrush(), titleBrush); | |
|
710 | #endif | |
|
711 | QSKIP("Test is not implemented.", SkipAll); | |
|
712 | } | |
|
713 | ||
|
714 | void tst_QChart::titleFont_data() | |
|
715 | { | |
|
716 | QTest::addColumn<QFont>("titleFont"); | |
|
717 | QTest::newRow("null") << QFont(); | |
|
718 | } | |
|
719 | ||
|
720 | // public QFont titleFont() const | |
|
721 | void tst_QChart::titleFont() | |
|
722 | { | |
|
723 | #if 0 | |
|
724 | QFETCH(QFont, titleFont); | |
|
725 | ||
|
726 | SubQChart chart; | |
|
727 | ||
|
728 | QCOMPARE(chart.titleFont(), titleFont); | |
|
729 | #endif | |
|
730 | QSKIP("Test is not implemented.", SkipAll); | |
|
731 | } | |
|
732 | ||
|
733 | void tst_QChart::zoomIn_data() | |
|
734 | { | |
|
735 | QTest::addColumn<int>("foo"); | |
|
736 | QTest::newRow("0") << 0; | |
|
737 | QTest::newRow("-1") << -1; | |
|
738 | } | |
|
739 | ||
|
740 | // public void zoomIn() | |
|
741 | void tst_QChart::zoomIn() | |
|
742 | { | |
|
743 | #if 0 | |
|
744 | QFETCH(int, foo); | |
|
745 | ||
|
746 | SubQChart chart; | |
|
747 | ||
|
748 | chart.zoomIn(); | |
|
749 | #endif | |
|
750 | QSKIP("Test is not implemented.", SkipAll); | |
|
751 | } | |
|
752 | ||
|
753 | void tst_QChart::zoomOut_data() | |
|
754 | { | |
|
755 | QTest::addColumn<int>("foo"); | |
|
756 | QTest::newRow("0") << 0; | |
|
757 | QTest::newRow("-1") << -1; | |
|
758 | } | |
|
759 | ||
|
760 | // public void zoomOut() | |
|
761 | void tst_QChart::zoomOut() | |
|
762 | { | |
|
763 | #if 0 | |
|
764 | QFETCH(int, foo); | |
|
765 | ||
|
766 | SubQChart chart; | |
|
767 | ||
|
768 | chart.zoomOut(); | |
|
769 | #endif | |
|
770 | QSKIP("Test is not implemented.", SkipAll); | |
|
771 | } | |
|
772 | ||
|
773 | QTEST_MAIN(tst_QChart) | |
|
774 | #include "tst_qchart.moc" | |
|
775 |
@@ -1,2 +1,2 | |||
|
1 | 1 | TEMPLATE = subdirs |
|
2 | SUBDIRS += chartdataset domain qchartview No newline at end of file | |
|
2 | SUBDIRS += chartdataset domain qchartview qchart No newline at end of file |
@@ -1,216 +1,215 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | |
|
22 | 22 | #include <QtTest/QtTest> |
|
23 | 23 | #include <qchartview.h> |
|
24 | 24 | #include <qlineseries.h> |
|
25 | #include <qlegend.h> | |
|
26 | 25 | #include <cmath> |
|
27 | 26 | |
|
28 | 27 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
29 | 28 | |
|
30 | 29 | |
|
31 | 30 | Q_DECLARE_METATYPE(QChart*) |
|
32 | 31 | Q_DECLARE_METATYPE(QChartView::RubberBands) |
|
33 | 32 | Q_DECLARE_METATYPE(Qt::Key) |
|
34 | 33 | |
|
35 | 34 | class tst_QChartView : public QObject |
|
36 | 35 | { |
|
37 | 36 | Q_OBJECT |
|
38 | 37 | |
|
39 | 38 | public Q_SLOTS: |
|
40 | 39 | void initTestCase(); |
|
41 | 40 | void cleanupTestCase(); |
|
42 | 41 | void init(); |
|
43 | 42 | void cleanup(); |
|
44 | 43 | |
|
45 | 44 | private Q_SLOTS: |
|
46 | 45 | void qchartview_data(); |
|
47 | 46 | void qchartview(); |
|
48 | 47 | void chart_data(); |
|
49 | 48 | void chart(); |
|
50 | 49 | void rubberBand_data(); |
|
51 | 50 | void rubberBand(); |
|
52 | 51 | void keys_data(); |
|
53 | 52 | void keys(); |
|
54 | 53 | |
|
55 | 54 | private: |
|
56 | 55 | QChartView* m_view; |
|
57 | 56 | }; |
|
58 | 57 | |
|
59 | 58 | void tst_QChartView::initTestCase() |
|
60 | 59 | { |
|
61 | 60 | //test tracks mouse, give a while to user to relese it |
|
62 | 61 | QTest::qWait(1000); |
|
63 | 62 | } |
|
64 | 63 | |
|
65 | 64 | void tst_QChartView::cleanupTestCase() |
|
66 | 65 | { |
|
67 | 66 | } |
|
68 | 67 | |
|
69 | 68 | void tst_QChartView::init() |
|
70 | 69 | { |
|
71 | 70 | m_view = new QChartView(new QChart()); |
|
72 | 71 | m_view->chart()->legend()->setVisible(false); |
|
73 | 72 | } |
|
74 | 73 | |
|
75 | 74 | void tst_QChartView::cleanup() |
|
76 | 75 | { |
|
77 | 76 | delete m_view; |
|
78 | 77 | m_view =0; |
|
79 | 78 | } |
|
80 | 79 | |
|
81 | 80 | void tst_QChartView::qchartview_data() |
|
82 | 81 | { |
|
83 | 82 | |
|
84 | 83 | } |
|
85 | 84 | |
|
86 | 85 | void tst_QChartView::qchartview() |
|
87 | 86 | { |
|
88 | 87 | QVERIFY(m_view->chart()); |
|
89 | 88 | QCOMPARE(m_view->rubberBand(), QChartView::NoRubberBand); |
|
90 | 89 | m_view->show(); |
|
91 | 90 | QTest::qWaitForWindowShown(m_view); |
|
92 | 91 | } |
|
93 | 92 | |
|
94 | 93 | void tst_QChartView::chart_data() |
|
95 | 94 | { |
|
96 | 95 | |
|
97 | 96 | QTest::addColumn<QChart*>("chart"); |
|
98 | 97 | QTest::newRow("qchart") << new QChart(); |
|
99 | 98 | } |
|
100 | 99 | |
|
101 | 100 | void tst_QChartView::chart() |
|
102 | 101 | { |
|
103 | 102 | QFETCH(QChart*, chart); |
|
104 | 103 | QChartView* view = new QChartView(chart); |
|
105 | 104 | QCOMPARE(view->chart(), chart); |
|
106 | 105 | delete view; |
|
107 | 106 | } |
|
108 | 107 | |
|
109 | 108 | void tst_QChartView::rubberBand_data() |
|
110 | 109 | { |
|
111 | 110 | QTest::addColumn<QChartView::RubberBands>("rubberBand"); |
|
112 | 111 | QTest::addColumn<int>("Xcount"); |
|
113 | 112 | QTest::addColumn<int>("Ycount"); |
|
114 | 113 | |
|
115 | 114 | QTest::addColumn<int>("minX"); |
|
116 | 115 | QTest::addColumn<int>("maxX"); |
|
117 | 116 | QTest::addColumn<int>("minY"); |
|
118 | 117 | QTest::addColumn<int>("maxY"); |
|
119 | 118 | |
|
120 | 119 | QTest::newRow("HorizonalRubberBand") << QChartView::RubberBands(QChartView::HorizonalRubberBand) << 0 << 1 << 10 << 90 << 0<< 100; |
|
121 | 120 | QTest::newRow("VerticalRubberBand") << QChartView::RubberBands(QChartView::VerticalRubberBand) << 1 << 0 << 0 << 100 << 10<< 90; |
|
122 | 121 | QTest::newRow("RectangleRubberBand") << QChartView::RubberBands(QChartView::RectangleRubberBand) << 1 << 1 <<10 << 90 << 10<< 90; |
|
123 | 122 | } |
|
124 | 123 | |
|
125 | 124 | void tst_QChartView::rubberBand() |
|
126 | 125 | { |
|
127 | 126 | QFETCH(QChartView::RubberBands, rubberBand); |
|
128 | 127 | QFETCH(int, Xcount); |
|
129 | 128 | QFETCH(int, Ycount); |
|
130 | 129 | QFETCH(int, minX); |
|
131 | 130 | QFETCH(int, maxX); |
|
132 | 131 | QFETCH(int, minY); |
|
133 | 132 | QFETCH(int, maxY); |
|
134 | 133 | |
|
135 | 134 | m_view->setRubberBand(rubberBand); |
|
136 | 135 | QRectF padding = m_view->chart()->margins(); |
|
137 | 136 | QCOMPARE(m_view->rubberBand(), rubberBand); |
|
138 | 137 | |
|
139 | 138 | QLineSeries* line = new QLineSeries(); |
|
140 | 139 | *line << QPointF(0, 0) << QPointF(100, 100); |
|
141 | 140 | |
|
142 | 141 | m_view->chart()->addSeries(line); |
|
143 | 142 | m_view->resize(100 + padding.left() + padding.right(), 100 + padding.top()+ padding.bottom()); |
|
144 | 143 | m_view->show(); |
|
145 | 144 | |
|
146 | 145 | //this is hack since view does not get events otherwise |
|
147 | 146 | m_view->setMouseTracking(true); |
|
148 | 147 | |
|
149 | 148 | QChartAxis* axisY = m_view->chart()->axisY(); |
|
150 | 149 | QSignalSpy spy0(axisY, SIGNAL(rangeChanged(qreal, qreal))); |
|
151 | 150 | QChartAxis* axisX = m_view->chart()->axisX(); |
|
152 | 151 | QSignalSpy spy1(axisX, SIGNAL(rangeChanged(qreal, qreal))); |
|
153 | 152 | |
|
154 | 153 | QTest::qWaitForWindowShown(m_view); |
|
155 | 154 | QTest::mouseMove(m_view->viewport(), QPoint(minX, minY) + padding.topLeft().toPoint()); |
|
156 | 155 | QTest::mousePress(m_view->viewport(), Qt::LeftButton, 0, QPoint(minX, minY) + padding.topLeft().toPoint()); |
|
157 | 156 | QTest::mouseMove(m_view->viewport(), QPoint(maxX, maxY) + padding.topLeft().toPoint()); |
|
158 | 157 | QTest::mouseRelease(m_view->viewport(), Qt::LeftButton, 0, QPoint(maxX, maxY)+ padding.topLeft().toPoint()); |
|
159 | 158 | |
|
160 | 159 | |
|
161 | 160 | QCOMPARE(spy0.count(), Xcount); |
|
162 | 161 | QCOMPARE(spy1.count(), Ycount); |
|
163 | 162 | |
|
164 | 163 | //this is hack since view does not get events otherwise |
|
165 | 164 | m_view->setMouseTracking(false); |
|
166 | 165 | |
|
167 | 166 | QVERIFY(axisX->min() - minX < 1); |
|
168 | 167 | QVERIFY(axisX->max() - maxX < 1); |
|
169 | 168 | QVERIFY(axisY->min() - minY < 1); |
|
170 | 169 | QVERIFY(axisY->max() - maxY < 1); |
|
171 | 170 | } |
|
172 | 171 | |
|
173 | 172 | void tst_QChartView::keys_data() |
|
174 | 173 | { |
|
175 | 174 | QTest::addColumn<Qt::Key>("key"); |
|
176 | 175 | QTest::addColumn<int>("Xcount"); |
|
177 | 176 | QTest::addColumn<int>("Ycount"); |
|
178 | 177 | QTest::newRow("Qt::Key_Plus") << Qt::Key_Plus << 1 << 1; |
|
179 | 178 | QTest::newRow("Qt::Key_Minus") << Qt::Key_Minus << 1 << 1; |
|
180 | 179 | QTest::newRow("Qt::Key_Up") << Qt::Key_Up << 0 << 1; |
|
181 | 180 | QTest::newRow("Qt::Key_Down") << Qt::Key_Down << 0 << 1; |
|
182 | 181 | QTest::newRow("Qt::Key_Left") << Qt::Key_Left << 1 << 0; |
|
183 | 182 | QTest::newRow("Qt::Key_Right") << Qt::Key_Right << 1 << 0; |
|
184 | 183 | } |
|
185 | 184 | |
|
186 | 185 | void tst_QChartView::keys() |
|
187 | 186 | { |
|
188 | 187 | QFETCH(Qt::Key,key); |
|
189 | 188 | QFETCH(int, Xcount); |
|
190 | 189 | QFETCH(int, Ycount); |
|
191 | 190 | |
|
192 | 191 | QRectF padding = m_view->chart()->margins(); |
|
193 | 192 | |
|
194 | 193 | QLineSeries* line = new QLineSeries(); |
|
195 | 194 | *line << QPointF(0, 0) << QPointF(100, 100); |
|
196 | 195 | |
|
197 | 196 | m_view->chart()->addSeries(line); |
|
198 | 197 | m_view->resize(100 + padding.left() + padding.right(), 100 + padding.top()+ padding.bottom()); |
|
199 | 198 | m_view->show(); |
|
200 | 199 | |
|
201 | 200 | QChartAxis* axisY = m_view->chart()->axisY(); |
|
202 | 201 | QSignalSpy spy0(axisY, SIGNAL(rangeChanged(qreal, qreal))); |
|
203 | 202 | QChartAxis* axisX = m_view->chart()->axisX(); |
|
204 | 203 | QSignalSpy spy1(axisX, SIGNAL(rangeChanged(qreal, qreal))); |
|
205 | 204 | |
|
206 | 205 | QTest::keyPress(m_view, key); |
|
207 | 206 | QTest::keyRelease(m_view, key); |
|
208 | 207 | |
|
209 | 208 | QCOMPARE(spy0.count(), Ycount); |
|
210 | 209 | QCOMPARE(spy1.count(), Xcount); |
|
211 | 210 | |
|
212 | 211 | } |
|
213 | 212 | |
|
214 | 213 | QTEST_MAIN(tst_QChartView) |
|
215 | 214 | #include "tst_qchartview.moc" |
|
216 | 215 |
General Comments 0
You need to be logged in to leave comments.
Login now