summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp')
-rw-r--r--tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp25
1 files changed, 25 insertions, 0 deletions
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"