From e92f76cf9ea91e87ec2e3e68234899fd9c12142f Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Wed, 29 Nov 2017 16:40:07 +0100 Subject: 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 --- tests/auto/quick/qquicktext/tst_qquicktext.cpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'tests/auto/quick/qquicktext/tst_qquicktext.cpp') 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 object(textComponent.create()); QQuickText *textObject = qobject_cast(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() -- cgit v1.2.3