diff options
author | Mike Krus <mike.krus@kdab.com> | 2017-05-30 22:39:09 +0100 |
---|---|---|
committer | Mike Krus <mike.krus@kdab.com> | 2018-01-26 11:13:53 +0000 |
commit | fb05d2eb013eb0a5b2bb80c28e0272ec723d1fb5 (patch) | |
tree | b52193298c21f6275ce8940e86cbe9da5a94a97c /tests | |
parent | c753f187e4df86435f366d3573eb0f120002cf8a (diff) |
Fix componentAdded/componentRemoved notifications dispatch to components
When a component is added to an entity, two change
notifications were sent but they both were directed
to the entity.
This makes sure one message is sent to the entity
and one to the component, as was intended.
Same for remove notifications.
Fixed the unit tests which where incorrectly testing for the
subject id of the change notification.
Change-Id: Ic697c08e92e884abf28e675e4ae2b44a93ca45d5
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/core/nodes/tst_nodes.cpp | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/tests/auto/core/nodes/tst_nodes.cpp b/tests/auto/core/nodes/tst_nodes.cpp index 49618821c..717bb3200 100644 --- a/tests/auto/core/nodes/tst_nodes.cpp +++ b/tests/auto/core/nodes/tst_nodes.cpp @@ -958,15 +958,22 @@ void tst_Nodes::appendingParentlessComponentToEntity() // return early in such a case. // Check that we received ComponentAdded - for (const auto event: { entitySpy.events.takeFirst().change().dynamicCast<Qt3DCore::QComponentAddedChange>(), - componentSpy.events.takeLast().change().dynamicCast<Qt3DCore::QComponentAddedChange>() }) { + const auto event = entitySpy.events.takeFirst().change().dynamicCast<Qt3DCore::QComponentAddedChange>(); QCOMPARE(event->type(), Qt3DCore::ComponentAdded); QCOMPARE(event->subjectId(), entity->id()); QCOMPARE(event->entityId(), entity->id()); QCOMPARE(event->componentId(), comp->id()); QCOMPARE(event->componentMetaObject(), comp->metaObject()); } + { + const auto event = componentSpy.events.takeFirst().change().dynamicCast<Qt3DCore::QComponentAddedChange>(); + QCOMPARE(event->type(), Qt3DCore::ComponentAdded); + QCOMPARE(event->subjectId(), comp->id()); + QCOMPARE(event->entityId(), entity->id()); + QCOMPARE(event->componentId(), comp->id()); + QCOMPARE(event->componentMetaObject(), comp->metaObject()); + } } } @@ -997,15 +1004,22 @@ void tst_Nodes::appendingComponentToEntity() QVERIFY(comp->parentNode() == entity.data()); QCOMPARE(entitySpy.events.size(), 1); QVERIFY(entitySpy.events.first().wasLocked()); - for (const auto event: { entitySpy.events.takeFirst().change().dynamicCast<Qt3DCore::QComponentAddedChange>(), - componentSpy.events.takeFirst().change().dynamicCast<Qt3DCore::QComponentAddedChange>() }) { + const auto event = entitySpy.events.takeFirst().change().dynamicCast<Qt3DCore::QComponentAddedChange>(); QCOMPARE(event->type(), Qt3DCore::ComponentAdded); QCOMPARE(event->subjectId(), entity->id()); QCOMPARE(event->entityId(), entity->id()); QCOMPARE(event->componentId(), comp->id()); QCOMPARE(event->componentMetaObject(), comp->metaObject()); } + { + const auto event = componentSpy.events.takeFirst().change().dynamicCast<Qt3DCore::QComponentAddedChange>(); + QCOMPARE(event->type(), Qt3DCore::ComponentAdded); + QCOMPARE(event->subjectId(), comp->id()); + QCOMPARE(event->entityId(), entity->id()); + QCOMPARE(event->componentId(), comp->id()); + QCOMPARE(event->componentMetaObject(), comp->metaObject()); + } } } @@ -1040,14 +1054,22 @@ void tst_Nodes::removingComponentFromEntity() QCOMPARE(entitySpy.events.size(), 1); QVERIFY(entitySpy.events.first().wasLocked()); QCOMPARE(componentSpy.events.size(), 1); - for (const auto event: { entitySpy.events.takeFirst().change().dynamicCast<Qt3DCore::QComponentRemovedChange>(), - componentSpy.events.takeFirst().change().dynamicCast<Qt3DCore::QComponentRemovedChange>() }) { + { + const auto event = entitySpy.events.takeFirst().change().dynamicCast<Qt3DCore::QComponentRemovedChange>(); QCOMPARE(event->type(), Qt3DCore::ComponentRemoved); QCOMPARE(event->subjectId(), entity->id()); QCOMPARE(event->entityId(), entity->id()); QCOMPARE(event->componentId(), comp->id()); QCOMPARE(event->componentMetaObject(), comp->metaObject()); } + { + const auto event = componentSpy.events.takeFirst().change().dynamicCast<Qt3DCore::QComponentRemovedChange>(); + QCOMPARE(event->type(), Qt3DCore::ComponentRemoved); + QCOMPARE(event->subjectId(), comp->id()); + QCOMPARE(event->entityId(), entity->id()); + QCOMPARE(event->componentId(), comp->id()); + QCOMPARE(event->componentMetaObject(), comp->metaObject()); + } } } |