diff options
author | Alexis Menard <alexis.menard@nokia.com> | 2009-04-21 13:25:51 (GMT) |
---|---|---|
committer | Alexis Menard <alexis.menard@nokia.com> | 2009-04-21 13:29:16 (GMT) |
commit | 95b7c50e503dd4743e22c35f341aa31105ea7d73 (patch) | |
tree | 6adfdc77c2323a6f5c9b63da3902a823cd205659 /tests/auto/qgraphicsitem | |
parent | 49b4685a185f6932bcf4c685dc211cf2c4a3dddd (diff) | |
download | Qt-95b7c50e503dd4743e22c35f341aa31105ea7d73.zip Qt-95b7c50e503dd4743e22c35f341aa31105ea7d73.tar.gz Qt-95b7c50e503dd4743e22c35f341aa31105ea7d73.tar.bz2 |
We don't need to call two times itemChange when an item is deleted.
Previously we were calling two times itemChange on the parent to give
QGraphicsItem::ItemChildAddedChange. We don't need that. One is enough.
BT : yes
Task-number: BT
Reviewed-by: Andreas
Diffstat (limited to 'tests/auto/qgraphicsitem')
-rw-r--r-- | tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 5565aa6..583a959 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -3654,6 +3654,8 @@ void tst_QGraphicsItem::defaultItemTest_QGraphicsEllipseItem() class ItemChangeTester : public QGraphicsRectItem { public: + ItemChangeTester(){} + ItemChangeTester(QGraphicsItem *parent) : QGraphicsRectItem(parent) {} QVariant itemChangeReturnValue; QGraphicsScene *itemSceneChangeTargetScene; @@ -3928,6 +3930,39 @@ void tst_QGraphicsItem::itemChange() QCOMPARE(tester.changes.size(), ++changeCount); QCOMPARE(tester.changes.last(), QGraphicsItem::ItemChildRemovedChange); QCOMPARE(qVariantValue<QGraphicsItem *>(tester.values.last()), (QGraphicsItem *)&testerHelper); + + // ItemChildRemovedChange 1 + ItemChangeTester *test = new ItemChangeTester; + test->itemSceneChangeTargetScene = 0; + int count = 0; + QGraphicsScene *scene = new QGraphicsScene; + scene->addItem(test); + count = test->changes.size(); + //We test here the fact that when a child is deleted the parent receive only one ItemChildRemovedChange + QGraphicsRectItem *child = new QGraphicsRectItem(test); + //We received ItemChildAddedChange + QCOMPARE(test->changes.size(), ++count); + QCOMPARE(test->changes.last(), QGraphicsItem::ItemChildAddedChange); + delete child; + child = 0; + QCOMPARE(test->changes.size(), ++count); + QCOMPARE(test->changes.last(), QGraphicsItem::ItemChildRemovedChange); + + ItemChangeTester *childTester = new ItemChangeTester(test); + //Changes contains all sceneHasChanged and so on, we don't want to test that + int childCount = childTester->changes.size(); + //We received ItemChildAddedChange + QCOMPARE(test->changes.size(), ++count); + child = new QGraphicsRectItem(childTester); + //We received ItemChildAddedChange + QCOMPARE(childTester->changes.size(), ++childCount); + QCOMPARE(childTester->changes.last(), QGraphicsItem::ItemChildAddedChange); + //Delete the child of the top level with all its children + delete childTester; + //Only one removal + QCOMPARE(test->changes.size(), ++count); + QCOMPARE(test->changes.last(), QGraphicsItem::ItemChildRemovedChange); + delete scene; } { // ItemChildRemovedChange 2 |