summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qpainter/tst_qpainter.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp
index e4f267d..8ed83cb 100644
--- a/tests/auto/qpainter/tst_qpainter.cpp
+++ b/tests/auto/qpainter/tst_qpainter.cpp
@@ -238,6 +238,8 @@ private slots:
void taskQT4444_dontOverflowDashOffset();
+ void painterBegin();
+
private:
void fillData();
QColor baseColor( int k, int intensity=255 );
@@ -4312,5 +4314,43 @@ void tst_QPainter::taskQT4444_dontOverflowDashOffset()
QVERIFY(true); // Don't crash
}
+void tst_QPainter::painterBegin()
+{
+ QImage nullImage;
+ QImage indexed8Image(16, 16, QImage::Format_Indexed8);
+ QImage rgb32Image(16, 16, QImage::Format_RGB32);
+ QImage argb32Image(16, 16, QImage::Format_ARGB32_Premultiplied);
+
+ QPainter p;
+
+ // Painting on null image should fail.
+ QVERIFY(!p.begin(&nullImage));
+
+ // Check that the painter is not messed up by using it on another image.
+ QVERIFY(p.begin(&rgb32Image));
+ QVERIFY(p.end());
+
+ // If painting on indexed8 image fails, the painter state should still be OK.
+ if (p.begin(&indexed8Image))
+ QVERIFY(p.end());
+ QVERIFY(p.begin(&rgb32Image));
+ QVERIFY(p.end());
+
+ // Try opening a painter on the two different images.
+ QVERIFY(p.begin(&rgb32Image));
+ QVERIFY(!p.begin(&argb32Image));
+ QVERIFY(p.end());
+
+ // Try opening two painters on the same image.
+ QVERIFY(p.begin(&rgb32Image));
+ QPainter q;
+ QVERIFY(!q.begin(&rgb32Image));
+ QVERIFY(!q.end());
+ QVERIFY(p.end());
+
+ // Try ending an inactive painter.
+ QVERIFY(!p.end());
+}
+
QTEST_MAIN(tst_QPainter)
#include "tst_qpainter.moc"