##// END OF EJS Templates
Adds tst_chart draft
Michal Klocek -
r896:d007baef4c4a
parent child
Show More
@@ -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 TEMPLATE = subdirs
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
@@ -22,7 +22,6
22 #include <QtTest/QtTest>
22 #include <QtTest/QtTest>
23 #include <qchartview.h>
23 #include <qchartview.h>
24 #include <qlineseries.h>
24 #include <qlineseries.h>
25 #include <qlegend.h>
26 #include <cmath>
25 #include <cmath>
27
26
28 QTCOMMERCIALCHART_USE_NAMESPACE
27 QTCOMMERCIALCHART_USE_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now