summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/auto/qtextdocument/tst_qtextdocument.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/auto/qtextdocument/tst_qtextdocument.cpp b/tests/auto/qtextdocument/tst_qtextdocument.cpp
index 72f3ea8..4643df0 100644
--- a/tests/auto/qtextdocument/tst_qtextdocument.cpp
+++ b/tests/auto/qtextdocument/tst_qtextdocument.cpp
@@ -55,8 +55,13 @@
#include <qtextlist.h>
#include <qtextcodec.h>
#include <qurl.h>
+#include <qpainter.h>
+#include <qfontmetrics.h>
+#include <qimage.h>
+#include <qtextlayout.h>
#include "common.h"
+
QT_FORWARD_DECLARE_CLASS(QTextDocument)
//TESTED_CLASS=
@@ -93,6 +98,8 @@ private slots:
void noundo_isModified3();
void mightBeRichText();
+ void task240325();
+
void toHtml_data();
void toHtml();
void toHtml2();
@@ -532,6 +539,38 @@ void tst_QTextDocument::noundo_basicIsModifiedChecks()
QCOMPARE(spy.count(), 0);
}
+void tst_QTextDocument::task240325()
+{
+ doc->setHtml("<html><img width=\"100\" height=\"100\" align=\"right\"/>Foobar Foobar Foobar Foobar</html>");
+
+ QImage img(1000, 7000, QImage::Format_ARGB32_Premultiplied);
+ QPainter p(&img);
+ QFontMetrics fm(p.font());
+
+ // Set page size to contain image and one "Foobar"
+ doc->setPageSize(QSize(100 + fm.width("Foobar")*2, 1000));
+
+ // Force layout
+ doc->drawContents(&p);
+
+ QCOMPARE(doc->blockCount(), 1);
+ for (QTextBlock block = doc->begin() ; block!=doc->end() ; block = block.next()) {
+ QTextLayout *layout = block.layout();
+ QCOMPARE(layout->lineCount(), 4);
+ for (int lineIdx=0;lineIdx<layout->lineCount();++lineIdx) {
+ QTextLine line = layout->lineAt(lineIdx);
+
+ QString text = block.text().mid(line.textStart(), line.textLength()).trimmed();
+
+ // Remove start token
+ if (lineIdx == 0)
+ text = text.mid(1);
+
+ QCOMPARE(text, QString::fromLatin1("Foobar"));
+ }
+ }
+}
+
void tst_QTextDocument::noundo_moreIsModified()
{
doc->setUndoRedoEnabled(false);