diff options
Diffstat (limited to 'tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp')
-rw-r--r-- | tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp | 53 |
1 files changed, 46 insertions, 7 deletions
diff --git a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp index 52708e1b14..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) @@ -1175,7 +1179,7 @@ void tst_QTextDocumentFragment::copySubTable() table->cellAt(row, col).firstCursorPosition().insertText(rowS + QString::number(col)); } - QCOMPARE(table->format().columnWidthConstraints().count(), table->columns()); + QCOMPARE(table->format().columnWidthConstraints().size(), table->columns()); // select 2x2 subtable cursor = table->cellAt(1, 1).firstCursorPosition(); @@ -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>"; @@ -2235,7 +2255,7 @@ void tst_QTextDocumentFragment::html_frameImport() cursor.insertFragment(frag); QList<QTextFrame *> childFrames = doc->rootFrame()->childFrames(); - QCOMPARE(childFrames.count(), 1); + QCOMPARE(childFrames.size(), 1); QTextFrame *frame = childFrames.first(); QCOMPARE(frame->frameFormat().margin(), ffmt.margin()); QCOMPARE(frame->frameFormat().border(), ffmt.border()); @@ -2263,7 +2283,7 @@ void tst_QTextDocumentFragment::html_frameImport2() cursor.insertFragment(frag); QList<QTextFrame *> childFrames = doc->rootFrame()->childFrames(); - QCOMPARE(childFrames.count(), 1); + QCOMPARE(childFrames.size(), 1); QTextFrame *frame = childFrames.first(); QCOMPARE(frame->frameFormat().topMargin(), ffmt.topMargin()); QCOMPARE(frame->frameFormat().bottomMargin(), ffmt.bottomMargin()); @@ -2278,7 +2298,7 @@ void tst_QTextDocumentFragment::html_dontAddMarginsAcrossTableCells() cursor.insertFragment(QTextDocumentFragment::fromHtml(QString::fromLatin1(html))); QList<QTextFrame *> childFrames = doc->rootFrame()->childFrames(); - QCOMPARE(childFrames.count(), 1); + QCOMPARE(childFrames.size(), 1); QTextFrame *frame = childFrames.first(); cursor = frame->firstCursorPosition(); QCOMPARE(cursor.blockFormat().leftMargin(), qreal(50.0)); @@ -2760,7 +2780,7 @@ void tst_QTextDocumentFragment::html_columnWidths() QTextTableFormat fmt = table->format(); const QList<QTextLength> columnWidths = fmt.columnWidthConstraints(); - QCOMPARE(columnWidths.count(), 2); + QCOMPARE(columnWidths.size(), 2); QCOMPARE(columnWidths.at(0).type(), QTextLength::VariableLength); QCOMPARE(columnWidths.at(1).type(), QTextLength::PercentageLength); QCOMPARE(columnWidths.at(1).rawValue(), qreal(1)); @@ -4168,7 +4188,7 @@ void tst_QTextDocumentFragment::html_entities() setHtml(html); QCOMPARE(doc->blockCount(), 1); QString txt = doc->begin().text(); - QCOMPARE(txt.length(), 1); + QCOMPARE(txt.size(), 1); QCOMPARE(txt.at(0).unicode(), code); } @@ -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" |