##// END OF EJS Templates
mouse hover test cases for barcharts
sauimone -
r1146:8ca640098b8f
parent child
Show More
@@ -63,8 +63,10 private slots:
63 63 void categories();
64 64 void setLabelsVisible_data();
65 65 void setLabelsVisible();
66 void mouseclick_data();
67 void mouseclick();
66 void mouseclicked_data();
67 void mouseclicked();
68 void mousehovered_data();
69 void mousehovered();
68 70
69 71 private:
70 72 QBarSeries* m_barseries;
@@ -424,12 +426,12 void tst_QBarSeries::setLabelsVisible()
424 426 }
425 427 }
426 428
427 void tst_QBarSeries::mouseclick_data()
429 void tst_QBarSeries::mouseclicked_data()
428 430 {
429 431
430 432 }
431 433
432 void tst_QBarSeries::mouseclick()
434 void tst_QBarSeries::mouseclicked()
433 435 {
434 436 QBarSeries* series = new QBarSeries();
435 437 QBarCategories categories;
@@ -561,6 +563,109 void tst_QBarSeries::mouseclick()
561 563 QCOMPARE(seriesSpy.count(), 0);
562 564 }
563 565
566 void tst_QBarSeries::mousehovered_data()
567 {
568
569 }
570
571 void tst_QBarSeries::mousehovered()
572 {
573 QBarSeries* series = new QBarSeries();
574 QBarCategories categories;
575 categories << "test1" << "test2" << "test3";
576 series->setCategories(categories);
577
578 QBarSet* set1 = new QBarSet(QString("set 1"));
579 *set1 << 10 << 10 << 10;
580 series->appendBarSet(set1);
581
582 QBarSet* set2 = new QBarSet(QString("set 2"));
583 *set2 << 10 << 10 << 10;
584 series->appendBarSet(set2);
585
586 QSignalSpy setSpy1(set1, SIGNAL(hovered(bool)));
587 QSignalSpy setSpy2(set2, SIGNAL(hovered(bool)));
588 QSignalSpy seriesSpy(series,SIGNAL(hovered(QBarSet*,bool)));
589
590 QChartView view(new QChart());
591 view.resize(400,300);
592 view.chart()->addSeries(series);
593 view.show();
594 QTest::qWaitForWindowShown(&view);
595
596 //=======================================================================
597 // move mouse to left border
598 QTest::mouseMove(view.viewport(), QPoint(0, 180));
599
600 QVERIFY(setSpy1.count() == 0);
601 QVERIFY(setSpy2.count() == 0);
602 QVERIFY(seriesSpy.count() == 0);
603
604 //=======================================================================
605 // move mouse on top of set1
606 QTest::mouseMove(view.viewport(), QPoint(100,180));
607
608 QVERIFY(setSpy1.count() == 1);
609 QVERIFY(setSpy2.count() == 0);
610 QVERIFY(seriesSpy.count() == 1);
611
612 QList<QVariant> setSpyArg = setSpy1.takeFirst();
613 QVERIFY(setSpyArg.at(0).type() == QVariant::Bool);
614 QVERIFY(setSpyArg.at(0).toBool() == true);
615
616 QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
617 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
618
619 //=======================================================================
620 // move mouse from top of set1 to top of set2
621 QTest::mouseMove(view.viewport(), QPoint(130,180));
622
623 QVERIFY(setSpy1.count() == 1);
624 QVERIFY(setSpy2.count() == 1);
625 QVERIFY(seriesSpy.count() == 2);
626
627 // should leave set1
628 setSpyArg = setSpy1.takeFirst();
629 QVERIFY(setSpyArg.at(0).type() == QVariant::Bool);
630 QVERIFY(setSpyArg.at(0).toBool() == false);
631
632 // should enter set2
633 setSpyArg = setSpy2.takeFirst();
634 QVERIFY(setSpyArg.at(0).type() == QVariant::Bool);
635 QVERIFY(setSpyArg.at(0).toBool() == true);
636
637 // should leave set1
638 seriesSpyArg = seriesSpy.takeFirst();
639 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
640 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
641 QVERIFY(seriesSpyArg.at(1).toBool() == false);
642
643 // should enter set2
644 seriesSpyArg = seriesSpy.takeFirst();
645 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
646 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
647 QVERIFY(seriesSpyArg.at(1).toBool() == true);
648
649 //=======================================================================
650 // move mouse from top of set2 to background
651 QTest::mouseMove(view.viewport(), QPoint(160,180));
652
653 QVERIFY(setSpy1.count() == 0);
654 QVERIFY(setSpy2.count() == 1);
655 QVERIFY(seriesSpy.count() == 1);
656
657 // should leave set2 (event via set)
658 setSpyArg = setSpy2.takeFirst();
659 QVERIFY(setSpyArg.at(0).type() == QVariant::Bool);
660 QVERIFY(setSpyArg.at(0).toBool() == false);
661
662 // should leave set2 (event via series)
663 seriesSpyArg = seriesSpy.takeFirst();
664 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
665 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
666 QVERIFY(seriesSpyArg.at(1).toBool() == false);
667 }
668
564 669 /*
565 670 bool setModel(QAbstractItemModel *model);
566 671 void setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation = Qt::Vertical);
@@ -43,8 +43,10 private slots:
43 43 void qpercentbarseries();
44 44 void type_data();
45 45 void type();
46 void mouseclick_data();
47 void mouseclick();
46 void mouseclicked_data();
47 void mouseclicked();
48 void mousehovered_data();
49 void mousehovered();
48 50
49 51 private:
50 52 QPercentBarSeries* m_barseries;
@@ -90,12 +92,12 void tst_QPercentBarSeries::type()
90 92 QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypePercentBar);
91 93 }
92 94
93 void tst_QPercentBarSeries::mouseclick_data()
95 void tst_QPercentBarSeries::mouseclicked_data()
94 96 {
95 97
96 98 }
97 99
98 void tst_QPercentBarSeries::mouseclick()
100 void tst_QPercentBarSeries::mouseclicked()
99 101 {
100 102 QPercentBarSeries* series = new QPercentBarSeries();
101 103 QBarCategories categories;
@@ -227,6 +229,110 void tst_QPercentBarSeries::mouseclick()
227 229 QCOMPARE(seriesSpy.count(), 0);
228 230 }
229 231
232 void tst_QPercentBarSeries::mousehovered_data()
233 {
234
235 }
236
237 void tst_QPercentBarSeries::mousehovered()
238 {
239 QPercentBarSeries* series = new QPercentBarSeries();
240 QBarCategories categories;
241 categories << "test1" << "test2" << "test3";
242 series->setCategories(categories);
243
244 QBarSet* set1 = new QBarSet(QString("set 1"));
245 *set1 << 10 << 10 << 10;
246 series->appendBarSet(set1);
247
248 QBarSet* set2 = new QBarSet(QString("set 2"));
249 *set2 << 10 << 10 << 10;
250 series->appendBarSet(set2);
251
252 QSignalSpy setSpy1(set1, SIGNAL(hovered(bool)));
253 QSignalSpy setSpy2(set2, SIGNAL(hovered(bool)));
254 QSignalSpy seriesSpy(series,SIGNAL(hovered(QBarSet*,bool)));
255
256 QChartView view(new QChart());
257 view.resize(400,300);
258 view.chart()->addSeries(series);
259 view.show();
260 QTest::qWaitForWindowShown(&view);
261
262 //=======================================================================
263 // move mouse to left border
264 QTest::mouseMove(view.viewport(), QPoint(0, 230));
265
266
267 QVERIFY(setSpy1.count() == 0);
268 QVERIFY(setSpy2.count() == 0);
269 QVERIFY(seriesSpy.count() == 0);
270
271 //=======================================================================
272 // move mouse on top of set1
273 QTest::mouseMove(view.viewport(), QPoint(115,230));
274
275 QVERIFY(setSpy1.count() == 1);
276 QVERIFY(setSpy2.count() == 0);
277 QVERIFY(seriesSpy.count() == 1);
278
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();
284 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
285
286 //=======================================================================
287 // move mouse from top of set1 to top of set2
288 QTest::mouseMove(view.viewport(), QPoint(115,140));
289
290 QVERIFY(setSpy1.count() == 1);
291 QVERIFY(setSpy2.count() == 1);
292 QVERIFY(seriesSpy.count() == 2);
293
294 // 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();
306 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
307 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
308 QVERIFY(seriesSpyArg.at(1).toBool() == false);
309
310 // should enter set2
311 seriesSpyArg = seriesSpy.takeFirst();
312 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
313 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
314 QVERIFY(seriesSpyArg.at(1).toBool() == true);
315
316 //=======================================================================
317 // move mouse from top of set2 to background
318 QTest::mouseMove(view.viewport(), QPoint(0,140));
319
320 QVERIFY(setSpy1.count() == 0);
321 QVERIFY(setSpy2.count() == 1);
322 QVERIFY(seriesSpy.count() == 1);
323
324 // should leave set2 (event via set)
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();
331 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
332 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
333 QVERIFY(seriesSpyArg.at(1).toBool() == false);
334 }
335
230 336 /*
231 337 bool setModel(QAbstractItemModel *model);
232 338 void setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation = Qt::Vertical);
@@ -43,8 +43,10 private slots:
43 43 void qstackedbarseries();
44 44 void type_data();
45 45 void type();
46 void mouseclick_data();
47 void mouseclick();
46 void mouseclicked_data();
47 void mouseclicked();
48 void mousehovered_data();
49 void mousehovered();
48 50
49 51 private:
50 52 QStackedBarSeries* m_barseries;
@@ -90,12 +92,12 void tst_QStackedBarSeries::type()
90 92 QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypeStackedBar);
91 93 }
92 94
93 void tst_QStackedBarSeries::mouseclick_data()
95 void tst_QStackedBarSeries::mouseclicked_data()
94 96 {
95 97
96 98 }
97 99
98 void tst_QStackedBarSeries::mouseclick()
100 void tst_QStackedBarSeries::mouseclicked()
99 101 {
100 102 QStackedBarSeries* series = new QStackedBarSeries();
101 103 QBarCategories categories;
@@ -227,6 +229,110 void tst_QStackedBarSeries::mouseclick()
227 229 QCOMPARE(seriesSpy.count(), 0);
228 230 }
229 231
232 void tst_QStackedBarSeries::mousehovered_data()
233 {
234
235 }
236
237 void tst_QStackedBarSeries::mousehovered()
238 {
239 QStackedBarSeries* series = new QStackedBarSeries();
240 QBarCategories categories;
241 categories << "test1" << "test2" << "test3";
242 series->setCategories(categories);
243
244 QBarSet* set1 = new QBarSet(QString("set 1"));
245 *set1 << 10 << 10 << 10;
246 series->appendBarSet(set1);
247
248 QBarSet* set2 = new QBarSet(QString("set 2"));
249 *set2 << 10 << 10 << 10;
250 series->appendBarSet(set2);
251
252 QSignalSpy setSpy1(set1, SIGNAL(hovered(bool)));
253 QSignalSpy setSpy2(set2, SIGNAL(hovered(bool)));
254 QSignalSpy seriesSpy(series,SIGNAL(hovered(QBarSet*,bool)));
255
256 QChartView view(new QChart());
257 view.resize(400,300);
258 view.chart()->addSeries(series);
259 view.show();
260 QTest::qWaitForWindowShown(&view);
261
262 //=======================================================================
263 // move mouse to left border
264 QTest::mouseMove(view.viewport(), QPoint(0, 230));
265
266 QVERIFY(setSpy1.count() == 0);
267 QVERIFY(setSpy2.count() == 0);
268 QVERIFY(seriesSpy.count() == 0);
269
270 //=======================================================================
271 // move mouse on top of set1
272 QTest::mouseMove(view.viewport(), QPoint(115,230));
273
274 QVERIFY(setSpy1.count() == 1);
275 QVERIFY(setSpy2.count() == 0);
276 QVERIFY(seriesSpy.count() == 1);
277
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();
283 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
284
285 //=======================================================================
286 // move mouse from top of set1 to top of set2
287 QTest::mouseMove(view.viewport(), QPoint(115,140));
288
289 QVERIFY(setSpy1.count() == 1);
290 QVERIFY(setSpy2.count() == 1);
291 QVERIFY(seriesSpy.count() == 2);
292
293 // 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();
305 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
306 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
307 QVERIFY(seriesSpyArg.at(1).toBool() == false);
308
309 // should enter set2
310 seriesSpyArg = seriesSpy.takeFirst();
311 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
312 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
313 QVERIFY(seriesSpyArg.at(1).toBool() == true);
314
315 //=======================================================================
316 // move mouse from top of set2 to background
317 QTest::mouseMove(view.viewport(), QPoint(0,140));
318
319 QVERIFY(setSpy1.count() == 0);
320 QVERIFY(setSpy2.count() == 1);
321 QVERIFY(seriesSpy.count() == 1);
322
323 // should leave set2 (event via set)
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();
330 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
331 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
332 QVERIFY(seriesSpyArg.at(1).toBool() == false);
333 }
334
335
230 336 /*
231 337 bool setModel(QAbstractItemModel *model);
232 338 void setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation = Qt::Vertical);
General Comments 0
You need to be logged in to leave comments. Login now