summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/text/qtextlist/tst_qtextlist.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/gui/text/qtextlist/tst_qtextlist.cpp')
-rw-r--r--tests/auto/gui/text/qtextlist/tst_qtextlist.cpp60
1 files changed, 59 insertions, 1 deletions
diff --git a/tests/auto/gui/text/qtextlist/tst_qtextlist.cpp b/tests/auto/gui/text/qtextlist/tst_qtextlist.cpp
index 134249ee83..28eae93f6a 100644
--- a/tests/auto/gui/text/qtextlist/tst_qtextlist.cpp
+++ b/tests/auto/gui/text/qtextlist/tst_qtextlist.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -36,6 +36,8 @@ private slots:
void blockUpdate();
void numbering_data();
void numbering();
+ void start_data();
+ void start();
private:
QTextDocument *doc;
@@ -400,5 +402,61 @@ void tst_QTextList::numbering()
QCOMPARE(cursor.currentList()->itemText(cursor.block()), result);
}
+void tst_QTextList::start_data()
+{
+ QTest::addColumn<int>("format");
+ QTest::addColumn<int>("start");
+ QTest::addColumn<QStringList>("expectedItemTexts");
+
+ QTest::newRow("-1.") << int(QTextListFormat::ListDecimal) << -1
+ << QStringList{ "-1.", "0.", "1." };
+ QTest::newRow("0.") << int(QTextListFormat::ListDecimal) << 0
+ << QStringList{ "0.", "1.", "2." };
+ QTest::newRow("1.") << int(QTextListFormat::ListDecimal) << 1
+ << QStringList{ "1.", "2.", "3." };
+
+ QTest::newRow("A. -1") << int(QTextListFormat::ListUpperAlpha) << -1
+ << QStringList{ "-1.", "0.", "A." };
+ QTest::newRow("A. 0.") << int(QTextListFormat::ListUpperAlpha) << 0
+ << QStringList{ "0.", "A.", "B." };
+ QTest::newRow("a. -1") << int(QTextListFormat::ListLowerAlpha) << -1
+ << QStringList{ "-1.", "0.", "a." };
+ QTest::newRow("a. 0.") << int(QTextListFormat::ListLowerAlpha) << 0
+ << QStringList{ "0.", "a.", "b." };
+ QTest::newRow("d. 4.") << int(QTextListFormat::ListLowerAlpha) << 4
+ << QStringList{ "d.", "e.", "f." };
+
+ QTest::newRow("I. -1") << int(QTextListFormat::ListUpperRoman) << -1
+ << QStringList{ "-1.", "0.", "I." };
+ QTest::newRow("I. 0.") << int(QTextListFormat::ListUpperRoman) << 0
+ << QStringList{ "0.", "I.", "II." };
+ QTest::newRow("i. -1") << int(QTextListFormat::ListLowerRoman) << -1
+ << QStringList{ "-1.", "0.", "i." };
+ QTest::newRow("i. 0.") << int(QTextListFormat::ListLowerRoman) << 0
+ << QStringList{ "0.", "i.", "ii." };
+}
+
+void tst_QTextList::start()
+{
+ QFETCH(int, format);
+ QFETCH(int, start);
+ QFETCH(QStringList, expectedItemTexts);
+
+ QTextListFormat fmt;
+ fmt.setStyle(QTextListFormat::Style(format));
+ fmt.setStart(start);
+ QTextList *list = cursor.createList(fmt);
+ QVERIFY(list);
+
+ while (list->count() < int(expectedItemTexts.size()))
+ cursor.insertBlock();
+
+ QCOMPARE(list->count(), expectedItemTexts.size());
+
+ for (int i = 0; i < list->count(); ++i)
+ QCOMPARE(cursor.currentList()->itemText(cursor.currentList()->item(i)),
+ expectedItemTexts[i]);
+}
+
QTEST_MAIN(tst_QTextList)
#include "tst_qtextlist.moc"