diff options
author | Aleix Pol <aleixpol@kde.org> | 2017-11-29 16:40:07 +0100 |
---|---|---|
committer | Aleix Pol Gonzalez <aleixpol@kde.org> | 2018-07-31 16:38:01 +0000 |
commit | e92f76cf9ea91e87ec2e3e68234899fd9c12142f (patch) | |
tree | f90d2d8a3d7a787368a25b8e868835cbf7d3fe9c /tests/auto/quick/qquicktext | |
parent | 6952f40a3ef47e5bc62286f75b26b2d79eaa9d74 (diff) |
Increase fine-grained signals for some properties in Text
Text.[content/painted][Width/Height] were being always notified of
changes at bulk. This is can be harmful in performance of QML
applications that will trigger change requests on the program whenever
a property is modified.
This introduces separate signals so it's not a problem anymore.
Change-Id: I5b82cf13158298dbc91157b837d0ed4aadeb86cf
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Diffstat (limited to 'tests/auto/quick/qquicktext')
-rw-r--r-- | tests/auto/quick/qquicktext/tst_qquicktext.cpp | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp index 48069ab8c5..63e023644f 100644 --- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp @@ -2384,23 +2384,31 @@ void tst_qquicktext::contentSize() QScopedPointer<QObject> object(textComponent.create()); QQuickText *textObject = qobject_cast<QQuickText *>(object.data()); - QSignalSpy spy(textObject, SIGNAL(contentSizeChanged())); + QSignalSpy spySize(textObject, SIGNAL(contentSizeChanged())); + QSignalSpy spyWidth(textObject, SIGNAL(contentWidthChanged(qreal))); + QSignalSpy spyHeight(textObject, SIGNAL(contentHeightChanged(qreal))); textObject->setText("The quick red fox jumped over the lazy brown dog"); QVERIFY(textObject->contentWidth() > textObject->width()); QVERIFY(textObject->contentHeight() < textObject->height()); - QCOMPARE(spy.count(), 1); + QCOMPARE(spySize.count(), 1); + QCOMPARE(spyWidth.count(), 1); + QCOMPARE(spyHeight.count(), 0); textObject->setWrapMode(QQuickText::WordWrap); QVERIFY(textObject->contentWidth() <= textObject->width()); QVERIFY(textObject->contentHeight() > textObject->height()); - QCOMPARE(spy.count(), 2); + QCOMPARE(spySize.count(), 2); + QCOMPARE(spyWidth.count(), 2); + QCOMPARE(spyHeight.count(), 1); textObject->setElideMode(QQuickText::ElideRight); QVERIFY(textObject->contentWidth() <= textObject->width()); QVERIFY(textObject->contentHeight() < textObject->height()); - QCOMPARE(spy.count(), 3); + QCOMPARE(spySize.count(), 3); + QCOMPARE(spyWidth.count(), 3); + QCOMPARE(spyHeight.count(), 2); int spyCount = 3; qreal elidedWidth = textObject->contentWidth(); @@ -2409,14 +2417,16 @@ void tst_qquicktext::contentSize() QVERIFY(textObject->contentHeight() < textObject->height()); // this text probably won't have the same elided width, but it's not guaranteed. if (textObject->contentWidth() != elidedWidth) - QCOMPARE(spy.count(), ++spyCount); + QCOMPARE(spySize.count(), ++spyCount); else - QCOMPARE(spy.count(), spyCount); + QCOMPARE(spySize.count(), spyCount); textObject->setElideMode(QQuickText::ElideNone); QVERIFY(textObject->contentWidth() > textObject->width()); QVERIFY(textObject->contentHeight() > textObject->height()); - QCOMPARE(spy.count(), ++spyCount); + QCOMPARE(spySize.count(), ++spyCount); + QCOMPARE(spyWidth.count(), spyCount); + QCOMPARE(spyHeight.count(), 3); } void tst_qquicktext::geometryChanged() |