summaryrefslogtreecommitdiffstats
path: root/tests/auto/qtextlayout
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-05-31 10:00:54 +0200
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-05-31 13:18:10 +0200
commit817469519a784b1cc84f89cb3cb84f7560874f8e (patch)
treed4bac4e4e96cc52d79ffe3e7e1e6258cca33e357 /tests/auto/qtextlayout
parent59e281bcc2bc24ae93eaf2751cc6fcc48bfd6302 (diff)
Fix unreasonably large width of QTextLayout::boundingRect()
When no lineWidth is set on the QTextLine, the QScriptLine::width will be the maximum value that can be represented by QFixed, thus always overriding the width of the bounding rect. The lineWidth of the QTextLine should never be used as the width of the bounding rect, since it's not a calculated value. The real bounding rect is found by querying the natural text width. Task-number: QTBUG-11104 Reviewed-by: Rhys Weatherley
Diffstat (limited to 'tests/auto/qtextlayout')
-rw-r--r--tests/auto/qtextlayout/tst_qtextlayout.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/auto/qtextlayout/tst_qtextlayout.cpp b/tests/auto/qtextlayout/tst_qtextlayout.cpp
index caf9bd3f00..b67dc30883 100644
--- a/tests/auto/qtextlayout/tst_qtextlayout.cpp
+++ b/tests/auto/qtextlayout/tst_qtextlayout.cpp
@@ -110,6 +110,7 @@ private slots:
void longText();
void widthOfTabs();
void columnWrapWithTabs();
+ void boundingRectForUnsetLineWidth();
// QTextLine stuff
void setNumColumnsWrapAtWordBoundaryOrAnywhere();
@@ -1307,6 +1308,17 @@ void tst_QTextLayout::columnWrapWithTabs()
}
+void tst_QTextLayout::boundingRectForUnsetLineWidth()
+{
+ QTextLayout layout("FOOBAR");
+
+ layout.beginLayout();
+ QTextLine line = layout.createLine();
+ layout.endLayout();
+
+ QCOMPARE(layout.boundingRect().width(), line.naturalTextWidth());
+}
+
void tst_QTextLayout::lineWidthFromBOM()
{
const QString string(QChar(0xfeff)); // BYTE ORDER MARK