@@ -282,11 +282,11 void tst_qpieseries::clickedSignal() | |||
|
282 | 282 | { |
|
283 | 283 | // create a pie series |
|
284 | 284 | QPieSeries *series = new QPieSeries(); |
|
285 | series->setPieSize(1.0); | |
|
286 | 285 | QPieSlice *s1 = series->append("slice 1", 1); |
|
287 |
series->append("slice 2", |
|
|
288 |
series->append("slice 3", |
|
|
289 | QSignalSpy clickSpy1(series, SIGNAL(clicked(QPieSlice*))); | |
|
286 | QPieSlice *s2 = series->append("slice 2", 1); | |
|
287 | QPieSlice *s3 = series->append("slice 3", 1); | |
|
288 | QPieSlice *s4 = series->append("slice 4", 1); | |
|
289 | QSignalSpy clickSpy(series, SIGNAL(clicked(QPieSlice*))); | |
|
290 | 290 | |
|
291 | 291 | // add series to the chart |
|
292 | 292 | QChartView view(new QChart()); |
@@ -296,11 +296,68 void tst_qpieseries::clickedSignal() | |||
|
296 | 296 | view.show(); |
|
297 | 297 | QTest::qWaitForWindowShown(&view); |
|
298 | 298 | |
|
299 | // simulate clicks | |
|
300 | // pie rectangle: QRectF(60,60 121x121) | |
|
301 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(146, 90)); // inside slice 1 | |
|
302 | TRY_COMPARE(clickSpy1.count(), 1); | |
|
303 | QCOMPARE(qvariant_cast<QPieSlice*>(clickSpy1.at(0).at(0)), s1); | |
|
299 | // if you devide the chart in four equal tiles these | |
|
300 | // are the center points of those tiles | |
|
301 | QPoint p1(90.25, 90); | |
|
302 | QPoint p2(150, 90); | |
|
303 | QPoint p3(90, 150); | |
|
304 | QPoint p4(150, 150); | |
|
305 | ||
|
306 | QPoint center(120, 120); | |
|
307 | ||
|
308 | series->setPieSize(1.0); | |
|
309 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, p1); | |
|
310 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, p2); | |
|
311 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, p3); | |
|
312 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, p4); | |
|
313 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, center); | |
|
314 | TRY_COMPARE(clickSpy.count(), 5); // all hit | |
|
315 | QCOMPARE(qvariant_cast<QPieSlice*>(clickSpy.at(0).at(0)), s4); | |
|
316 | QCOMPARE(qvariant_cast<QPieSlice*>(clickSpy.at(1).at(0)), s1); | |
|
317 | QCOMPARE(qvariant_cast<QPieSlice*>(clickSpy.at(2).at(0)), s3); | |
|
318 | QCOMPARE(qvariant_cast<QPieSlice*>(clickSpy.at(3).at(0)), s2); | |
|
319 | clickSpy.clear(); | |
|
320 | ||
|
321 | series->setPieSize(0.5); | |
|
322 | series->setVerticalPosition(0.25); | |
|
323 | series->setHorizontalPosition(0.25); | |
|
324 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, p1); // hits | |
|
325 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, p2); | |
|
326 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, p3); | |
|
327 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, p4); | |
|
328 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, center); | |
|
329 | TRY_COMPARE(clickSpy.count(), 1); | |
|
330 | clickSpy.clear(); | |
|
331 | ||
|
332 | series->setVerticalPosition(0.25); | |
|
333 | series->setHorizontalPosition(0.75); | |
|
334 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, p1); | |
|
335 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, p2); // hits | |
|
336 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, p3); | |
|
337 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, p4); | |
|
338 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, center); | |
|
339 | TRY_COMPARE(clickSpy.count(), 1); | |
|
340 | clickSpy.clear(); | |
|
341 | ||
|
342 | series->setVerticalPosition(0.75); | |
|
343 | series->setHorizontalPosition(0.25); | |
|
344 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, p1); | |
|
345 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, p2); | |
|
346 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, p3); // hits | |
|
347 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, p4); | |
|
348 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, center); | |
|
349 | TRY_COMPARE(clickSpy.count(), 1); | |
|
350 | clickSpy.clear(); | |
|
351 | ||
|
352 | series->setVerticalPosition(0.75); | |
|
353 | series->setHorizontalPosition(0.75); | |
|
354 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, p1); | |
|
355 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, p2); | |
|
356 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, p3); | |
|
357 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, p4); // hits | |
|
358 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, center); | |
|
359 | TRY_COMPARE(clickSpy.count(), 1); | |
|
360 | clickSpy.clear(); | |
|
304 | 361 | } |
|
305 | 362 | |
|
306 | 363 | void tst_qpieseries::hoverSignal() |
General Comments 0
You need to be logged in to leave comments.
Login now