diff --git a/tests/components/proc/play/output-slot-protocol-test.cpp b/tests/components/proc/play/output-slot-protocol-test.cpp index 2bdc7b09d..c83d6bff3 100644 --- a/tests/components/proc/play/output-slot-protocol-test.cpp +++ b/tests/components/proc/play/output-slot-protocol-test.cpp @@ -24,6 +24,7 @@ #include "lib/test/run.hpp" //#include "lib/util.hpp" #include "proc/play/diagnostic-output-slot.hpp" +#include "proc/engine/buffhandle.hpp" //#include //#include @@ -33,11 +34,13 @@ //using std::cout; -namespace engine{ +namespace proc { +namespace play { namespace test { // using lib::AllocationCluster; // using mobject::session::PEffect; + using ::engine::BuffHandle; namespace { // Test fixture @@ -46,7 +49,11 @@ namespace test { /******************************************************************* - * @test basic render node properties and behaviour. + * @test verify the OutputSlot interface and base implementation + * by performing full data exchange cycle. This is a + * kind of "dry run" for documentation purposes, + * both the actual OutputSlot implementation + * as the client using this slot are Mocks. */ class OutputSlotProtocol_test : public Test { @@ -54,7 +61,81 @@ namespace test { run (Arg) { UNIMPLEMENTED ("build a mock output slot and perform a full lifecycle"); - } + verifyStandardCase(); + } + + + void + verifyStandardCase() + { + // Create Test fixture. + // In real usage, the OutputSlot will be preconfigured + // (Media format, number of channels, physical connections) + // and then registered with / retrieved from an OutputManager + OutputSlot& oSlot = DiagnosticOutputSlot::build(); + + // Client claims the OutputSlot + // and opens it for exclusive use. + Allocation alloc = oSlot.allocate(); + + // Now the client is able to prepare + // "calculation streams" for the individual + // Channels to be output through this slot. + OutputSlot::OpenedSinks sinks = alloc.getOpenedSinks(); + DataSink sink1 = *sinks++; + DataSink sink2 = *sinks++; + + // within the frame-calculation "loop" + // we perform an data exchange cycle + int64_t frameNr = 123; + BuffHandle buff00 = sink1.lockBufferFor (frameNr); + BuffHandle buff10 = sink2.lockBufferFor (frameNr); + buff00.create(); + buff10.create(); + + // rendering process calculates content.... + buff00.access() = testData[0,0]; + + // while further frames might be processed in parallel + BuffHandle buff11 = sink2.lockBufferFor (++frameNr); + buff11.create(); + buff11.access() = testData[1,1]; + buff10.access() = testData[1,0]; + + // Now it's time to emit the output + sink2.emit (frameNr-1); + sink2.emit (frameNr ); + sink1.emit (frameNr-1); + // that's all for the client + + // Verify sane operation.... + DiagnosticOutputSlot checker = DiagnosticOutputSlot::access(oSlot); + CHECK (checker.buffer_was_used (0,0)); + CHECK (checker.buffer_unused (0,1)); + CHECK (checker.buffer_was_used (1,0)); + CHECK (checker.buffer_was_used (1,1)); + + CHECK (checker.buffer_was_closed (0,0)); + CHECK (checker.buffer_was_closed (1,0)); + CHECK (checker.buffer_was_closed (1,1)); + + CHECK ( checker.emitted (0,0)); + CHECK (!checker.emitted (0,1)); + CHECK ( checker.emitted (1,0)); + CHECK ( checker.emitted (1,1)); + + DiagnosticOutputSlot::OutFrames stream0 = checker.getChannel(0); + DiagnosticOutputSlot::OutFrames stream1 = checker.getChannel(1); + + CHECK ( stream0); + CHECK (*stream0++ == testData[0,0]); + CHECK (!stream0); + + CHECK ( stream1); + CHECK (*stream1++ == testData[1,0]); + CHECK (*stream1++ == testData[1,1]); + CHECK (!stream1); + } }; @@ -63,4 +144,4 @@ namespace test { -}} // namespace engine::test +}}} // namespace proc::play::test