Un-blacklist markdown tests: QSKIP when fonts are scrambled
On QNX in CI we see system fonts: fixed: monospace 9; general: Sans Serif 9 and "monospace" isn't really a fixed pitch font. On B2Qt arm7 in CI we see system fonts: fixed: monospace 9; general Sans Serif 9 and Sans Serif is actually fixed pitch. So these tests can go wrong both ways; we need to skip them whenever the fonts would lead QTextMarkdownWriter astray. Pick-to: 6.3 6.2 Task-number: QTBUG-89819 Task-number: QTBUG-99676 Task-number: QTBUG-100515 Task-number: QTBUG-103484 Change-Id: I7b9adca967eaf9b8d33d1e03ef2627f70f375196 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
This commit is contained in:
parent
3e78f501b7
commit
1ad456c908
@ -1,3 +0,0 @@
|
||||
# QTBUG-89819
|
||||
[lists]
|
||||
ci b2qt 32bit
|
@ -42,6 +42,9 @@ private slots:
|
||||
void pathological_data();
|
||||
void pathological();
|
||||
|
||||
private:
|
||||
bool isMainFontFixed();
|
||||
|
||||
public:
|
||||
enum CharFormat {
|
||||
Normal = 0x0,
|
||||
@ -59,6 +62,18 @@ public:
|
||||
Q_DECLARE_METATYPE(tst_QTextMarkdownImporter::CharFormats)
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(tst_QTextMarkdownImporter::CharFormats)
|
||||
|
||||
bool tst_QTextMarkdownImporter::isMainFontFixed()
|
||||
{
|
||||
bool ret = QFontInfo(QGuiApplication::font()).fixedPitch();
|
||||
if (ret) {
|
||||
qCWarning(lcTests) << "QFontDatabase::GeneralFont is monospaced: markdown writing is likely to use too many backticks";
|
||||
qCWarning(lcTests) << "system fonts: fixed" << QFontDatabase::systemFont(QFontDatabase::FixedFont)
|
||||
<< "fixed?" << QFontInfo(QFontDatabase::systemFont(QFontDatabase::FixedFont)).fixedPitch()
|
||||
<< "general" << QFontDatabase::systemFont(QFontDatabase::GeneralFont);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void tst_QTextMarkdownImporter::headingBulletsContinuations()
|
||||
{
|
||||
const QStringList expectedBlocks = QStringList() <<
|
||||
@ -249,6 +264,8 @@ void tst_QTextMarkdownImporter::lists()
|
||||
}
|
||||
QCOMPARE(itemCount, expectedItemCount);
|
||||
QCOMPARE(emptyItems, expectedEmptyItems);
|
||||
if (doc.toMarkdown() != rewrite && isMainFontFixed())
|
||||
QEXPECT_FAIL("", "fixed-pitch main font (QTBUG-103484)", Continue);
|
||||
QCOMPARE(doc.toMarkdown(), rewrite);
|
||||
}
|
||||
|
||||
|
@ -1,4 +0,0 @@
|
||||
# QTBUG-89819
|
||||
ci b2qt 32bit
|
||||
[fromHtml:preformats with embedded backticks]
|
||||
qnx ci
|
@ -9,9 +9,13 @@
|
||||
#include <QTextTable>
|
||||
#include <QBuffer>
|
||||
#include <QDebug>
|
||||
#include <QFontInfo>
|
||||
#include <QLoggingCategory>
|
||||
|
||||
#include <private/qtextmarkdownwriter_p.h>
|
||||
|
||||
Q_LOGGING_CATEGORY(lcTests, "qt.text.tests")
|
||||
|
||||
// #define DEBUG_WRITE_OUTPUT
|
||||
|
||||
class tst_QTextMarkdownWriter : public QObject
|
||||
@ -37,6 +41,8 @@ private slots:
|
||||
void fromHtml();
|
||||
|
||||
private:
|
||||
bool isMainFontFixed();
|
||||
bool isFixedFontProportional();
|
||||
QString documentToUnixMarkdown();
|
||||
|
||||
private:
|
||||
@ -53,10 +59,39 @@ void tst_QTextMarkdownWriter::cleanup()
|
||||
delete document;
|
||||
}
|
||||
|
||||
bool tst_QTextMarkdownWriter::isMainFontFixed()
|
||||
{
|
||||
bool ret = QFontInfo(QGuiApplication::font()).fixedPitch();
|
||||
if (ret) {
|
||||
qCWarning(lcTests) << "QFontDatabase::GeneralFont is monospaced: markdown writing is likely to use too many backticks"
|
||||
<< QFontDatabase::systemFont(QFontDatabase::GeneralFont);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool tst_QTextMarkdownWriter::isFixedFontProportional()
|
||||
{
|
||||
bool ret = !QFontInfo(QFontDatabase::systemFont(QFontDatabase::FixedFont)).fixedPitch();
|
||||
if (ret) {
|
||||
qCWarning(lcTests) << "QFontDatabase::FixedFont is NOT monospaced: markdown writing is likely to use too few backticks"
|
||||
<< QFontDatabase::systemFont(QFontDatabase::FixedFont);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
QString tst_QTextMarkdownWriter::documentToUnixMarkdown()
|
||||
{
|
||||
QString ret;
|
||||
QTextStream ts(&ret, QIODevice::WriteOnly);
|
||||
QTextMarkdownWriter writer(ts, QTextDocument::MarkdownDialectGitHub);
|
||||
writer.writeAll(document);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void tst_QTextMarkdownWriter::testWriteParagraph_data()
|
||||
{
|
||||
QTest::addColumn<QString>("input");
|
||||
QTest::addColumn<QString>("output");
|
||||
QTest::addColumn<QString>("expectedOutput");
|
||||
|
||||
QTest::newRow("empty") << "" <<
|
||||
"";
|
||||
@ -79,12 +114,15 @@ void tst_QTextMarkdownWriter::testWriteParagraph_data()
|
||||
void tst_QTextMarkdownWriter::testWriteParagraph()
|
||||
{
|
||||
QFETCH(QString, input);
|
||||
QFETCH(QString, output);
|
||||
QFETCH(QString, expectedOutput);
|
||||
|
||||
QTextCursor cursor(document);
|
||||
cursor.insertText(input);
|
||||
|
||||
QCOMPARE(documentToUnixMarkdown(), output);
|
||||
const QString output = documentToUnixMarkdown();
|
||||
if (output != expectedOutput && isMainFontFixed())
|
||||
QEXPECT_FAIL("", "fixed-pitch main font (QTBUG-103484)", Continue);
|
||||
QCOMPARE(output, expectedOutput);
|
||||
}
|
||||
|
||||
void tst_QTextMarkdownWriter::testWriteList()
|
||||
@ -97,8 +135,11 @@ void tst_QTextMarkdownWriter::testWriteList()
|
||||
cursor.insertText("ListItem 2");
|
||||
list->add(cursor.block());
|
||||
|
||||
QCOMPARE(documentToUnixMarkdown(), QString::fromLatin1(
|
||||
"- ListItem 1\n- ListItem 2\n"));
|
||||
const QString output = documentToUnixMarkdown();
|
||||
const QString expected = QString::fromLatin1("- ListItem 1\n- ListItem 2\n");
|
||||
if (output != expected && isMainFontFixed())
|
||||
QEXPECT_FAIL("", "fixed-pitch main font (QTBUG-103484)", Continue);
|
||||
QCOMPARE(output, expected);
|
||||
}
|
||||
|
||||
void tst_QTextMarkdownWriter::testWriteEmptyList()
|
||||
@ -133,8 +174,12 @@ void tst_QTextMarkdownWriter::testWriteCheckboxListItemEndingWithCode()
|
||||
QCOMPARE(cursor.selectedText(), QString::fromLatin1("Image.originalSize"));
|
||||
cursor.setCharFormat(fmt);
|
||||
|
||||
QCOMPARE(documentToUnixMarkdown(), QString::fromLatin1(
|
||||
"- [ ] `Image.originalSize` property (not necessary; `PdfDocument.pagePointSize()`\n substitutes)\n"));
|
||||
const QString output = documentToUnixMarkdown();
|
||||
const QString expected = QString::fromLatin1(
|
||||
"- [ ] `Image.originalSize` property (not necessary; `PdfDocument.pagePointSize()`\n substitutes)\n");
|
||||
if (output != expected && isMainFontFixed())
|
||||
QEXPECT_FAIL("", "fixed-pitch main font (QTBUG-103484)", Continue);
|
||||
QCOMPARE(output, expected);
|
||||
}
|
||||
|
||||
void tst_QTextMarkdownWriter::testWriteNestedBulletLists_data()
|
||||
@ -216,7 +261,7 @@ void tst_QTextMarkdownWriter::testWriteNestedBulletLists()
|
||||
cursor.insertText("continuation");
|
||||
}
|
||||
|
||||
QString output = documentToUnixMarkdown();
|
||||
const QString output = documentToUnixMarkdown();
|
||||
#ifdef DEBUG_WRITE_OUTPUT
|
||||
{
|
||||
QFile out("/tmp/" + QLatin1String(QTest::currentDataTag()) + ".md");
|
||||
@ -225,7 +270,9 @@ void tst_QTextMarkdownWriter::testWriteNestedBulletLists()
|
||||
out.close();
|
||||
}
|
||||
#endif
|
||||
QCOMPARE(documentToUnixMarkdown(), expectedOutput);
|
||||
if (output != expectedOutput && isMainFontFixed())
|
||||
QEXPECT_FAIL("", "fixed-pitch main font (QTBUG-103484)", Continue);
|
||||
QCOMPARE(output, expectedOutput);
|
||||
}
|
||||
|
||||
void tst_QTextMarkdownWriter::testWriteNestedNumericLists()
|
||||
@ -257,9 +304,13 @@ void tst_QTextMarkdownWriter::testWriteNestedNumericLists()
|
||||
cursor.insertText("ListItem 5");
|
||||
list2->add(cursor.block());
|
||||
|
||||
const QString output = documentToUnixMarkdown();
|
||||
// There's no QTextList API to set the starting number so we hard-coded all lists to start at 1 (QTBUG-65384)
|
||||
QCOMPARE(documentToUnixMarkdown(), QString::fromLatin1(
|
||||
"1. ListItem 1\n 1) ListItem 2\n 1. ListItem 3\n2. ListItem 4\n 2) ListItem 5\n"));
|
||||
const QString expected = QString::fromLatin1(
|
||||
"1. ListItem 1\n 1) ListItem 2\n 1. ListItem 3\n2. ListItem 4\n 2) ListItem 5\n");
|
||||
if (output != expected && isMainFontFixed())
|
||||
QEXPECT_FAIL("", "fixed-pitch main font (QTBUG-103484)", Continue);
|
||||
QCOMPARE(output, expected);
|
||||
}
|
||||
|
||||
void tst_QTextMarkdownWriter::testWriteTable()
|
||||
@ -312,6 +363,8 @@ void tst_QTextMarkdownWriter::testWriteTable()
|
||||
|
||||
QString expected = QString::fromLatin1(
|
||||
"\n|one |two |three|\n|------|----|-----|\n|alice |bob |carl |\n|dennis|eric|fiona|\n|gina | | |\n\n");
|
||||
if (md != expected && isMainFontFixed())
|
||||
QEXPECT_FAIL("", "fixed-pitch main font (QTBUG-103484)", Continue);
|
||||
QCOMPARE(md, expected);
|
||||
|
||||
// create table with merged cells
|
||||
@ -361,7 +414,10 @@ void tst_QTextMarkdownWriter::testWriteTable()
|
||||
}
|
||||
#endif
|
||||
|
||||
QCOMPARE(md, QString::fromLatin1("\n|a ||b|\n|-|-|-|\n|c|d ||\n|e|f| |\n\n"));
|
||||
expected = QString::fromLatin1("\n|a ||b|\n|-|-|-|\n|c|d ||\n|e|f| |\n\n");
|
||||
if (md != expected && isMainFontFixed())
|
||||
QEXPECT_FAIL("", "fixed-pitch main font (QTBUG-103484)", Continue);
|
||||
QCOMPARE(md, expected);
|
||||
}
|
||||
|
||||
void tst_QTextMarkdownWriter::rewriteDocument_data()
|
||||
@ -394,12 +450,14 @@ void tst_QTextMarkdownWriter::rewriteDocument()
|
||||
out.close();
|
||||
#endif
|
||||
|
||||
if (md != orig && isMainFontFixed())
|
||||
QEXPECT_FAIL("", "fixed-pitch main font (QTBUG-103484)", Continue);
|
||||
QCOMPARE(md, orig);
|
||||
}
|
||||
|
||||
void tst_QTextMarkdownWriter::fromHtml_data()
|
||||
{
|
||||
QTest::addColumn<QString>("expectedInput");
|
||||
QTest::addColumn<QString>("input");
|
||||
QTest::addColumn<QString>("expectedOutput");
|
||||
|
||||
QTest::newRow("long URL") <<
|
||||
@ -448,10 +506,10 @@ void tst_QTextMarkdownWriter::fromHtml_data()
|
||||
|
||||
void tst_QTextMarkdownWriter::fromHtml()
|
||||
{
|
||||
QFETCH(QString, expectedInput);
|
||||
QFETCH(QString, input);
|
||||
QFETCH(QString, expectedOutput);
|
||||
|
||||
document->setHtml(expectedInput);
|
||||
document->setHtml(input);
|
||||
QString output = documentToUnixMarkdown();
|
||||
|
||||
#ifdef DEBUG_WRITE_OUTPUT
|
||||
@ -463,17 +521,10 @@ void tst_QTextMarkdownWriter::fromHtml()
|
||||
}
|
||||
#endif
|
||||
|
||||
if (output != expectedOutput && (isMainFontFixed() || isFixedFontProportional()))
|
||||
QEXPECT_FAIL("", "fixed main font or proportional fixed font (QTBUG-103484)", Continue);
|
||||
QCOMPARE(output, expectedOutput);
|
||||
}
|
||||
|
||||
QString tst_QTextMarkdownWriter::documentToUnixMarkdown()
|
||||
{
|
||||
QString ret;
|
||||
QTextStream ts(&ret, QIODevice::WriteOnly);
|
||||
QTextMarkdownWriter writer(ts, QTextDocument::MarkdownDialectGitHub);
|
||||
writer.writeAll(document);
|
||||
return ret;
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QTextMarkdownWriter)
|
||||
#include "tst_qtextmarkdownwriter.moc"
|
||||
|
Loading…
x
Reference in New Issue
Block a user