summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/text
diff options
context:
space:
mode:
authorVladimir Belyavsky <belyavskyv@gmail.com>2022-09-26 19:32:50 +0300
committerVladimir Belyavsky <belyavskyv@gmail.com>2022-10-06 08:43:11 +0000
commit4945fd93f13d2fc34adf260fd0e0325d0794f3f7 (patch)
treea6e96dd90f56a16ae77a5f75986bd295008716cf /tests/auto/gui/text
parentfd28c970750e0570bf1d107922fa29eae161e93d (diff)
QTextLayout: fix maximumWidth() for a text containing spaces
When laying out a text and calculating maxWidth, we must _always_ take into account the accumulated width of spaces (lbh.spaceData.textWidth) regardless of wrapMode, other text content, spaces position, etc. Fixes: QTBUG-106947 Change-Id: I2ac9af92ed7dd07c1e040bfcf83949a358d1c9c9 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'tests/auto/gui/text')
-rw-r--r--tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
index 4ae1b33d79..c85d498318 100644
--- a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
+++ b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
@@ -124,6 +124,7 @@ private slots:
void tooManyDirectionalCharctersCrash_qtbug77819();
void softHyphens_data();
void softHyphens();
+ void min_maximumWidth_data();
void min_maximumWidth();
private:
@@ -2647,10 +2648,21 @@ void tst_QTextLayout::softHyphens()
}
}
+void tst_QTextLayout::min_maximumWidth_data()
+{
+ QTest::addColumn<QString>("text");
+
+ QTest::newRow("long string") << QStringLiteral("lmong_long_crazy_87235982735_23857239682376923876923876-fuwhfhfw-names-AAAA-deeaois2019-03-03.and.more");
+ QTest::newRow("QTBUG-106947") << QStringLiteral("text text");
+ QTest::newRow("spaces") << QStringLiteral(" text text ");
+}
+
void tst_QTextLayout::min_maximumWidth()
{
- QString longString("lmong_long_crazy_87235982735_23857239682376923876923876-fuwhfhfw-names-AAAA-deeaois2019-03-03.and.more");
- QTextLayout layout(longString, testFont);
+ QFETCH(QString, text);
+
+ QTextLayout layout(text, testFont);
+ layout.setCacheEnabled(true);
for (int wrapMode = QTextOption::NoWrap; wrapMode <= QTextOption::WrapAtWordBoundaryOrAnywhere; ++wrapMode) {
QTextOption opt;