##// END OF EJS Templates
QBarSet auto test to show the sets in QChartView
Tero Ahola -
r1335:2ed58f4cde3a
parent child
Show More
@@ -20,6 +20,8
20 20
21 21 #include <QtTest/QtTest>
22 22 #include <qbarset.h>
23 #include <qgroupedbarseries.h>
24 #include <qchartview.h>
23 25
24 26 QTCOMMERCIALCHART_USE_NAMESPACE
25 27
@@ -56,14 +58,7 private slots:
56 58 void count();
57 59 void sum_data();
58 60 void sum();
59 void setPen_data();
60 void setPen();
61 void setBrush_data();
62 void setBrush();
63 void setLabelBrush_data();
64 void setLabelBrush();
65 void setLabelFont_data();
66 void setLabelFont();
61 void customize();
67 62
68 63 private:
69 64 QBarSet* m_barset;
@@ -346,72 +341,68 void tst_QBarSet::sum()
346 341 QVERIFY(qFuzzyCompare(m_barset->sum(),10.0));
347 342 }
348 343
349 void tst_QBarSet::setPen_data()
350 {
351
352 }
353
354 void tst_QBarSet::setPen()
355 {
356 QVERIFY(m_barset->pen() == QPen());
357
358 QPen pen;
359 pen.setColor(QColor(128,128,128,128));
360 m_barset->setPen(pen);
361
362 QVERIFY(m_barset->pen() == pen);
363 }
364
365 void tst_QBarSet::setBrush_data()
366 {
367
368 }
369
370 void tst_QBarSet::setBrush()
371 {
372 QVERIFY(m_barset->brush() == QBrush());
373
374 QBrush brush;
375 brush.setColor(QColor(128,128,128,128));
376 m_barset->setBrush(brush);
377
378 QVERIFY(m_barset->brush() == brush);
379 }
380
381 void tst_QBarSet::setLabelBrush_data()
382 {
383
384 }
385
386 void tst_QBarSet::setLabelBrush()
387 {
388 QVERIFY(m_barset->labelBrush() == QBrush());
389
390 QBrush brush;
391 brush.setColor(QColor(128,128,128,128));
392 m_barset->setLabelBrush(brush);
393
394 QVERIFY(m_barset->labelBrush() == brush);
395 }
396
397 void tst_QBarSet::setLabelFont_data()
398 {
399
400 }
401
402 void tst_QBarSet::setLabelFont()
403 {
404 QVERIFY(m_barset->labelFont() == QFont());
405
344 void tst_QBarSet::customize()
345 {
346 // Create sets
347 QBarSet *set1 = new QBarSet("set1");
348 QBarSet *set2 = new QBarSet("set2");
349
350 // Append set1 to series
351 QGroupedBarSeries *series = new QGroupedBarSeries();
352 series->append(set1);
353
354 // Add series to the chart
355 QChartView view(new QChart());
356 view.resize(200, 200);
357 view.chart()->addSeries(series);
358 view.show();
359 QTest::qWaitForWindowShown(&view);
360
361 // Test adding data to the sets
362 *set1 << 1 << 2 << 1 << 3;
363 *set2 << 2 << 1 << 3 << 1;
364
365 // Test pen
366 QVERIFY(set1->pen() != QPen());
367 QVERIFY(set2->pen() == QPen());
368 QPen pen(QColor(128,128,128,128));
369 set1->setPen(pen);
370 QVERIFY(set1->pen() == pen);
371 QVERIFY(set2->pen() == QPen());
372
373 // Test brush
374 QVERIFY(set1->brush() != QBrush());
375 QVERIFY(set2->brush() == QBrush());
376 QBrush brush(QColor(128,128,128,128));
377 set1->setBrush(brush);
378 QVERIFY(set1->brush() == brush);
379 QVERIFY(set2->brush() == QBrush());
380
381 // Test label brush
382 QVERIFY(set1->labelBrush() != QBrush());
383 QVERIFY(set2->labelBrush() == QBrush());
384 set1->setLabelBrush(brush);
385 QVERIFY(set1->labelBrush() == brush);
386 QVERIFY(set2->labelBrush() == QBrush());
387
388 // Test label font
389 // Note: QFont empty constructor creates font with application's default font, so the font may or may not be the
390 // same for the set added to the series (depending on the QChart's theme configuration)
391 QVERIFY(set1->labelFont() != QFont() || set1->labelFont() == QFont());
392 QVERIFY(set2->labelFont() == QFont());
406 393 QFont font;
407 394 font.setBold(true);
408 395 font.setItalic(true);
409 m_barset->setLabelFont(font);
396 set1->setLabelFont(font);
397 QVERIFY(set1->labelFont() == font);
398 QVERIFY(set2->labelFont() == QFont());
410 399
411 QVERIFY(m_barset->labelFont() == font);
400 // Test adding data to the sets
401 *set1 << 1 << 2 << 1 << 3;
402 *set2 << 2 << 1 << 3 << 1;
403 QTest::qWait(3000);
412 404 }
413 405
414
415 406 QTEST_MAIN(tst_QBarSet)
416 407
417 408 #include "tst_qbarset.moc"
General Comments 0
You need to be logged in to leave comments. Login now