##// END OF EJS Templates
barseries autotest update
sauimone -
r1287:b2453e3ca679
parent child
Show More
@@ -113,7 +113,7 QVector<QRectF> BarChartItem::calculateLayout()
113 qreal scaleY = (height / rangeY);
113 qreal scaleY = (height / rangeY);
114 qreal scaleX = (width / rangeX);
114 qreal scaleX = (width / rangeX);
115 qreal categoryWidth = width / categoryCount;
115 qreal categoryWidth = width / categoryCount;
116 qreal barWidth = categoryWidth / setCount - categoryWidth * m_series->d_func()->barMargin();
116 qreal barWidth = categoryWidth - categoryWidth * m_series->d_func()->barMargin();
117
117
118 int itemIndex(0);
118 int itemIndex(0);
119 for (int category = 0; category < categoryCount; category++) {
119 for (int category = 0; category < categoryCount; category++) {
@@ -442,8 +442,6 void tst_QBarSeries::mouseclicked()
442 *set2 << QPointF(0.3,10) << QPointF(1.3,10) << QPointF(2.3,10);
442 *set2 << QPointF(0.3,10) << QPointF(1.3,10) << QPointF(2.3,10);
443 series->append(set2);
443 series->append(set2);
444
444
445 QSignalSpy setSpy1(set1, SIGNAL(clicked(QString)));
446 QSignalSpy setSpy2(set2, SIGNAL(clicked(QString)));
447 QSignalSpy seriesSpy(series,SIGNAL(clicked(QBarSet*,QString)));
445 QSignalSpy seriesSpy(series,SIGNAL(clicked(QBarSet*,QString)));
448
446
449 QChartView view(new QChart());
447 QChartView view(new QChart());
@@ -454,109 +452,75 void tst_QBarSeries::mouseclicked()
454
452
455 //====================================================================================
453 //====================================================================================
456 // barset 1, category test1
454 // barset 1, category test1
457 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(105,180));
455 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(106,142));
458 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
456 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
459
457
460 QCOMPARE(setSpy1.count(), 1);
461 QCOMPARE(setSpy2.count(), 0);
462 QCOMPARE(seriesSpy.count(), 1);
458 QCOMPARE(seriesSpy.count(), 1);
463 QList<QVariant> setSpyArg = setSpy1.takeFirst();
464 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
465 QVERIFY(setSpyArg.at(0).toString().compare(QString("test1")) == 0);
466
459
467 QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
460 QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
468 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
461 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
462 QVERIFY(seriesSpyArg.at(1).type() == QVariant::String);
463 QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test1")) == 0);
469
464
470 //====================================================================================
465 //====================================================================================
471 // barset 1, category test2
466 // barset 1, category test2
472 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(200,180));
467 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(199,142));
473 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
468 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
474
469
475 QCOMPARE(setSpy1.count(), 1);
476 QCOMPARE(setSpy2.count(), 0);
477 QCOMPARE(seriesSpy.count(), 1);
470 QCOMPARE(seriesSpy.count(), 1);
478 setSpyArg = setSpy1.takeFirst();
479 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
480 QVERIFY(setSpyArg.at(0).toString().compare(QString("test2")) == 0);
481
471
482 seriesSpyArg = seriesSpy.takeFirst();
472 seriesSpyArg = seriesSpy.takeFirst();
483 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
473 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
474 QVERIFY(seriesSpyArg.at(1).type() == QVariant::String);
475 QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test2")) == 0);
484
476
485 //====================================================================================
477 //====================================================================================
486 // barset 1, category test3
478 // barset 1, category test3
487 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(295,180));
479 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(291,142));
488 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
480 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
489
481
490 QCOMPARE(setSpy1.count(), 1);
491 QCOMPARE(setSpy2.count(), 0);
492 QCOMPARE(seriesSpy.count(), 1);
482 QCOMPARE(seriesSpy.count(), 1);
493 setSpyArg = setSpy1.takeFirst();
494 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
495 QVERIFY(setSpyArg.at(0).toString().compare(QString("test3")) == 0);
496
483
497 seriesSpyArg = seriesSpy.takeFirst();
484 seriesSpyArg = seriesSpy.takeFirst();
498 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
485 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
486 QVERIFY(seriesSpyArg.at(1).type() == QVariant::String);
487 QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test3")) == 0);
499
488
500 //====================================================================================
489 //====================================================================================
501 // barset 2, category test1
490 // barset 2, category test1
502 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(145,180));
491 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(134,142));
503 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
492 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
504
493
505 QCOMPARE(setSpy1.count(), 0);
506 QCOMPARE(setSpy2.count(), 1);
507 QCOMPARE(seriesSpy.count(), 1);
494 QCOMPARE(seriesSpy.count(), 1);
508 setSpyArg = setSpy2.takeFirst();
509 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
510 QVERIFY(setSpyArg.at(0).toString().compare(QString("test1")) == 0);
511
495
512 seriesSpyArg = seriesSpy.takeFirst();
496 seriesSpyArg = seriesSpy.takeFirst();
513 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
497 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
498 QVERIFY(seriesSpyArg.at(1).type() == QVariant::String);
499 QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test1")) == 0);
514
500
515 //====================================================================================
501 //====================================================================================
516 // barset 2, category test2
502 // barset 2, category test2
517 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(240,180));
503 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(227,142));
518 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
504 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
519
505
520 QCOMPARE(setSpy1.count(), 0);
521 QCOMPARE(setSpy2.count(), 1);
522 QCOMPARE(seriesSpy.count(), 1);
506 QCOMPARE(seriesSpy.count(), 1);
523 setSpyArg = setSpy2.takeFirst();
524 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
525 QVERIFY(setSpyArg.at(0).toString().compare(QString("test2")) == 0);
526
507
527 seriesSpyArg = seriesSpy.takeFirst();
508 seriesSpyArg = seriesSpy.takeFirst();
528 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
509 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
510 QVERIFY(seriesSpyArg.at(1).type() == QVariant::String);
511 QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test2")) == 0);
529
512
530 //====================================================================================
513 //====================================================================================
531 // barset 2, category test3
514 // barset 2, category test3
532 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(335,180));
515 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(319,142));
533 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
516 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
534
517
535 QCOMPARE(setSpy1.count(), 0);
536 QCOMPARE(setSpy2.count(), 1);
537 QCOMPARE(seriesSpy.count(), 1);
518 QCOMPARE(seriesSpy.count(), 1);
538 setSpyArg = setSpy2.takeFirst();
539 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
540 QVERIFY(setSpyArg.at(0).toString().compare(QString("test3")) == 0);
541
519
542 seriesSpyArg = seriesSpy.takeFirst();
520 seriesSpyArg = seriesSpy.takeFirst();
543 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
521 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
544
522 QVERIFY(seriesSpyArg.at(1).type() == QVariant::String);
545 //====================================================================================
523 QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test3")) == 0);
546 // no event cases
547 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(1,1)); // Outside of both sets
548 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(1,1)); // Right mouse button outside and inside sets
549 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(105,180)); // barset 1, category test1
550 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(200,180)); // barset 1, category test2
551 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(295,180)); // barset 1, category test3
552 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(145,180)); // barset 2, category test1
553 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(240,180)); // barset 2, category test2
554 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(335,180)); // barset 2, category test3
555
556 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
557 QCOMPARE(setSpy1.count(), 0);
558 QCOMPARE(setSpy2.count(), 0);
559 QCOMPARE(seriesSpy.count(), 0);
560 }
524 }
561
525
562 void tst_QBarSeries::mousehovered_data()
526 void tst_QBarSeries::mousehovered_data()
@@ -579,8 +543,6 void tst_QBarSeries::mousehovered()
579 *set2 << QPointF(0.3,10) << QPointF(1.3,10) << QPointF(2.3,10);
543 *set2 << QPointF(0.3,10) << QPointF(1.3,10) << QPointF(2.3,10);
580 series->append(set2);
544 series->append(set2);
581
545
582 QSignalSpy setSpy1(set1, SIGNAL(hovered(bool)));
583 QSignalSpy setSpy2(set2, SIGNAL(hovered(bool)));
584 QSignalSpy seriesSpy(series,SIGNAL(hovered(QBarSet*,bool)));
546 QSignalSpy seriesSpy(series,SIGNAL(hovered(QBarSet*,bool)));
585
547
586 QChartView view(new QChart());
548 QChartView view(new QChart());
@@ -589,48 +551,33 void tst_QBarSeries::mousehovered()
589 view.show();
551 view.show();
590 QTest::qWaitForWindowShown(&view);
552 QTest::qWaitForWindowShown(&view);
591
553
554 //this is hack since view does not get events otherwise
555 view.setMouseTracking(true);
556
592 //=======================================================================
557 //=======================================================================
593 // move mouse to left border
558 // move mouse to left border
594 QTest::mouseMove(view.viewport(), QPoint(0, 180));
559 QTest::mouseMove(view.viewport(), QPoint(0, 142));
595
560
596 QVERIFY(setSpy1.count() == 0);
597 QVERIFY(setSpy2.count() == 0);
598 QVERIFY(seriesSpy.count() == 0);
561 QVERIFY(seriesSpy.count() == 0);
599
562
600 //=======================================================================
563 //=======================================================================
601 // move mouse on top of set1
564 // move mouse on top of set1
602 QTest::mouseMove(view.viewport(), QPoint(105,180));
565 QTest::mouseMove(view.viewport(), QPoint(106,142));
603
566
604 QVERIFY(setSpy1.count() == 1);
605 QVERIFY(setSpy2.count() == 0);
606 QVERIFY(seriesSpy.count() == 1);
567 QVERIFY(seriesSpy.count() == 1);
607
568
608 QList<QVariant> setSpyArg = setSpy1.takeFirst();
609 QVERIFY(setSpyArg.at(0).type() == QVariant::Bool);
610 QVERIFY(setSpyArg.at(0).toBool() == true);
611
612 QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
569 QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
613 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
570 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
571 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
572 QVERIFY(seriesSpyArg.at(1).toBool() == true);
614
573
615 //=======================================================================
574 //=======================================================================
616 // move mouse from top of set1 to top of set2
575 // move mouse from top of set1 to top of set2
617 QTest::mouseMove(view.viewport(), QPoint(145,180));
576 QTest::mouseMove(view.viewport(), QPoint(134,142));
618
577
619 QVERIFY(setSpy1.count() == 1);
620 QVERIFY(setSpy2.count() == 1);
621 QVERIFY(seriesSpy.count() == 2);
578 QVERIFY(seriesSpy.count() == 2);
622
579
623 // should leave set1
580 // should leave set1
624 setSpyArg = setSpy1.takeFirst();
625 QVERIFY(setSpyArg.at(0).type() == QVariant::Bool);
626 QVERIFY(setSpyArg.at(0).toBool() == false);
627
628 // should enter set2
629 setSpyArg = setSpy2.takeFirst();
630 QVERIFY(setSpyArg.at(0).type() == QVariant::Bool);
631 QVERIFY(setSpyArg.at(0).toBool() == true);
632
633 // should leave set1
634 seriesSpyArg = seriesSpy.takeFirst();
581 seriesSpyArg = seriesSpy.takeFirst();
635 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
582 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
636 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
583 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
@@ -644,29 +591,16 void tst_QBarSeries::mousehovered()
644
591
645 //=======================================================================
592 //=======================================================================
646 // move mouse from top of set2 to background
593 // move mouse from top of set2 to background
647 QTest::mouseMove(view.viewport(), QPoint(175,180));
594 QTest::mouseMove(view.viewport(), QPoint(134,0));
648
649 QVERIFY(setSpy1.count() == 0);
650 QVERIFY(setSpy2.count() == 1);
651 QVERIFY(seriesSpy.count() == 1);
595 QVERIFY(seriesSpy.count() == 1);
652
596
653 // should leave set2 (event via set)
597 // should leave set2
654 setSpyArg = setSpy2.takeFirst();
655 QVERIFY(setSpyArg.at(0).type() == QVariant::Bool);
656 QVERIFY(setSpyArg.at(0).toBool() == false);
657
658 // should leave set2 (event via series)
659 seriesSpyArg = seriesSpy.takeFirst();
598 seriesSpyArg = seriesSpy.takeFirst();
660 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
599 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
661 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
600 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
662 QVERIFY(seriesSpyArg.at(1).toBool() == false);
601 QVERIFY(seriesSpyArg.at(1).toBool() == false);
663 }
602 }
664
603
665 /*
666 bool setModel(QAbstractItemModel *model);
667 void setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation = Qt::Vertical);
668 void setModelMappingRange(int first, int count = -1);
669 */
670 QTEST_MAIN(tst_QBarSeries)
604 QTEST_MAIN(tst_QBarSeries)
671
605
672 #include "tst_qbarseries.moc"
606 #include "tst_qbarseries.moc"
@@ -114,8 +114,6 void tst_QGroupedBarSeries::mouseclicked()
114 *set2 << 10 << 10 << 10;
114 *set2 << 10 << 10 << 10;
115 series->append(set2);
115 series->append(set2);
116
116
117 QSignalSpy setSpy1(set1, SIGNAL(clicked(QString)));
118 QSignalSpy setSpy2(set2, SIGNAL(clicked(QString)));
119 QSignalSpy seriesSpy(series,SIGNAL(clicked(QBarSet*,QString)));
117 QSignalSpy seriesSpy(series,SIGNAL(clicked(QBarSet*,QString)));
120
118
121 QChartView view(new QChart());
119 QChartView view(new QChart());
@@ -126,109 +124,75 void tst_QGroupedBarSeries::mouseclicked()
126
124
127 //====================================================================================
125 //====================================================================================
128 // barset 1, category test1
126 // barset 1, category test1
129 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(90,180));
127 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(95,143));
130 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
128 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
131
129
132 QCOMPARE(setSpy1.count(), 1);
133 QCOMPARE(setSpy2.count(), 0);
134 QCOMPARE(seriesSpy.count(), 1);
130 QCOMPARE(seriesSpy.count(), 1);
135 QList<QVariant> setSpyArg = setSpy1.takeFirst();
136 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
137 QVERIFY(setSpyArg.at(0).toString().compare(QString("test1")) == 0);
138
131
139 QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
132 QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
140 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
133 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
134 QVERIFY(seriesSpyArg.at(1).type() == QVariant::String);
135 QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test1")) == 0);
141
136
142 //====================================================================================
137 //====================================================================================
143 // barset 1, category test2
138 // barset 1, category test2
144 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(185,180));
139 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(187,143));
145 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
140 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
146
141
147 QCOMPARE(setSpy1.count(), 1);
148 QCOMPARE(setSpy2.count(), 0);
149 QCOMPARE(seriesSpy.count(), 1);
142 QCOMPARE(seriesSpy.count(), 1);
150 setSpyArg = setSpy1.takeFirst();
151 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
152 QVERIFY(setSpyArg.at(0).toString().compare(QString("test2")) == 0);
153
143
154 seriesSpyArg = seriesSpy.takeFirst();
144 seriesSpyArg = seriesSpy.takeFirst();
155 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
145 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
146 QVERIFY(seriesSpyArg.at(1).type() == QVariant::String);
147 QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test2")) == 0);
156
148
157 //====================================================================================
149 //====================================================================================
158 // barset 1, category test3
150 // barset 1, category test3
159 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(280,180));
151 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(280,143));
160 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
152 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
161
153
162 QCOMPARE(setSpy1.count(), 1);
163 QCOMPARE(setSpy2.count(), 0);
164 QCOMPARE(seriesSpy.count(), 1);
154 QCOMPARE(seriesSpy.count(), 1);
165 setSpyArg = setSpy1.takeFirst();
166 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
167 QVERIFY(setSpyArg.at(0).toString().compare(QString("test3")) == 0);
168
155
169 seriesSpyArg = seriesSpy.takeFirst();
156 seriesSpyArg = seriesSpy.takeFirst();
170 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
157 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
158 QVERIFY(seriesSpyArg.at(1).type() == QVariant::String);
159 QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test3")) == 0);
171
160
172 //====================================================================================
161 //====================================================================================
173 // barset 2, category test1
162 // barset 2, category test1
174 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(135,180));
163 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(118,143));
175 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
164 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
176
165
177 QCOMPARE(setSpy1.count(), 0);
178 QCOMPARE(setSpy2.count(), 1);
179 QCOMPARE(seriesSpy.count(), 1);
166 QCOMPARE(seriesSpy.count(), 1);
180 setSpyArg = setSpy2.takeFirst();
181 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
182 QVERIFY(setSpyArg.at(0).toString().compare(QString("test1")) == 0);
183
167
184 seriesSpyArg = seriesSpy.takeFirst();
168 seriesSpyArg = seriesSpy.takeFirst();
185 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
169 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
170 QVERIFY(seriesSpyArg.at(1).type() == QVariant::String);
171 QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test1")) == 0);
186
172
187 //====================================================================================
173 //====================================================================================
188 // barset 2, category test2
174 // barset 2, category test2
189 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(230,180));
175 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(210,143));
190 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
176 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
191
177
192 QCOMPARE(setSpy1.count(), 0);
193 QCOMPARE(setSpy2.count(), 1);
194 QCOMPARE(seriesSpy.count(), 1);
178 QCOMPARE(seriesSpy.count(), 1);
195 setSpyArg = setSpy2.takeFirst();
196 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
197 QVERIFY(setSpyArg.at(0).toString().compare(QString("test2")) == 0);
198
179
199 seriesSpyArg = seriesSpy.takeFirst();
180 seriesSpyArg = seriesSpy.takeFirst();
200 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
181 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
182 QVERIFY(seriesSpyArg.at(1).type() == QVariant::String);
183 QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test2")) == 0);
201
184
202 //====================================================================================
185 //====================================================================================
203 // barset 2, category test3
186 // barset 2, category test3
204 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(320,180));
187 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(303,143));
205 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
188 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
206
189
207 QCOMPARE(setSpy1.count(), 0);
208 QCOMPARE(setSpy2.count(), 1);
209 QCOMPARE(seriesSpy.count(), 1);
190 QCOMPARE(seriesSpy.count(), 1);
210 setSpyArg = setSpy2.takeFirst();
211 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
212 QVERIFY(setSpyArg.at(0).toString().compare(QString("test3")) == 0);
213
191
214 seriesSpyArg = seriesSpy.takeFirst();
192 seriesSpyArg = seriesSpy.takeFirst();
215 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
193 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
216
194 QVERIFY(seriesSpyArg.at(1).type() == QVariant::String);
217 //====================================================================================
195 QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test3")) == 0);
218 // no event cases
219 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(1,1)); // Outside of both sets
220 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(1,1)); // Right mouse button outside and inside sets
221 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(900,180)); // barset 1, category test1
222 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(185,180)); // barset 1, category test2
223 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(280,180)); // barset 1, category test3
224 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(135,180)); // barset 2, category test1
225 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(230,180)); // barset 2, category test2
226 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(320,180)); // barset 2, category test3
227
228 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
229 QCOMPARE(setSpy1.count(), 0);
230 QCOMPARE(setSpy2.count(), 0);
231 QCOMPARE(seriesSpy.count(), 0);
232 }
196 }
233
197
234 void tst_QGroupedBarSeries::mousehovered_data()
198 void tst_QGroupedBarSeries::mousehovered_data()
@@ -251,8 +215,6 void tst_QGroupedBarSeries::mousehovered()
251 *set2 << 10 << 10 << 10;
215 *set2 << 10 << 10 << 10;
252 series->append(set2);
216 series->append(set2);
253
217
254 QSignalSpy setSpy1(set1, SIGNAL(hovered(bool)));
255 QSignalSpy setSpy2(set2, SIGNAL(hovered(bool)));
256 QSignalSpy seriesSpy(series,SIGNAL(hovered(QBarSet*,bool)));
218 QSignalSpy seriesSpy(series,SIGNAL(hovered(QBarSet*,bool)));
257
219
258 QChartView view(new QChart());
220 QChartView view(new QChart());
@@ -260,7 +222,6 void tst_QGroupedBarSeries::mousehovered()
260 view.chart()->addSeries(series);
222 view.chart()->addSeries(series);
261 view.show();
223 view.show();
262 QTest::qWaitForWindowShown(&view);
224 QTest::qWaitForWindowShown(&view);
263 // QTest::qWait(1000*20);
264
225
265 //this is hack since view does not get events otherwise
226 //this is hack since view does not get events otherwise
266 view.setMouseTracking(true);
227 view.setMouseTracking(true);
@@ -268,51 +229,33 void tst_QGroupedBarSeries::mousehovered()
268 //=======================================================================
229 //=======================================================================
269 // move mouse to left border
230 // move mouse to left border
270 qDebug() << "move mouse to left border";
231 qDebug() << "move mouse to left border";
271 QTest::mouseMove(view.viewport(), QPoint(0, 180));
232 QTest::mouseMove(view.viewport(), QPoint(0, 143));
272 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
233 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
273
234
274 QVERIFY(setSpy1.count() == 0);
275 QVERIFY(setSpy2.count() == 0);
276 QVERIFY(seriesSpy.count() == 0);
235 QVERIFY(seriesSpy.count() == 0);
277
236
278 //=======================================================================
237 //=======================================================================
279 // move mouse on top of set1
238 // move mouse on top of set1
280 qDebug() << "move mouse on top of set1";
239 qDebug() << "move mouse on top of set1";
281 QTest::mouseMove(view.viewport(), QPoint(90,180));
240 QTest::mouseMove(view.viewport(), QPoint(95,143));
282 QCoreApplication::processEvents(QEventLoop::AllEvents, 10000);
241 QCoreApplication::processEvents(QEventLoop::AllEvents, 10000);
283
242
284 QVERIFY(setSpy1.count() == 1);
285 QVERIFY(setSpy2.count() == 0);
286 QVERIFY(seriesSpy.count() == 1);
243 QVERIFY(seriesSpy.count() == 1);
287
244
288 QList<QVariant> setSpyArg = setSpy1.takeFirst();
289 QVERIFY(setSpyArg.at(0).type() == QVariant::Bool);
290 QVERIFY(setSpyArg.at(0).toBool() == true);
291
292 QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
245 QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
293 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
246 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
247 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
248 QVERIFY(seriesSpyArg.at(1).toBool() == true);
294
249
295 //=======================================================================
250 //=======================================================================
296 // move mouse from top of set1 to top of set2
251 // move mouse from top of set1 to top of set2
297 qDebug() << "move mouse from top of set1 to top of set2";
252 qDebug() << "move mouse from top of set1 to top of set2";
298 QTest::mouseMove(view.viewport(), QPoint(135,180));
253 QTest::mouseMove(view.viewport(), QPoint(118,143));
299 QCoreApplication::processEvents(QEventLoop::AllEvents, 10000);
254 QCoreApplication::processEvents(QEventLoop::AllEvents, 10000);
300
255
301 QVERIFY(setSpy1.count() == 1);
302 QVERIFY(setSpy2.count() == 1);
303 QVERIFY(seriesSpy.count() == 2);
256 QVERIFY(seriesSpy.count() == 2);
304
257
305 // should leave set1
258 // should leave set1
306 setSpyArg = setSpy1.takeFirst();
307 QVERIFY(setSpyArg.at(0).type() == QVariant::Bool);
308 QVERIFY(setSpyArg.at(0).toBool() == false);
309
310 // should enter set2
311 setSpyArg = setSpy2.takeFirst();
312 QVERIFY(setSpyArg.at(0).type() == QVariant::Bool);
313 QVERIFY(setSpyArg.at(0).toBool() == true);
314
315 // should leave set1
316 seriesSpyArg = seriesSpy.takeFirst();
259 seriesSpyArg = seriesSpy.takeFirst();
317 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
260 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
318 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
261 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
@@ -328,19 +271,12 void tst_QGroupedBarSeries::mousehovered()
328 // move mouse from top of set2 to background
271 // move mouse from top of set2 to background
329 qDebug() << "move mouse from top of set2 to background";
272 qDebug() << "move mouse from top of set2 to background";
330
273
331 QTest::mouseMove(view.viewport(), QPoint(135,0));
274 QTest::mouseMove(view.viewport(), QPoint(118,0));
332 QCoreApplication::processEvents(QEventLoop::AllEvents, 10000);
275 QCoreApplication::processEvents(QEventLoop::AllEvents, 10000);
333
276
334 QVERIFY(setSpy1.count() == 0);
335 QVERIFY(setSpy2.count() == 1);
336 QVERIFY(seriesSpy.count() == 1);
277 QVERIFY(seriesSpy.count() == 1);
337
278
338 // should leave set2 (event via set)
279 // should leave set2
339 setSpyArg = setSpy2.takeFirst();
340 QVERIFY(setSpyArg.at(0).type() == QVariant::Bool);
341 QVERIFY(setSpyArg.at(0).toBool() == false);
342
343 // should leave set2 (event via series)
344 seriesSpyArg = seriesSpy.takeFirst();
280 seriesSpyArg = seriesSpy.takeFirst();
345 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
281 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
346 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
282 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
@@ -112,8 +112,6 void tst_QPercentBarSeries::mouseclicked()
112 *set2 << 10 << 10 << 10;
112 *set2 << 10 << 10 << 10;
113 series->append(set2);
113 series->append(set2);
114
114
115 QSignalSpy setSpy1(set1, SIGNAL(clicked(QString)));
116 QSignalSpy setSpy2(set2, SIGNAL(clicked(QString)));
117 QSignalSpy seriesSpy(series,SIGNAL(clicked(QBarSet*,QString)));
115 QSignalSpy seriesSpy(series,SIGNAL(clicked(QBarSet*,QString)));
118
116
119 QChartView view(new QChart());
117 QChartView view(new QChart());
@@ -124,109 +122,69 void tst_QPercentBarSeries::mouseclicked()
124
122
125 //====================================================================================
123 //====================================================================================
126 // barset 1, category test1
124 // barset 1, category test1
127 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(115,230));
125 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(106,190));
128 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
126 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
129
127
130 QCOMPARE(setSpy1.count(), 1);
131 QCOMPARE(setSpy2.count(), 0);
132 QCOMPARE(seriesSpy.count(), 1);
128 QCOMPARE(seriesSpy.count(), 1);
133 QList<QVariant> setSpyArg = setSpy1.takeFirst();
134 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
135 QVERIFY(setSpyArg.at(0).toString().compare(QString("test1")) == 0);
136
129
137 QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
130 QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
138 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
131 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
132 QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test1")) == 0);
139
133
140 //====================================================================================
134 //====================================================================================
141 // barset 1, category test2
135 // barset 1, category test2
142 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(205,230));
136 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(199,190));
143 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
137 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
144
138
145 QCOMPARE(setSpy1.count(), 1);
146 QCOMPARE(setSpy2.count(), 0);
147 QCOMPARE(seriesSpy.count(), 1);
139 QCOMPARE(seriesSpy.count(), 1);
148 setSpyArg = setSpy1.takeFirst();
149 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
150 QVERIFY(setSpyArg.at(0).toString().compare(QString("test2")) == 0);
151
140
152 seriesSpyArg = seriesSpy.takeFirst();
141 seriesSpyArg = seriesSpy.takeFirst();
153 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
142 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
143 QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test2")) == 0);
154
144
155 //====================================================================================
145 //====================================================================================
156 // barset 1, category test3
146 // barset 1, category test3
157 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(300,230));
147 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(292,190));
158 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
148 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
159
149
160 QCOMPARE(setSpy1.count(), 1);
161 QCOMPARE(setSpy2.count(), 0);
162 QCOMPARE(seriesSpy.count(), 1);
150 QCOMPARE(seriesSpy.count(), 1);
163 setSpyArg = setSpy1.takeFirst();
164 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
165 QVERIFY(setSpyArg.at(0).toString().compare(QString("test3")) == 0);
166
151
167 seriesSpyArg = seriesSpy.takeFirst();
152 seriesSpyArg = seriesSpy.takeFirst();
168 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
153 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
154 QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test3")) == 0);
169
155
170 //====================================================================================
156 //====================================================================================
171 // barset 2, category test1
157 // barset 2, category test1
172 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(115,140));
158 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(106,95));
173 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
159 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
174
160
175 QCOMPARE(setSpy1.count(), 0);
176 QCOMPARE(setSpy2.count(), 1);
177 QCOMPARE(seriesSpy.count(), 1);
161 QCOMPARE(seriesSpy.count(), 1);
178 setSpyArg = setSpy2.takeFirst();
179 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
180 QVERIFY(setSpyArg.at(0).toString().compare(QString("test1")) == 0);
181
162
182 seriesSpyArg = seriesSpy.takeFirst();
163 seriesSpyArg = seriesSpy.takeFirst();
183 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
164 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
165 QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test1")) == 0);
184
166
185 //====================================================================================
167 //====================================================================================
186 // barset 2, category test2
168 // barset 2, category test2
187 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(205,140));
169 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(199,95));
188 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
170 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
189
171
190 QCOMPARE(setSpy1.count(), 0);
191 QCOMPARE(setSpy2.count(), 1);
192 QCOMPARE(seriesSpy.count(), 1);
172 QCOMPARE(seriesSpy.count(), 1);
193 setSpyArg = setSpy2.takeFirst();
194 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
195 QVERIFY(setSpyArg.at(0).toString().compare(QString("test2")) == 0);
196
173
197 seriesSpyArg = seriesSpy.takeFirst();
174 seriesSpyArg = seriesSpy.takeFirst();
198 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
175 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
176 QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test2")) == 0);
199
177
200 //====================================================================================
178 //====================================================================================
201 // barset 2, category test3
179 // barset 2, category test3
202 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(300,140));
180 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(292,95));
203 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
181 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
204
182
205 QCOMPARE(setSpy1.count(), 0);
206 QCOMPARE(setSpy2.count(), 1);
207 QCOMPARE(seriesSpy.count(), 1);
183 QCOMPARE(seriesSpy.count(), 1);
208 setSpyArg = setSpy2.takeFirst();
209 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
210 QVERIFY(setSpyArg.at(0).toString().compare(QString("test3")) == 0);
211
184
212 seriesSpyArg = seriesSpy.takeFirst();
185 seriesSpyArg = seriesSpy.takeFirst();
213 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
186 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
214
187 QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test3")) == 0);
215 //====================================================================================
216 // no event cases
217 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(1,1)); // Outside of both sets
218 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(1,1)); // Right mouse button outside and inside sets
219 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(115,230)); // barset 1, category test1
220 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(205,230)); // barset 1, category test2
221 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(300,230)); // barset 1, category test3
222 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(115,140)); // barset 2, category test1
223 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(205,140)); // barset 2, category test2
224 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(300,140)); // barset 2, category test3
225
226 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
227 QCOMPARE(setSpy1.count(), 0);
228 QCOMPARE(setSpy2.count(), 0);
229 QCOMPARE(seriesSpy.count(), 0);
230 }
188 }
231
189
232 void tst_QPercentBarSeries::mousehovered_data()
190 void tst_QPercentBarSeries::mousehovered_data()
@@ -249,8 +207,6 void tst_QPercentBarSeries::mousehovered()
249 *set2 << 10 << 10 << 10;
207 *set2 << 10 << 10 << 10;
250 series->append(set2);
208 series->append(set2);
251
209
252 QSignalSpy setSpy1(set1, SIGNAL(hovered(bool)));
253 QSignalSpy setSpy2(set2, SIGNAL(hovered(bool)));
254 QSignalSpy seriesSpy(series,SIGNAL(hovered(QBarSet*,bool)));
210 QSignalSpy seriesSpy(series,SIGNAL(hovered(QBarSet*,bool)));
255
211
256 QChartView view(new QChart());
212 QChartView view(new QChart());
@@ -259,49 +215,33 void tst_QPercentBarSeries::mousehovered()
259 view.show();
215 view.show();
260 QTest::qWaitForWindowShown(&view);
216 QTest::qWaitForWindowShown(&view);
261
217
218 //this is hack since view does not get events otherwise
219 view.setMouseTracking(true);
220
262 //=======================================================================
221 //=======================================================================
263 // move mouse to left border
222 // move mouse to left border
264 QTest::mouseMove(view.viewport(), QPoint(0, 230));
223 QTest::mouseMove(view.viewport(), QPoint(0, 190));
265
266
224
267 QVERIFY(setSpy1.count() == 0);
268 QVERIFY(setSpy2.count() == 0);
269 QVERIFY(seriesSpy.count() == 0);
225 QVERIFY(seriesSpy.count() == 0);
270
226
271 //=======================================================================
227 //=======================================================================
272 // move mouse on top of set1
228 // move mouse on top of set1
273 QTest::mouseMove(view.viewport(), QPoint(115,230));
229 QTest::mouseMove(view.viewport(), QPoint(106,190));
274
230
275 QVERIFY(setSpy1.count() == 1);
276 QVERIFY(setSpy2.count() == 0);
277 QVERIFY(seriesSpy.count() == 1);
231 QVERIFY(seriesSpy.count() == 1);
278
232
279 QList<QVariant> setSpyArg = setSpy1.takeFirst();
280 QVERIFY(setSpyArg.at(0).type() == QVariant::Bool);
281 QVERIFY(setSpyArg.at(0).toBool() == true);
282
283 QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
233 QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
284 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
234 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
235 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
236 QVERIFY(seriesSpyArg.at(1).toBool() == true);
285
237
286 //=======================================================================
238 //=======================================================================
287 // move mouse from top of set1 to top of set2
239 // move mouse from top of set1 to top of set2
288 QTest::mouseMove(view.viewport(), QPoint(115,140));
240 QTest::mouseMove(view.viewport(), QPoint(106,95));
289
241
290 QVERIFY(setSpy1.count() == 1);
291 QVERIFY(setSpy2.count() == 1);
292 QVERIFY(seriesSpy.count() == 2);
242 QVERIFY(seriesSpy.count() == 2);
293
243
294 // should leave set1
244 // should leave set1
295 setSpyArg = setSpy1.takeFirst();
296 QVERIFY(setSpyArg.at(0).type() == QVariant::Bool);
297 QVERIFY(setSpyArg.at(0).toBool() == false);
298
299 // should enter set2
300 setSpyArg = setSpy2.takeFirst();
301 QVERIFY(setSpyArg.at(0).type() == QVariant::Bool);
302 QVERIFY(setSpyArg.at(0).toBool() == true);
303
304 // should leave set1
305 seriesSpyArg = seriesSpy.takeFirst();
245 seriesSpyArg = seriesSpy.takeFirst();
306 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
246 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
307 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
247 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
@@ -315,29 +255,17 void tst_QPercentBarSeries::mousehovered()
315
255
316 //=======================================================================
256 //=======================================================================
317 // move mouse from top of set2 to background
257 // move mouse from top of set2 to background
318 QTest::mouseMove(view.viewport(), QPoint(0,140));
258 QTest::mouseMove(view.viewport(), QPoint(106,0));
319
259
320 QVERIFY(setSpy1.count() == 0);
321 QVERIFY(setSpy2.count() == 1);
322 QVERIFY(seriesSpy.count() == 1);
260 QVERIFY(seriesSpy.count() == 1);
323
261
324 // should leave set2 (event via set)
262 // should leave set2
325 setSpyArg = setSpy2.takeFirst();
326 QVERIFY(setSpyArg.at(0).type() == QVariant::Bool);
327 QVERIFY(setSpyArg.at(0).toBool() == false);
328
329 // should leave set2 (event via series)
330 seriesSpyArg = seriesSpy.takeFirst();
263 seriesSpyArg = seriesSpy.takeFirst();
331 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
264 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
332 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
265 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
333 QVERIFY(seriesSpyArg.at(1).toBool() == false);
266 QVERIFY(seriesSpyArg.at(1).toBool() == false);
334 }
267 }
335
268
336 /*
337 bool setModel(QAbstractItemModel *model);
338 void setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation = Qt::Vertical);
339 void setModelMappingRange(int first, int count = -1);
340 */
341 QTEST_MAIN(tst_QPercentBarSeries)
269 QTEST_MAIN(tst_QPercentBarSeries)
342
270
343 #include "tst_qpercentbarseries.moc"
271 #include "tst_qpercentbarseries.moc"
@@ -112,8 +112,6 void tst_QStackedBarSeries::mouseclicked()
112 *set2 << 10 << 10 << 10;
112 *set2 << 10 << 10 << 10;
113 series->append(set2);
113 series->append(set2);
114
114
115 QSignalSpy setSpy1(set1, SIGNAL(clicked(QString)));
116 QSignalSpy setSpy2(set2, SIGNAL(clicked(QString)));
117 QSignalSpy seriesSpy(series,SIGNAL(clicked(QBarSet*,QString)));
115 QSignalSpy seriesSpy(series,SIGNAL(clicked(QBarSet*,QString)));
118
116
119 QChartView view(new QChart());
117 QChartView view(new QChart());
@@ -124,109 +122,69 void tst_QStackedBarSeries::mouseclicked()
124
122
125 //====================================================================================
123 //====================================================================================
126 // barset 1, category test1
124 // barset 1, category test1
127 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(115,230));
125 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(106,190));
128 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
126 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
129
127
130 QCOMPARE(setSpy1.count(), 1);
131 QCOMPARE(setSpy2.count(), 0);
132 QCOMPARE(seriesSpy.count(), 1);
128 QCOMPARE(seriesSpy.count(), 1);
133 QList<QVariant> setSpyArg = setSpy1.takeFirst();
134 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
135 QVERIFY(setSpyArg.at(0).toString().compare(QString("test1")) == 0);
136
129
137 QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
130 QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
138 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
131 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
132 QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test1")) == 0);
139
133
140 //====================================================================================
134 //====================================================================================
141 // barset 1, category test2
135 // barset 1, category test2
142 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(205,230));
136 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(199,190));
143 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
137 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
144
138
145 QCOMPARE(setSpy1.count(), 1);
146 QCOMPARE(setSpy2.count(), 0);
147 QCOMPARE(seriesSpy.count(), 1);
139 QCOMPARE(seriesSpy.count(), 1);
148 setSpyArg = setSpy1.takeFirst();
149 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
150 QVERIFY(setSpyArg.at(0).toString().compare(QString("test2")) == 0);
151
140
152 seriesSpyArg = seriesSpy.takeFirst();
141 seriesSpyArg = seriesSpy.takeFirst();
153 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
142 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
143 QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test2")) == 0);
154
144
155 //====================================================================================
145 //====================================================================================
156 // barset 1, category test3
146 // barset 1, category test3
157 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(300,230));
147 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(292,190));
158 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
148 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
159
149
160 QCOMPARE(setSpy1.count(), 1);
161 QCOMPARE(setSpy2.count(), 0);
162 QCOMPARE(seriesSpy.count(), 1);
150 QCOMPARE(seriesSpy.count(), 1);
163 setSpyArg = setSpy1.takeFirst();
164 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
165 QVERIFY(setSpyArg.at(0).toString().compare(QString("test3")) == 0);
166
151
167 seriesSpyArg = seriesSpy.takeFirst();
152 seriesSpyArg = seriesSpy.takeFirst();
168 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
153 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
154 QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test3")) == 0);
169
155
170 //====================================================================================
156 //====================================================================================
171 // barset 2, category test1
157 // barset 2, category test1
172 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(115,140));
158 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(106,95));
173 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
159 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
174
160
175 QCOMPARE(setSpy1.count(), 0);
176 QCOMPARE(setSpy2.count(), 1);
177 QCOMPARE(seriesSpy.count(), 1);
161 QCOMPARE(seriesSpy.count(), 1);
178 setSpyArg = setSpy2.takeFirst();
179 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
180 QVERIFY(setSpyArg.at(0).toString().compare(QString("test1")) == 0);
181
162
182 seriesSpyArg = seriesSpy.takeFirst();
163 seriesSpyArg = seriesSpy.takeFirst();
183 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
164 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
165 QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test1")) == 0);
184
166
185 //====================================================================================
167 //====================================================================================
186 // barset 2, category test2
168 // barset 2, category test2
187 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(205,140));
169 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(199,95));
188 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
170 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
189
171
190 QCOMPARE(setSpy1.count(), 0);
191 QCOMPARE(setSpy2.count(), 1);
192 QCOMPARE(seriesSpy.count(), 1);
172 QCOMPARE(seriesSpy.count(), 1);
193 setSpyArg = setSpy2.takeFirst();
194 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
195 QVERIFY(setSpyArg.at(0).toString().compare(QString("test2")) == 0);
196
173
197 seriesSpyArg = seriesSpy.takeFirst();
174 seriesSpyArg = seriesSpy.takeFirst();
198 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
175 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
176 QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test2")) == 0);
199
177
200 //====================================================================================
178 //====================================================================================
201 // barset 2, category test3
179 // barset 2, category test3
202 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(300,140));
180 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(292,95));
203 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
181 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
204
182
205 QCOMPARE(setSpy1.count(), 0);
206 QCOMPARE(setSpy2.count(), 1);
207 QCOMPARE(seriesSpy.count(), 1);
183 QCOMPARE(seriesSpy.count(), 1);
208 setSpyArg = setSpy2.takeFirst();
209 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
210 QVERIFY(setSpyArg.at(0).toString().compare(QString("test3")) == 0);
211
184
212 seriesSpyArg = seriesSpy.takeFirst();
185 seriesSpyArg = seriesSpy.takeFirst();
213 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
186 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
214
187 QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test3")) == 0);
215 //====================================================================================
216 // no event cases
217 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(1,1)); // Outside of both sets
218 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(1,1)); // Right mouse button outside and inside sets
219 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(115,230)); // barset 1, category test1
220 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(205,230)); // barset 1, category test2
221 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(300,230)); // barset 1, category test3
222 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(115,140)); // barset 2, category test1
223 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(205,140)); // barset 2, category test2
224 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(300,140)); // barset 2, category test3
225
226 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
227 QCOMPARE(setSpy1.count(), 0);
228 QCOMPARE(setSpy2.count(), 0);
229 QCOMPARE(seriesSpy.count(), 0);
230 }
188 }
231
189
232 void tst_QStackedBarSeries::mousehovered_data()
190 void tst_QStackedBarSeries::mousehovered_data()
@@ -249,8 +207,6 void tst_QStackedBarSeries::mousehovered()
249 *set2 << 10 << 10 << 10;
207 *set2 << 10 << 10 << 10;
250 series->append(set2);
208 series->append(set2);
251
209
252 QSignalSpy setSpy1(set1, SIGNAL(hovered(bool)));
253 QSignalSpy setSpy2(set2, SIGNAL(hovered(bool)));
254 QSignalSpy seriesSpy(series,SIGNAL(hovered(QBarSet*,bool)));
210 QSignalSpy seriesSpy(series,SIGNAL(hovered(QBarSet*,bool)));
255
211
256 QChartView view(new QChart());
212 QChartView view(new QChart());
@@ -259,48 +215,33 void tst_QStackedBarSeries::mousehovered()
259 view.show();
215 view.show();
260 QTest::qWaitForWindowShown(&view);
216 QTest::qWaitForWindowShown(&view);
261
217
218 //this is hack since view does not get events otherwise
219 view.setMouseTracking(true);
220
262 //=======================================================================
221 //=======================================================================
263 // move mouse to left border
222 // move mouse to left border
264 QTest::mouseMove(view.viewport(), QPoint(0, 230));
223 QTest::mouseMove(view.viewport(), QPoint(0, 190));
265
224
266 QVERIFY(setSpy1.count() == 0);
267 QVERIFY(setSpy2.count() == 0);
268 QVERIFY(seriesSpy.count() == 0);
225 QVERIFY(seriesSpy.count() == 0);
269
226
270 //=======================================================================
227 //=======================================================================
271 // move mouse on top of set1
228 // move mouse on top of set1
272 QTest::mouseMove(view.viewport(), QPoint(115,230));
229 QTest::mouseMove(view.viewport(), QPoint(106,190));
273
230
274 QVERIFY(setSpy1.count() == 1);
275 QVERIFY(setSpy2.count() == 0);
276 QVERIFY(seriesSpy.count() == 1);
231 QVERIFY(seriesSpy.count() == 1);
277
232
278 QList<QVariant> setSpyArg = setSpy1.takeFirst();
279 QVERIFY(setSpyArg.at(0).type() == QVariant::Bool);
280 QVERIFY(setSpyArg.at(0).toBool() == true);
281
282 QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
233 QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
283 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
234 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
235 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
236 QVERIFY(seriesSpyArg.at(1).toBool() == true);
284
237
285 //=======================================================================
238 //=======================================================================
286 // move mouse from top of set1 to top of set2
239 // move mouse from top of set1 to top of set2
287 QTest::mouseMove(view.viewport(), QPoint(115,140));
240 QTest::mouseMove(view.viewport(), QPoint(106,95));
288
241
289 QVERIFY(setSpy1.count() == 1);
290 QVERIFY(setSpy2.count() == 1);
291 QVERIFY(seriesSpy.count() == 2);
242 QVERIFY(seriesSpy.count() == 2);
292
243
293 // should leave set1
244 // should leave set1
294 setSpyArg = setSpy1.takeFirst();
295 QVERIFY(setSpyArg.at(0).type() == QVariant::Bool);
296 QVERIFY(setSpyArg.at(0).toBool() == false);
297
298 // should enter set2
299 setSpyArg = setSpy2.takeFirst();
300 QVERIFY(setSpyArg.at(0).type() == QVariant::Bool);
301 QVERIFY(setSpyArg.at(0).toBool() == true);
302
303 // should leave set1
304 seriesSpyArg = seriesSpy.takeFirst();
245 seriesSpyArg = seriesSpy.takeFirst();
305 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
246 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
306 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
247 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
@@ -314,30 +255,17 void tst_QStackedBarSeries::mousehovered()
314
255
315 //=======================================================================
256 //=======================================================================
316 // move mouse from top of set2 to background
257 // move mouse from top of set2 to background
317 QTest::mouseMove(view.viewport(), QPoint(0,140));
258 QTest::mouseMove(view.viewport(), QPoint(106,0));
318
259
319 QVERIFY(setSpy1.count() == 0);
320 QVERIFY(setSpy2.count() == 1);
321 QVERIFY(seriesSpy.count() == 1);
260 QVERIFY(seriesSpy.count() == 1);
322
261
323 // should leave set2 (event via set)
262 // should leave set2
324 setSpyArg = setSpy2.takeFirst();
325 QVERIFY(setSpyArg.at(0).type() == QVariant::Bool);
326 QVERIFY(setSpyArg.at(0).toBool() == false);
327
328 // should leave set2 (event via series)
329 seriesSpyArg = seriesSpy.takeFirst();
263 seriesSpyArg = seriesSpy.takeFirst();
330 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
264 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
331 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
265 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
332 QVERIFY(seriesSpyArg.at(1).toBool() == false);
266 QVERIFY(seriesSpyArg.at(1).toBool() == false);
333 }
267 }
334
268
335
336 /*
337 bool setModel(QAbstractItemModel *model);
338 void setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation = Qt::Vertical);
339 void setModelMappingRange(int first, int count = -1);
340 */
341 QTEST_MAIN(tst_QStackedBarSeries)
269 QTEST_MAIN(tst_QStackedBarSeries)
342
270
343 #include "tst_qstackedbarseries.moc"
271 #include "tst_qstackedbarseries.moc"
General Comments 0
You need to be logged in to leave comments. Login now