void checkCloning() { // GIVEN QFETCH(Qt3DRender::QGeometry *, geometry); QFETCH(int, attributeCount); // WHEN Qt3DCore::QNodeCreatedChangeGenerator creationChangeGenerator(geometry); QVector<Qt3DCore::QNodeCreatedChangeBasePtr> creationChanges = creationChangeGenerator.creationChanges(); // THEN QCOMPARE(creationChanges.size(), 1 + geometry->childNodes().size()); const Qt3DCore::QNodeCreatedChangePtr<Qt3DRender::QGeometryData> creationChangeData = qSharedPointerCast<Qt3DCore::QNodeCreatedChange<Qt3DRender::QGeometryData>>(creationChanges.first()); const Qt3DRender::QGeometryData &cloneData = creationChangeData->data; QCOMPARE(geometry->id(), creationChangeData->subjectId()); QCOMPARE(geometry->isEnabled(), creationChangeData->isNodeEnabled()); QCOMPARE(geometry->metaObject(), creationChangeData->metaObject()); QCOMPARE(attributeCount, geometry->attributes().count()); QCOMPARE(attributeCount, cloneData.attributeIds.count()); if (geometry->boundingVolumePositionAttribute()) QCOMPARE(geometry->boundingVolumePositionAttribute()->id(), cloneData.boundingVolumePositionAttributeId); for (int i = 0; i < attributeCount; ++i) { Qt3DRender::QAttribute *originalAttribute = static_cast<Qt3DRender::QAttribute *>(geometry->attributes()[i]); QCOMPARE(originalAttribute->id(), cloneData.attributeIds.at(i)); } }
void checkPropertyUpdates() { // GIVEN TestArbiter arbiter; QScopedPointer<Qt3DRender::QGeometry> geometry(new Qt3DRender::QGeometry()); arbiter.setArbiterOnNode(geometry.data()); // WHEN Qt3DRender::QAttribute attr; geometry->addAttribute(&attr); QCoreApplication::processEvents(); // THEN QCOMPARE(arbiter.events.size(), 1); Qt3DCore::QPropertyNodeAddedChangePtr nodeAddedChange = arbiter.events.first().staticCast<Qt3DCore::QPropertyNodeAddedChange>(); QCOMPARE(nodeAddedChange->propertyName(), "attribute"); QCOMPARE(nodeAddedChange->addedNodeId(), attr.id()); QCOMPARE(nodeAddedChange->type(), Qt3DCore::PropertyValueAdded); arbiter.events.clear(); // WHEN geometry->addAttribute(&attr); QCoreApplication::processEvents(); // THEN QCOMPARE(arbiter.events.size(), 0); // WHEN geometry->removeAttribute(&attr); QCoreApplication::processEvents(); // THEN QCOMPARE(arbiter.events.size(), 1); Qt3DCore::QPropertyNodeRemovedChangePtr nodeRemovedChange = arbiter.events.first().staticCast<Qt3DCore::QPropertyNodeRemovedChange>(); QCOMPARE(nodeRemovedChange->propertyName(), "attribute"); QCOMPARE(nodeRemovedChange->removedNodeId(), attr.id()); QCOMPARE(nodeRemovedChange->type(), Qt3DCore::PropertyValueRemoved); arbiter.events.clear(); }