From 9fa471b72d8ac7fb1f5b2020463dac2340e1a963 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 1 Feb 2024 15:04:10 -0700 Subject: [PATCH] Fix frontMatter tests: fixed fonts and testdata When the main font is a fixed-width font, QTextMarkdownWriter generates backticks around plain text; so QEXPECT_FAIL if we detect that. tst_QTextMarkdownWriter::frontMatter() Compared values are not the same Actual (output) : "---\nfoo\n---\n`bar`\n\n" Expected ("---\nfoo\n---\nbar\n\n") Also, include all test data as resources for platforms that need it (such as Android). Task-number: QTBUG-103484 Change-Id: If18ca493c402b128cdc0fb1910b2e822512af6e8 Reviewed-by: Shawn Rutledge --- tests/auto/gui/text/qtextmarkdownimporter/CMakeLists.txt | 8 ++++---- tests/auto/gui/text/qtextmarkdownwriter/CMakeLists.txt | 6 ++++-- .../text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp | 5 ++++- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/tests/auto/gui/text/qtextmarkdownimporter/CMakeLists.txt b/tests/auto/gui/text/qtextmarkdownimporter/CMakeLists.txt index 1b13d23d308..937dd5bd803 100644 --- a/tests/auto/gui/text/qtextmarkdownimporter/CMakeLists.txt +++ b/tests/auto/gui/text/qtextmarkdownimporter/CMakeLists.txt @@ -12,10 +12,10 @@ if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) endif() # Collect test data -list(APPEND test_data "data/thematicBreaks.md") -list(APPEND test_data "data/headingBulletsContinuations.md") -list(APPEND test_data "data/fuzz20450.md") -list(APPEND test_data "data/fuzz20580.md") +file(GLOB_RECURSE test_data + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + data/* +) qt_internal_add_test(tst_qtextmarkdownimporter SOURCES diff --git a/tests/auto/gui/text/qtextmarkdownwriter/CMakeLists.txt b/tests/auto/gui/text/qtextmarkdownwriter/CMakeLists.txt index 1d56f8e5302..0cdf1d92258 100644 --- a/tests/auto/gui/text/qtextmarkdownwriter/CMakeLists.txt +++ b/tests/auto/gui/text/qtextmarkdownwriter/CMakeLists.txt @@ -12,8 +12,10 @@ if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) endif() # Collect test data -list(APPEND test_data "data/example.md") -list(APPEND test_data "data/blockquotes.md") +file(GLOB_RECURSE test_data + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + data/* +) qt_internal_add_test(tst_qtextmarkdownwriter SOURCES diff --git a/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp b/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp index 71c4588a6a9..ab913cf41f8 100644 --- a/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp +++ b/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp @@ -533,7 +533,10 @@ void tst_QTextMarkdownWriter::frontMatter() document->setMetaInformation(QTextDocument::FrontMatter, "foo"); const QString output = documentToUnixMarkdown(); - QCOMPARE(output, "---\nfoo\n---\nbar\n\n"); + const QString expectedOutput("---\nfoo\n---\nbar\n\n"); + if (output != expectedOutput && isMainFontFixed()) + QEXPECT_FAIL("", "fixed-pitch main font (QTBUG-103484)", Continue); + QCOMPARE(output, expectedOutput); } void tst_QTextMarkdownWriter::rewriteDocument_data()