summaryrefslogtreecommitdiffstats
path: root/tests/auto/qstatictext
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-03-26 09:43:40 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-03-26 10:46:46 (GMT)
commit47472906fd00e0eff820870330d481c4229ee285 (patch)
tree2543c9449bca6b7148a609567b9aa16f6d910f3d /tests/auto/qstatictext
parent075918e796b98155b81871f15bf2eb266a783561 (diff)
downloadQt-47472906fd00e0eff820870330d481c4229ee285.zip
Qt-47472906fd00e0eff820870330d481c4229ee285.tar.gz
Qt-47472906fd00e0eff820870330d481c4229ee285.tar.bz2
Synchronize rich text and plain text code paths in QStaticText
Drawing a string as plain text and rich text should have identical results unless special formatting information is added in the html. This means we should not have any implicit margin on the QTextDocument used to paint the text, and we should make up for the fact that the drawStaticText() call currently takes the position of the baseline and QTextDocument::drawContents() takes the top-left corner. Reviewed-by: Gunnar
Diffstat (limited to 'tests/auto/qstatictext')
-rw-r--r--tests/auto/qstatictext/tst_qstatictext.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/auto/qstatictext/tst_qstatictext.cpp b/tests/auto/qstatictext/tst_qstatictext.cpp
index 16832ad..a038878 100644
--- a/tests/auto/qstatictext/tst_qstatictext.cpp
+++ b/tests/auto/qstatictext/tst_qstatictext.cpp
@@ -79,6 +79,8 @@ private slots:
void projectedPainter();
void rotatedScaledAndTranslatedPainter();
void transformationChanged();
+
+ void plainTextVsRichText();
};
void tst_QStaticText::init()
@@ -482,5 +484,39 @@ void tst_QStaticText::transformationChanged()
QCOMPARE(imageDrawStaticText, imageDrawText);
}
+void tst_QStaticText::plainTextVsRichText()
+{
+ QPixmap imagePlainText(1000, 1000);
+ imagePlainText.fill(Qt::white);
+ {
+ QPainter p(&imagePlainText);
+
+ QStaticText staticText;
+ staticText.setText("FOObar");
+ staticText.setTextFormat(Qt::PlainText);
+
+ p.drawStaticText(10, 10, staticText);
+ }
+
+ QPixmap imageRichText(1000, 1000);
+ imageRichText.fill(Qt::white);
+ {
+ QPainter p(&imageRichText);
+
+ QStaticText staticText;
+ staticText.setText("<html><body>FOObar</body></html>");
+ staticText.setTextFormat(Qt::RichText);
+
+ p.drawStaticText(10, 10, staticText);
+ }
+
+#if defined(DEBUG_SAVE_IMAGE)
+ imagePlainText.save("plainTextVsRichText_imagePlainText.png");
+ imageRichText.save("plainTextVsRichText_imageRichText.png");
+#endif
+
+ QCOMPARE(imagePlainText, imageRichText);
+}
+
QTEST_MAIN(tst_QStaticText)
#include "tst_qstatictext.moc"