summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAleix Pol <aleixpol@kde.org>2016-01-20 17:45:00 +0100
committerAleix Pol Gonzalez <aleixpol@kde.org>2016-02-09 21:24:46 +0000
commit8b4ac65e2913bd7fbdd996ca290b129659f89a9e (patch)
treeb09fe3f2de0439c13493d5f4300b123b29e16a27 /tests
parent22c262d2d7a7c262c7cecf68c2f6bef5ec29e6b5 (diff)
Provide QCss with the correct font for <pre> blocks
Labels would use a statically defined font for <pre> blocks. Use the one defined by the QPlatformTheme instead, through QFontDatabase::systemFont(FixedFont) Task-number: QTBUG-50564 Change-Id: I5491bd0defce651bdf809bcbc6a529a900f4959b Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
index 7378ca85ee..02e2bf27e2 100644
--- a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
+++ b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
@@ -95,6 +95,8 @@ private slots:
void task240325();
+ void preFont();
+
void stylesheetFont_data();
void stylesheetFont();
@@ -675,6 +677,30 @@ void tst_QTextDocument::stylesheetFont()
QCOMPARE(actualFont.pixelSize(), font.pixelSize());
}
+void tst_QTextDocument::preFont()
+{
+ const QFont font = QFontDatabase::systemFont(QFontDatabase::FixedFont);
+ const QString html = QString::fromLatin1( "<html>"
+ "<body>"
+ "<pre>"
+ "Foobar"
+ "</pre>"
+ "</body>"
+ "</html>");
+
+ doc->setHtml(html);
+ QCOMPARE(doc->blockCount(), 1);
+
+ // First and only block
+ QTextBlock block = doc->firstBlock();
+
+ QString text = block.text();
+ QCOMPARE(text, QString::fromLatin1("Foobar"));
+
+ QFont actualFont = block.charFormat().font();
+ QCOMPARE(actualFont.family(), font.family());
+}
+
void tst_QTextDocument::noundo_moreIsModified()
{
doc->setUndoRedoEnabled(false);