summaryrefslogtreecommitdiffstats
path: root/tests/auto/render/computecommand/tst_computecommand.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/render/computecommand/tst_computecommand.cpp')
-rw-r--r--tests/auto/render/computecommand/tst_computecommand.cpp48
1 files changed, 40 insertions, 8 deletions
diff --git a/tests/auto/render/computecommand/tst_computecommand.cpp b/tests/auto/render/computecommand/tst_computecommand.cpp
index 990c0cd98..d6fa1d579 100644
--- a/tests/auto/render/computecommand/tst_computecommand.cpp
+++ b/tests/auto/render/computecommand/tst_computecommand.cpp
@@ -31,12 +31,17 @@
#include <Qt3DRender/qcomputecommand.h>
#include <Qt3DRender/private/qcomputecommand_p.h>
#include <Qt3DRender/private/computecommand_p.h>
+#include <Qt3DRender/private/nodemanagers_p.h>
+#include <Qt3DRender/private/managers_p.h>
#include <Qt3DCore/private/qbackendnode_p.h>
+#include <Qt3DCore/private/qaspectmanager_p.h>
+#include <Qt3DCore/private/qscene_p.h>
#include <Qt3DCore/qpropertyupdatedchange.h>
#include "qbackendnodetester.h"
#include "testrenderer.h"
#include "testpostmanarbiter.h"
+
class tst_ComputeCommand : public Qt3DCore::QBackendNodeTester
{
Q_OBJECT
@@ -54,6 +59,7 @@ private Q_SLOTS:
QCOMPARE(backendComputeCommand.x(), 1);
QCOMPARE(backendComputeCommand.y(), 1);
QCOMPARE(backendComputeCommand.z(), 1);
+ QCOMPARE(backendComputeCommand.hasReachedFrameCount(), false);
QCOMPARE(backendComputeCommand.runType(), Qt3DRender::QComputeCommand::Continuous);
QCOMPARE(backendComputeCommand.frameCount(), 0);
}
@@ -61,15 +67,27 @@ private Q_SLOTS:
void checkCleanupState()
{
// GIVEN
+ TestRenderer renderer;
Qt3DRender::Render::ComputeCommand backendComputeCommand;
+ Qt3DRender::QComputeCommand computeCommand;
+ computeCommand.setWorkGroupX(256);
+ computeCommand.setWorkGroupY(512);
+ computeCommand.setWorkGroupZ(128);
+ computeCommand.setRunType(Qt3DRender::QComputeCommand::Manual);
+ computeCommand.trigger(1);
// WHEN
+ backendComputeCommand.setRenderer(&renderer);
+ simulateInitializationSync(&computeCommand, &backendComputeCommand);
+
backendComputeCommand.setEnabled(true);
+ backendComputeCommand.hasReachedFrameCount();
backendComputeCommand.cleanup();
// THEN
QCOMPARE(backendComputeCommand.isEnabled(), false);
+ QCOMPARE(backendComputeCommand.hasReachedFrameCount(), false);
}
void checkInitializeFromPeer()
@@ -207,6 +225,7 @@ private Q_SLOTS:
// THEN
QCOMPARE(backendComputeCommand.frameCount(), 6 - (i + 1));
QCOMPARE(backendComputeCommand.isEnabled(), true);
+ QCOMPARE(backendComputeCommand.hasReachedFrameCount(), false);
QCOMPARE(arbiter.events.size(), 0);
}
@@ -214,15 +233,28 @@ private Q_SLOTS:
backendComputeCommand.updateFrameCount();
// THEN
- QCOMPARE(backendComputeCommand.frameCount(), false);
+ QCOMPARE(backendComputeCommand.hasReachedFrameCount(), true);
+ QCOMPARE(backendComputeCommand.frameCount(), 0);
+ // Backend stays with enabled == true, frontend will be updated
+ // to be disabled and backend should be disabled on the next sync
+
+ // WHEN
+ computeCommand.setEnabled(false);
+ backendComputeCommand.syncFromFrontEnd(&computeCommand, false);
+
+ // THEN
QCOMPARE(backendComputeCommand.isEnabled(), false);
- QCOMPARE(arbiter.events.size(), 1);
- {
- auto change = arbiter.events.first().staticCast<Qt3DCore::QPropertyUpdatedChange>();
- QCOMPARE(change->propertyName(), "enabled");
- QCOMPARE(change->value().value<int>(), false);
- QCOMPARE(change->type(), Qt3DCore::PropertyUpdated);
- }
+ QCOMPARE(backendComputeCommand.frameCount(), 0);
+
+ // WHEN
+ computeCommand.trigger(1);
+ backendComputeCommand.syncFromFrontEnd(&computeCommand, false);
+
+ // THEN
+ QCOMPARE(computeCommand.isEnabled(), true);
+ QCOMPARE(backendComputeCommand.isEnabled(), true);
+ QCOMPARE(backendComputeCommand.hasReachedFrameCount(), false);
+ QCOMPARE(backendComputeCommand.frameCount(), 1);
}
};