summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicseffect
diff options
context:
space:
mode:
authorAriya Hidayat <ariya.hidayat@nokia.com>2009-09-14 14:09:47 (GMT)
committerAriya Hidayat <ariya.hidayat@nokia.com>2009-09-14 14:58:08 (GMT)
commit3ecf8f5de029e0a67ec90f6eba60754078374f01 (patch)
tree0bee19c7f3545d92ad16147ba86b668d86edfb0a /tests/auto/qgraphicseffect
parentb590ed186b38491dd338e55372f509e7c3feb2b4 (diff)
downloadQt-3ecf8f5de029e0a67ec90f6eba60754078374f01.zip
Qt-3ecf8f5de029e0a67ec90f6eba60754078374f01.tar.gz
Qt-3ecf8f5de029e0a67ec90f6eba60754078374f01.tar.bz2
Add simple autotest for QGraphicsColorizeEffect.
Reviewed-by: Bjørn Erik Nilsen
Diffstat (limited to 'tests/auto/qgraphicseffect')
-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"