diff options
Diffstat (limited to 'tests/auto/qvalueaxis/tst_qvalueaxis.cpp')
-rw-r--r-- | tests/auto/qvalueaxis/tst_qvalueaxis.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/auto/qvalueaxis/tst_qvalueaxis.cpp b/tests/auto/qvalueaxis/tst_qvalueaxis.cpp index 4de89cb1..1527cb2b 100644 --- a/tests/auto/qvalueaxis/tst_qvalueaxis.cpp +++ b/tests/auto/qvalueaxis/tst_qvalueaxis.cpp @@ -71,6 +71,7 @@ private slots: void autoscale_data(); void autoscale(); void reverse(); + void labels(); private: QValueAxis* m_valuesaxis; @@ -437,6 +438,41 @@ void tst_QValueAxis::reverse() QCOMPARE(m_valuesaxis->isReverse(), true); } +void tst_QValueAxis::labels() +{ + m_chart->setAxisX(m_valuesaxis, m_series); + m_view->resize(300, 300); + m_view->show(); + QTest::qWaitForWindowShown(m_view); + + QList<QGraphicsItem *> childItems = m_chart->scene()->items(); + QList<QGraphicsTextItem *> textItems; + QStringList originalStrings; + for (QGraphicsItem *i : childItems) { + if (QGraphicsTextItem *text = qgraphicsitem_cast<QGraphicsTextItem *>(i)) { + if (text->parentItem() != m_chart) { + textItems << text; + originalStrings << text->toPlainText(); + } + } + } + m_valuesaxis->setLabelFormat("%.0f"); + // Wait for the format to have updated + QTest::qWait(100); + QStringList updatedStrings; + for (QGraphicsTextItem *i : textItems) + updatedStrings << i->toPlainText(); + // The order will be the same as we kept the order of the items + QVERIFY(originalStrings != updatedStrings); + updatedStrings.clear(); + // The labels should be back to the original defaults + m_valuesaxis->setLabelFormat(""); + QTest::qWait(100); + for (QGraphicsTextItem *i : textItems) + updatedStrings << i->toPlainText(); + QCOMPARE(originalStrings, updatedStrings); +} + QTEST_MAIN(tst_QValueAxis) #include "tst_qvalueaxis.moc" |