diff options
author | Ariya Hidayat <ariya.hidayat@nokia.com> | 2009-09-14 13:47:06 (GMT) |
---|---|---|
committer | Ariya Hidayat <ariya.hidayat@nokia.com> | 2009-09-14 14:58:08 (GMT) |
commit | b590ed186b38491dd338e55372f509e7c3feb2b4 (patch) | |
tree | 7cbd49b531cb4f7d7a0a5b31b6a912643a96c8ca /tests | |
parent | ef0f72e2ed861982fdcbf620c88f188b009b0cf1 (diff) | |
download | Qt-b590ed186b38491dd338e55372f509e7c3feb2b4.zip Qt-b590ed186b38491dd338e55372f509e7c3feb2b4.tar.gz Qt-b590ed186b38491dd338e55372f509e7c3feb2b4.tar.bz2 |
Add simple autotest for QGraphicsGrayscaleEffect.
Reviewed-by: Bjørn Erik Nilsen
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp index b36cf73..c0d23eb 100644 --- a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp +++ b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp @@ -63,6 +63,7 @@ private slots: void boundingRect(); void draw(); void opacity(); + void grayscale(); }; void tst_QGraphicsEffect::initTestCase() @@ -365,6 +366,29 @@ void tst_QGraphicsEffect::opacity() QCOMPARE(effect->m_opacity, qreal(0.5)); } +void tst_QGraphicsEffect::grayscale() +{ + 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 + + QGraphicsGrayscaleEffect *effect = new QGraphicsGrayscaleEffect; + 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(148, 148, 148)); +} + QTEST_MAIN(tst_QGraphicsEffect) #include "tst_qgraphicseffect.moc" |