diff options
author | Andrew den Exter <andrew.den-exter@nokia.com> | 2012-04-20 11:40:40 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-20 08:05:15 +0200 |
commit | 04794c29cee0d97fb3b32e1c71a072e34ee37e9c (patch) | |
tree | b161691c1af10d24432e2cc8ba753a80c3adc7ab /tests/auto/quick/qquicktext | |
parent | 2e0a348927d5d9ad47cad724bc687c72e592c8d6 (diff) |
Fix eliding when text width is reset by an implicitWidth change.
After emitting implicit size changed signals, reevaluate any conditions
that were dependent on the validity of the item dimensions.
Change-Id: Ie4ee0c87a22cf82752c207c69d426056c36ede67
Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests/auto/quick/qquicktext')
-rw-r--r-- | tests/auto/quick/qquicktext/tst_qquicktext.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp index 125e056dad..297fa0106f 100644 --- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp @@ -72,6 +72,8 @@ private slots: void elide(); void multilineElide_data(); void multilineElide(); + void implicitElide_data(); + void implicitElide(); void textFormat(); void alignments_data(); @@ -531,6 +533,56 @@ void tst_qquicktext::multilineElide() delete canvas; } +void tst_qquicktext::implicitElide_data() +{ + QTest::addColumn<QString>("width"); + QTest::addColumn<QString>("initialText"); + QTest::addColumn<QString>("text"); + + QTest::newRow("maximum width, empty") + << "Math.min(implicitWidth, 100)" + << ""; + QTest::newRow("maximum width, short") + << "Math.min(implicitWidth, 100)" + << "the"; + QTest::newRow("maximum width, long") + << "Math.min(implicitWidth, 100)" + << "the quick brown fox jumped over the lazy dog"; + QTest::newRow("reset width, empty") + << "implicitWidth > 100 ? 100 : undefined" + << ""; + QTest::newRow("reset width, short") + << "implicitWidth > 100 ? 100 : undefined" + << "the"; + QTest::newRow("reset width, long") + << "implicitWidth > 100 ? 100 : undefined" + << "the quick brown fox jumped over the lazy dog"; +} + +void tst_qquicktext::implicitElide() +{ + QFETCH(QString, width); + QFETCH(QString, initialText); + + QString componentStr = + "import QtQuick 2.0\n" + "Text {\n" + "width: " + width + "\n" + "text: \"" + initialText + "\"\n" + "elide: Text.ElideRight\n" + "}"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create()); + + QVERIFY(textObject->contentWidth() <= textObject->width()); + + textObject->setText("the quick brown fox jumped over"); + + QVERIFY(textObject->contentWidth() > 0); + QVERIFY(textObject->contentWidth() <= textObject->width()); +} + void tst_qquicktext::textFormat() { { |