##// END OF EJS Templates
autotests: try to fix bar hover failures in bamboo
Jani Honkonen -
r1466:730672220f94
parent child
Show More
@@ -1,508 +1,507
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
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>
24 #include <qchartview.h>
25 #include <qchart.h>
25 #include <qchart.h>
26 #include "tst_definitions.h"
26
27
27 QTCOMMERCIALCHART_USE_NAMESPACE
28 QTCOMMERCIALCHART_USE_NAMESPACE
28
29
29 Q_DECLARE_METATYPE(QBarSet*)
30 Q_DECLARE_METATYPE(QBarSet*)
30
31
31 class tst_QBarSeries : public QObject
32 class tst_QBarSeries : public QObject
32 {
33 {
33 Q_OBJECT
34 Q_OBJECT
34
35
35 public slots:
36 public slots:
36 void initTestCase();
37 void initTestCase();
37 void cleanupTestCase();
38 void cleanupTestCase();
38 void init();
39 void init();
39 void cleanup();
40 void cleanup();
40
41
41 private slots:
42 private slots:
42 void qbarseries_data();
43 void qbarseries_data();
43 void qbarseries();
44 void qbarseries();
44 void type_data();
45 void type_data();
45 void type();
46 void type();
46 void append_data();
47 void append_data();
47 void append();
48 void append();
48 void remove_data();
49 void remove_data();
49 void remove();
50 void remove();
50 void appendList_data();
51 void appendList_data();
51 void appendList();
52 void appendList();
52 void count_data();
53 void count_data();
53 void count();
54 void count();
54 void barSets_data();
55 void barSets_data();
55 void barSets();
56 void barSets();
56 void setLabelsVisible_data();
57 void setLabelsVisible_data();
57 void setLabelsVisible();
58 void setLabelsVisible();
58 void mouseclicked_data();
59 void mouseclicked_data();
59 void mouseclicked();
60 void mouseclicked();
60 void mousehovered_data();
61 void mousehovered_data();
61 void mousehovered();
62 void mousehovered();
62 void clearWithAnimations();
63 void clearWithAnimations();
63
64
64 private:
65 private:
65 QBarSeries* m_barseries;
66 QBarSeries* m_barseries;
66 QBarSeries* m_barseries_with_sets;
67 QBarSeries* m_barseries_with_sets;
67
68
68 QList<QBarSet*> m_testSets;
69 QList<QBarSet*> m_testSets;
69
70
70 };
71 };
71
72
72 void tst_QBarSeries::initTestCase()
73 void tst_QBarSeries::initTestCase()
73 {
74 {
74 qRegisterMetaType<QBarSet*>("QBarSet*");
75 qRegisterMetaType<QBarSet*>("QBarSet*");
75 }
76 }
76
77
77 void tst_QBarSeries::cleanupTestCase()
78 void tst_QBarSeries::cleanupTestCase()
78 {
79 {
79 }
80 }
80
81
81 void tst_QBarSeries::init()
82 void tst_QBarSeries::init()
82 {
83 {
83 m_barseries = new QBarSeries();
84 m_barseries = new QBarSeries();
84 m_barseries_with_sets = new QBarSeries();
85 m_barseries_with_sets = new QBarSeries();
85
86
86 for (int i=0; i<5; i++) {
87 for (int i=0; i<5; i++) {
87 m_testSets.append(new QBarSet("testset"));
88 m_testSets.append(new QBarSet("testset"));
88 m_barseries_with_sets->append(m_testSets.at(i));
89 m_barseries_with_sets->append(m_testSets.at(i));
89 }
90 }
90 }
91 }
91
92
92 void tst_QBarSeries::cleanup()
93 void tst_QBarSeries::cleanup()
93 {
94 {
94 foreach(QBarSet* s, m_testSets) {
95 foreach(QBarSet* s, m_testSets) {
95 m_barseries_with_sets->remove(s);
96 m_barseries_with_sets->remove(s);
96 delete s;
97 delete s;
97 }
98 }
98 m_testSets.clear();
99 m_testSets.clear();
99
100
100 delete m_barseries;
101 delete m_barseries;
101 m_barseries = 0;
102 m_barseries = 0;
102 delete m_barseries_with_sets;
103 delete m_barseries_with_sets;
103 m_barseries_with_sets = 0;
104 m_barseries_with_sets = 0;
104 }
105 }
105
106
106 void tst_QBarSeries::qbarseries_data()
107 void tst_QBarSeries::qbarseries_data()
107 {
108 {
108 }
109 }
109
110
110 void tst_QBarSeries::qbarseries()
111 void tst_QBarSeries::qbarseries()
111 {
112 {
112 QBarSeries *barseries = new QBarSeries();
113 QBarSeries *barseries = new QBarSeries();
113 QVERIFY(barseries != 0);
114 QVERIFY(barseries != 0);
114 }
115 }
115
116
116 void tst_QBarSeries::type_data()
117 void tst_QBarSeries::type_data()
117 {
118 {
118
119
119 }
120 }
120
121
121 void tst_QBarSeries::type()
122 void tst_QBarSeries::type()
122 {
123 {
123 QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypeBar);
124 QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypeBar);
124 }
125 }
125
126
126 void tst_QBarSeries::append_data()
127 void tst_QBarSeries::append_data()
127 {
128 {
128 }
129 }
129
130
130 void tst_QBarSeries::append()
131 void tst_QBarSeries::append()
131 {
132 {
132 QVERIFY(m_barseries->count() == 0);
133 QVERIFY(m_barseries->count() == 0);
133
134
134 bool ret = false;
135 bool ret = false;
135
136
136 // Try adding barset
137 // Try adding barset
137 QBarSet *barset = new QBarSet("testset");
138 QBarSet *barset = new QBarSet("testset");
138 ret = m_barseries->append(barset);
139 ret = m_barseries->append(barset);
139
140
140 QVERIFY(ret == true);
141 QVERIFY(ret == true);
141 QVERIFY(m_barseries->count() == 1);
142 QVERIFY(m_barseries->count() == 1);
142
143
143 // Try adding another set
144 // Try adding another set
144 QBarSet *barset2 = new QBarSet("testset2");
145 QBarSet *barset2 = new QBarSet("testset2");
145 ret = m_barseries->append(barset2);
146 ret = m_barseries->append(barset2);
146
147
147 QVERIFY(ret == true);
148 QVERIFY(ret == true);
148 QVERIFY(m_barseries->count() == 2);
149 QVERIFY(m_barseries->count() == 2);
149
150
150 // Try adding same set again
151 // Try adding same set again
151 ret = m_barseries->append(barset2);
152 ret = m_barseries->append(barset2);
152 QVERIFY(ret == false);
153 QVERIFY(ret == false);
153 QVERIFY(m_barseries->count() == 2);
154 QVERIFY(m_barseries->count() == 2);
154
155
155 // Try adding null set
156 // Try adding null set
156 ret = m_barseries->append(0);
157 ret = m_barseries->append(0);
157 QVERIFY(ret == false);
158 QVERIFY(ret == false);
158 QVERIFY(m_barseries->count() == 2);
159 QVERIFY(m_barseries->count() == 2);
159
160
160 }
161 }
161
162
162 void tst_QBarSeries::remove_data()
163 void tst_QBarSeries::remove_data()
163 {
164 {
164 }
165 }
165
166
166 void tst_QBarSeries::remove()
167 void tst_QBarSeries::remove()
167 {
168 {
168 int count = m_testSets.count();
169 int count = m_testSets.count();
169 QVERIFY(m_barseries_with_sets->count() == count);
170 QVERIFY(m_barseries_with_sets->count() == count);
170
171
171 // Try to remove null pointer (should not remove, should not crash)
172 // Try to remove null pointer (should not remove, should not crash)
172 bool ret = false;
173 bool ret = false;
173 ret = m_barseries_with_sets->remove(0);
174 ret = m_barseries_with_sets->remove(0);
174 QVERIFY(ret == false);
175 QVERIFY(ret == false);
175 QVERIFY(m_barseries_with_sets->count() == count);
176 QVERIFY(m_barseries_with_sets->count() == count);
176
177
177 // Try to remove invalid pointer (should not remove, should not crash)
178 // Try to remove invalid pointer (should not remove, should not crash)
178 ret = m_barseries_with_sets->remove((QBarSet*) (m_testSets.at(0) + 1) );
179 ret = m_barseries_with_sets->remove((QBarSet*) (m_testSets.at(0) + 1) );
179 QVERIFY(ret == false);
180 QVERIFY(ret == false);
180 QVERIFY(m_barseries_with_sets->count() == count);
181 QVERIFY(m_barseries_with_sets->count() == count);
181
182
182 // remove some sets
183 // remove some sets
183 ret = m_barseries_with_sets->remove(m_testSets.at(2));
184 ret = m_barseries_with_sets->remove(m_testSets.at(2));
184 QVERIFY(ret == true);
185 QVERIFY(ret == true);
185 ret = m_barseries_with_sets->remove(m_testSets.at(3));
186 ret = m_barseries_with_sets->remove(m_testSets.at(3));
186 QVERIFY(ret == true);
187 QVERIFY(ret == true);
187 ret = m_barseries_with_sets->remove(m_testSets.at(4));
188 ret = m_barseries_with_sets->remove(m_testSets.at(4));
188 QVERIFY(ret == true);
189 QVERIFY(ret == true);
189
190
190 QVERIFY(m_barseries_with_sets->count() == 2);
191 QVERIFY(m_barseries_with_sets->count() == 2);
191
192
192 QList<QBarSet*> verifysets = m_barseries_with_sets->barSets();
193 QList<QBarSet*> verifysets = m_barseries_with_sets->barSets();
193
194
194 QVERIFY(verifysets.at(0) == m_testSets.at(0));
195 QVERIFY(verifysets.at(0) == m_testSets.at(0));
195 QVERIFY(verifysets.at(1) == m_testSets.at(1));
196 QVERIFY(verifysets.at(1) == m_testSets.at(1));
196
197
197 // Try removing all sets again (should be ok, even if some sets have already been removed)
198 // Try removing all sets again (should be ok, even if some sets have already been removed)
198 ret = false;
199 ret = false;
199 for (int i=0; i<count; i++) {
200 for (int i=0; i<count; i++) {
200 ret |= m_barseries_with_sets->remove(m_testSets.at(i));
201 ret |= m_barseries_with_sets->remove(m_testSets.at(i));
201 }
202 }
202
203
203 QVERIFY(ret == true);
204 QVERIFY(ret == true);
204 QVERIFY(m_barseries_with_sets->count() == 0);
205 QVERIFY(m_barseries_with_sets->count() == 0);
205 }
206 }
206
207
207 void tst_QBarSeries::appendList_data()
208 void tst_QBarSeries::appendList_data()
208 {
209 {
209
210
210 }
211 }
211
212
212 void tst_QBarSeries::appendList()
213 void tst_QBarSeries::appendList()
213 {
214 {
214 int count = 5;
215 int count = 5;
215 QVERIFY(m_barseries->count() == 0);
216 QVERIFY(m_barseries->count() == 0);
216
217
217 QList<QBarSet*> sets;
218 QList<QBarSet*> sets;
218 for (int i=0; i<count; i++) {
219 for (int i=0; i<count; i++) {
219 sets.append(new QBarSet("testset"));
220 sets.append(new QBarSet("testset"));
220 }
221 }
221
222
222 // Append new sets (should succeed, count should match the count of sets)
223 // Append new sets (should succeed, count should match the count of sets)
223 bool ret = false;
224 bool ret = false;
224 ret = m_barseries->append(sets);
225 ret = m_barseries->append(sets);
225 QVERIFY(ret == true);
226 QVERIFY(ret == true);
226 QVERIFY(m_barseries->count() == count);
227 QVERIFY(m_barseries->count() == count);
227
228
228 // Append same sets again (should fail, count should remain same)
229 // Append same sets again (should fail, count should remain same)
229 ret = m_barseries->append(sets);
230 ret = m_barseries->append(sets);
230 QVERIFY(ret == false);
231 QVERIFY(ret == false);
231 QVERIFY(m_barseries->count() == count);
232 QVERIFY(m_barseries->count() == count);
232
233
233 // Try append empty list (should succeed, but count should remain same)
234 // Try append empty list (should succeed, but count should remain same)
234 QList<QBarSet*> invalidList;
235 QList<QBarSet*> invalidList;
235 ret = m_barseries->append(invalidList);
236 ret = m_barseries->append(invalidList);
236 QVERIFY(ret == true);
237 QVERIFY(ret == true);
237 QVERIFY(m_barseries->count() == count);
238 QVERIFY(m_barseries->count() == count);
238
239
239 // Try append list with one new and one existing set (should fail, count remains same)
240 // Try append list with one new and one existing set (should fail, count remains same)
240 invalidList.append(new QBarSet("ok set"));
241 invalidList.append(new QBarSet("ok set"));
241 invalidList.append(sets.at(0));
242 invalidList.append(sets.at(0));
242 ret = m_barseries->append(invalidList);
243 ret = m_barseries->append(invalidList);
243 QVERIFY(ret == false);
244 QVERIFY(ret == false);
244 QVERIFY(m_barseries->count() == count);
245 QVERIFY(m_barseries->count() == count);
245
246
246 // Try append list with null pointers (should fail, count remains same)
247 // Try append list with null pointers (should fail, count remains same)
247 QList<QBarSet*> invalidList2;
248 QList<QBarSet*> invalidList2;
248 invalidList2.append(0);
249 invalidList2.append(0);
249 invalidList2.append(0);
250 invalidList2.append(0);
250 invalidList2.append(0);
251 invalidList2.append(0);
251 ret = m_barseries->append(invalidList2);
252 ret = m_barseries->append(invalidList2);
252 QVERIFY(ret == false);
253 QVERIFY(ret == false);
253 QVERIFY(m_barseries->count() == count);
254 QVERIFY(m_barseries->count() == count);
254 }
255 }
255
256
256 void tst_QBarSeries::count_data()
257 void tst_QBarSeries::count_data()
257 {
258 {
258
259
259 }
260 }
260
261
261 void tst_QBarSeries::count()
262 void tst_QBarSeries::count()
262 {
263 {
263 QVERIFY(m_barseries->count() == 0);
264 QVERIFY(m_barseries->count() == 0);
264 QVERIFY(m_barseries_with_sets->count() == m_testSets.count());
265 QVERIFY(m_barseries_with_sets->count() == m_testSets.count());
265 }
266 }
266
267
267 void tst_QBarSeries::barSets_data()
268 void tst_QBarSeries::barSets_data()
268 {
269 {
269
270
270 }
271 }
271
272
272 void tst_QBarSeries::barSets()
273 void tst_QBarSeries::barSets()
273 {
274 {
274 QVERIFY(m_barseries->barSets().count() == 0);
275 QVERIFY(m_barseries->barSets().count() == 0);
275
276
276 QList<QBarSet*> sets = m_barseries_with_sets->barSets();
277 QList<QBarSet*> sets = m_barseries_with_sets->barSets();
277 QVERIFY(sets.count() == m_testSets.count());
278 QVERIFY(sets.count() == m_testSets.count());
278
279
279 for (int i=0; i<m_testSets.count(); i++) {
280 for (int i=0; i<m_testSets.count(); i++) {
280 QVERIFY(sets.at(i) == m_testSets.at(i));
281 QVERIFY(sets.at(i) == m_testSets.at(i));
281 }
282 }
282 }
283 }
283
284
284 void tst_QBarSeries::setLabelsVisible_data()
285 void tst_QBarSeries::setLabelsVisible_data()
285 {
286 {
286
287
287 }
288 }
288
289
289 void tst_QBarSeries::setLabelsVisible()
290 void tst_QBarSeries::setLabelsVisible()
290 {
291 {
291 // labels should be invisible by default
292 // labels should be invisible by default
292 QVERIFY(m_barseries->isLabelsVisible() == false);
293 QVERIFY(m_barseries->isLabelsVisible() == false);
293 QVERIFY(m_barseries_with_sets->isLabelsVisible() == false);
294 QVERIFY(m_barseries_with_sets->isLabelsVisible() == false);
294
295
295 // turn labels to visible
296 // turn labels to visible
296 m_barseries_with_sets->setLabelsVisible(true);
297 m_barseries_with_sets->setLabelsVisible(true);
297 // TODO: test the signal
298 // TODO: test the signal
298 QVERIFY(m_barseries_with_sets->isLabelsVisible() == true);
299 QVERIFY(m_barseries_with_sets->isLabelsVisible() == true);
299
300
300 // turn labels to invisible
301 // turn labels to invisible
301 m_barseries_with_sets->setLabelsVisible(false);
302 m_barseries_with_sets->setLabelsVisible(false);
302 // TODO: test the signal
303 // TODO: test the signal
303 QVERIFY(m_barseries_with_sets->isLabelsVisible() == false);
304 QVERIFY(m_barseries_with_sets->isLabelsVisible() == false);
304
305
305 // without parameter, should turn labels to visible
306 // without parameter, should turn labels to visible
306 m_barseries_with_sets->setLabelsVisible();
307 m_barseries_with_sets->setLabelsVisible();
307 // TODO: test the signal
308 // TODO: test the signal
308 QVERIFY(m_barseries_with_sets->isLabelsVisible() == true);
309 QVERIFY(m_barseries_with_sets->isLabelsVisible() == true);
309 }
310 }
310
311
311 void tst_QBarSeries::mouseclicked_data()
312 void tst_QBarSeries::mouseclicked_data()
312 {
313 {
313
314
314 }
315 }
315
316
316 void tst_QBarSeries::mouseclicked()
317 void tst_QBarSeries::mouseclicked()
317 {
318 {
318 QBarSeries* series = new QBarSeries();
319 QBarSeries* series = new QBarSeries();
319
320
320 QBarSet* set1 = new QBarSet(QString("set 1"));
321 QBarSet* set1 = new QBarSet(QString("set 1"));
321 *set1 << QPointF(0,10) << QPointF(1,10) << QPointF(2,10);
322 *set1 << QPointF(0,10) << QPointF(1,10) << QPointF(2,10);
322 series->append(set1);
323 series->append(set1);
323
324
324 QBarSet* set2 = new QBarSet(QString("set 2"));
325 QBarSet* set2 = new QBarSet(QString("set 2"));
325 *set2 << QPointF(0.3,10) << QPointF(1.3,10) << QPointF(2.3,10);
326 *set2 << QPointF(0.3,10) << QPointF(1.3,10) << QPointF(2.3,10);
326 series->append(set2);
327 series->append(set2);
327
328
328 QSignalSpy seriesSpy(series,SIGNAL(clicked(QBarSet*,int)));
329 QSignalSpy seriesSpy(series,SIGNAL(clicked(QBarSet*,int)));
329
330
330 QChartView view(new QChart());
331 QChartView view(new QChart());
331 view.resize(400,300);
332 view.resize(400,300);
332 view.chart()->addSeries(series);
333 view.chart()->addSeries(series);
333 view.show();
334 view.show();
334 QTest::qWaitForWindowShown(&view);
335 QTest::qWaitForWindowShown(&view);
335
336
336 //====================================================================================
337 //====================================================================================
337 // barset 1, bar 0
338 // barset 1, bar 0
338 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(102,142));
339 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(102,142));
339 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
340 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
340
341
341 QCOMPARE(seriesSpy.count(), 1);
342 QCOMPARE(seriesSpy.count(), 1);
342
343
343 QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
344 QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
344 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
345 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
345 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
346 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
346 QVERIFY(seriesSpyArg.at(1).toInt() == 0);
347 QVERIFY(seriesSpyArg.at(1).toInt() == 0);
347
348
348 //====================================================================================
349 //====================================================================================
349 // barset 1, bar 1
350 // barset 1, bar 1
350 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(186,142));
351 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(186,142));
351 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
352 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
352
353
353 QCOMPARE(seriesSpy.count(), 1);
354 QCOMPARE(seriesSpy.count(), 1);
354
355
355 seriesSpyArg = seriesSpy.takeFirst();
356 seriesSpyArg = seriesSpy.takeFirst();
356 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
357 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
357 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
358 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
358 QVERIFY(seriesSpyArg.at(1).toInt() == 1);
359 QVERIFY(seriesSpyArg.at(1).toInt() == 1);
359
360
360 //====================================================================================
361 //====================================================================================
361 // barset 1, bar 2
362 // barset 1, bar 2
362 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(271,142));
363 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(271,142));
363 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
364 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
364
365
365 QCOMPARE(seriesSpy.count(), 1);
366 QCOMPARE(seriesSpy.count(), 1);
366
367
367 seriesSpyArg = seriesSpy.takeFirst();
368 seriesSpyArg = seriesSpy.takeFirst();
368 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
369 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
369 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
370 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
370 QVERIFY(seriesSpyArg.at(1).toInt() == 2);
371 QVERIFY(seriesSpyArg.at(1).toInt() == 2);
371
372
372 //====================================================================================
373 //====================================================================================
373 // barset 2, bar 0
374 // barset 2, bar 0
374 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(127,142));
375 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(127,142));
375 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
376 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
376
377
377 QCOMPARE(seriesSpy.count(), 1);
378 QCOMPARE(seriesSpy.count(), 1);
378
379
379 seriesSpyArg = seriesSpy.takeFirst();
380 seriesSpyArg = seriesSpy.takeFirst();
380 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
381 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
381 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
382 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
382 QVERIFY(seriesSpyArg.at(1).toInt() == 0);
383 QVERIFY(seriesSpyArg.at(1).toInt() == 0);
383
384
384 //====================================================================================
385 //====================================================================================
385 // barset 2, bar 1
386 // barset 2, bar 1
386 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(212,142));
387 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(212,142));
387 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
388 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
388
389
389 QCOMPARE(seriesSpy.count(), 1);
390 QCOMPARE(seriesSpy.count(), 1);
390
391
391 seriesSpyArg = seriesSpy.takeFirst();
392 seriesSpyArg = seriesSpy.takeFirst();
392 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
393 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
393 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
394 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
394 QVERIFY(seriesSpyArg.at(1).toInt() == 1);
395 QVERIFY(seriesSpyArg.at(1).toInt() == 1);
395
396
396 //====================================================================================
397 //====================================================================================
397 // barset 2, bar 2
398 // barset 2, bar 2
398 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(296,142));
399 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(296,142));
399 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
400 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
400
401
401 QCOMPARE(seriesSpy.count(), 1);
402 QCOMPARE(seriesSpy.count(), 1);
402
403
403 seriesSpyArg = seriesSpy.takeFirst();
404 seriesSpyArg = seriesSpy.takeFirst();
404 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
405 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
405 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
406 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
406 QVERIFY(seriesSpyArg.at(1).toInt() == 2);
407 QVERIFY(seriesSpyArg.at(1).toInt() == 2);
407 }
408 }
408
409
409 void tst_QBarSeries::mousehovered_data()
410 void tst_QBarSeries::mousehovered_data()
410 {
411 {
411
412
412 }
413 }
413
414
414 void tst_QBarSeries::mousehovered()
415 void tst_QBarSeries::mousehovered()
415 {
416 {
416 QBarSeries* series = new QBarSeries();
417 QBarSeries* series = new QBarSeries();
417
418
418 QBarSet* set1 = new QBarSet(QString("set 1"));
419 QBarSet* set1 = new QBarSet(QString("set 1"));
419 *set1 << QPointF(0,10) << QPointF(1,10) << QPointF(2,10);
420 *set1 << QPointF(0,10) << QPointF(1,10) << QPointF(2,10);
420 series->append(set1);
421 series->append(set1);
421
422
422 QBarSet* set2 = new QBarSet(QString("set 2"));
423 QBarSet* set2 = new QBarSet(QString("set 2"));
423 *set2 << QPointF(0.3,10) << QPointF(1.3,10) << QPointF(2.3,10);
424 *set2 << QPointF(0.3,10) << QPointF(1.3,10) << QPointF(2.3,10);
424 series->append(set2);
425 series->append(set2);
425
426
426 QSignalSpy seriesSpy(series,SIGNAL(hovered(QBarSet*,bool)));
427 QSignalSpy seriesSpy(series,SIGNAL(hovered(QBarSet*,bool)));
427
428
428 QChartView view(new QChart());
429 QChartView view(new QChart());
429 view.resize(400,300);
430 view.resize(400,300);
430 view.chart()->addSeries(series);
431 view.chart()->addSeries(series);
431 view.show();
432 view.show();
432 QTest::qWaitForWindowShown(&view);
433 QTest::qWaitForWindowShown(&view);
433
434
434 //this is hack since view does not get events otherwise
435 //this is hack since view does not get events otherwise
435 view.setMouseTracking(true);
436 view.setMouseTracking(true);
436
437
437 //=======================================================================
438 //=======================================================================
438 // move mouse to left border
439 // move mouse to left border
439 QTest::mouseMove(view.viewport(), QPoint(0, 142));
440 QTest::mouseMove(view.viewport(), QPoint(0, 142));
440
441 QCoreApplication::processEvents(QEventLoop::AllEvents, 10000);
441 QVERIFY(seriesSpy.count() == 0);
442 TRY_COMPARE(seriesSpy.count(), 0);
442
443
443 //=======================================================================
444 //=======================================================================
444 // move mouse on top of set1
445 // move mouse on top of set1
445 QTest::mouseMove(view.viewport(), QPoint(102,142));
446 QTest::mouseMove(view.viewport(), QPoint(102,142));
446
447 TRY_COMPARE(seriesSpy.count(), 1);
447 QVERIFY(seriesSpy.count() == 1);
448
448
449 QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
449 QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
450 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
450 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
451 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
451 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
452 QVERIFY(seriesSpyArg.at(1).toBool() == true);
452 QVERIFY(seriesSpyArg.at(1).toBool() == true);
453
453
454 //=======================================================================
454 //=======================================================================
455 // move mouse from top of set1 to top of set2
455 // move mouse from top of set1 to top of set2
456 QTest::mouseMove(view.viewport(), QPoint(127,142));
456 QTest::mouseMove(view.viewport(), QPoint(127,142));
457
457 TRY_COMPARE(seriesSpy.count(), 2);
458 QVERIFY(seriesSpy.count() == 2);
459
458
460 // should leave set1
459 // should leave set1
461 seriesSpyArg = seriesSpy.takeFirst();
460 seriesSpyArg = seriesSpy.takeFirst();
462 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
461 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
463 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
462 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
464 QVERIFY(seriesSpyArg.at(1).toBool() == false);
463 QVERIFY(seriesSpyArg.at(1).toBool() == false);
465
464
466 // should enter set2
465 // should enter set2
467 seriesSpyArg = seriesSpy.takeFirst();
466 seriesSpyArg = seriesSpy.takeFirst();
468 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
467 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
469 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
468 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
470 QVERIFY(seriesSpyArg.at(1).toBool() == true);
469 QVERIFY(seriesSpyArg.at(1).toBool() == true);
471
470
472 //=======================================================================
471 //=======================================================================
473 // move mouse from top of set2 to background
472 // move mouse from top of set2 to background
474 QTest::mouseMove(view.viewport(), QPoint(127,0));
473 QTest::mouseMove(view.viewport(), QPoint(127,0));
475 QVERIFY(seriesSpy.count() == 1);
474 TRY_COMPARE(seriesSpy.count(), 1);
476
475
477 // should leave set2
476 // should leave set2
478 seriesSpyArg = seriesSpy.takeFirst();
477 seriesSpyArg = seriesSpy.takeFirst();
479 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
478 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
480 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
479 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
481 QVERIFY(seriesSpyArg.at(1).toBool() == false);
480 QVERIFY(seriesSpyArg.at(1).toBool() == false);
482 }
481 }
483
482
484 void tst_QBarSeries::clearWithAnimations()
483 void tst_QBarSeries::clearWithAnimations()
485 {
484 {
486 QBarSeries* series = new QBarSeries();
485 QBarSeries* series = new QBarSeries();
487
486
488 QBarSet* set1 = new QBarSet(QString("set 1"));
487 QBarSet* set1 = new QBarSet(QString("set 1"));
489 *set1 << QPointF(0,10) << QPointF(1,10) << QPointF(2,10);
488 *set1 << QPointF(0,10) << QPointF(1,10) << QPointF(2,10);
490 series->append(set1);
489 series->append(set1);
491
490
492 QBarSet* set2 = new QBarSet(QString("set 2"));
491 QBarSet* set2 = new QBarSet(QString("set 2"));
493 *set2 << QPointF(0.3,10) << QPointF(1.3,10) << QPointF(2.3,10);
492 *set2 << QPointF(0.3,10) << QPointF(1.3,10) << QPointF(2.3,10);
494 series->append(set2);
493 series->append(set2);
495
494
496 QChartView view(new QChart());
495 QChartView view(new QChart());
497 view.resize(400,300);
496 view.resize(400,300);
498 view.chart()->setAnimationOptions(QChart::SeriesAnimations);
497 view.chart()->setAnimationOptions(QChart::SeriesAnimations);
499 view.chart()->addSeries(series);
498 view.chart()->addSeries(series);
500 view.show();
499 view.show();
501
500
502 series->clear();
501 series->clear();
503 }
502 }
504
503
505 QTEST_MAIN(tst_QBarSeries)
504 QTEST_MAIN(tst_QBarSeries)
506
505
507 #include "tst_qbarseries.moc"
506 #include "tst_qbarseries.moc"
508
507
@@ -1,283 +1,277
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include <QtTest/QtTest>
21 #include <QtTest/QtTest>
22 #include <qgroupedbarseries.h>
22 #include <qgroupedbarseries.h>
23 #include <qbarset.h>
23 #include <qbarset.h>
24 #include <qchartview.h>
24 #include <qchartview.h>
25 #include <qchart.h>
25 #include <qchart.h>
26 #include <QBarModelMapper>
26 #include <QBarModelMapper>
27 #include <QStandardItemModel>
27 #include <QStandardItemModel>
28 #include "tst_definitions.h"
28
29
29 QTCOMMERCIALCHART_USE_NAMESPACE
30 QTCOMMERCIALCHART_USE_NAMESPACE
30
31
31 Q_DECLARE_METATYPE(QBarSet*)
32 Q_DECLARE_METATYPE(QBarSet*)
32
33
33 class tst_QGroupedBarSeries : public QObject
34 class tst_QGroupedBarSeries : public QObject
34 {
35 {
35 Q_OBJECT
36 Q_OBJECT
36
37
37 public slots:
38 public slots:
38 void initTestCase();
39 void initTestCase();
39 void cleanupTestCase();
40 void cleanupTestCase();
40 void init();
41 void init();
41 void cleanup();
42 void cleanup();
42
43
43 private slots:
44 private slots:
44 void qgroupedbarseries_data();
45 void qgroupedbarseries_data();
45 void qgroupedbarseries();
46 void qgroupedbarseries();
46 void type_data();
47 void type_data();
47 void type();
48 void type();
48 void mouseclicked_data();
49 void mouseclicked_data();
49 void mouseclicked();
50 void mouseclicked();
50 void mousehovered_data();
51 void mousehovered_data();
51 void mousehovered();
52 void mousehovered();
52
53
53 private:
54 private:
54 QGroupedBarSeries* m_barseries;
55 QGroupedBarSeries* m_barseries;
55 };
56 };
56
57
57 void tst_QGroupedBarSeries::initTestCase()
58 void tst_QGroupedBarSeries::initTestCase()
58 {
59 {
59 qRegisterMetaType<QBarSet*>("QBarSet*");
60 qRegisterMetaType<QBarSet*>("QBarSet*");
60 }
61 }
61
62
62 void tst_QGroupedBarSeries::cleanupTestCase()
63 void tst_QGroupedBarSeries::cleanupTestCase()
63 {
64 {
64 }
65 }
65
66
66 void tst_QGroupedBarSeries::init()
67 void tst_QGroupedBarSeries::init()
67 {
68 {
68 m_barseries = new QGroupedBarSeries();
69 m_barseries = new QGroupedBarSeries();
69 }
70 }
70
71
71 void tst_QGroupedBarSeries::cleanup()
72 void tst_QGroupedBarSeries::cleanup()
72 {
73 {
73 delete m_barseries;
74 delete m_barseries;
74 m_barseries = 0;
75 m_barseries = 0;
75 }
76 }
76
77
77 void tst_QGroupedBarSeries::qgroupedbarseries_data()
78 void tst_QGroupedBarSeries::qgroupedbarseries_data()
78 {
79 {
79 }
80 }
80
81
81 void tst_QGroupedBarSeries::qgroupedbarseries()
82 void tst_QGroupedBarSeries::qgroupedbarseries()
82 {
83 {
83 QGroupedBarSeries *barseries = new QGroupedBarSeries();
84 QGroupedBarSeries *barseries = new QGroupedBarSeries();
84 QVERIFY(barseries != 0);
85 QVERIFY(barseries != 0);
85 }
86 }
86
87
87 void tst_QGroupedBarSeries::type_data()
88 void tst_QGroupedBarSeries::type_data()
88 {
89 {
89
90
90 }
91 }
91
92
92 void tst_QGroupedBarSeries::type()
93 void tst_QGroupedBarSeries::type()
93 {
94 {
94 QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypeGroupedBar);
95 QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypeGroupedBar);
95 }
96 }
96
97
97 void tst_QGroupedBarSeries::mouseclicked_data()
98 void tst_QGroupedBarSeries::mouseclicked_data()
98 {
99 {
99
100
100 }
101 }
101
102
102 void tst_QGroupedBarSeries::mouseclicked()
103 void tst_QGroupedBarSeries::mouseclicked()
103 {
104 {
104 QGroupedBarSeries* series = new QGroupedBarSeries();
105 QGroupedBarSeries* series = new QGroupedBarSeries();
105
106
106 QBarSet* set1 = new QBarSet(QString("set 1"));
107 QBarSet* set1 = new QBarSet(QString("set 1"));
107 *set1 << 10 << 10 << 10;
108 *set1 << 10 << 10 << 10;
108 series->append(set1);
109 series->append(set1);
109
110
110 QBarSet* set2 = new QBarSet(QString("set 2"));
111 QBarSet* set2 = new QBarSet(QString("set 2"));
111 *set2 << 10 << 10 << 10;
112 *set2 << 10 << 10 << 10;
112 series->append(set2);
113 series->append(set2);
113
114
114 QSignalSpy seriesSpy(series,SIGNAL(clicked(QBarSet*,int)));
115 QSignalSpy seriesSpy(series,SIGNAL(clicked(QBarSet*,int)));
115
116
116 QChartView view(new QChart());
117 QChartView view(new QChart());
117 view.resize(400,300);
118 view.resize(400,300);
118 view.chart()->addSeries(series);
119 view.chart()->addSeries(series);
119 view.show();
120 view.show();
120 QTest::qWaitForWindowShown(&view);
121 QTest::qWaitForWindowShown(&view);
121
122
122 //====================================================================================
123 //====================================================================================
123 // barset 1, category test1
124 // barset 1, category test1
124 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(95,143));
125 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(95,143));
125 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
126 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
126
127
127 QCOMPARE(seriesSpy.count(), 1);
128 QCOMPARE(seriesSpy.count(), 1);
128
129
129 QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
130 QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
130 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
131 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
131 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
132 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
132 QVERIFY(seriesSpyArg.at(1).toInt() == 0);
133 QVERIFY(seriesSpyArg.at(1).toInt() == 0);
133
134
134 //====================================================================================
135 //====================================================================================
135 // barset 1, category test2
136 // barset 1, category test2
136 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(187,143));
137 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(187,143));
137 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
138 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
138
139
139 QCOMPARE(seriesSpy.count(), 1);
140 QCOMPARE(seriesSpy.count(), 1);
140
141
141 seriesSpyArg = seriesSpy.takeFirst();
142 seriesSpyArg = seriesSpy.takeFirst();
142 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
143 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
143 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
144 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
144 QVERIFY(seriesSpyArg.at(1).toInt() == 1);
145 QVERIFY(seriesSpyArg.at(1).toInt() == 1);
145
146
146 //====================================================================================
147 //====================================================================================
147 // barset 1, category test3
148 // barset 1, category test3
148 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(280,143));
149 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(280,143));
149 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
150 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
150
151
151 QCOMPARE(seriesSpy.count(), 1);
152 QCOMPARE(seriesSpy.count(), 1);
152
153
153 seriesSpyArg = seriesSpy.takeFirst();
154 seriesSpyArg = seriesSpy.takeFirst();
154 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
155 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
155 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
156 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
156 QVERIFY(seriesSpyArg.at(1).toInt() == 2);
157 QVERIFY(seriesSpyArg.at(1).toInt() == 2);
157
158
158 //====================================================================================
159 //====================================================================================
159 // barset 2, category test1
160 // barset 2, category test1
160 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(118,143));
161 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(118,143));
161 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
162 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
162
163
163 QCOMPARE(seriesSpy.count(), 1);
164 QCOMPARE(seriesSpy.count(), 1);
164
165
165 seriesSpyArg = seriesSpy.takeFirst();
166 seriesSpyArg = seriesSpy.takeFirst();
166 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
167 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
167 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
168 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
168 QVERIFY(seriesSpyArg.at(1).toInt() == 0);
169 QVERIFY(seriesSpyArg.at(1).toInt() == 0);
169
170
170 //====================================================================================
171 //====================================================================================
171 // barset 2, category test2
172 // barset 2, category test2
172 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(210,143));
173 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(210,143));
173 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
174 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
174
175
175 QCOMPARE(seriesSpy.count(), 1);
176 QCOMPARE(seriesSpy.count(), 1);
176
177
177 seriesSpyArg = seriesSpy.takeFirst();
178 seriesSpyArg = seriesSpy.takeFirst();
178 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
179 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
179 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
180 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
180 QVERIFY(seriesSpyArg.at(1).toInt() == 1);
181 QVERIFY(seriesSpyArg.at(1).toInt() == 1);
181
182
182 //====================================================================================
183 //====================================================================================
183 // barset 2, category test3
184 // barset 2, category test3
184 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(303,143));
185 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(303,143));
185 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
186 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
186
187
187 QCOMPARE(seriesSpy.count(), 1);
188 QCOMPARE(seriesSpy.count(), 1);
188
189
189 seriesSpyArg = seriesSpy.takeFirst();
190 seriesSpyArg = seriesSpy.takeFirst();
190 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
191 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
191 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
192 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
192 QVERIFY(seriesSpyArg.at(1).toInt() == 2);
193 QVERIFY(seriesSpyArg.at(1).toInt() == 2);
193 }
194 }
194
195
195 void tst_QGroupedBarSeries::mousehovered_data()
196 void tst_QGroupedBarSeries::mousehovered_data()
196 {
197 {
197
198
198 }
199 }
199
200
200 void tst_QGroupedBarSeries::mousehovered()
201 void tst_QGroupedBarSeries::mousehovered()
201 {
202 {
202 QGroupedBarSeries* series = new QGroupedBarSeries();
203 QGroupedBarSeries* series = new QGroupedBarSeries();
203
204
204 QBarSet* set1 = new QBarSet(QString("set 1"));
205 QBarSet* set1 = new QBarSet(QString("set 1"));
205 *set1 << 10 << 10 << 10;
206 *set1 << 10 << 10 << 10;
206 series->append(set1);
207 series->append(set1);
207
208
208 QBarSet* set2 = new QBarSet(QString("set 2"));
209 QBarSet* set2 = new QBarSet(QString("set 2"));
209 *set2 << 10 << 10 << 10;
210 *set2 << 10 << 10 << 10;
210 series->append(set2);
211 series->append(set2);
211
212
212 QSignalSpy seriesSpy(series,SIGNAL(hovered(QBarSet*,bool)));
213 QSignalSpy seriesSpy(series,SIGNAL(hovered(QBarSet*,bool)));
213
214
214 QChartView view(new QChart());
215 QChartView view(new QChart());
215 view.resize(400,300);
216 view.resize(400,300);
216 view.chart()->addSeries(series);
217 view.chart()->addSeries(series);
217 view.show();
218 view.show();
218 QTest::qWaitForWindowShown(&view);
219 QTest::qWaitForWindowShown(&view);
219
220
220 //this is hack since view does not get events otherwise
221 //this is hack since view does not get events otherwise
221 view.setMouseTracking(true);
222 view.setMouseTracking(true);
222
223
223 //=======================================================================
224 //=======================================================================
224 // move mouse to left border
225 // move mouse to left border
225 qDebug() << "move mouse to left border";
226 qDebug() << "move mouse to left border";
226 QTest::mouseMove(view.viewport(), QPoint(0, 143));
227 QTest::mouseMove(view.viewport(), QPoint(0, 143));
227 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
228 QCoreApplication::processEvents(QEventLoop::AllEvents, 10000);
228
229 TRY_COMPARE(seriesSpy.count(), 0);
229 QVERIFY(seriesSpy.count() == 0);
230
230
231 //=======================================================================
231 //=======================================================================
232 // move mouse on top of set1
232 // move mouse on top of set1
233 qDebug() << "move mouse on top of set1";
233 qDebug() << "move mouse on top of set1";
234 QTest::mouseMove(view.viewport(), QPoint(95,143));
234 QTest::mouseMove(view.viewport(), QPoint(95,143));
235 QCoreApplication::processEvents(QEventLoop::AllEvents, 10000);
235 TRY_COMPARE(seriesSpy.count(), 1);
236
237 QVERIFY(seriesSpy.count() == 1);
238
236
239 QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
237 QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
240 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
238 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
241 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
239 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
242 QVERIFY(seriesSpyArg.at(1).toBool() == true);
240 QVERIFY(seriesSpyArg.at(1).toBool() == true);
243
241
244 //=======================================================================
242 //=======================================================================
245 // move mouse from top of set1 to top of set2
243 // move mouse from top of set1 to top of set2
246 qDebug() << "move mouse from top of set1 to top of set2";
244 qDebug() << "move mouse from top of set1 to top of set2";
247 QTest::mouseMove(view.viewport(), QPoint(118,143));
245 QTest::mouseMove(view.viewport(), QPoint(118,143));
248 QCoreApplication::processEvents(QEventLoop::AllEvents, 10000);
246 TRY_COMPARE(seriesSpy.count(), 2);
249
250 QVERIFY(seriesSpy.count() == 2);
251
247
252 // should leave set1
248 // should leave set1
253 seriesSpyArg = seriesSpy.takeFirst();
249 seriesSpyArg = seriesSpy.takeFirst();
254 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
250 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
255 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
251 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
256 QVERIFY(seriesSpyArg.at(1).toBool() == false);
252 QVERIFY(seriesSpyArg.at(1).toBool() == false);
257
253
258 // should enter set2
254 // should enter set2
259 seriesSpyArg = seriesSpy.takeFirst();
255 seriesSpyArg = seriesSpy.takeFirst();
260 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
256 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
261 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
257 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
262 QVERIFY(seriesSpyArg.at(1).toBool() == true);
258 QVERIFY(seriesSpyArg.at(1).toBool() == true);
263
259
264 //=======================================================================
260 //=======================================================================
265 // move mouse from top of set2 to background
261 // move mouse from top of set2 to background
266 qDebug() << "move mouse from top of set2 to background";
262 qDebug() << "move mouse from top of set2 to background";
267
263
268 QTest::mouseMove(view.viewport(), QPoint(118,0));
264 QTest::mouseMove(view.viewport(), QPoint(118,0));
269 QCoreApplication::processEvents(QEventLoop::AllEvents, 10000);
265 TRY_COMPARE(seriesSpy.count(), 1);
270
271 QVERIFY(seriesSpy.count() == 1);
272
266
273 // should leave set2
267 // should leave set2
274 seriesSpyArg = seriesSpy.takeFirst();
268 seriesSpyArg = seriesSpy.takeFirst();
275 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
269 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
276 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
270 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
277 QVERIFY(seriesSpyArg.at(1).toBool() == false);
271 QVERIFY(seriesSpyArg.at(1).toBool() == false);
278 }
272 }
279
273
280 QTEST_MAIN(tst_QGroupedBarSeries)
274 QTEST_MAIN(tst_QGroupedBarSeries)
281
275
282 #include "tst_qgroupedbarseries.moc"
276 #include "tst_qgroupedbarseries.moc"
283
277
@@ -1,272 +1,270
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
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>
24 #include <qchartview.h>
25 #include <qchart.h>
25 #include <qchart.h>
26 #include "tst_definitions.h"
26
27
27 QTCOMMERCIALCHART_USE_NAMESPACE
28 QTCOMMERCIALCHART_USE_NAMESPACE
28
29
29 Q_DECLARE_METATYPE(QBarSet*)
30 Q_DECLARE_METATYPE(QBarSet*)
30
31
31 class tst_QPercentBarSeries : public QObject
32 class tst_QPercentBarSeries : public QObject
32 {
33 {
33 Q_OBJECT
34 Q_OBJECT
34
35
35 public slots:
36 public slots:
36 void initTestCase();
37 void initTestCase();
37 void cleanupTestCase();
38 void cleanupTestCase();
38 void init();
39 void init();
39 void cleanup();
40 void cleanup();
40
41
41 private slots:
42 private slots:
42 void qpercentbarseries_data();
43 void qpercentbarseries_data();
43 void qpercentbarseries();
44 void qpercentbarseries();
44 void type_data();
45 void type_data();
45 void type();
46 void type();
46 void mouseclicked_data();
47 void mouseclicked_data();
47 void mouseclicked();
48 void mouseclicked();
48 void mousehovered_data();
49 void mousehovered_data();
49 void mousehovered();
50 void mousehovered();
50
51
51 private:
52 private:
52 QPercentBarSeries* m_barseries;
53 QPercentBarSeries* m_barseries;
53 };
54 };
54
55
55 void tst_QPercentBarSeries::initTestCase()
56 void tst_QPercentBarSeries::initTestCase()
56 {
57 {
57 qRegisterMetaType<QBarSet*>("QBarSet*");
58 qRegisterMetaType<QBarSet*>("QBarSet*");
58 }
59 }
59
60
60 void tst_QPercentBarSeries::cleanupTestCase()
61 void tst_QPercentBarSeries::cleanupTestCase()
61 {
62 {
62 }
63 }
63
64
64 void tst_QPercentBarSeries::init()
65 void tst_QPercentBarSeries::init()
65 {
66 {
66 m_barseries = new QPercentBarSeries();
67 m_barseries = new QPercentBarSeries();
67 }
68 }
68
69
69 void tst_QPercentBarSeries::cleanup()
70 void tst_QPercentBarSeries::cleanup()
70 {
71 {
71 delete m_barseries;
72 delete m_barseries;
72 m_barseries = 0;
73 m_barseries = 0;
73 }
74 }
74
75
75 void tst_QPercentBarSeries::qpercentbarseries_data()
76 void tst_QPercentBarSeries::qpercentbarseries_data()
76 {
77 {
77 }
78 }
78
79
79 void tst_QPercentBarSeries::qpercentbarseries()
80 void tst_QPercentBarSeries::qpercentbarseries()
80 {
81 {
81 QPercentBarSeries *barseries = new QPercentBarSeries();
82 QPercentBarSeries *barseries = new QPercentBarSeries();
82 QVERIFY(barseries != 0);
83 QVERIFY(barseries != 0);
83 }
84 }
84
85
85 void tst_QPercentBarSeries::type_data()
86 void tst_QPercentBarSeries::type_data()
86 {
87 {
87
88
88 }
89 }
89
90
90 void tst_QPercentBarSeries::type()
91 void tst_QPercentBarSeries::type()
91 {
92 {
92 QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypePercentBar);
93 QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypePercentBar);
93 }
94 }
94
95
95 void tst_QPercentBarSeries::mouseclicked_data()
96 void tst_QPercentBarSeries::mouseclicked_data()
96 {
97 {
97
98
98 }
99 }
99
100
100 void tst_QPercentBarSeries::mouseclicked()
101 void tst_QPercentBarSeries::mouseclicked()
101 {
102 {
102 QPercentBarSeries* series = new QPercentBarSeries();
103 QPercentBarSeries* series = new QPercentBarSeries();
103
104
104 QBarSet* set1 = new QBarSet(QString("set 1"));
105 QBarSet* set1 = new QBarSet(QString("set 1"));
105 *set1 << 10 << 10 << 10;
106 *set1 << 10 << 10 << 10;
106 series->append(set1);
107 series->append(set1);
107
108
108 QBarSet* set2 = new QBarSet(QString("set 2"));
109 QBarSet* set2 = new QBarSet(QString("set 2"));
109 *set2 << 10 << 10 << 10;
110 *set2 << 10 << 10 << 10;
110 series->append(set2);
111 series->append(set2);
111
112
112 QSignalSpy seriesSpy(series,SIGNAL(clicked(QBarSet*,int)));
113 QSignalSpy seriesSpy(series,SIGNAL(clicked(QBarSet*,int)));
113
114
114 QChartView view(new QChart());
115 QChartView view(new QChart());
115 view.resize(400,300);
116 view.resize(400,300);
116 view.chart()->addSeries(series);
117 view.chart()->addSeries(series);
117 view.show();
118 view.show();
118 QTest::qWaitForWindowShown(&view);
119 QTest::qWaitForWindowShown(&view);
119
120
120 //====================================================================================
121 //====================================================================================
121 // barset 1, category test1
122 // barset 1, category test1
122 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(106,190));
123 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(106,190));
123 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
124 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
124
125
125 QCOMPARE(seriesSpy.count(), 1);
126 QCOMPARE(seriesSpy.count(), 1);
126
127
127 QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
128 QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
128 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
129 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
129 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
130 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
130 QVERIFY(seriesSpyArg.at(1).toInt() == 0);
131 QVERIFY(seriesSpyArg.at(1).toInt() == 0);
131
132
132 //====================================================================================
133 //====================================================================================
133 // barset 1, category test2
134 // barset 1, category test2
134 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(199,190));
135 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(199,190));
135 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
136 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
136
137
137 QCOMPARE(seriesSpy.count(), 1);
138 QCOMPARE(seriesSpy.count(), 1);
138
139
139 seriesSpyArg = seriesSpy.takeFirst();
140 seriesSpyArg = seriesSpy.takeFirst();
140 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
141 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
141 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
142 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
142 QVERIFY(seriesSpyArg.at(1).toInt() == 1);
143 QVERIFY(seriesSpyArg.at(1).toInt() == 1);
143
144
144 //====================================================================================
145 //====================================================================================
145 // barset 1, category test3
146 // barset 1, category test3
146 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(292,190));
147 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(292,190));
147 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
148 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
148
149
149 QCOMPARE(seriesSpy.count(), 1);
150 QCOMPARE(seriesSpy.count(), 1);
150
151
151 seriesSpyArg = seriesSpy.takeFirst();
152 seriesSpyArg = seriesSpy.takeFirst();
152 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
153 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
153 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
154 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
154 QVERIFY(seriesSpyArg.at(1).toInt() == 2);
155 QVERIFY(seriesSpyArg.at(1).toInt() == 2);
155
156
156 //====================================================================================
157 //====================================================================================
157 // barset 2, category test1
158 // barset 2, category test1
158 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(106,95));
159 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(106,95));
159 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
160 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
160
161
161 QCOMPARE(seriesSpy.count(), 1);
162 QCOMPARE(seriesSpy.count(), 1);
162
163
163 seriesSpyArg = seriesSpy.takeFirst();
164 seriesSpyArg = seriesSpy.takeFirst();
164 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
165 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
165 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
166 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
166 QVERIFY(seriesSpyArg.at(1).toInt() == 0);
167 QVERIFY(seriesSpyArg.at(1).toInt() == 0);
167
168
168 //====================================================================================
169 //====================================================================================
169 // barset 2, category test2
170 // barset 2, category test2
170 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(199,95));
171 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(199,95));
171 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
172 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
172
173
173 QCOMPARE(seriesSpy.count(), 1);
174 QCOMPARE(seriesSpy.count(), 1);
174
175
175 seriesSpyArg = seriesSpy.takeFirst();
176 seriesSpyArg = seriesSpy.takeFirst();
176 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
177 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
177 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
178 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
178 QVERIFY(seriesSpyArg.at(1).toInt() == 1);
179 QVERIFY(seriesSpyArg.at(1).toInt() == 1);
179
180
180 //====================================================================================
181 //====================================================================================
181 // barset 2, category test3
182 // barset 2, category test3
182 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(292,95));
183 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(292,95));
183 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
184 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
184
185
185 QCOMPARE(seriesSpy.count(), 1);
186 QCOMPARE(seriesSpy.count(), 1);
186
187
187 seriesSpyArg = seriesSpy.takeFirst();
188 seriesSpyArg = seriesSpy.takeFirst();
188 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
189 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
189 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
190 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
190 QVERIFY(seriesSpyArg.at(1).toInt() == 2);
191 QVERIFY(seriesSpyArg.at(1).toInt() == 2);
191 }
192 }
192
193
193 void tst_QPercentBarSeries::mousehovered_data()
194 void tst_QPercentBarSeries::mousehovered_data()
194 {
195 {
195
196
196 }
197 }
197
198
198 void tst_QPercentBarSeries::mousehovered()
199 void tst_QPercentBarSeries::mousehovered()
199 {
200 {
200 QPercentBarSeries* series = new QPercentBarSeries();
201 QPercentBarSeries* series = new QPercentBarSeries();
201
202
202 QBarSet* set1 = new QBarSet(QString("set 1"));
203 QBarSet* set1 = new QBarSet(QString("set 1"));
203 *set1 << 10 << 10 << 10;
204 *set1 << 10 << 10 << 10;
204 series->append(set1);
205 series->append(set1);
205
206
206 QBarSet* set2 = new QBarSet(QString("set 2"));
207 QBarSet* set2 = new QBarSet(QString("set 2"));
207 *set2 << 10 << 10 << 10;
208 *set2 << 10 << 10 << 10;
208 series->append(set2);
209 series->append(set2);
209
210
210 QSignalSpy seriesSpy(series,SIGNAL(hovered(QBarSet*,bool)));
211 QSignalSpy seriesSpy(series,SIGNAL(hovered(QBarSet*,bool)));
211
212
212 QChartView view(new QChart());
213 QChartView view(new QChart());
213 view.resize(400,300);
214 view.resize(400,300);
214 view.chart()->addSeries(series);
215 view.chart()->addSeries(series);
215 view.show();
216 view.show();
216 QTest::qWaitForWindowShown(&view);
217 QTest::qWaitForWindowShown(&view);
217
218
218 //this is hack since view does not get events otherwise
219 //this is hack since view does not get events otherwise
219 view.setMouseTracking(true);
220 view.setMouseTracking(true);
220
221
221 //=======================================================================
222 //=======================================================================
222 // move mouse to left border
223 // move mouse to left border
223 QTest::mouseMove(view.viewport(), QPoint(0, 190));
224 QTest::mouseMove(view.viewport(), QPoint(0, 190));
224
225 QCoreApplication::processEvents(QEventLoop::AllEvents, 10000);
225 QVERIFY(seriesSpy.count() == 0);
226 TRY_COMPARE(seriesSpy.count(), 0);
226
227
227 //=======================================================================
228 //=======================================================================
228 // move mouse on top of set1
229 // move mouse on top of set1
229 QTest::mouseMove(view.viewport(), QPoint(106,190));
230 QTest::mouseMove(view.viewport(), QPoint(106,190));
230
231 TRY_COMPARE(seriesSpy.count(), 1);
231 QVERIFY(seriesSpy.count() == 1);
232
232
233 QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
233 QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
234 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);
235 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
236 QVERIFY(seriesSpyArg.at(1).toBool() == true);
236 QVERIFY(seriesSpyArg.at(1).toBool() == true);
237
237
238 //=======================================================================
238 //=======================================================================
239 // move mouse from top of set1 to top of set2
239 // move mouse from top of set1 to top of set2
240 QTest::mouseMove(view.viewport(), QPoint(106,95));
240 QTest::mouseMove(view.viewport(), QPoint(106,95));
241
241 TRY_COMPARE(seriesSpy.count(), 2);
242 QVERIFY(seriesSpy.count() == 2);
243
242
244 // should leave set1
243 // should leave set1
245 seriesSpyArg = seriesSpy.takeFirst();
244 seriesSpyArg = seriesSpy.takeFirst();
246 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
245 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
247 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
246 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
248 QVERIFY(seriesSpyArg.at(1).toBool() == false);
247 QVERIFY(seriesSpyArg.at(1).toBool() == false);
249
248
250 // should enter set2
249 // should enter set2
251 seriesSpyArg = seriesSpy.takeFirst();
250 seriesSpyArg = seriesSpy.takeFirst();
252 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
251 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
253 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
252 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
254 QVERIFY(seriesSpyArg.at(1).toBool() == true);
253 QVERIFY(seriesSpyArg.at(1).toBool() == true);
255
254
256 //=======================================================================
255 //=======================================================================
257 // move mouse from top of set2 to background
256 // move mouse from top of set2 to background
258 QTest::mouseMove(view.viewport(), QPoint(106,0));
257 QTest::mouseMove(view.viewport(), QPoint(106,0));
259
258 TRY_COMPARE(seriesSpy.count(), 1);
260 QVERIFY(seriesSpy.count() == 1);
261
259
262 // should leave set2
260 // should leave set2
263 seriesSpyArg = seriesSpy.takeFirst();
261 seriesSpyArg = seriesSpy.takeFirst();
264 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
262 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
265 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
263 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
266 QVERIFY(seriesSpyArg.at(1).toBool() == false);
264 QVERIFY(seriesSpyArg.at(1).toBool() == false);
267 }
265 }
268
266
269 QTEST_MAIN(tst_QPercentBarSeries)
267 QTEST_MAIN(tst_QPercentBarSeries)
270
268
271 #include "tst_qpercentbarseries.moc"
269 #include "tst_qpercentbarseries.moc"
272
270
@@ -1,272 +1,270
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
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>
24 #include <qchartview.h>
25 #include <qchart.h>
25 #include <qchart.h>
26 #include "tst_definitions.h"
26
27
27 QTCOMMERCIALCHART_USE_NAMESPACE
28 QTCOMMERCIALCHART_USE_NAMESPACE
28
29
29 Q_DECLARE_METATYPE(QBarSet*)
30 Q_DECLARE_METATYPE(QBarSet*)
30
31
31 class tst_QStackedBarSeries : public QObject
32 class tst_QStackedBarSeries : public QObject
32 {
33 {
33 Q_OBJECT
34 Q_OBJECT
34
35
35 public slots:
36 public slots:
36 void initTestCase();
37 void initTestCase();
37 void cleanupTestCase();
38 void cleanupTestCase();
38 void init();
39 void init();
39 void cleanup();
40 void cleanup();
40
41
41 private slots:
42 private slots:
42 void qstackedbarseries_data();
43 void qstackedbarseries_data();
43 void qstackedbarseries();
44 void qstackedbarseries();
44 void type_data();
45 void type_data();
45 void type();
46 void type();
46 void mouseclicked_data();
47 void mouseclicked_data();
47 void mouseclicked();
48 void mouseclicked();
48 void mousehovered_data();
49 void mousehovered_data();
49 void mousehovered();
50 void mousehovered();
50
51
51 private:
52 private:
52 QStackedBarSeries* m_barseries;
53 QStackedBarSeries* m_barseries;
53 };
54 };
54
55
55 void tst_QStackedBarSeries::initTestCase()
56 void tst_QStackedBarSeries::initTestCase()
56 {
57 {
57 qRegisterMetaType<QBarSet*>("QBarSet*");
58 qRegisterMetaType<QBarSet*>("QBarSet*");
58 }
59 }
59
60
60 void tst_QStackedBarSeries::cleanupTestCase()
61 void tst_QStackedBarSeries::cleanupTestCase()
61 {
62 {
62 }
63 }
63
64
64 void tst_QStackedBarSeries::init()
65 void tst_QStackedBarSeries::init()
65 {
66 {
66 m_barseries = new QStackedBarSeries();
67 m_barseries = new QStackedBarSeries();
67 }
68 }
68
69
69 void tst_QStackedBarSeries::cleanup()
70 void tst_QStackedBarSeries::cleanup()
70 {
71 {
71 delete m_barseries;
72 delete m_barseries;
72 m_barseries = 0;
73 m_barseries = 0;
73 }
74 }
74
75
75 void tst_QStackedBarSeries::qstackedbarseries_data()
76 void tst_QStackedBarSeries::qstackedbarseries_data()
76 {
77 {
77 }
78 }
78
79
79 void tst_QStackedBarSeries::qstackedbarseries()
80 void tst_QStackedBarSeries::qstackedbarseries()
80 {
81 {
81 QStackedBarSeries *barseries = new QStackedBarSeries();
82 QStackedBarSeries *barseries = new QStackedBarSeries();
82 QVERIFY(barseries != 0);
83 QVERIFY(barseries != 0);
83 }
84 }
84
85
85 void tst_QStackedBarSeries::type_data()
86 void tst_QStackedBarSeries::type_data()
86 {
87 {
87
88
88 }
89 }
89
90
90 void tst_QStackedBarSeries::type()
91 void tst_QStackedBarSeries::type()
91 {
92 {
92 QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypeStackedBar);
93 QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypeStackedBar);
93 }
94 }
94
95
95 void tst_QStackedBarSeries::mouseclicked_data()
96 void tst_QStackedBarSeries::mouseclicked_data()
96 {
97 {
97
98
98 }
99 }
99
100
100 void tst_QStackedBarSeries::mouseclicked()
101 void tst_QStackedBarSeries::mouseclicked()
101 {
102 {
102 QStackedBarSeries* series = new QStackedBarSeries();
103 QStackedBarSeries* series = new QStackedBarSeries();
103
104
104 QBarSet* set1 = new QBarSet(QString("set 1"));
105 QBarSet* set1 = new QBarSet(QString("set 1"));
105 *set1 << 10 << 10 << 10;
106 *set1 << 10 << 10 << 10;
106 series->append(set1);
107 series->append(set1);
107
108
108 QBarSet* set2 = new QBarSet(QString("set 2"));
109 QBarSet* set2 = new QBarSet(QString("set 2"));
109 *set2 << 10 << 10 << 10;
110 *set2 << 10 << 10 << 10;
110 series->append(set2);
111 series->append(set2);
111
112
112 QSignalSpy seriesSpy(series,SIGNAL(clicked(QBarSet*,int)));
113 QSignalSpy seriesSpy(series,SIGNAL(clicked(QBarSet*,int)));
113
114
114 QChartView view(new QChart());
115 QChartView view(new QChart());
115 view.resize(400,300);
116 view.resize(400,300);
116 view.chart()->addSeries(series);
117 view.chart()->addSeries(series);
117 view.show();
118 view.show();
118 QTest::qWaitForWindowShown(&view);
119 QTest::qWaitForWindowShown(&view);
119
120
120 //====================================================================================
121 //====================================================================================
121 // barset 1, category test1
122 // barset 1, category test1
122 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(106,190));
123 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(106,190));
123 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
124 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
124
125
125 QCOMPARE(seriesSpy.count(), 1);
126 QCOMPARE(seriesSpy.count(), 1);
126
127
127 QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
128 QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
128 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
129 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
129 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
130 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
130 QVERIFY(seriesSpyArg.at(1).toInt() == 0);
131 QVERIFY(seriesSpyArg.at(1).toInt() == 0);
131
132
132 //====================================================================================
133 //====================================================================================
133 // barset 1, category test2
134 // barset 1, category test2
134 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(199,190));
135 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(199,190));
135 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
136 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
136
137
137 QCOMPARE(seriesSpy.count(), 1);
138 QCOMPARE(seriesSpy.count(), 1);
138
139
139 seriesSpyArg = seriesSpy.takeFirst();
140 seriesSpyArg = seriesSpy.takeFirst();
140 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
141 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
141 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
142 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
142 QVERIFY(seriesSpyArg.at(1).toInt() == 1);
143 QVERIFY(seriesSpyArg.at(1).toInt() == 1);
143
144
144 //====================================================================================
145 //====================================================================================
145 // barset 1, category test3
146 // barset 1, category test3
146 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(292,190));
147 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(292,190));
147 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
148 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
148
149
149 QCOMPARE(seriesSpy.count(), 1);
150 QCOMPARE(seriesSpy.count(), 1);
150
151
151 seriesSpyArg = seriesSpy.takeFirst();
152 seriesSpyArg = seriesSpy.takeFirst();
152 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
153 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
153 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
154 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
154 QVERIFY(seriesSpyArg.at(1).toInt() == 2);
155 QVERIFY(seriesSpyArg.at(1).toInt() == 2);
155
156
156 //====================================================================================
157 //====================================================================================
157 // barset 2, category test1
158 // barset 2, category test1
158 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(106,95));
159 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(106,95));
159 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
160 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
160
161
161 QCOMPARE(seriesSpy.count(), 1);
162 QCOMPARE(seriesSpy.count(), 1);
162
163
163 seriesSpyArg = seriesSpy.takeFirst();
164 seriesSpyArg = seriesSpy.takeFirst();
164 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
165 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
165 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
166 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
166 QVERIFY(seriesSpyArg.at(1).toInt() == 0);
167 QVERIFY(seriesSpyArg.at(1).toInt() == 0);
167
168
168 //====================================================================================
169 //====================================================================================
169 // barset 2, category test2
170 // barset 2, category test2
170 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(199,95));
171 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(199,95));
171 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
172 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
172
173
173 QCOMPARE(seriesSpy.count(), 1);
174 QCOMPARE(seriesSpy.count(), 1);
174
175
175 seriesSpyArg = seriesSpy.takeFirst();
176 seriesSpyArg = seriesSpy.takeFirst();
176 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
177 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
177 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
178 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
178 QVERIFY(seriesSpyArg.at(1).toInt() == 1);
179 QVERIFY(seriesSpyArg.at(1).toInt() == 1);
179
180
180 //====================================================================================
181 //====================================================================================
181 // barset 2, category test3
182 // barset 2, category test3
182 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(292,95));
183 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(292,95));
183 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
184 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
184
185
185 QCOMPARE(seriesSpy.count(), 1);
186 QCOMPARE(seriesSpy.count(), 1);
186
187
187 seriesSpyArg = seriesSpy.takeFirst();
188 seriesSpyArg = seriesSpy.takeFirst();
188 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
189 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
189 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
190 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int);
190 QVERIFY(seriesSpyArg.at(1).toInt() == 2);
191 QVERIFY(seriesSpyArg.at(1).toInt() == 2);
191 }
192 }
192
193
193 void tst_QStackedBarSeries::mousehovered_data()
194 void tst_QStackedBarSeries::mousehovered_data()
194 {
195 {
195
196
196 }
197 }
197
198
198 void tst_QStackedBarSeries::mousehovered()
199 void tst_QStackedBarSeries::mousehovered()
199 {
200 {
200 QStackedBarSeries* series = new QStackedBarSeries();
201 QStackedBarSeries* series = new QStackedBarSeries();
201
202
202 QBarSet* set1 = new QBarSet(QString("set 1"));
203 QBarSet* set1 = new QBarSet(QString("set 1"));
203 *set1 << 10 << 10 << 10;
204 *set1 << 10 << 10 << 10;
204 series->append(set1);
205 series->append(set1);
205
206
206 QBarSet* set2 = new QBarSet(QString("set 2"));
207 QBarSet* set2 = new QBarSet(QString("set 2"));
207 *set2 << 10 << 10 << 10;
208 *set2 << 10 << 10 << 10;
208 series->append(set2);
209 series->append(set2);
209
210
210 QSignalSpy seriesSpy(series,SIGNAL(hovered(QBarSet*,bool)));
211 QSignalSpy seriesSpy(series,SIGNAL(hovered(QBarSet*,bool)));
211
212
212 QChartView view(new QChart());
213 QChartView view(new QChart());
213 view.resize(400,300);
214 view.resize(400,300);
214 view.chart()->addSeries(series);
215 view.chart()->addSeries(series);
215 view.show();
216 view.show();
216 QTest::qWaitForWindowShown(&view);
217 QTest::qWaitForWindowShown(&view);
217
218
218 //this is hack since view does not get events otherwise
219 //this is hack since view does not get events otherwise
219 view.setMouseTracking(true);
220 view.setMouseTracking(true);
220
221
221 //=======================================================================
222 //=======================================================================
222 // move mouse to left border
223 // move mouse to left border
223 QTest::mouseMove(view.viewport(), QPoint(0, 190));
224 QTest::mouseMove(view.viewport(), QPoint(0, 190));
224
225 QCoreApplication::processEvents(QEventLoop::AllEvents, 10000);
225 QVERIFY(seriesSpy.count() == 0);
226 TRY_COMPARE(seriesSpy.count(), 0);
226
227
227 //=======================================================================
228 //=======================================================================
228 // move mouse on top of set1
229 // move mouse on top of set1
229 QTest::mouseMove(view.viewport(), QPoint(106,190));
230 QTest::mouseMove(view.viewport(), QPoint(106,190));
230
231 TRY_COMPARE(seriesSpy.count(), 1);
231 QVERIFY(seriesSpy.count() == 1);
232
232
233 QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
233 QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
234 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);
235 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
236 QVERIFY(seriesSpyArg.at(1).toBool() == true);
236 QVERIFY(seriesSpyArg.at(1).toBool() == true);
237
237
238 //=======================================================================
238 //=======================================================================
239 // move mouse from top of set1 to top of set2
239 // move mouse from top of set1 to top of set2
240 QTest::mouseMove(view.viewport(), QPoint(106,95));
240 QTest::mouseMove(view.viewport(), QPoint(106,95));
241
241 TRY_COMPARE(seriesSpy.count(), 2);
242 QVERIFY(seriesSpy.count() == 2);
243
242
244 // should leave set1
243 // should leave set1
245 seriesSpyArg = seriesSpy.takeFirst();
244 seriesSpyArg = seriesSpy.takeFirst();
246 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
245 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1);
247 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
246 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
248 QVERIFY(seriesSpyArg.at(1).toBool() == false);
247 QVERIFY(seriesSpyArg.at(1).toBool() == false);
249
248
250 // should enter set2
249 // should enter set2
251 seriesSpyArg = seriesSpy.takeFirst();
250 seriesSpyArg = seriesSpy.takeFirst();
252 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
251 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
253 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
252 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
254 QVERIFY(seriesSpyArg.at(1).toBool() == true);
253 QVERIFY(seriesSpyArg.at(1).toBool() == true);
255
254
256 //=======================================================================
255 //=======================================================================
257 // move mouse from top of set2 to background
256 // move mouse from top of set2 to background
258 QTest::mouseMove(view.viewport(), QPoint(106,0));
257 QTest::mouseMove(view.viewport(), QPoint(106,0));
259
258 TRY_COMPARE(seriesSpy.count(), 1);
260 QVERIFY(seriesSpy.count() == 1);
261
259
262 // should leave set2
260 // should leave set2
263 seriesSpyArg = seriesSpy.takeFirst();
261 seriesSpyArg = seriesSpy.takeFirst();
264 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
262 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2);
265 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
263 QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool);
266 QVERIFY(seriesSpyArg.at(1).toBool() == false);
264 QVERIFY(seriesSpyArg.at(1).toBool() == false);
267 }
265 }
268
266
269 QTEST_MAIN(tst_QStackedBarSeries)
267 QTEST_MAIN(tst_QStackedBarSeries)
270
268
271 #include "tst_qstackedbarseries.moc"
269 #include "tst_qstackedbarseries.moc"
272
270
General Comments 0
You need to be logged in to leave comments. Login now