summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2022-01-10 20:04:32 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2022-01-12 00:18:35 +0100
commit8d2417ed9a591100115cd58a278f75912b20f51a (patch)
treefa96a717d5e74d9c462da46fb4ac5c440849f7e1 /tests
parentcdfbe7092304c3677e8fae95892f53852a90adfc (diff)
Add a markdown writer test for a checklist item ending with `code`
Task-number: QTBUG-81583 Change-Id: I32540615be66f4e45bb1b3b19e914bea3aacf3e7 Pick-to: 6.3 6.2 5.15 Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp b/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp
index bc6ee81ad4..353a0c52b6 100644
--- a/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp
+++ b/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp
@@ -51,6 +51,7 @@ private slots:
void testWriteParagraph();
void testWriteList();
void testWriteEmptyList();
+ void testWriteCheckboxListItemEndingWithCode();
void testWriteNestedBulletLists_data();
void testWriteNestedBulletLists();
void testWriteNestedNumericLists();
@@ -133,6 +134,34 @@ void tst_QTextMarkdownWriter::testWriteEmptyList()
QCOMPARE(documentToUnixMarkdown(), QString::fromLatin1("- \n"));
}
+void tst_QTextMarkdownWriter::testWriteCheckboxListItemEndingWithCode()
+{
+ QTextCursor cursor(document);
+ QTextList *list = cursor.createList(QTextListFormat::ListDisc);
+ cursor.insertText("Image.originalSize property (not necessary; PdfDocument.pagePointSize() substitutes)");
+ list->add(cursor.block());
+ {
+ auto fmt = cursor.block().blockFormat();
+ fmt.setMarker(QTextBlockFormat::MarkerType::Unchecked);
+ cursor.setBlockFormat(fmt);
+ }
+ cursor.movePosition(QTextCursor::PreviousWord, QTextCursor::MoveAnchor, 2);
+ cursor.movePosition(QTextCursor::Left, QTextCursor::MoveAnchor);
+ cursor.movePosition(QTextCursor::PreviousWord, QTextCursor::KeepAnchor, 4);
+ QCOMPARE(cursor.selectedText(), QString::fromLatin1("PdfDocument.pagePointSize()"));
+ auto fmt = cursor.charFormat();
+ fmt.setFontFixedPitch(true);
+ cursor.setCharFormat(fmt);
+ cursor.movePosition(QTextCursor::PreviousWord, QTextCursor::MoveAnchor, 5);
+ cursor.movePosition(QTextCursor::Left, QTextCursor::MoveAnchor);
+ cursor.movePosition(QTextCursor::PreviousWord, QTextCursor::KeepAnchor, 4);
+ QCOMPARE(cursor.selectedText(), QString::fromLatin1("Image.originalSize"));
+ cursor.setCharFormat(fmt);
+
+ QCOMPARE(documentToUnixMarkdown(), QString::fromLatin1(
+ "- [ ] `Image.originalSize` property (not necessary; `PdfDocument.pagePointSize()`\n substitutes)\n"));
+}
+
void tst_QTextMarkdownWriter::testWriteNestedBulletLists_data()
{
QTest::addColumn<bool>("checkbox");