summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2018-01-18 18:00:39 +0100
committerLiang Qi <liang.qi@qt.io>2018-01-18 21:24:19 +0100
commit175d864fbb96ed64cc609fe08df4b28668368040 (patch)
treeda48270824b39ad76d912187a8f8790962e56efd /tests
parentd8ee9960736172e94def03d01a90c95e8c8c234f (diff)
parenta2eb6b3b15e19d5c8215c41694ce8c74918cb58a (diff)
Merge remote-tracking branch 'origin/5.9' into 5.10
Conflicts: .qmake.conf Change-Id: I02fb1d17385bfb520e7f6dd2d7c69d79a2890bcd
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qvalueaxis/tst_qvalueaxis.cpp36
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"