lumiera_documentation/tests/vault/out/output-slot-protocol-test.cpp

137 lines
4.6 KiB
C++
Raw Normal View History

/*
OutputSlotProtocol(Test) - covering the basic usage cycle of an output slot
Copyright: clarify and simplify the file headers * Lumiera source code always was copyrighted by individual contributors * there is no entity "Lumiera.org" which holds any copyrights * Lumiera source code is provided under the GPL Version 2+ == Explanations == Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above. For this to become legally effective, the ''File COPYING in the root directory is sufficient.'' The licensing header in each file is not strictly necessary, yet considered good practice; attaching a licence notice increases the likeliness that this information is retained in case someone extracts individual code files. However, it is not by the presence of some text, that legally binding licensing terms become effective; rather the fact matters that a given piece of code was provably copyrighted and published under a license. Even reformatting the code, renaming some variables or deleting parts of the code will not alter this legal situation, but rather creates a derivative work, which is likewise covered by the GPL! The most relevant information in the file header is the notice regarding the time of the first individual copyright claim. By virtue of this initial copyright, the first author is entitled to choose the terms of licensing. All further modifications are permitted and covered by the License. The specific wording or format of the copyright header is not legally relevant, as long as the intention to publish under the GPL remains clear. The extended wording was based on a recommendation by the FSF. It can be shortened, because the full terms of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
Copyright (C)
2011, Hermann Vosseler <Ichthyostega@web.de>
Copyright: clarify and simplify the file headers * Lumiera source code always was copyrighted by individual contributors * there is no entity "Lumiera.org" which holds any copyrights * Lumiera source code is provided under the GPL Version 2+ == Explanations == Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above. For this to become legally effective, the ''File COPYING in the root directory is sufficient.'' The licensing header in each file is not strictly necessary, yet considered good practice; attaching a licence notice increases the likeliness that this information is retained in case someone extracts individual code files. However, it is not by the presence of some text, that legally binding licensing terms become effective; rather the fact matters that a given piece of code was provably copyrighted and published under a license. Even reformatting the code, renaming some variables or deleting parts of the code will not alter this legal situation, but rather creates a derivative work, which is likewise covered by the GPL! The most relevant information in the file header is the notice regarding the time of the first individual copyright claim. By virtue of this initial copyright, the first author is entitled to choose the terms of licensing. All further modifications are permitted and covered by the License. The specific wording or format of the copyright header is not legally relevant, as long as the intention to publish under the GPL remains clear. The extended wording was based on a recommendation by the FSF. It can be shortened, because the full terms of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
  **Lumiera** is free software; you can redistribute it and/or modify it
  under the terms of the GNU General Public License as published by the
  Free Software Foundation; either version 2 of the License, or (at your
  option) any later version. See the file COPYING for further details.
Copyright: clarify and simplify the file headers * Lumiera source code always was copyrighted by individual contributors * there is no entity "Lumiera.org" which holds any copyrights * Lumiera source code is provided under the GPL Version 2+ == Explanations == Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above. For this to become legally effective, the ''File COPYING in the root directory is sufficient.'' The licensing header in each file is not strictly necessary, yet considered good practice; attaching a licence notice increases the likeliness that this information is retained in case someone extracts individual code files. However, it is not by the presence of some text, that legally binding licensing terms become effective; rather the fact matters that a given piece of code was provably copyrighted and published under a license. Even reformatting the code, renaming some variables or deleting parts of the code will not alter this legal situation, but rather creates a derivative work, which is likewise covered by the GPL! The most relevant information in the file header is the notice regarding the time of the first individual copyright claim. By virtue of this initial copyright, the first author is entitled to choose the terms of licensing. All further modifications are permitted and covered by the License. The specific wording or format of the copyright header is not legally relevant, as long as the intention to publish under the GPL remains clear. The extended wording was based on a recommendation by the FSF. It can be shortened, because the full terms of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
* *****************************************************************/
/** @file output-slot-protocol-test.cpp
** unit test \ref OutputSlotProtocol_test
*/
#include "test/run.hpp"
#include "vault/out/diagnostic-output-slot.hpp"
#include "vault/mem/buffhandle.hpp"
#include "test/test-frame.hpp"
using test::TestFrame;
using test::testData;
using vault::mem::BuffHandle;
namespace vault{
namespace out {
namespace test {
/***************************************************************//**
2011-07-10 18:18:20 +02:00
* @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
{
virtual void
2025-06-07 23:59:57 +02:00
run (Arg)
{
2011-07-10 18:18:20 +02:00
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
DiagnosticOutputSlot oSlot;
2011-07-10 18:18:20 +02:00
// Client claims the OutputSlot
// and opens it for exclusive use.
OutputSlot::Allocation& alloc = oSlot.allocate();
2011-07-10 18:18:20 +02:00
// 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 sink0 = *sinks;
DataSink sink1 = *++sinks;
2011-07-10 18:18:20 +02:00
// within the frame-calculation "loop"
// we perform a data exchange cycle
FrameCnt frameNr = 123;
BuffHandle buff00 = sink0.lockBufferFor (frameNr);
BuffHandle buff10 = sink1.lockBufferFor (frameNr);
2011-07-10 18:18:20 +02:00
// rendering process calculates content....
buff00.accessAs<TestFrame>() = testData(0,0);
2011-07-10 18:18:20 +02:00
// while further frames might be processed in parallel
BuffHandle buff11 = sink1.lockBufferFor (frameNr+1);
buff11.accessAs<TestFrame>() = testData(1,1);
buff10.accessAs<TestFrame>() = testData(1,0);
2011-07-10 18:18:20 +02:00
// Now it's time to emit the output
buff11.emit();
buff00.emit();
// Buffers must be marked as released when done
buff00.release();
buff10.release();
buff11.release();
2011-07-10 18:18:20 +02:00
// that's all for the client
// Verify sane operation....
CHECK (watch(oSlot).cntLocked() == 3);
CHECK (watch(oSlot).cntEmitted() == 2);
CHECK (watch(oSlot).cntReleased() == 3);
CHECK ( watch(oSlot).feed(0).frame(123).wasLocked());
CHECK (not watch(oSlot).feed(0).frame(124).wasLocked());
CHECK ( watch(oSlot).feed(1).frame(123).wasLocked());
CHECK ( watch(oSlot).feed(1).frame(124).wasLocked());
2011-07-10 18:18:20 +02:00
CHECK ( watch(oSlot).feed(0).frame(123).wasEmitted());
CHECK (not watch(oSlot).feed(0).frame(124).wasEmitted());
CHECK (not watch(oSlot).feed(1).frame(123).wasEmitted());
CHECK ( watch(oSlot).feed(1).frame(124).wasEmitted());
2011-07-10 18:18:20 +02:00
CHECK ( watch(oSlot).feed(0).frame(123).wasReleased());
CHECK (not watch(oSlot).feed(0).frame(124).wasReleased());
CHECK ( watch(oSlot).feed(1).frame(123).wasReleased());
CHECK ( watch(oSlot).feed(1).frame(124).wasReleased());
2011-07-10 18:18:20 +02:00
auto stream0 = watch(oSlot).getFeed(0);
auto stream1 = watch(oSlot).getFeed(1);
2011-07-10 18:18:20 +02:00
CHECK ( stream0);
CHECK (*stream0 == testData(0,0)); ++stream0;
2011-07-10 18:18:20 +02:00
CHECK (!stream0);
CHECK ( stream1);
CHECK (*stream1 == testData(1,0)); ++stream1;
CHECK (*stream1 == testData(1,1)); ++stream1;
2011-07-10 18:18:20 +02:00
CHECK (!stream1);
}
};
/** Register this test class... */
LAUNCHER (OutputSlotProtocol_test, "unit play");
}}} // namespace vault::out::test