##// END OF EJS Templates
mouse click test cases for barcharts. Fixed found error
sauimone -
r1145:db0bfcadc777
parent child
Show More
@@ -29,7 +29,7 Bar::Bar(QBarSet *barset, QString category, QGraphicsItem *parent) : QGraphicsRe
29 m_category(category),
29 m_category(category),
30 m_barset(barset)
30 m_barset(barset)
31 {
31 {
32 setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton);
32 setAcceptedMouseButtons(Qt::LeftButton /*| Qt::RightButton*/);
33 setAcceptHoverEvents(true);
33 setAcceptHoverEvents(true);
34 }
34 }
35
35
@@ -21,9 +21,13
21 #include <QtTest/QtTest>
21 #include <QtTest/QtTest>
22 #include <qbarseries.h>
22 #include <qbarseries.h>
23 #include <qbarset.h>
23 #include <qbarset.h>
24 #include <qchartview.h>
25 #include <qchart.h>
24
26
25 QTCOMMERCIALCHART_USE_NAMESPACE
27 QTCOMMERCIALCHART_USE_NAMESPACE
26
28
29 Q_DECLARE_METATYPE(QBarSet*)
30
27 class tst_QBarSeries : public QObject
31 class tst_QBarSeries : public QObject
28 {
32 {
29 Q_OBJECT
33 Q_OBJECT
@@ -59,6 +63,8 private slots:
59 void categories();
63 void categories();
60 void setLabelsVisible_data();
64 void setLabelsVisible_data();
61 void setLabelsVisible();
65 void setLabelsVisible();
66 void mouseclick_data();
67 void mouseclick();
62
68
63 private:
69 private:
64 QBarSeries* m_barseries;
70 QBarSeries* m_barseries;
@@ -71,6 +77,7 private:
71
77
72 void tst_QBarSeries::initTestCase()
78 void tst_QBarSeries::initTestCase()
73 {
79 {
80 qRegisterMetaType<QBarSet*>("QBarSet*");
74 }
81 }
75
82
76 void tst_QBarSeries::cleanupTestCase()
83 void tst_QBarSeries::cleanupTestCase()
@@ -417,6 +424,143 void tst_QBarSeries::setLabelsVisible()
417 }
424 }
418 }
425 }
419
426
427 void tst_QBarSeries::mouseclick_data()
428 {
429
430 }
431
432 void tst_QBarSeries::mouseclick()
433 {
434 QBarSeries* series = new QBarSeries();
435 QBarCategories categories;
436 categories << "test1" << "test2" << "test3";
437 series->setCategories(categories);
438
439 QBarSet* set1 = new QBarSet(QString("set 1"));
440 *set1 << 10 << 10 << 10;
441 series->appendBarSet(set1);
442
443 QBarSet* set2 = new QBarSet(QString("set 2"));
444 *set2 << 10 << 10 << 10;
445 series->appendBarSet(set2);
446
447 QSignalSpy setSpy1(set1, SIGNAL(clicked(QString)));
448 QSignalSpy setSpy2(set2, SIGNAL(clicked(QString)));
449 QSignalSpy seriesSpy(series,SIGNAL(clicked(QBarSet*,QString)));
450
451 QChartView view(new QChart());
452 view.resize(400,300);
453 view.chart()->addSeries(series);
454 view.show();
455 QTest::qWaitForWindowShown(&view);
456
457 //====================================================================================
458 // barset 1, category test1
459 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(100,180));
460 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
461
462 QCOMPARE(setSpy1.count(), 1);
463 QCOMPARE(setSpy2.count(), 0);
464 QCOMPARE(seriesSpy.count(), 1);
465 QList<QVariant> setSpyArg = setSpy1.takeFirst();
466 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
467 QVERIFY(setSpyArg.at(0).toString().compare(QString("test1")) == 0);
468
469 QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
470 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
471
472 //====================================================================================
473 // barset 1, category test2
474 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(190,180));
475 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
476
477 QCOMPARE(setSpy1.count(), 1);
478 QCOMPARE(setSpy2.count(), 0);
479 QCOMPARE(seriesSpy.count(), 1);
480 setSpyArg = setSpy1.takeFirst();
481 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
482 QVERIFY(setSpyArg.at(0).toString().compare(QString("test2")) == 0);
483
484 seriesSpyArg = seriesSpy.takeFirst();
485 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
486
487 //====================================================================================
488 // barset 1, category test3
489 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(280,180));
490 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
491
492 QCOMPARE(setSpy1.count(), 1);
493 QCOMPARE(setSpy2.count(), 0);
494 QCOMPARE(seriesSpy.count(), 1);
495 setSpyArg = setSpy1.takeFirst();
496 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
497 QVERIFY(setSpyArg.at(0).toString().compare(QString("test3")) == 0);
498
499 seriesSpyArg = seriesSpy.takeFirst();
500 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
501
502 //====================================================================================
503 // barset 2, category test1
504 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(130,180));
505 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
506
507 QCOMPARE(setSpy1.count(), 0);
508 QCOMPARE(setSpy2.count(), 1);
509 QCOMPARE(seriesSpy.count(), 1);
510 setSpyArg = setSpy2.takeFirst();
511 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
512 QVERIFY(setSpyArg.at(0).toString().compare(QString("test1")) == 0);
513
514 seriesSpyArg = seriesSpy.takeFirst();
515 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
516
517 //====================================================================================
518 // barset 2, category test2
519 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(220,180));
520 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
521
522 QCOMPARE(setSpy1.count(), 0);
523 QCOMPARE(setSpy2.count(), 1);
524 QCOMPARE(seriesSpy.count(), 1);
525 setSpyArg = setSpy2.takeFirst();
526 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
527 QVERIFY(setSpyArg.at(0).toString().compare(QString("test2")) == 0);
528
529 seriesSpyArg = seriesSpy.takeFirst();
530 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
531
532 //====================================================================================
533 // barset 2, category test3
534 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(310,180));
535 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
536
537 QCOMPARE(setSpy1.count(), 0);
538 QCOMPARE(setSpy2.count(), 1);
539 QCOMPARE(seriesSpy.count(), 1);
540 setSpyArg = setSpy2.takeFirst();
541 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
542 QVERIFY(setSpyArg.at(0).toString().compare(QString("test3")) == 0);
543
544 seriesSpyArg = seriesSpy.takeFirst();
545 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
546
547 //====================================================================================
548 // no event cases
549 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(1,1)); // Outside of both sets
550 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(1,1)); // Right mouse button outside and inside sets
551 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(100,180)); // barset 1, category test1
552 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(190,180)); // barset 1, category test2
553 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(280,180)); // barset 1, category test3
554 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(130,180)); // barset 2, category test1
555 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(220,180)); // barset 2, category test2
556 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(310,180)); // barset 2, category test3
557
558 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
559 QCOMPARE(setSpy1.count(), 0);
560 QCOMPARE(setSpy2.count(), 0);
561 QCOMPARE(seriesSpy.count(), 0);
562 }
563
420 /*
564 /*
421 bool setModel(QAbstractItemModel *model);
565 bool setModel(QAbstractItemModel *model);
422 void setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation = Qt::Vertical);
566 void setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation = Qt::Vertical);
@@ -21,9 +21,13
21 #include <QtTest/QtTest>
21 #include <QtTest/QtTest>
22 #include <qpercentbarseries.h>
22 #include <qpercentbarseries.h>
23 #include <qbarset.h>
23 #include <qbarset.h>
24 #include <qchartview.h>
25 #include <qchart.h>
24
26
25 QTCOMMERCIALCHART_USE_NAMESPACE
27 QTCOMMERCIALCHART_USE_NAMESPACE
26
28
29 Q_DECLARE_METATYPE(QBarSet*)
30
27 class tst_QPercentBarSeries : public QObject
31 class tst_QPercentBarSeries : public QObject
28 {
32 {
29 Q_OBJECT
33 Q_OBJECT
@@ -39,6 +43,8 private slots:
39 void qpercentbarseries();
43 void qpercentbarseries();
40 void type_data();
44 void type_data();
41 void type();
45 void type();
46 void mouseclick_data();
47 void mouseclick();
42
48
43 private:
49 private:
44 QPercentBarSeries* m_barseries;
50 QPercentBarSeries* m_barseries;
@@ -46,6 +52,7 private:
46
52
47 void tst_QPercentBarSeries::initTestCase()
53 void tst_QPercentBarSeries::initTestCase()
48 {
54 {
55 qRegisterMetaType<QBarSet*>("QBarSet*");
49 }
56 }
50
57
51 void tst_QPercentBarSeries::cleanupTestCase()
58 void tst_QPercentBarSeries::cleanupTestCase()
@@ -83,6 +90,142 void tst_QPercentBarSeries::type()
83 QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypePercentBar);
90 QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypePercentBar);
84 }
91 }
85
92
93 void tst_QPercentBarSeries::mouseclick_data()
94 {
95
96 }
97
98 void tst_QPercentBarSeries::mouseclick()
99 {
100 QPercentBarSeries* series = new QPercentBarSeries();
101 QBarCategories categories;
102 categories << "test1" << "test2" << "test3";
103 series->setCategories(categories);
104
105 QBarSet* set1 = new QBarSet(QString("set 1"));
106 *set1 << 10 << 10 << 10;
107 series->appendBarSet(set1);
108
109 QBarSet* set2 = new QBarSet(QString("set 2"));
110 *set2 << 10 << 10 << 10;
111 series->appendBarSet(set2);
112
113 QSignalSpy setSpy1(set1, SIGNAL(clicked(QString)));
114 QSignalSpy setSpy2(set2, SIGNAL(clicked(QString)));
115 QSignalSpy seriesSpy(series,SIGNAL(clicked(QBarSet*,QString)));
116
117 QChartView view(new QChart());
118 view.resize(400,300);
119 view.chart()->addSeries(series);
120 view.show();
121 QTest::qWaitForWindowShown(&view);
122
123 //====================================================================================
124 // barset 1, category test1
125 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(115,230));
126 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
127
128 QCOMPARE(setSpy1.count(), 1);
129 QCOMPARE(setSpy2.count(), 0);
130 QCOMPARE(seriesSpy.count(), 1);
131 QList<QVariant> setSpyArg = setSpy1.takeFirst();
132 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
133 QVERIFY(setSpyArg.at(0).toString().compare(QString("test1")) == 0);
134
135 QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
136 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
137
138 //====================================================================================
139 // barset 1, category test2
140 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(205,230));
141 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
142
143 QCOMPARE(setSpy1.count(), 1);
144 QCOMPARE(setSpy2.count(), 0);
145 QCOMPARE(seriesSpy.count(), 1);
146 setSpyArg = setSpy1.takeFirst();
147 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
148 QVERIFY(setSpyArg.at(0).toString().compare(QString("test2")) == 0);
149
150 seriesSpyArg = seriesSpy.takeFirst();
151 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
152
153 //====================================================================================
154 // barset 1, category test3
155 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(300,230));
156 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
157
158 QCOMPARE(setSpy1.count(), 1);
159 QCOMPARE(setSpy2.count(), 0);
160 QCOMPARE(seriesSpy.count(), 1);
161 setSpyArg = setSpy1.takeFirst();
162 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
163 QVERIFY(setSpyArg.at(0).toString().compare(QString("test3")) == 0);
164
165 seriesSpyArg = seriesSpy.takeFirst();
166 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
167
168 //====================================================================================
169 // barset 2, category test1
170 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(115,140));
171 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
172
173 QCOMPARE(setSpy1.count(), 0);
174 QCOMPARE(setSpy2.count(), 1);
175 QCOMPARE(seriesSpy.count(), 1);
176 setSpyArg = setSpy2.takeFirst();
177 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
178 QVERIFY(setSpyArg.at(0).toString().compare(QString("test1")) == 0);
179
180 seriesSpyArg = seriesSpy.takeFirst();
181 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
182
183 //====================================================================================
184 // barset 2, category test2
185 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(205,140));
186 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
187
188 QCOMPARE(setSpy1.count(), 0);
189 QCOMPARE(setSpy2.count(), 1);
190 QCOMPARE(seriesSpy.count(), 1);
191 setSpyArg = setSpy2.takeFirst();
192 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
193 QVERIFY(setSpyArg.at(0).toString().compare(QString("test2")) == 0);
194
195 seriesSpyArg = seriesSpy.takeFirst();
196 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
197
198 //====================================================================================
199 // barset 2, category test3
200 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(300,140));
201 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
202
203 QCOMPARE(setSpy1.count(), 0);
204 QCOMPARE(setSpy2.count(), 1);
205 QCOMPARE(seriesSpy.count(), 1);
206 setSpyArg = setSpy2.takeFirst();
207 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
208 QVERIFY(setSpyArg.at(0).toString().compare(QString("test3")) == 0);
209
210 seriesSpyArg = seriesSpy.takeFirst();
211 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
212
213 //====================================================================================
214 // no event cases
215 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(1,1)); // Outside of both sets
216 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(1,1)); // Right mouse button outside and inside sets
217 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(115,230)); // barset 1, category test1
218 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(205,230)); // barset 1, category test2
219 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(300,230)); // barset 1, category test3
220 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(115,140)); // barset 2, category test1
221 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(205,140)); // barset 2, category test2
222 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(300,140)); // barset 2, category test3
223
224 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
225 QCOMPARE(setSpy1.count(), 0);
226 QCOMPARE(setSpy2.count(), 0);
227 QCOMPARE(seriesSpy.count(), 0);
228 }
86
229
87 /*
230 /*
88 bool setModel(QAbstractItemModel *model);
231 bool setModel(QAbstractItemModel *model);
@@ -21,9 +21,13
21 #include <QtTest/QtTest>
21 #include <QtTest/QtTest>
22 #include <qstackedbarseries.h>
22 #include <qstackedbarseries.h>
23 #include <qbarset.h>
23 #include <qbarset.h>
24 #include <qchartview.h>
25 #include <qchart.h>
24
26
25 QTCOMMERCIALCHART_USE_NAMESPACE
27 QTCOMMERCIALCHART_USE_NAMESPACE
26
28
29 Q_DECLARE_METATYPE(QBarSet*)
30
27 class tst_QStackedBarSeries : public QObject
31 class tst_QStackedBarSeries : public QObject
28 {
32 {
29 Q_OBJECT
33 Q_OBJECT
@@ -39,6 +43,8 private slots:
39 void qstackedbarseries();
43 void qstackedbarseries();
40 void type_data();
44 void type_data();
41 void type();
45 void type();
46 void mouseclick_data();
47 void mouseclick();
42
48
43 private:
49 private:
44 QStackedBarSeries* m_barseries;
50 QStackedBarSeries* m_barseries;
@@ -46,6 +52,7 private:
46
52
47 void tst_QStackedBarSeries::initTestCase()
53 void tst_QStackedBarSeries::initTestCase()
48 {
54 {
55 qRegisterMetaType<QBarSet*>("QBarSet*");
49 }
56 }
50
57
51 void tst_QStackedBarSeries::cleanupTestCase()
58 void tst_QStackedBarSeries::cleanupTestCase()
@@ -83,6 +90,143 void tst_QStackedBarSeries::type()
83 QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypeStackedBar);
90 QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypeStackedBar);
84 }
91 }
85
92
93 void tst_QStackedBarSeries::mouseclick_data()
94 {
95
96 }
97
98 void tst_QStackedBarSeries::mouseclick()
99 {
100 QStackedBarSeries* series = new QStackedBarSeries();
101 QBarCategories categories;
102 categories << "test1" << "test2" << "test3";
103 series->setCategories(categories);
104
105 QBarSet* set1 = new QBarSet(QString("set 1"));
106 *set1 << 10 << 10 << 10;
107 series->appendBarSet(set1);
108
109 QBarSet* set2 = new QBarSet(QString("set 2"));
110 *set2 << 10 << 10 << 10;
111 series->appendBarSet(set2);
112
113 QSignalSpy setSpy1(set1, SIGNAL(clicked(QString)));
114 QSignalSpy setSpy2(set2, SIGNAL(clicked(QString)));
115 QSignalSpy seriesSpy(series,SIGNAL(clicked(QBarSet*,QString)));
116
117 QChartView view(new QChart());
118 view.resize(400,300);
119 view.chart()->addSeries(series);
120 view.show();
121 QTest::qWaitForWindowShown(&view);
122
123 //====================================================================================
124 // barset 1, category test1
125 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(115,230));
126 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
127
128 QCOMPARE(setSpy1.count(), 1);
129 QCOMPARE(setSpy2.count(), 0);
130 QCOMPARE(seriesSpy.count(), 1);
131 QList<QVariant> setSpyArg = setSpy1.takeFirst();
132 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
133 QVERIFY(setSpyArg.at(0).toString().compare(QString("test1")) == 0);
134
135 QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
136 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
137
138 //====================================================================================
139 // barset 1, category test2
140 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(205,230));
141 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
142
143 QCOMPARE(setSpy1.count(), 1);
144 QCOMPARE(setSpy2.count(), 0);
145 QCOMPARE(seriesSpy.count(), 1);
146 setSpyArg = setSpy1.takeFirst();
147 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
148 QVERIFY(setSpyArg.at(0).toString().compare(QString("test2")) == 0);
149
150 seriesSpyArg = seriesSpy.takeFirst();
151 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
152
153 //====================================================================================
154 // barset 1, category test3
155 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(300,230));
156 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
157
158 QCOMPARE(setSpy1.count(), 1);
159 QCOMPARE(setSpy2.count(), 0);
160 QCOMPARE(seriesSpy.count(), 1);
161 setSpyArg = setSpy1.takeFirst();
162 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
163 QVERIFY(setSpyArg.at(0).toString().compare(QString("test3")) == 0);
164
165 seriesSpyArg = seriesSpy.takeFirst();
166 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
167
168 //====================================================================================
169 // barset 2, category test1
170 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(115,140));
171 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
172
173 QCOMPARE(setSpy1.count(), 0);
174 QCOMPARE(setSpy2.count(), 1);
175 QCOMPARE(seriesSpy.count(), 1);
176 setSpyArg = setSpy2.takeFirst();
177 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
178 QVERIFY(setSpyArg.at(0).toString().compare(QString("test1")) == 0);
179
180 seriesSpyArg = seriesSpy.takeFirst();
181 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
182
183 //====================================================================================
184 // barset 2, category test2
185 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(205,140));
186 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
187
188 QCOMPARE(setSpy1.count(), 0);
189 QCOMPARE(setSpy2.count(), 1);
190 QCOMPARE(seriesSpy.count(), 1);
191 setSpyArg = setSpy2.takeFirst();
192 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
193 QVERIFY(setSpyArg.at(0).toString().compare(QString("test2")) == 0);
194
195 seriesSpyArg = seriesSpy.takeFirst();
196 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
197
198 //====================================================================================
199 // barset 2, category test3
200 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(300,140));
201 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
202
203 QCOMPARE(setSpy1.count(), 0);
204 QCOMPARE(setSpy2.count(), 1);
205 QCOMPARE(seriesSpy.count(), 1);
206 setSpyArg = setSpy2.takeFirst();
207 QVERIFY(setSpyArg.at(0).type() == QVariant::String);
208 QVERIFY(setSpyArg.at(0).toString().compare(QString("test3")) == 0);
209
210 seriesSpyArg = seriesSpy.takeFirst();
211 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
212
213 //====================================================================================
214 // no event cases
215 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(1,1)); // Outside of both sets
216 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(1,1)); // Right mouse button outside and inside sets
217 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(115,230)); // barset 1, category test1
218 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(205,230)); // barset 1, category test2
219 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(300,230)); // barset 1, category test3
220 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(115,140)); // barset 2, category test1
221 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(205,140)); // barset 2, category test2
222 QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(300,140)); // barset 2, category test3
223
224 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
225 QCOMPARE(setSpy1.count(), 0);
226 QCOMPARE(setSpy2.count(), 0);
227 QCOMPARE(seriesSpy.count(), 0);
228 }
229
86 /*
230 /*
87 bool setModel(QAbstractItemModel *model);
231 bool setModel(QAbstractItemModel *model);
88 void setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation = Qt::Vertical);
232 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