From 86aabb500cce306d0729d159f82bfdcef9ac547a Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 9 Nov 2018 15:57:42 +0100 Subject: Add lancelot tests to verify vertical alignment of inline images Adds a test case for 199f9c54484b0dae3bc81f83c880a965192ecb24. Task-number: QTBUG-59310 Change-Id: Iee26f8bc21884da36471935f64524b62c3f79ff4 Reviewed-by: Eirik Aavitsland --- tests/auto/other/lancelot/paintcommands.cpp | 28 ++++++++++++++++++++++++++ tests/auto/other/lancelot/paintcommands.h | 1 + tests/auto/other/lancelot/scripts/richtext.qps | 9 +++++++++ 3 files changed, 38 insertions(+) create mode 100644 tests/auto/other/lancelot/scripts/richtext.qps diff --git a/tests/auto/other/lancelot/paintcommands.cpp b/tests/auto/other/lancelot/paintcommands.cpp index 65a688ec40..8aa3a035e3 100644 --- a/tests/auto/other/lancelot/paintcommands.cpp +++ b/tests/auto/other/lancelot/paintcommands.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #ifndef QT_NO_OPENGL @@ -441,6 +442,10 @@ void PaintCommands::staticInit() "^drawStaticText\\s+(-?\\w*)\\s+(-?\\w*)\\s+\"(.*)\"$", "drawStaticText ", "drawStaticText 10 10 \"my text\""); + DECL_PAINTCOMMAND("drawTextDocument", command_drawTextDocument, + "^drawTextDocument\\s+(-?\\w*)\\s+(-?\\w*)\\s+\"(.*)\"$", + "drawTextDocument ", + "drawTextDocument 10 10 \"html\""); DECL_PAINTCOMMAND("drawTiledPixmap", command_drawTiledPixmap, "^drawTiledPixmap\\s+([\\w.:\\/]*)" "\\s+(-?\\w*)\\s+(-?\\w*)\\s*(-?\\w*)\\s*(-?\\w*)" @@ -1295,6 +1300,29 @@ void PaintCommands::command_drawStaticText(QRegularExpressionMatch re) m_painter->drawStaticText(x, y, QStaticText(txt)); } +void PaintCommands::command_drawTextDocument(QRegularExpressionMatch re) +{ + if (!m_shouldDrawText) + return; + QStringList caps = re.capturedTexts(); + int x = convertToInt(caps.at(1)); + int y = convertToInt(caps.at(2)); + QString txt = caps.at(3); + + if (m_verboseMode) + printf(" -(lance) drawTextDocument(%d, %d, %s)\n", x, y, qPrintable(txt)); + + QTextDocument doc; + doc.setBaseUrl(QUrl::fromLocalFile(QDir::currentPath() + QLatin1String("/"))); + doc.setHtml(txt); + + m_painter->save(); + m_painter->translate(x, y); + doc.drawContents(m_painter); + m_painter->restore(); +} + + /***************************************************************************************************/ void PaintCommands::command_noop(QRegularExpressionMatch) { diff --git a/tests/auto/other/lancelot/paintcommands.h b/tests/auto/other/lancelot/paintcommands.h index 83e3bbc11c..79bdab634a 100644 --- a/tests/auto/other/lancelot/paintcommands.h +++ b/tests/auto/other/lancelot/paintcommands.h @@ -198,6 +198,7 @@ private: void command_drawRoundRect(QRegularExpressionMatch re); void command_drawText(QRegularExpressionMatch re); void command_drawStaticText(QRegularExpressionMatch re); + void command_drawTextDocument(QRegularExpressionMatch re); void command_drawTiledPixmap(QRegularExpressionMatch re); void command_path_addEllipse(QRegularExpressionMatch re); void command_path_addPolygon(QRegularExpressionMatch re); diff --git a/tests/auto/other/lancelot/scripts/richtext.qps b/tests/auto/other/lancelot/scripts/richtext.qps new file mode 100644 index 0000000000..787c97421b --- /dev/null +++ b/tests/auto/other/lancelot/scripts/richtext.qps @@ -0,0 +1,9 @@ +drawTextDocument 10 10 "Xy" +drawTextDocument 10 210 "Xy" +drawTextDocument 310 210 "Xy" +drawTextDocument 10 310 "Xy" + +drawTextDocument 10 410 "Xy" +drawTextDocument 10 510 "Xy" +drawTextDocument 310 410 "Xy" +drawTextDocument 310 510 "Xy" -- cgit v1.2.3