From 3ecf8f5de029e0a67ec90f6eba60754078374f01 Mon Sep 17 00:00:00 2001 From: Ariya Hidayat Date: Mon, 14 Sep 2009 16:09:47 +0200 Subject: Add simple autotest for QGraphicsColorizeEffect. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Bjørn Erik Nilsen --- tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp index c0d23eb..5363fd6 100644 --- a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp +++ b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp @@ -64,6 +64,7 @@ private slots: void draw(); void opacity(); void grayscale(); + void colorize(); }; void tst_QGraphicsEffect::initTestCase() @@ -389,6 +390,30 @@ void tst_QGraphicsEffect::grayscale() QCOMPARE(image.pixel(10, 10), qRgb(148, 148, 148)); } +void tst_QGraphicsEffect::colorize() +{ + QGraphicsScene scene(0, 0, 100, 100); + + QGraphicsRectItem *item = scene.addRect(0, 0, 50, 50); + item->setPen(Qt::NoPen); + item->setBrush(QColor(122, 193, 66)); // Qt light green + + QGraphicsColorizeEffect *effect = new QGraphicsColorizeEffect; + effect->setColor(QColor(102, 153, 51)); // Qt dark green + item->setGraphicsEffect(effect); + + QPainter painter; + QImage image(100, 100, QImage::Format_ARGB32_Premultiplied); + + image.fill(0); + painter.begin(&image); + painter.setRenderHint(QPainter::Antialiasing); + scene.render(&painter); + painter.end(); + + QCOMPARE(image.pixel(10, 10), qRgb(191, 212, 169)); +} + QTEST_MAIN(tst_QGraphicsEffect) #include "tst_qgraphicseffect.moc" -- cgit v0.12