summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
diff options
context:
space:
mode:
authorBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-08-21 12:05:33 +0200
committerBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-08-21 12:05:33 +0200
commit487f636523dfded4c07a39e4d96ab3e83c64f95e (patch)
tree3e3a590f42424c831215d08d19a9790ec5eb0698 /tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
parentfad6c792d4ead4ff14eaed3c9bc7564142989af7 (diff)
Add auto-tests for QGraphicsItem/QWidget::setGraphicsEffect.
Diffstat (limited to 'tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp')
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index 184bfe27bf..931e2d3b5c 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -285,6 +285,7 @@ private slots:
void reverseCreateAutoFocusProxy();
void focusProxyDeletion();
void negativeZStacksBehindParent();
+ void setGraphicsEffect();
// task specific tests below me
void task141694_textItemEnsureVisible();
@@ -7708,5 +7709,36 @@ void tst_QGraphicsItem::negativeZStacksBehindParent()
QVERIFY(rect.flags() & QGraphicsItem::ItemStacksBehindParent);
}
+void tst_QGraphicsItem::setGraphicsEffect()
+{
+ // Check that we don't have any effect by default.
+ QGraphicsItem *item = new QGraphicsRectItem(0, 0, 10, 10);
+ QVERIFY(!item->graphicsEffect());
+
+ // SetGet check.
+ QPointer<QGraphicsEffect> blurEffect = new QGraphicsBlurEffect;
+ item->setGraphicsEffect(blurEffect);
+ QCOMPARE(item->graphicsEffect(), static_cast<QGraphicsEffect *>(blurEffect));
+
+ // Ensure the existing effect is deleted when setting a new one.
+ QPointer<QGraphicsEffect> shadowEffect = new QGraphicsDropShadowEffect;
+ item->setGraphicsEffect(shadowEffect);
+ QVERIFY(!blurEffect);
+ QCOMPARE(item->graphicsEffect(), static_cast<QGraphicsEffect *>(shadowEffect));
+ blurEffect = new QGraphicsBlurEffect;
+
+ // Ensure the effect is uninstalled when setting it on a new target.
+ QGraphicsItem *anotherItem = new QGraphicsRectItem(0, 0, 10, 10);
+ anotherItem->setGraphicsEffect(blurEffect);
+ item->setGraphicsEffect(blurEffect);
+ QVERIFY(!anotherItem->graphicsEffect());
+ QVERIFY(!shadowEffect);
+
+ // Ensure the existing effect is deleted when deleting the item.
+ delete item;
+ QVERIFY(!blurEffect);
+ delete anotherItem;
+}
+
QTEST_MAIN(tst_QGraphicsItem)
#include "tst_qgraphicsitem.moc"