예제 #1
0
    void checkParameterBookkeeping()
    {
        // GIVEN
        QScopedPointer<Qt3DRender::QRenderPassFilter> passFilter(new Qt3DRender::QRenderPassFilter);
        {
            // WHEN
            Qt3DRender::QParameter param;
            passFilter->addParameter(&param);

            // THEN
            QCOMPARE(param.parent(), passFilter.data());
            QCOMPARE(passFilter->parameters().size(), 1);
        }
        // THEN (Should not crash and parameter be unset)
        QVERIFY(passFilter->parameters().empty());

        {
            // WHEN
            Qt3DRender::QRenderPassFilter someOtherPassFilter;
            QScopedPointer<Qt3DRender::QParameter> param(new Qt3DRender::QParameter(&someOtherPassFilter));
            passFilter->addParameter(param.data());

            // THEN
            QCOMPARE(param->parent(), &someOtherPassFilter);
            QCOMPARE(passFilter->parameters().size(), 1);

            // WHEN
            passFilter.reset();
            param.reset();

            // THEN Should not crash when the parameter is destroyed (tests for failed removal of destruction helper)
        }
    }
예제 #2
0
    void checkCloning()
    {
        // GIVEN
        QFETCH(Qt3DRender::QTechniqueFilter*, techniqueFilter);
        QFETCH(QList<Qt3DRender::QParameter *>, parameters);
        QFETCH(QList<Qt3DRender::QAnnotation *>, annotations);

        // THEN
        QCOMPARE(techniqueFilter->parameters(), parameters);
        QCOMPARE(techniqueFilter->criteria(), annotations);

        // WHEN
        Qt3DRender::QTechniqueFilter *clone = static_cast<Qt3DRender::QTechniqueFilter *>(QNode::clone(techniqueFilter));

        // THEN
        QVERIFY(clone != Q_NULLPTR);
        QCOMPARE(techniqueFilter->id(), clone->id());

        QCOMPARE(techniqueFilter->criteria().count(), clone->criteria().count());
        QCOMPARE(techniqueFilter->parameters().count(), clone->parameters().count());

        for (int i = 0, m = parameters.count(); i < m; ++i) {
            Qt3DRender::QParameter *pClone = clone->parameters().at(i);
            Qt3DRender::QParameter *pOrig = parameters.at(i);
            QCOMPARE(pOrig->id(),pClone->id());
            QCOMPARE(pOrig->name(), pClone->name());
            QCOMPARE(pOrig->value(), pClone->value());
            QVERIFY(pClone->parent() == clone);
            QVERIFY(pOrig->parent() == techniqueFilter);
        }

        for (int i = 0, m = annotations.count(); i < m; ++i) {
            Qt3DRender::QAnnotation *aClone = clone->criteria().at(i);
            Qt3DRender::QAnnotation *aOrig = annotations.at(i);
            QCOMPARE(aOrig->id(),aClone->id());
            QCOMPARE(aOrig->name(), aClone->name());
            QCOMPARE(aOrig->value(), aClone->value());
            QVERIFY(aClone->parent() == clone);
            QVERIFY(aOrig->parent() == techniqueFilter);
        }

        delete techniqueFilter;
        delete clone;
    }