diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-01-15 12:19:22 (GMT) |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-01-15 12:19:22 (GMT) |
commit | 5ff3ab8f2ddcac57df3f3d9114fe3913659fcee8 (patch) | |
tree | 782a244524b69d85a04a2a85ed820c337689ebbb /tests/auto/qstatictext | |
parent | 7d2d897eca62d70943a8e7c3aba99336f368e19f (diff) | |
download | Qt-5ff3ab8f2ddcac57df3f3d9114fe3913659fcee8.zip Qt-5ff3ab8f2ddcac57df3f3d9114fe3913659fcee8.tar.gz Qt-5ff3ab8f2ddcac57df3f3d9114fe3913659fcee8.tar.bz2 |
Add tests for QStaticText::prepare()
Diffstat (limited to 'tests/auto/qstatictext')
-rw-r--r-- | tests/auto/qstatictext/tst_qstatictext.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/auto/qstatictext/tst_qstatictext.cpp b/tests/auto/qstatictext/tst_qstatictext.cpp index 0e1532b..66275b2 100644 --- a/tests/auto/qstatictext/tst_qstatictext.cpp +++ b/tests/auto/qstatictext/tst_qstatictext.cpp @@ -61,6 +61,8 @@ private slots: void drawToRect(); void setFont(); void setMaximumSize(); + void prepareToCorrectData(); + void prepareToWrongData(); void translatedPainter(); void rotatedPainter(); @@ -116,9 +118,58 @@ void tst_QStaticText::drawToRect() p.drawStaticText(11, 12, text); } + QCOMPARE(imageDrawStaticText, imageDrawText); +} + +void tst_QStaticText::prepareToCorrectData() +{ + QTransform transform; + transform.scale(2.0, 2.0); + transform.rotate(90, Qt::ZAxis); + + QImage imageDrawText(1000, 1000, QImage::Format_ARGB32_Premultiplied); + { + QPainter p(&imageDrawText); + p.setTransform(transform); + p.drawText(11, 12, "Lorem ipsum dolor sit amet, consectetur adipiscing elit."); + } + + QImage imageDrawStaticText(1000, 1000, QImage::Format_ARGB32_Premultiplied); + { + QPainter p(&imageDrawStaticText); + p.setTransform(transform); + QStaticText text("Lorem ipsum dolor sit amet, consectetur adipiscing elit."); + text.prepare(transform, p.font()); + p.drawStaticText(11, 12, text); + } + + QCOMPARE(imageDrawStaticText, imageDrawText); +} + +void tst_QStaticText::prepareToWrongData() +{ + QTransform transform; + transform.scale(2.0, 2.0); + transform.rotate(90, Qt::ZAxis); + + QImage imageDrawText(1000, 1000, QImage::Format_ARGB32_Premultiplied); + { + QPainter p(&imageDrawText); + p.drawText(11, 12, "Lorem ipsum dolor sit amet, consectetur adipiscing elit."); + } + + QImage imageDrawStaticText(1000, 1000, QImage::Format_ARGB32_Premultiplied); + { + QPainter p(&imageDrawStaticText); + QStaticText text("Lorem ipsum dolor sit amet, consectetur adipiscing elit."); + text.prepare(transform, p.font()); + p.drawStaticText(11, 12, text); + } + QCOMPARE(imageDrawStaticText, imageDrawText); } + void tst_QStaticText::setFont() { QFont font = QApplication::font(); |