summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2020-01-16 01:00:11 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2020-01-16 11:20:42 +0100
commit0a4e5bb265c4a2345a9cbffab1b5150124b8d31e (patch)
treeb243668d53f710af3d57a44c18e1ed0c40b100f7 /tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp
parent4772a2da15ae0624633f3fc4d029d5f0e1e33892 (diff)
parentbd828bacb982a51ee21f03487f8390cfc96cc6d3 (diff)
Merge remote-tracking branch 'origin/5.15' into dev
Conflicts: src/widgets/kernel/qshortcut.cpp tests/auto/network/access/spdy/tst_spdy.cpp Change-Id: If76c434beac2c0a393440aa365f89f77439774ce
Diffstat (limited to 'tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp')
-rw-r--r--tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp36
1 files changed, 35 insertions, 1 deletions
diff --git a/tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp b/tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp
index 2f0b877799..39a1370f6f 100644
--- a/tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp
+++ b/tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp
@@ -55,12 +55,13 @@ private slots:
void thematicBreaks();
void lists_data();
void lists();
+ void avoidBlankLineAtBeginning_data();
+ void avoidBlankLineAtBeginning();
};
void tst_QTextMarkdownImporter::headingBulletsContinuations()
{
const QStringList expectedBlocks = QStringList() <<
- "" << // we could do without this blank line before the heading, but currently it happens
"heading" <<
"bullet 1 continuation line 1, indented via tab" <<
"bullet 2 continuation line 2, indented via 4 spaces" <<
@@ -222,5 +223,38 @@ void tst_QTextMarkdownImporter::lists()
QCOMPARE(doc.toMarkdown(), rewrite);
}
+void tst_QTextMarkdownImporter::avoidBlankLineAtBeginning_data()
+{
+ QTest::addColumn<QString>("input");
+ QTest::addColumn<int>("expectedNumberOfParagraphs");
+
+ QTest::newRow("Text block") << QString("Markdown text") << 1;
+ QTest::newRow("Headline") << QString("Markdown text\n============") << 1;
+ QTest::newRow("Code block") << QString(" Markdown text") << 2;
+ QTest::newRow("Unordered list") << QString("* Markdown text") << 1;
+ QTest::newRow("Ordered list") << QString("1. Markdown text") << 1;
+ QTest::newRow("Blockquote") << QString("> Markdown text") << 1;
+}
+
+void tst_QTextMarkdownImporter::avoidBlankLineAtBeginning() // QTBUG-81060
+{
+ QFETCH(QString, input);
+ QFETCH(int, expectedNumberOfParagraphs);
+
+ QTextDocument doc;
+ QTextMarkdownImporter(QTextMarkdownImporter::DialectGitHub).import(&doc, input);
+ QTextFrame::iterator iterator = doc.rootFrame()->begin();
+ int i = 0;
+ while (!iterator.atEnd()) {
+ QTextBlock block = iterator.currentBlock();
+ // Make sure there is no empty paragraph at the beginning of the document
+ if (i == 0)
+ QVERIFY(!block.text().isEmpty());
+ ++iterator;
+ ++i;
+ }
+ QCOMPARE(i, expectedNumberOfParagraphs);
+}
+
QTEST_MAIN(tst_QTextMarkdownImporter)
#include "tst_qtextmarkdownimporter.moc"