aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den.exter@jollamobile.com>2013-05-31 12:13:40 +1000
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-05-31 09:56:42 +0200
commite171d1e8c4b4324374cb57a6d7d181a57fc17dbe (patch)
treec003e6bc4326aa77262f8aae8edc6ee9373d949e /tests
parent9f9330c524092e63cf5b490d193fd9172938526f (diff)
Fix assert when calculating the implicit width of truncated lines.
Guard against reading past the end of the final line. Task-number: QTBUG-31471 Change-Id: I489f742936ee16f12ad9762b7c0891bfa9377e21 Reviewed-by: Martin Jones <martin.jones@jollamobile.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qquicktext/data/elideBeforeMaximumLineCount.qml10
-rw-r--r--tests/auto/quick/qquicktext/tst_qquicktext.cpp14
2 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicktext/data/elideBeforeMaximumLineCount.qml b/tests/auto/quick/qquicktext/data/elideBeforeMaximumLineCount.qml
new file mode 100644
index 0000000000..7f1ce705dd
--- /dev/null
+++ b/tests/auto/quick/qquicktext/data/elideBeforeMaximumLineCount.qml
@@ -0,0 +1,10 @@
+import QtQuick 2.0
+
+Text {
+ width: implicitWidth / 2
+ height: implicitHeight / 2
+ elide: Text.ElideRight
+ maximumLineCount: 4
+
+ text: "Line one\nLine two\nLine three\nLine four"
+}
diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
index b95a646bd6..fb3b62b8d2 100644
--- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp
+++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
@@ -149,6 +149,8 @@ private slots:
void htmlLists();
void htmlLists_data();
+ void elideBeforeMaximumLineCount();
+
private:
QStringList standard;
QStringList richText;
@@ -3638,6 +3640,18 @@ void tst_qquicktext::htmlLists_data()
QTest::newRow("unordered list bad") << "<ul type=\"bad\"><li>one</li><li>two</li></ul>" << 2;
}
+void tst_qquicktext::elideBeforeMaximumLineCount()
+{ // QTBUG-31471
+ QQmlComponent component(&engine, testFile("elideBeforeMaximumLineCount.qml"));
+
+ QScopedPointer<QObject> object(component.create());
+
+ QQuickText *item = qobject_cast<QQuickText *>(object.data());
+ QVERIFY(item);
+
+ QCOMPARE(item->lineCount(), 2);
+}
+
QTEST_MAIN(tst_qquicktext)
#include "tst_qquicktext.moc"