diff options
Diffstat (limited to 'tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp')
-rw-r--r-- | tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp index 4cc4a253ee..f2c3b36dcd 100644 --- a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp +++ b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.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> @@ -16,6 +16,8 @@ #include <qtextcursor.h> +using namespace Qt::StringLiterals; + QT_FORWARD_DECLARE_CLASS(QTextDocument) class tst_QTextDocumentFragment : public QObject @@ -96,6 +98,7 @@ private slots: void html_thCentered(); void orderedListNumbering(); void html_blockAfterList(); + void html_listStartAttribute(); void html_subAndSuperScript(); void html_cssColors(); void obeyFragmentMarkersInImport(); @@ -244,6 +247,7 @@ private slots: void html_fromFirefox(); void html_emptyInlineInsideBlock(); void css_fontAndWordSpacing(); + void html_brWithWhitespaceAfterList(); private: inline void setHtml(const QString &html) @@ -1471,6 +1475,22 @@ void tst_QTextDocumentFragment::html_blockAfterList() QCOMPARE(cursor.blockFormat().indent(), 0); } +void tst_QTextDocumentFragment::html_listStartAttribute() +{ + const char html[] = "<ol start=-1><li>Foo</ol><ol><li>Bar</ol>"; + cursor.insertFragment(QTextDocumentFragment::fromHtml(html)); + + cursor.movePosition(QTextCursor::Start); + + QVERIFY(cursor.currentList()); + QCOMPARE(cursor.currentList()->format().start(), -1); + + QVERIFY(cursor.movePosition(QTextCursor::NextBlock)); + + QVERIFY(cursor.currentList()); + QCOMPARE(cursor.currentList()->format().start(), 1); +} + void tst_QTextDocumentFragment::html_subAndSuperScript() { const char subHtml[] = "<sub>Subby</sub>"; @@ -4303,5 +4323,24 @@ void tst_QTextDocumentFragment::css_fontAndWordSpacing() } } +void tst_QTextDocumentFragment::html_brWithWhitespaceAfterList() // QTBUG-81662 +{ + setHtml(QString::fromLatin1("<ul><li>one</li><li>two</li></ul>\n <br/>\nhello")); + + QCOMPARE(doc->blockCount(), 3); + + QTextBlock block = doc->begin(); + QVERIFY(block.textList()); + + block = block.next(); + QVERIFY(block.textList()); + + block = block.next(); + QCOMPARE(block.text(), u"\u2028hello"_s); + + block = block.next(); + QVERIFY(block.text().isEmpty()); +} + QTEST_MAIN(tst_QTextDocumentFragment) #include "tst_qtextdocumentfragment.moc" |