summaryrefslogtreecommitdiffstats
path: root/tests/auto/core/nodes/tst_nodes.cpp
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2015-07-03 17:08:08 +0200
committerSean Harmer <sean.harmer@kdab.com>2015-07-12 19:14:00 +0000
commit2b3f68d588c15830ebbacf55823b2af049d76b47 (patch)
treed4bbc39f0c19226f0adc67c4ad2131a4e460c170 /tests/auto/core/nodes/tst_nodes.cpp
parent6fcaef11f89994cfc9f117a07cb64b0e8959da2c (diff)
QChangeArbiter/QPostMan: batch frontend changes
- Updated unit tests - Added QAbstractPostman and QAbstractArbiter as they are more than QObserverInterfaces but still need to be easily testable. Change-Id: I0fc2ce48031eecc9bf893798650ef68e9d7d8bb7 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'tests/auto/core/nodes/tst_nodes.cpp')
-rw-r--r--tests/auto/core/nodes/tst_nodes.cpp33
1 files changed, 31 insertions, 2 deletions
diff --git a/tests/auto/core/nodes/tst_nodes.cpp b/tests/auto/core/nodes/tst_nodes.cpp
index 66751f3cf..41ddcad43 100644
--- a/tests/auto/core/nodes/tst_nodes.cpp
+++ b/tests/auto/core/nodes/tst_nodes.cpp
@@ -40,6 +40,7 @@
#include <Qt3DCore/qcomponent.h>
#include <Qt3DCore/private/qscene_p.h>
#include <Qt3DCore/qscenepropertychange.h>
+#include <private/qpostman_p.h>
#include <Qt3DCore/private/qlockableobserverinterface_p.h>
#include <Qt3DCore/private/qnode_p.h>
@@ -82,7 +83,23 @@ private slots:
void verifyCopy();
};
-class ObserverSpy : public Qt3D::QLockableObserverInterface
+class ObserverSpy;
+class SimplePostman : public Qt3D::QAbstractPostman
+{
+public:
+ SimplePostman(ObserverSpy *spy)
+ : m_spy(spy)
+ {}
+
+ void sceneChangeEvent(const Qt3D::QSceneChangePtr &) Q_DECL_FINAL {};
+ void setScene(Qt3D::QScene *) Q_DECL_FINAL {};
+ void notifyBackend(const Qt3D::QSceneChangePtr &change) Q_DECL_FINAL;
+
+private:
+ ObserverSpy *m_spy;
+};
+
+class ObserverSpy : public Qt3D::QAbstractArbiter
{
public:
class ChangeRecord : public QPair<Qt3D::QSceneChangePtr, bool>
@@ -98,8 +115,9 @@ public:
};
ObserverSpy(Qt3D::QNode *node)
- : Qt3D::QLockableObserverInterface()
+ : Qt3D::QAbstractArbiter()
, m_node(node)
+ , m_postman(new SimplePostman(this))
{
Qt3D::QNodePrivate::get(node)->setArbiter(this);
}
@@ -126,10 +144,21 @@ public:
events << ChangeRecord(e, false);
}
+ Qt3D::QAbstractPostman *postman() const Q_DECL_FINAL
+ {
+ return m_postman.data();
+ }
+
QList<ChangeRecord> events;
Qt3D::QNode *m_node;
+ QScopedPointer<SimplePostman> m_postman;
};
+void SimplePostman::notifyBackend(const Qt3D::QSceneChangePtr &change)
+{
+ m_spy->sceneChangeEventWithLock(change);
+}
+
class MyQNode : public Qt3D::QNode
{
Q_OBJECT