summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/text/qtextdocumentfragment
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@qt.io>2018-12-14 12:36:22 +0100
committerKai Koehne <kai.koehne@qt.io>2019-02-13 08:14:47 +0000
commitd6c474b49b349dc6c30ea059040285221e712217 (patch)
tree04dc52f4ef2db85959bfbc51789eea080c6a10d6 /tests/auto/gui/text/qtextdocumentfragment
parent81fd7f4c8af260d753a834480f790c82fb161889 (diff)
QTextDocument: Do respect white-space:nowrap
Prevent automatic insertion of line-breaks in blocks formatted with 'white-space:nowrap'. This follows the example of white-space:pre. Fixes: QTBUG-54787 Change-Id: If26f6a54106a02fe0e388947f6368ae4e86acf63 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests/auto/gui/text/qtextdocumentfragment')
-rw-r--r--tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp
index 3e354b7523..d652bb066d 100644
--- a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp
+++ b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp
@@ -195,6 +195,8 @@ private slots:
void css_linkPseudo();
void css_pageBreaks();
void css_cellPaddings();
+ void css_whiteSpace_data();
+ void css_whiteSpace();
void universalSelectors_data();
void universalSelectors();
void screenMedia();
@@ -1770,6 +1772,26 @@ void tst_QTextDocumentFragment::css_cellPaddings()
QCOMPARE(cell.format().toTableCellFormat().bottomPadding(), qreal(15));
}
+void tst_QTextDocumentFragment::css_whiteSpace_data()
+{
+ QTest::addColumn<QString>("htmlText");
+ QTest::addColumn<bool>("nowrap");
+
+ QTest::newRow("default") << QString("<p>Normal Text</p>") << false;
+ QTest::newRow("white-space:nowrap") << QString("<p style=white-space:nowrap>Normal Text</p>") << true;
+ QTest::newRow("white-space:pre") << QString("<p style=white-space:pre>Normal Text</p>") << true;
+}
+
+void tst_QTextDocumentFragment::css_whiteSpace()
+{
+ QFETCH(QString, htmlText);
+ QFETCH(bool, nowrap);
+
+ doc->setHtml(htmlText);
+ QCOMPARE(doc->blockCount(), 1);
+ QCOMPARE(doc->begin().blockFormat().nonBreakableLines(), nowrap);
+}
+
void tst_QTextDocumentFragment::html_blockLevelDiv()
{
const char html[] = "<div align=right><b>Hello World";