@@ -0,0 +1,38 | |||||
|
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_DEFINITIONS_H | |||
|
22 | #define TST_DEFINITIONS_H | |||
|
23 | ||||
|
24 | #include <QtTest/QtTest> | |||
|
25 | ||||
|
26 | #define TRY_COMPARE(actual, expected) { \ | |||
|
27 | do { \ | |||
|
28 | const int timeout(1000); \ | |||
|
29 | const int waitStep(30); \ | |||
|
30 | /* always wait before comparing to catch possible extra signals */ \ | |||
|
31 | QTest::qWait(waitStep); \ | |||
|
32 | for (int time(0); actual != expected && time < timeout; time += waitStep) \ | |||
|
33 | QTest::qWait(waitStep); \ | |||
|
34 | QCOMPARE(actual, expected); \ | |||
|
35 | } while (0); \ | |||
|
36 | } | |||
|
37 | ||||
|
38 | #endif // TST_DEFINITIONS_H |
@@ -4,3 +4,6 | |||||
4 |
|
4 | |||
5 | CONFIG += qtestlib |
|
5 | CONFIG += qtestlib | |
6 | !contains(TARGET, ^tst_.*):TARGET = $$join(TARGET,,"tst_") |
|
6 | !contains(TARGET, ^tst_.*):TARGET = $$join(TARGET,,"tst_") | |
|
7 | ||||
|
8 | INCLUDEPATH += ../inc | |||
|
9 | HEADERS += ../inc/tst_definitions.h |
@@ -23,6 +23,7 | |||||
23 | #include <qlineseries.h> |
|
23 | #include <qlineseries.h> | |
24 | #include <private/chartdataset_p.h> |
|
24 | #include <private/chartdataset_p.h> | |
25 | #include <private/domain_p.h> |
|
25 | #include <private/domain_p.h> | |
|
26 | #include <tst_definitions.h> | |||
26 |
|
27 | |||
27 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
28 | QTCOMMERCIALCHART_USE_NAMESPACE | |
28 |
|
29 | |||
@@ -151,10 +152,10 void tst_ChartDataSet::addSeries() | |||||
151 | m_dataset->addSeries(series1,axis1); |
|
152 | m_dataset->addSeries(series1,axis1); | |
152 | m_dataset->addSeries(series2,axis2); |
|
153 | m_dataset->addSeries(series2,axis2); | |
153 |
|
154 | |||
154 |
|
|
155 | TRY_COMPARE(spy0.count(), axisCount); | |
155 |
|
|
156 | TRY_COMPARE(spy1.count(), 0); | |
156 |
|
|
157 | TRY_COMPARE(spy2.count(), 3); | |
157 |
|
|
158 | TRY_COMPARE(spy3.count(), 0); | |
158 |
|
159 | |||
159 | if(axis0==0) axis0 = m_dataset->axisY(); |
|
160 | if(axis0==0) axis0 = m_dataset->axisY(); | |
160 | if(axis1==0) axis1 = m_dataset->axisY(); |
|
161 | if(axis1==0) axis1 = m_dataset->axisY(); | |
@@ -193,10 +194,10 void tst_ChartDataSet::removeSeries() | |||||
193 | m_dataset->removeSeries(series1); |
|
194 | m_dataset->removeSeries(series1); | |
194 | m_dataset->removeSeries(series2); |
|
195 | m_dataset->removeSeries(series2); | |
195 |
|
196 | |||
196 |
|
|
197 | TRY_COMPARE(spy0.count(), 0); | |
197 |
|
|
198 | TRY_COMPARE(spy1.count(), axisCount); | |
198 |
|
|
199 | TRY_COMPARE(spy2.count(), 0); | |
199 |
|
|
200 | TRY_COMPARE(spy3.count(), 3); | |
200 | } |
|
201 | } | |
201 |
|
202 | |||
202 | void tst_ChartDataSet::removeAllSeries_data() |
|
203 | void tst_ChartDataSet::removeAllSeries_data() | |
@@ -225,10 +226,10 void tst_ChartDataSet::removeAllSeries() | |||||
225 |
|
226 | |||
226 | m_dataset->removeAllSeries(); |
|
227 | m_dataset->removeAllSeries(); | |
227 |
|
228 | |||
228 |
|
|
229 | TRY_COMPARE(spy0.count(), 0); | |
229 |
|
|
230 | TRY_COMPARE(spy1.count(), 4); | |
230 |
|
|
231 | TRY_COMPARE(spy2.count(), 0); | |
231 |
|
|
232 | TRY_COMPARE(spy3.count(), 3); | |
232 | } |
|
233 | } | |
233 |
|
234 | |||
234 |
|
235 | |||
@@ -296,10 +297,10 void tst_ChartDataSet::seriesCount() | |||||
296 | QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *))); |
|
297 | QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *))); | |
297 |
|
298 | |||
298 | QCOMPARE(m_dataset->seriesCount(series0->type()),3); |
|
299 | QCOMPARE(m_dataset->seriesCount(series0->type()),3); | |
299 |
|
|
300 | TRY_COMPARE(spy0.count(), 0); | |
300 |
|
|
301 | TRY_COMPARE(spy1.count(), 0); | |
301 |
|
|
302 | TRY_COMPARE(spy2.count(), 0); | |
302 |
|
|
303 | TRY_COMPARE(spy3.count(), 0); | |
303 | } |
|
304 | } | |
304 |
|
305 | |||
305 | void tst_ChartDataSet::seriesIndex_data() |
|
306 | void tst_ChartDataSet::seriesIndex_data() | |
@@ -333,10 +334,10 void tst_ChartDataSet::seriesIndex() | |||||
333 | QCOMPARE(m_dataset->seriesIndex(series1),1); |
|
334 | QCOMPARE(m_dataset->seriesIndex(series1),1); | |
334 | QCOMPARE(m_dataset->seriesIndex(series2),2); |
|
335 | QCOMPARE(m_dataset->seriesIndex(series2),2); | |
335 |
|
336 | |||
336 |
|
|
337 | TRY_COMPARE(spy0.count(), 0); | |
337 |
|
|
338 | TRY_COMPARE(spy1.count(), 0); | |
338 |
|
|
339 | TRY_COMPARE(spy2.count(), 0); | |
339 |
|
|
340 | TRY_COMPARE(spy3.count(), 0); | |
340 |
|
341 | |||
341 | m_dataset->removeSeries(series0); |
|
342 | m_dataset->removeSeries(series0); | |
342 | m_dataset->removeSeries(series1); |
|
343 | m_dataset->removeSeries(series1); | |
@@ -414,10 +415,10 void tst_ChartDataSet::domain() | |||||
414 | QVERIFY(m_dataset->domain(axis0)==m_dataset->domain(series0)); |
|
415 | QVERIFY(m_dataset->domain(axis0)==m_dataset->domain(series0)); | |
415 | QVERIFY(m_dataset->domain(axis1)==m_dataset->domain(series1)); |
|
416 | QVERIFY(m_dataset->domain(axis1)==m_dataset->domain(series1)); | |
416 | QVERIFY(m_dataset->domain(axis2)==m_dataset->domain(series2)); |
|
417 | QVERIFY(m_dataset->domain(axis2)==m_dataset->domain(series2)); | |
417 |
|
|
418 | TRY_COMPARE(spy0.count(), 0); | |
418 |
|
|
419 | TRY_COMPARE(spy1.count(), 0); | |
419 |
|
|
420 | TRY_COMPARE(spy2.count(), 0); | |
420 |
|
|
421 | TRY_COMPARE(spy3.count(), 0); | |
421 | } |
|
422 | } | |
422 |
|
423 | |||
423 | void tst_ChartDataSet::zoomInDomain_data() |
|
424 | void tst_ChartDataSet::zoomInDomain_data() | |
@@ -450,9 +451,9 void tst_ChartDataSet::zoomInDomain() | |||||
450 |
|
451 | |||
451 | m_dataset->zoomInDomain(QRect(0,0,100,100),QSize(1000,1000)); |
|
452 | m_dataset->zoomInDomain(QRect(0,0,100,100),QSize(1000,1000)); | |
452 |
|
453 | |||
453 |
|
|
454 | TRY_COMPARE(spy0.count(), 1); | |
454 |
|
|
455 | TRY_COMPARE(spy1.count(), 1); | |
455 |
|
|
456 | TRY_COMPARE(spy2.count(), 1); | |
456 | } |
|
457 | } | |
457 |
|
458 | |||
458 | void tst_ChartDataSet::zoomOutDomain_data() |
|
459 | void tst_ChartDataSet::zoomOutDomain_data() | |
@@ -486,9 +487,9 void tst_ChartDataSet::zoomOutDomain() | |||||
486 |
|
487 | |||
487 | m_dataset->zoomOutDomain(QRect(0,0,100,100),QSize(1000,1000)); |
|
488 | m_dataset->zoomOutDomain(QRect(0,0,100,100),QSize(1000,1000)); | |
488 |
|
489 | |||
489 |
|
|
490 | TRY_COMPARE(spy0.count(), 1); | |
490 |
|
|
491 | TRY_COMPARE(spy1.count(), 1); | |
491 |
|
|
492 | TRY_COMPARE(spy2.count(), 1); | |
492 | } |
|
493 | } | |
493 |
|
494 | |||
494 | void tst_ChartDataSet::scrollDomain_data() |
|
495 | void tst_ChartDataSet::scrollDomain_data() | |
@@ -522,9 +523,9 void tst_ChartDataSet::scrollDomain() | |||||
522 |
|
523 | |||
523 | m_dataset->scrollDomain(10,10,QSize(1000,1000)); |
|
524 | m_dataset->scrollDomain(10,10,QSize(1000,1000)); | |
524 |
|
525 | |||
525 |
|
|
526 | TRY_COMPARE(spy0.count(), 1); | |
526 |
|
|
527 | TRY_COMPARE(spy1.count(), 1); | |
527 |
|
|
528 | TRY_COMPARE(spy2.count(), 1); | |
528 | } |
|
529 | } | |
529 |
|
530 | |||
530 | QTEST_MAIN(tst_ChartDataSet) |
|
531 | QTEST_MAIN(tst_ChartDataSet) |
@@ -21,6 +21,7 | |||||
21 | #include <QtTest/QtTest> |
|
21 | #include <QtTest/QtTest> | |
22 | #include <private/domain_p.h> |
|
22 | #include <private/domain_p.h> | |
23 | #include <qaxis.h> |
|
23 | #include <qaxis.h> | |
|
24 | #include <tst_definitions.h> | |||
24 |
|
25 | |||
25 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
26 | QTCOMMERCIALCHART_USE_NAMESPACE | |
26 |
|
27 | |||
@@ -132,9 +133,9 void tst_Domain::handleAxisRangeXChanged() | |||||
132 | QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min)); |
|
133 | QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min)); | |
133 | QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max)); |
|
134 | QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max)); | |
134 |
|
135 | |||
135 |
|
|
136 | TRY_COMPARE(spy0.count(), 1); | |
136 |
|
|
137 | TRY_COMPARE(spy1.count(), 1); | |
137 |
|
|
138 | TRY_COMPARE(spy2.count(), 0); | |
138 |
|
139 | |||
139 | } |
|
140 | } | |
140 |
|
141 | |||
@@ -168,9 +169,9 void tst_Domain::handleAxisRangeYChanged() | |||||
168 | QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min)); |
|
169 | QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min)); | |
169 | QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max)); |
|
170 | QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max)); | |
170 |
|
171 | |||
171 |
|
|
172 | TRY_COMPARE(spy0.count(), 1); | |
172 |
|
|
173 | TRY_COMPARE(spy1.count(), 0); | |
173 |
|
|
174 | TRY_COMPARE(spy2.count(), 1); | |
174 | } |
|
175 | } | |
175 |
|
176 | |||
176 | void tst_Domain::isEmpty_data() |
|
177 | void tst_Domain::isEmpty_data() | |
@@ -226,9 +227,9 void tst_Domain::maxX() | |||||
226 | domain.setMaxX(maxX2); |
|
227 | domain.setMaxX(maxX2); | |
227 | QCOMPARE(domain.maxX(), maxX2); |
|
228 | QCOMPARE(domain.maxX(), maxX2); | |
228 |
|
229 | |||
229 |
|
|
230 | TRY_COMPARE(spy0.count(), count); | |
230 |
|
|
231 | TRY_COMPARE(spy1.count(), count); | |
231 |
|
|
232 | TRY_COMPARE(spy2.count(), 0); | |
232 |
|
233 | |||
233 | } |
|
234 | } | |
234 |
|
235 | |||
@@ -259,9 +260,9 void tst_Domain::maxY() | |||||
259 | domain.setMaxY(maxY2); |
|
260 | domain.setMaxY(maxY2); | |
260 | QCOMPARE(domain.maxY(), maxY2); |
|
261 | QCOMPARE(domain.maxY(), maxY2); | |
261 |
|
262 | |||
262 |
|
|
263 | TRY_COMPARE(spy0.count(), count); | |
263 |
|
|
264 | TRY_COMPARE(spy1.count(), 0); | |
264 |
|
|
265 | TRY_COMPARE(spy2.count(), count); | |
265 | } |
|
266 | } | |
266 |
|
267 | |||
267 | void tst_Domain::minX_data() |
|
268 | void tst_Domain::minX_data() | |
@@ -291,9 +292,9 void tst_Domain::minX() | |||||
291 | domain.setMinX(minX2); |
|
292 | domain.setMinX(minX2); | |
292 | QCOMPARE(domain.minX(), minX2); |
|
293 | QCOMPARE(domain.minX(), minX2); | |
293 |
|
294 | |||
294 |
|
|
295 | TRY_COMPARE(spy0.count(), count); | |
295 |
|
|
296 | TRY_COMPARE(spy1.count(), count); | |
296 |
|
|
297 | TRY_COMPARE(spy2.count(), 0); | |
297 | } |
|
298 | } | |
298 |
|
299 | |||
299 | void tst_Domain::minY_data() |
|
300 | void tst_Domain::minY_data() | |
@@ -323,9 +324,9 void tst_Domain::minY() | |||||
323 | domain.setMinY(minY2); |
|
324 | domain.setMinY(minY2); | |
324 | QCOMPARE(domain.minY(), minY2); |
|
325 | QCOMPARE(domain.minY(), minY2); | |
325 |
|
326 | |||
326 |
|
|
327 | TRY_COMPARE(spy0.count(), count); | |
327 |
|
|
328 | TRY_COMPARE(spy1.count(), 0); | |
328 |
|
|
329 | TRY_COMPARE(spy2.count(), count); | |
329 | } |
|
330 | } | |
330 |
|
331 | |||
331 | void tst_Domain::operatorEquals_data() |
|
332 | void tst_Domain::operatorEquals_data() | |
@@ -371,9 +372,9 void tst_Domain::operatorEquals() | |||||
371 | QCOMPARE(*domain1==*domain2, equals); |
|
372 | QCOMPARE(*domain1==*domain2, equals); | |
372 | QCOMPARE(*domain1!=*domain2, notEquals); |
|
373 | QCOMPARE(*domain1!=*domain2, notEquals); | |
373 |
|
374 | |||
374 |
|
|
375 | TRY_COMPARE(spy0.count(), 0); | |
375 |
|
|
376 | TRY_COMPARE(spy1.count(), 0); | |
376 |
|
|
377 | TRY_COMPARE(spy2.count(), 0); | |
377 | } |
|
378 | } | |
378 |
|
379 | |||
379 | void tst_Domain::setRange_data() |
|
380 | void tst_Domain::setRange_data() | |
@@ -407,9 +408,9 void tst_Domain::setRange() | |||||
407 | QCOMPARE(domain.minY(), minY); |
|
408 | QCOMPARE(domain.minY(), minY); | |
408 | QCOMPARE(domain.maxY(), maxY); |
|
409 | QCOMPARE(domain.maxY(), maxY); | |
409 |
|
410 | |||
410 |
|
|
411 | TRY_COMPARE(spy0.count(), 1); | |
411 |
|
|
412 | TRY_COMPARE(spy1.count(), 1); | |
412 |
|
|
413 | TRY_COMPARE(spy2.count(), 1); | |
413 |
|
414 | |||
414 | } |
|
415 | } | |
415 |
|
416 | |||
@@ -443,9 +444,9 void tst_Domain::setRangeX() | |||||
443 | QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min)); |
|
444 | QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min)); | |
444 | QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max)); |
|
445 | QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max)); | |
445 |
|
446 | |||
446 |
|
|
447 | TRY_COMPARE(spy0.count(), 1); | |
447 |
|
|
448 | TRY_COMPARE(spy1.count(), 1); | |
448 |
|
|
449 | TRY_COMPARE(spy2.count(), 0); | |
449 | } |
|
450 | } | |
450 |
|
451 | |||
451 | void tst_Domain::setRangeY_data() |
|
452 | void tst_Domain::setRangeY_data() | |
@@ -478,9 +479,9 void tst_Domain::setRangeY() | |||||
478 | QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min)); |
|
479 | QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min)); | |
479 | QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max)); |
|
480 | QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max)); | |
480 |
|
481 | |||
481 |
|
|
482 | TRY_COMPARE(spy0.count(), 1); | |
482 |
|
|
483 | TRY_COMPARE(spy1.count(), 0); | |
483 |
|
|
484 | TRY_COMPARE(spy2.count(), 1); | |
484 | } |
|
485 | } | |
485 |
|
486 | |||
486 | void tst_Domain::spanX_data() |
|
487 | void tst_Domain::spanX_data() | |
@@ -508,9 +509,9 void tst_Domain::spanX() | |||||
508 |
|
509 | |||
509 | QCOMPARE(domain.spanX(), spanX); |
|
510 | QCOMPARE(domain.spanX(), spanX); | |
510 |
|
511 | |||
511 |
|
|
512 | TRY_COMPARE(spy0.count(), 0); | |
512 |
|
|
513 | TRY_COMPARE(spy1.count(), 0); | |
513 |
|
|
514 | TRY_COMPARE(spy2.count(), 0); | |
514 | } |
|
515 | } | |
515 |
|
516 | |||
516 | void tst_Domain::spanY_data() |
|
517 | void tst_Domain::spanY_data() | |
@@ -538,9 +539,9 void tst_Domain::spanY() | |||||
538 |
|
539 | |||
539 | QCOMPARE(domain.spanY(), spanY); |
|
540 | QCOMPARE(domain.spanY(), spanY); | |
540 |
|
541 | |||
541 |
|
|
542 | TRY_COMPARE(spy0.count(), 0); | |
542 |
|
|
543 | TRY_COMPARE(spy1.count(), 0); | |
543 |
|
|
544 | TRY_COMPARE(spy2.count(), 0); | |
544 | } |
|
545 | } | |
545 |
|
546 | |||
546 | void tst_Domain::zoom_data() |
|
547 | void tst_Domain::zoom_data() | |
@@ -593,9 +594,9 void tst_Domain::zoom() | |||||
593 | QCOMPARE(domain == domain1, true); |
|
594 | QCOMPARE(domain == domain1, true); | |
594 | domain.zoomOut(rect0, size0); |
|
595 | domain.zoomOut(rect0, size0); | |
595 | QCOMPARE(domain == domain0, true); |
|
596 | QCOMPARE(domain == domain0, true); | |
596 |
|
|
597 | TRY_COMPARE(spy0.count(), 6); | |
597 |
|
|
598 | TRY_COMPARE(spy1.count(), 6); | |
598 |
|
|
599 | TRY_COMPARE(spy2.count(), 6); | |
599 |
|
600 | |||
600 | } |
|
601 | } | |
601 |
|
602 | |||
@@ -631,9 +632,9 void tst_Domain::move() | |||||
631 | result.setRange(dx, size.width() + dx, dy, size.height() + dy); |
|
632 | result.setRange(dx, size.width() + dx, dy, size.height() + dy); | |
632 |
|
633 | |||
633 | QCOMPARE(domain == result, true); |
|
634 | QCOMPARE(domain == result, true); | |
634 |
|
|
635 | TRY_COMPARE(spy0.count(), 1); | |
635 |
|
|
636 | TRY_COMPARE(spy1.count(), dx!=0?1:0); | |
636 |
|
|
637 | TRY_COMPARE(spy2.count(), dy!=0?1:0); | |
637 | } |
|
638 | } | |
638 |
|
639 | |||
639 | void tst_Domain::handleAxisXChanged_data() |
|
640 | void tst_Domain::handleAxisXChanged_data() | |
@@ -671,9 +672,9 void tst_Domain::handleAxisXChanged() | |||||
671 | QCOMPARE(resultMin, domain.minX()); |
|
672 | QCOMPARE(resultMin, domain.minX()); | |
672 | QCOMPARE(resultMax, domain.maxX()); |
|
673 | QCOMPARE(resultMax, domain.maxX()); | |
673 | QCOMPARE(resultTickCount, domain.tickXCount()); |
|
674 | QCOMPARE(resultTickCount, domain.tickXCount()); | |
674 |
|
|
675 | TRY_COMPARE(spy0.count(), 1); | |
675 |
|
|
676 | TRY_COMPARE(spy1.count(), 1); | |
676 |
|
|
677 | TRY_COMPARE(spy2.count(), 0); | |
677 |
|
678 | |||
678 | } |
|
679 | } | |
679 |
|
680 | |||
@@ -702,9 +703,9 void tst_Domain::handleAxisYChanged() | |||||
702 | QCOMPARE(resultMin, domain.minY()); |
|
703 | QCOMPARE(resultMin, domain.minY()); | |
703 | QCOMPARE(resultMax, domain.maxY()); |
|
704 | QCOMPARE(resultMax, domain.maxY()); | |
704 | QCOMPARE(resultTickCount, domain.tickYCount()); |
|
705 | QCOMPARE(resultTickCount, domain.tickYCount()); | |
705 |
|
|
706 | TRY_COMPARE(spy0.count(), 1); | |
706 |
|
|
707 | TRY_COMPARE(spy1.count(), 0); | |
707 |
|
|
708 | TRY_COMPARE(spy2.count(), 1); | |
708 | } |
|
709 | } | |
709 |
|
710 | |||
710 | QTEST_MAIN(tst_Domain) |
|
711 | QTEST_MAIN(tst_Domain) |
@@ -22,6 +22,7 | |||||
22 | #include <qchartview.h> |
|
22 | #include <qchartview.h> | |
23 | #include <qlineseries.h> |
|
23 | #include <qlineseries.h> | |
24 | #include <cmath> |
|
24 | #include <cmath> | |
|
25 | #include <tst_definitions.h> | |||
25 |
|
26 | |||
26 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
27 | QTCOMMERCIALCHART_USE_NAMESPACE | |
27 |
|
28 | |||
@@ -153,8 +154,8 void tst_QChartView::rubberBand() | |||||
153 | QTest::mouseMove(m_view->viewport(), QPoint(maxX, maxY) + padding.topLeft().toPoint()); |
|
154 | QTest::mouseMove(m_view->viewport(), QPoint(maxX, maxY) + padding.topLeft().toPoint()); | |
154 | QTest::mouseRelease(m_view->viewport(), Qt::LeftButton, 0, QPoint(maxX, maxY)+ padding.topLeft().toPoint()); |
|
155 | QTest::mouseRelease(m_view->viewport(), Qt::LeftButton, 0, QPoint(maxX, maxY)+ padding.topLeft().toPoint()); | |
155 |
|
156 | |||
156 |
|
|
157 | TRY_COMPARE(spy0.count(), Xcount); | |
157 |
|
|
158 | TRY_COMPARE(spy1.count(), Ycount); | |
158 |
|
159 | |||
159 | //this is hack since view does not get events otherwise |
|
160 | //this is hack since view does not get events otherwise | |
160 | m_view->setMouseTracking(false); |
|
161 | m_view->setMouseTracking(false); |
@@ -22,6 +22,7 | |||||
22 | #include <qlineseries.h> |
|
22 | #include <qlineseries.h> | |
23 | #include <qchartview.h> |
|
23 | #include <qchartview.h> | |
24 | #include <QStandardItemModel> |
|
24 | #include <QStandardItemModel> | |
|
25 | #include <tst_definitions.h> | |||
25 |
|
26 | |||
26 | Q_DECLARE_METATYPE(QList<QPointF>) |
|
27 | Q_DECLARE_METATYPE(QList<QPointF>) | |
27 |
|
28 | |||
@@ -173,10 +174,8 void tst_QLineSeries::append_raw() | |||||
173 | { |
|
174 | { | |
174 | QFETCH(QList<QPointF>, points); |
|
175 | QFETCH(QList<QPointF>, points); | |
175 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); |
|
176 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); | |
176 | QTest::qWait(200); |
|
|||
177 | m_series->append(points); |
|
177 | m_series->append(points); | |
178 | QTest::qWait(200); |
|
178 | TRY_COMPARE(spy0.count(), 0); | |
179 | QCOMPARE(spy0.count(), 0); |
|
|||
180 | QCOMPARE(m_series->points(), points); |
|
179 | QCOMPARE(m_series->points(), points); | |
181 | } |
|
180 | } | |
182 |
|
181 | |||
@@ -240,7 +239,7 void tst_QLineSeries::count_raw() | |||||
240 | for(int i=0 ; i< count; ++i) |
|
239 | for(int i=0 ; i< count; ++i) | |
241 | m_series->append(i,i); |
|
240 | m_series->append(i,i); | |
242 |
|
241 | |||
243 |
|
|
242 | TRY_COMPARE(spy0.count(), 0); | |
244 | QCOMPARE(m_series->count(), count); |
|
243 | QCOMPARE(m_series->count(), count); | |
245 | } |
|
244 | } | |
246 |
|
245 | |||
@@ -262,7 +261,7 void tst_QLineSeries::oper() | |||||
262 | } |
|
261 | } | |
263 |
|
262 | |||
264 | QCOMPARE(series.points(), points); |
|
263 | QCOMPARE(series.points(), points); | |
265 |
|
|
264 | TRY_COMPARE(spy0.count(), 0); | |
266 | } |
|
265 | } | |
267 |
|
266 | |||
268 |
|
267 | |||
@@ -283,7 +282,7 void tst_QLineSeries::pen() | |||||
283 | QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&))); |
|
282 | QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&))); | |
284 | series.setPen(pen); |
|
283 | series.setPen(pen); | |
285 |
|
284 | |||
286 |
|
|
285 | TRY_COMPARE(spy0.count(), 0); | |
287 | QCOMPARE(series.pen(), pen); |
|
286 | QCOMPARE(series.pen(), pen); | |
288 |
|
287 | |||
289 | m_chart->addSeries(&series); |
|
288 | m_chart->addSeries(&series); | |
@@ -308,7 +307,7 void tst_QLineSeries::pointsVisible_raw() | |||||
308 | QFETCH(bool, pointsVisible); |
|
307 | QFETCH(bool, pointsVisible); | |
309 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); |
|
308 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); | |
310 | m_series->setPointsVisible(pointsVisible); |
|
309 | m_series->setPointsVisible(pointsVisible); | |
311 |
|
|
310 | TRY_COMPARE(spy0.count(), 0); | |
312 | QCOMPARE(m_series->pointsVisible(), pointsVisible); |
|
311 | QCOMPARE(m_series->pointsVisible(), pointsVisible); | |
313 | } |
|
312 | } | |
314 |
|
313 | |||
@@ -322,17 +321,13 void tst_QLineSeries::remove_raw() | |||||
322 | QFETCH(QList<QPointF>, points); |
|
321 | QFETCH(QList<QPointF>, points); | |
323 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); |
|
322 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); | |
324 | m_series->append(points); |
|
323 | m_series->append(points); | |
325 | QTest::qWait(200); |
|
324 | TRY_COMPARE(spy0.count(), 0); | |
326 | QCOMPARE(spy0.count(), 0); |
|
|||
327 | QCOMPARE(m_series->points(), points); |
|
325 | QCOMPARE(m_series->points(), points); | |
328 |
|
326 | |||
329 | foreach(const QPointF& point,points) |
|
327 | foreach(const QPointF& point,points) | |
330 | { |
|
|||
331 | m_series->remove(point); |
|
328 | m_series->remove(point); | |
332 | QTest::qWait(200); |
|
|||
333 | } |
|
|||
334 |
|
329 | |||
335 |
|
|
330 | TRY_COMPARE(spy0.count(), 0); | |
336 | QCOMPARE(m_series->points().count(), 0); |
|
331 | QCOMPARE(m_series->points().count(), 0); | |
337 | } |
|
332 | } | |
338 |
|
333 | |||
@@ -371,12 +366,10 void tst_QLineSeries::removeAll_raw() | |||||
371 | QFETCH(QList<QPointF>, points); |
|
366 | QFETCH(QList<QPointF>, points); | |
372 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); |
|
367 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); | |
373 | m_series->append(points); |
|
368 | m_series->append(points); | |
374 |
|
|
369 | TRY_COMPARE(spy0.count(), 0); | |
375 | QCOMPARE(m_series->points(), points); |
|
370 | QCOMPARE(m_series->points(), points); | |
376 | QTest::qWait(200); |
|
|||
377 | m_series->removeAll(); |
|
371 | m_series->removeAll(); | |
378 | QTest::qWait(200); |
|
372 | TRY_COMPARE(spy0.count(), 0); | |
379 | QCOMPARE(spy0.count(), 0); |
|
|||
380 | QCOMPARE(m_series->points().count(), 0); |
|
373 | QCOMPARE(m_series->points().count(), 0); | |
381 | } |
|
374 | } | |
382 |
|
375 | |||
@@ -414,15 +407,11 void tst_QLineSeries::replace_raw() | |||||
414 | QFETCH(QList<QPointF>, points); |
|
407 | QFETCH(QList<QPointF>, points); | |
415 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); |
|
408 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); | |
416 | m_series->append(points); |
|
409 | m_series->append(points); | |
417 |
|
|
410 | TRY_COMPARE(spy0.count(), 0); | |
418 | QCOMPARE(m_series->points(), points); |
|
411 | QCOMPARE(m_series->points(), points); | |
419 | QTest::qWait(200); |
|
|||
420 |
|
412 | |||
421 | foreach(const QPointF& point,points) |
|
413 | foreach(const QPointF& point,points) | |
422 | { |
|
414 | m_series->replace(point.x(),point.y(),point.x(),0); | |
423 | m_series->replace(point.x(),point.y(),point.x(),0); |
|
|||
424 | QTest::qWait(200); |
|
|||
425 | } |
|
|||
426 |
|
415 | |||
427 | QList<QPointF> newPoints = m_series->points(); |
|
416 | QList<QPointF> newPoints = m_series->points(); | |
428 |
|
417 |
@@ -21,6 +21,7 | |||||
21 | #include <QtTest/QtTest> |
|
21 | #include <QtTest/QtTest> | |
22 | #include <qpieseries.h> |
|
22 | #include <qpieseries.h> | |
23 | #include <qpieslice.h> |
|
23 | #include <qpieslice.h> | |
|
24 | #include <tst_definitions.h> | |||
24 |
|
25 | |||
25 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
26 | QTCOMMERCIALCHART_USE_NAMESPACE | |
26 |
|
27 | |||
@@ -187,9 +188,9 void tst_qpieseries::remove() | |||||
187 | QCOMPARE(s.count(), 0); |
|
188 | QCOMPARE(s.count(), 0); | |
188 |
|
189 | |||
189 | // check that slices were actually destroyed |
|
190 | // check that slices were actually destroyed | |
190 |
|
|
191 | TRY_COMPARE(spy1.count(), 1); | |
191 |
|
|
192 | TRY_COMPARE(spy2.count(), 1); | |
192 |
|
|
193 | TRY_COMPARE(spy3.count(), 1); | |
193 | } |
|
194 | } | |
194 |
|
195 | |||
195 | /* |
|
196 | /* |
@@ -20,6 +20,7 | |||||
20 |
|
20 | |||
21 | #include <QtTest/QtTest> |
|
21 | #include <QtTest/QtTest> | |
22 | #include <qpieslice.h> |
|
22 | #include <qpieslice.h> | |
|
23 | #include <tst_definitions.h> | |||
23 |
|
24 | |||
24 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
25 | QTCOMMERCIALCHART_USE_NAMESPACE | |
25 |
|
26 | |||
@@ -122,7 +123,7 void tst_qpieslice::changedSignals() | |||||
122 | slice.setLabelArmLengthFactor(0.1); |
|
123 | slice.setLabelArmLengthFactor(0.1); | |
123 | slice.setExplodeDistanceFactor(0.1); |
|
124 | slice.setExplodeDistanceFactor(0.1); | |
124 | slice.setExplodeDistanceFactor(0.1); |
|
125 | slice.setExplodeDistanceFactor(0.1); | |
125 |
|
|
126 | TRY_COMPARE(spy.count(), 10); | |
126 | } |
|
127 | } | |
127 |
|
128 | |||
128 | QTEST_MAIN(tst_qpieslice) |
|
129 | QTEST_MAIN(tst_qpieslice) |
General Comments 0
You need to be logged in to leave comments.
Login now