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