summaryrefslogtreecommitdiffstats
path: root/tests/auto/render
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2016-06-02 07:32:37 +0200
committerSean Harmer <sean.harmer@kdab.com>2016-06-29 09:20:51 +0000
commitf2c8e786d49f931a11eada68619a47edb499ec5d (patch)
tree2591196287683938b9e95462772d0b140bf07a76 /tests/auto/render
parent53512a6ba82f68dedadade557723e4e0a0488f1f (diff)
tst_QAttribute: add test for buffer bookkeeping
Change-Id: I24346c8bfc5a7cb2c7811fabd6b0192511812bf2 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'tests/auto/render')
-rw-r--r--tests/auto/render/qattribute/tst_qattribute.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/render/qattribute/tst_qattribute.cpp b/tests/auto/render/qattribute/tst_qattribute.cpp
index 48bdf5c33..18a11fe4f 100644
--- a/tests/auto/render/qattribute/tst_qattribute.cpp
+++ b/tests/auto/render/qattribute/tst_qattribute.cpp
@@ -250,6 +250,40 @@ private Q_SLOTS:
QCOMPARE(change->type(), Qt3DCore::PropertyUpdated);
}
+
+ void checkBufferBookkeeping()
+ {
+ // GIVEN
+ QScopedPointer<Qt3DRender::QAttribute> attribute(new Qt3DRender::QAttribute);
+ {
+ // WHEN
+ Qt3DRender::QBuffer buf;
+ attribute->setBuffer(&buf);
+
+ // THEN
+ QCOMPARE(buf.parent(), attribute.data());
+ QCOMPARE(attribute->buffer(), &buf);
+ }
+ // THEN (Should not crash and parameter be unset)
+ QVERIFY(attribute->buffer() == nullptr);
+
+ {
+ // WHEN
+ Qt3DRender::QAttribute someOtherAttribute;
+ QScopedPointer<Qt3DRender::QBuffer> buf(new Qt3DRender::QBuffer(Qt3DRender::QBuffer::VertexBuffer, &someOtherAttribute));
+ attribute->setBuffer(buf.data());
+
+ // THEN
+ QCOMPARE(buf->parent(), &someOtherAttribute);
+ QCOMPARE(attribute->buffer(), buf.data());
+
+ // WHEN
+ attribute.reset();
+ buf.reset();
+
+ // THEN Should not crash when the buffer is destroyed (tests for failed removal of destruction helper)
+ }
+ }
};
QTEST_MAIN(tst_QAttribute)