summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-09-14 07:38:33 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-09-14 07:44:21 (GMT)
commit919c5a0e4b15b993d438dd137b17d4710228c595 (patch)
tree86263b28c8baa17e9537f3b9e043f6db10b3fffd
parent285799f27444fc7898641c0098e90d95c5e605e6 (diff)
downloadQt-919c5a0e4b15b993d438dd137b17d4710228c595.zip
Qt-919c5a0e4b15b993d438dd137b17d4710228c595.tar.gz
Qt-919c5a0e4b15b993d438dd137b17d4710228c595.tar.bz2
Skip sub pixel positions test if font smoothing is off
Copy/paste the test from qapplication_mac.mm where we detect if font smoothing is actually on by drawing an x into a buffer and checking the result for non-gray pixels. Reviewed-by: Jiang Jiang
-rw-r--r--tests/auto/qpainter/tst_qpainter.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp
index d16c37a..9b8444c 100644
--- a/tests/auto/qpainter/tst_qpainter.cpp
+++ b/tests/auto/qpainter/tst_qpainter.cpp
@@ -4570,6 +4570,31 @@ void tst_QPainter::drawText_subPixelPositionsInRaster_qtbug5053()
QSKIP("Only Mac/Cocoa supports sub pixel positions in raster engine currently", SkipAll);
#endif
+ int w = 10, h = 10;
+ QImage image(w, h, QImage::Format_RGB32);
+ image.fill(0xffffffff);
+ QPainter p(&image);
+ p.drawText(0, h, "X\\");
+ p.end();
+
+ bool foundNonGrayPixel = false;
+ const int *bits = (const int *) ((const QImage &) image).bits();
+ int bpl = image.bytesPerLine() / 4;
+ for (int y=0; y<w; ++y) {
+ for (int x=0; x<h; ++x) {
+ int r = qRed(bits[x]);
+ int g = qGreen(bits[x]);
+ int b = qBlue(bits[x]);
+ if (r != g || r != b) {
+ foundNonGrayPixel = true;
+ break;
+ }
+ }
+ bits += bpl;
+ }
+ if (!foundNonGrayPixel)
+ QSKIP("Font smoothing must be turned on for this test", SkipAll);
+
QFontMetricsF fm(qApp->font());
QImage baseLine(fm.width(QChar::fromLatin1('e')), fm.height(), QImage::Format_RGB32);