summaryrefslogtreecommitdiffstats
path: root/tests/auto/qtextlist
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qtextlist')
-rw-r--r--tests/auto/qtextlist/tst_qtextlist.cpp84
1 files changed, 80 insertions, 4 deletions
diff --git a/tests/auto/qtextlist/tst_qtextlist.cpp b/tests/auto/qtextlist/tst_qtextlist.cpp
index 64d178a..9ba0046 100644
--- a/tests/auto/qtextlist/tst_qtextlist.cpp
+++ b/tests/auto/qtextlist/tst_qtextlist.cpp
@@ -1,7 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the test suite of the Qt Toolkit.
@@ -21,9 +20,10 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this
+** package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
@@ -67,6 +67,8 @@ private slots:
void item();
void autoNumbering();
void autoNumberingRTL();
+ void romanNumbering();
+ void romanNumberingLimit();
void formatChange();
void cursorNavigation();
void partialRemoval();
@@ -75,6 +77,8 @@ private slots:
void add();
void defaultIndent();
void blockUpdate();
+ void numbering_data();
+ void numbering();
private:
QTextDocument *doc;
@@ -142,6 +146,40 @@ void tst_QTextList::autoNumberingRTL()
QVERIFY(cursor.currentList()->itemText(cursor.block()) == ".B");
}
+void tst_QTextList::romanNumbering()
+{
+ QTextListFormat fmt;
+ fmt.setStyle(QTextListFormat::ListUpperRoman);
+ QTextList *list = cursor.createList(fmt);
+ QVERIFY(list);
+
+ for (int i = 0; i < 4998; ++i)
+ cursor.insertBlock();
+
+ QVERIFY(list->count() == 4999);
+
+ QVERIFY(cursor.currentList());
+ QVERIFY(cursor.currentList()->itemNumber(cursor.block()) == 4998);
+ QVERIFY(cursor.currentList()->itemText(cursor.block()) == "MMMMCMXCIX.");
+}
+
+void tst_QTextList::romanNumberingLimit()
+{
+ QTextListFormat fmt;
+ fmt.setStyle(QTextListFormat::ListLowerRoman);
+ QTextList *list = cursor.createList(fmt);
+ QVERIFY(list);
+
+ for (int i = 0; i < 4999; ++i)
+ cursor.insertBlock();
+
+ QVERIFY(list->count() == 5000);
+
+ QVERIFY(cursor.currentList());
+ QVERIFY(cursor.currentList()->itemNumber(cursor.block()) == 4999);
+ QVERIFY(cursor.currentList()->itemText(cursor.block()) == "?.");
+}
+
void tst_QTextList::formatChange()
{
// testing the formatChanged slot in QTextListManager
@@ -300,5 +338,43 @@ void tst_QTextList::blockUpdate()
QVERIFY(!layout->error);
}
+void tst_QTextList::numbering_data()
+{
+ QTest::addColumn<int>("format");
+ QTest::addColumn<int>("number");
+ QTest::addColumn<QString>("result");
+
+ QTest::newRow("E.") << int(QTextListFormat::ListUpperAlpha) << 5 << "E.";
+ QTest::newRow("abc.") << int(QTextListFormat::ListLowerAlpha) << (26 + 2) * 26 + 3 << "abc.";
+ QTest::newRow("12.") << int(QTextListFormat::ListDecimal) << 12 << "12.";
+ QTest::newRow("XXIV.") << int(QTextListFormat::ListUpperRoman) << 24 << "XXIV.";
+ QTest::newRow("VIII.") << int(QTextListFormat::ListUpperRoman) << 8 << "VIII.";
+ QTest::newRow("xxx.") << int(QTextListFormat::ListLowerRoman) << 30 << "xxx.";
+ QTest::newRow("xxix.") << int(QTextListFormat::ListLowerRoman) << 29 << "xxix.";
+// QTest::newRow("xxx. alpha") << int(QTextListFormat::ListLowerAlpha) << (24 * 26 + 24) * 26 + 24 << "xxx."; //Too slow
+}
+
+void tst_QTextList::numbering()
+{
+ QFETCH(int, format);
+ QFETCH(int, number);
+ QFETCH(QString, result);
+
+
+ QTextListFormat fmt;
+ fmt.setStyle(QTextListFormat::Style(format));
+ QTextList *list = cursor.createList(fmt);
+ QVERIFY(list);
+
+ for (int i = 1; i < number; ++i)
+ cursor.insertBlock();
+
+ QCOMPARE(list->count(), number);
+
+ QVERIFY(cursor.currentList());
+ QCOMPARE(cursor.currentList()->itemNumber(cursor.block()), number - 1);
+ QCOMPARE(cursor.currentList()->itemText(cursor.block()), result);
+}
+
QTEST_MAIN(tst_QTextList)
#include "tst_qtextlist.moc"