summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorChristopher Ham <christopher.ham@nokia.com>2011-01-14 04:57:10 (GMT)
committerChristopher Ham <christopher.ham@nokia.com>2011-01-14 04:57:10 (GMT)
commit08bd83f5f1b738713e80bbfbd06468d27c5d3694 (patch)
tree31af2b0d55ae47e2990f4261f02d9151ac8b8392 /tests
parenta750cf02225e46063161a1352451d46eb2df5491 (diff)
downloadQt-08bd83f5f1b738713e80bbfbd06468d27c5d3694.zip
Qt-08bd83f5f1b738713e80bbfbd06468d27c5d3694.tar.gz
Qt-08bd83f5f1b738713e80bbfbd06468d27c5d3694.tar.bz2
QDeclarativeText has new multiline properties
LineCount should return the number of lines currently being displayed. Setting maximumLineCount limits the number of lines that will be shown Truncated will return true if the text has been elided normally, or if the lines have been limited due to maximumLineCount. Task-number: QTBUG-12305 Reviewed-by: Michael Brasser
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/lineCount.qml15
-rw-r--r--tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp30
2 files changed, 45 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativetext/data/lineCount.qml b/tests/auto/declarative/qdeclarativetext/data/lineCount.qml
new file mode 100644
index 0000000..b3d7bc1
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetext/data/lineCount.qml
@@ -0,0 +1,15 @@
+import QtQuick 1.0
+
+Item {
+ width: 200
+ height: 200
+
+ Text {
+ id: myText
+ objectName: "myText"
+ width: 200
+ wrapMode: Text.WordWrap
+ maximumLineCount: undefined
+ text: "Testing that maximumLines, visibleLines, and totalLines works properly in the autotests. The quick brown fox jumped over the lazy anything with the letter 'g'."
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp
index d6c37ae..ca23c9f 100644
--- a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp
+++ b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp
@@ -49,6 +49,7 @@
#include <qmath.h>
#include <QDeclarativeView>
#include <private/qapplication_p.h>
+#include <limits.h>
#include "../../../shared/util.h"
#include "testhttpserver.h"
@@ -78,6 +79,8 @@ private slots:
void embeddedImages_data();
void embeddedImages();
+ void lineCount();
+
// ### these tests may be trivial
void horizontalAlignment();
void verticalAlignment();
@@ -1020,6 +1023,33 @@ void tst_qdeclarativetext::embeddedImages()
}
}
+void tst_qdeclarativetext::lineCount()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/lineCount.qml");
+
+ QDeclarativeText *myText = canvas->rootObject()->findChild<QDeclarativeText*>("myText");
+ QVERIFY(myText != 0);
+
+ QVERIFY(myText->lineCount() > 1);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->maximumLineCount(), INT_MAX);
+
+ myText->setMaximumLineCount(2);
+ QCOMPARE(myText->lineCount(), 2);
+ QCOMPARE(myText->truncated(), true);
+ QCOMPARE(myText->maximumLineCount(), 2);
+
+ myText->resetMaximumLineCount();
+ QCOMPARE(myText->maximumLineCount(), INT_MAX);
+ QCOMPARE(myText->truncated(), false);
+
+ myText->setElideMode(QDeclarativeText::ElideRight);
+ myText->setMaximumLineCount(2);
+ QCOMPARE(myText->lineCount(), 2);
+ QCOMPARE(myText->truncated(), true);
+ QCOMPARE(myText->maximumLineCount(), 2);
+}
+
QTEST_MAIN(tst_qdeclarativetext)
#include "tst_qdeclarativetext.moc"