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.cpp87
1 files changed, 60 insertions, 27 deletions
diff --git a/tests/auto/gui/text/qtextlist/tst_qtextlist.cpp b/tests/auto/gui/text/qtextlist/tst_qtextlist.cpp
index b160d41a05..28eae93f6a 100644
--- a/tests/auto/gui/text/qtextlist/tst_qtextlist.cpp
+++ b/tests/auto/gui/text/qtextlist/tst_qtextlist.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -61,6 +36,8 @@ private slots:
void blockUpdate();
void numbering_data();
void numbering();
+ void start_data();
+ void start();
private:
QTextDocument *doc;
@@ -425,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"