diff options
author | David Faure <faure@kde.org> | 2009-11-06 11:59:35 (GMT) |
---|---|---|
committer | Samuel Rødal <sroedal@trolltech.com> | 2009-11-06 12:01:06 (GMT) |
commit | 9b500e9a09907f05002bd0e57869c5312ae101db (patch) | |
tree | 3ac295059349513975c72ce834906992a4afabba /tests/auto/qpainter | |
parent | 971c9c84a9cff8370e72fe120867be540e0aca8b (diff) | |
download | Qt-9b500e9a09907f05002bd0e57869c5312ae101db.zip Qt-9b500e9a09907f05002bd0e57869c5312ae101db.tar.gz Qt-9b500e9a09907f05002bd0e57869c5312ae101db.tar.bz2 |
Fix QPainter::setPen(pen with color but no style) on non-extended.
It was working with a QImage but not with a QPixmap, which is obviously
a bug. In addition, it broke WebCore::GraphicsContext::setPlatformStrokeColor
which does exactly what I put in the unittest: get pen, set color, set pen.
This commit fixes the wrong color in the underline of the links in
http://www.davidfaure.fr/kde/link_underline_color.html in QtWebkit.
Merge-request: 1995
Reviewed-by: Samuel Rødal <sroedal@trolltech.com>
Diffstat (limited to 'tests/auto/qpainter')
-rw-r--r-- | tests/auto/qpainter/tst_qpainter.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index bcdbe56..4d2c626 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -239,9 +239,12 @@ private slots: void taskQT4444_dontOverflowDashOffset(); void painterBegin(); + void setPenColorOnImage(); + void setPenColorOnPixmap(); private: void fillData(); + void setPenColor(QPainter& p); QColor baseColor( int k, int intensity=255 ); QImage getResImage( const QString &dir, const QString &addition, const QString &extension ); QBitmap getBitmap( const QString &dir, const QString &filename, bool mask ); @@ -4352,5 +4355,41 @@ void tst_QPainter::painterBegin() QVERIFY(!p.end()); } +void tst_QPainter::setPenColor(QPainter& p) +{ + p.setPen(Qt::NoPen); + + // Setting color, then style + // Should work even though the pen is "NoPen with color", temporarily. + QPen newPen(p.pen()); + newPen.setColor(Qt::red); + QCOMPARE(p.pen().style(), newPen.style()); + QCOMPARE(p.pen().style(), Qt::NoPen); + p.setPen(newPen); + + QCOMPARE(p.pen().color().name(), QString("#ff0000")); + + QPen newPen2(p.pen()); + newPen2.setStyle(Qt::SolidLine); + p.setPen(newPen2); + + QCOMPARE(p.pen().color().name(), QString("#ff0000")); +} + +void tst_QPainter::setPenColorOnImage() +{ + QImage img(QSize(10, 10), QImage::Format_ARGB32_Premultiplied); + QPainter p(&img); + setPenColor(p); +} + +void tst_QPainter::setPenColorOnPixmap() +{ + QPixmap pix(10, 10); + QPainter p(&pix); + setPenColor(p); +} + QTEST_MAIN(tst_QPainter) + #include "tst_qpainter.moc" |