diff options
Diffstat (limited to 'tests/auto/gui/text/qtextlist/tst_qtextlist.cpp')
-rw-r--r-- | tests/auto/gui/text/qtextlist/tst_qtextlist.cpp | 89 |
1 files changed, 62 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..10d44f6d70 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; @@ -163,6 +140,7 @@ void tst_QTextList::autoNumberingPrefixAndSuffixHtmlExportImport() QCOMPARE(list->count(), 28); +#ifndef QT_NO_TEXTHTMLPARSER QString htmlExport = doc->toHtml(); QTextDocument importDoc; importDoc.setHtml(htmlExport); @@ -175,6 +153,7 @@ void tst_QTextList::autoNumberingPrefixAndSuffixHtmlExportImport() QCOMPARE(importCursor.currentList()->itemNumber(importCursor.block()), 27); QCOMPARE(importCursor.currentList()->itemText(importCursor.block()), QLatin1String("\"ab#")); QCOMPARE(importCursor.currentList()->format().indent(), 10); +#endif } void tst_QTextList::autoNumberingRTL() @@ -425,5 +404,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" |