summaryrefslogtreecommitdiffstats
path: root/tests/auto/qpainter/tst_qpainter.cpp
diff options
context:
space:
mode:
authoraavit <qt-info@nokia.com>2010-11-19 12:30:09 (GMT)
committeraavit <qt-info@nokia.com>2010-11-19 12:30:09 (GMT)
commit8034cab2cce55b43dcc1100d0b22f8c85eb733c2 (patch)
tree5a1637fa48ce23e12c6a51490f6a481fd1ca1a5a /tests/auto/qpainter/tst_qpainter.cpp
parente614223831f2b3cc9051ae88586370a7d5b63db2 (diff)
parent1d152964adec62d03ce2f4a45ca40ddbd05819ae (diff)
downloadQt-8034cab2cce55b43dcc1100d0b22f8c85eb733c2.zip
Qt-8034cab2cce55b43dcc1100d0b22f8c85eb733c2.tar.gz
Qt-8034cab2cce55b43dcc1100d0b22f8c85eb733c2.tar.bz2
Merge branch 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-2
Diffstat (limited to 'tests/auto/qpainter/tst_qpainter.cpp')
-rw-r--r--tests/auto/qpainter/tst_qpainter.cpp51
1 files changed, 25 insertions, 26 deletions
diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp
index 42303d2..ab380a6 100644
--- a/tests/auto/qpainter/tst_qpainter.cpp
+++ b/tests/auto/qpainter/tst_qpainter.cpp
@@ -260,6 +260,7 @@ private slots:
void drawPointScaled();
void QTBUG14614_gradientCacheRaceCondition();
+ void drawTextOpacity();
private:
void fillData();
@@ -4581,32 +4582,6 @@ void tst_QPainter::drawText_subPixelPositionsInRaster_qtbug5053()
#if !defined(Q_WS_MAC) || !defined(QT_MAC_USE_COCOA)
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);
@@ -4685,6 +4660,30 @@ void tst_QPainter::QTBUG14614_gradientCacheRaceCondition()
producers[i].wait();
}
+void tst_QPainter::drawTextOpacity()
+{
+ QImage image(32, 32, QImage::Format_RGB32);
+ image.fill(0xffffffff);
+
+ QPainter p(&image);
+ p.setPen(QColor("#6F6F6F"));
+ p.setOpacity(0.5);
+ p.drawText(5, 30, QLatin1String("Qt"));
+ p.end();
+
+ QImage copy = image;
+ image.fill(0xffffffff);
+
+ p.begin(&image);
+ p.setPen(QColor("#6F6F6F"));
+ p.drawLine(-10, -10, -1, -1);
+ p.setOpacity(0.5);
+ p.drawText(5, 30, QLatin1String("Qt"));
+ p.end();
+
+ QCOMPARE(image, copy);
+}
+
QTEST_MAIN(tst_QPainter)
#include "tst_qpainter.moc"