diff options
author | Ariya Hidayat <ariya.hidayat@nokia.com> | 2009-09-14 14:09:47 (GMT) |
---|---|---|
committer | Ariya Hidayat <ariya.hidayat@nokia.com> | 2009-09-14 14:58:08 (GMT) |
commit | 3ecf8f5de029e0a67ec90f6eba60754078374f01 (patch) | |
tree | 0bee19c7f3545d92ad16147ba86b668d86edfb0a /tests | |
parent | b590ed186b38491dd338e55372f509e7c3feb2b4 (diff) | |
download | Qt-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')
-rw-r--r-- | tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp | 25 |
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" |