summaryrefslogtreecommitdiffstats
path: root/tests/auto/qstatictext
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eblomfel@trolltech.com>2009-08-19 13:30:25 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-01-14 12:56:43 (GMT)
commitbf86841fd9ec41263b2fd53b3f69661f09cfa9b9 (patch)
treecb4ba2b6a2a65482547e7e76faea396019b6a93a /tests/auto/qstatictext
parent5247001c8d1a012b5895223dd7f09a9a0fd9286e (diff)
downloadQt-bf86841fd9ec41263b2fd53b3f69661f09cfa9b9.zip
Qt-bf86841fd9ec41263b2fd53b3f69661f09cfa9b9.tar.gz
Qt-bf86841fd9ec41263b2fd53b3f69661f09cfa9b9.tar.bz2
Ignore rounding error when painting to rotated painter
There are tiny rounding errors in the matrix rotations which cause tiny differences in drawText() and drawStaticText(). I've chosen to ignore these. Instead of having a threshold on the comparison between the two images, I've chosen to take the easy way out and avoid the problem by not passing in any position for the text.
Diffstat (limited to 'tests/auto/qstatictext')
-rw-r--r--tests/auto/qstatictext/tst_qstatictext.cpp32
1 files changed, 17 insertions, 15 deletions
diff --git a/tests/auto/qstatictext/tst_qstatictext.cpp b/tests/auto/qstatictext/tst_qstatictext.cpp
index 47be17d..0eda3c3 100644
--- a/tests/auto/qstatictext/tst_qstatictext.cpp
+++ b/tests/auto/qstatictext/tst_qstatictext.cpp
@@ -47,7 +47,7 @@
#include <private/qstatictext_p.h>
-// #define DEBUG_SAVE_IMAGE
+#define DEBUG_SAVE_IMAGE
class tst_QStaticText: public QObject
{
@@ -191,17 +191,16 @@ void tst_QStaticText::rotatedPainter()
{
QPainter p(&imageDrawText);
p.rotate(30.0);
-
- p.drawText(11, 12, "Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
+ p.drawText(0, 0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
}
QImage imageDrawStaticText(1000, 1000, QImage::Format_ARGB32_Premultiplied);
{
+ QStaticText text("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
+
QPainter p(&imageDrawStaticText);
p.rotate(30.0);
-
- QStaticText text("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
- p.drawStaticText(11, 12, text);
+ p.drawStaticText(0, 0, text);
}
#if defined(DEBUG_SAVE_IMAGE)
@@ -210,7 +209,6 @@ void tst_QStaticText::rotatedPainter()
#endif
QCOMPARE(imageDrawStaticText, imageDrawText);
-
}
void tst_QStaticText::scaledPainter()
@@ -264,16 +262,16 @@ void tst_QStaticText::rotatedScaledAndTranslatedPainter()
void tst_QStaticText::transformationChanged()
{
QImage imageDrawText(1000, 1000, QImage::Format_ARGB32_Premultiplied);
+
{
QPainter p(&imageDrawText);
p.rotate(33.0);
p.scale(0.5, 0.7);
- p.drawText(11, 12, "Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
+ p.drawText(0, 0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
- p.rotate(77.0);
- p.scale(0.7, 0.5);
- p.drawText(100, 200, "Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
+ p.scale(7.0, 5.0);
+ p.drawText(0, 0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
}
QImage imageDrawStaticText(1000, 1000, QImage::Format_ARGB32_Premultiplied);
@@ -283,13 +281,17 @@ void tst_QStaticText::transformationChanged()
p.scale(0.5, 0.7);
QStaticText text("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
- p.drawStaticText(11, 12, text);
+ p.drawStaticText(0, 0, text);
- p.rotate(77.0);
- p.scale(0.7, 0.5);
- p.drawStaticText(100, 200, text);
+ p.scale(7.0, 5.0);
+ p.drawStaticText(0, 0, text);
}
+#if defined(DEBUG_SAVE_IMAGE)
+ imageDrawText.save("transformationChanged_imageDrawText.png");
+ imageDrawStaticText.save("transformationChanged_imageDrawStaticText.png");
+#endif
+
QCOMPARE(imageDrawStaticText, imageDrawText);
}