From 2eb39704fce6451650b737b49ac0a6b72a42054a Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Mon, 23 Jan 2012 02:25:12 +0100 Subject: [PATCH] test-driven brainstorming: how to use the dummy playback? this is an idea how to test a test setup :) --- src/proc/engine/engine-service-mock.cpp | 32 ++---- src/proc/engine/engine-service-mock.hpp | 28 ++--- src/proc/engine/engine-service.cpp | 4 +- src/proc/engine/engine-service.hpp | 5 +- tests/47playout.tests | 5 + .../proc/play/dummy-play-connection-test.cpp | 105 ++++++++++++++++++ 6 files changed, 129 insertions(+), 50 deletions(-) create mode 100644 tests/components/proc/play/dummy-play-connection-test.cpp diff --git a/src/proc/engine/engine-service-mock.cpp b/src/proc/engine/engine-service-mock.cpp index 43c6e60ee..5cb7e8ed2 100644 --- a/src/proc/engine/engine-service-mock.cpp +++ b/src/proc/engine/engine-service-mock.cpp @@ -61,33 +61,15 @@ namespace engine{ - /** core operation: activate the Lumiera Render Engine. - * Invoking this service effectively hooks up each channel - * of the given model exit point to deliver into the corresponding - * output sink on the given OutputConnection (which is assumed - * to be already allocated for active use by this connection). - * The generated calculation streams represent actively ongoing - * calculations within the engine, started right away, according - * to the given timing constraints and service quality. + /** special engine configuration for mock/testing operation. */ - CalcStreams - EngineServiceMock::calculate(ModelPort mPort, - Timings nominalTimings, - OutputConnection& output, - Quality serviceQuality) + RenderEnvironmentClosure& + EngineServiceMock::configureCalculation () { - UNIMPLEMENTED ("MOCK IMPLEMENTATION: build a list of standard calculation streams"); - } - - - - /** */ - CalcStreams - EngineServiceMock::calculateBackground(ModelPort mPort, - Timings nominalTimings, - Quality serviceQuality) - { - UNIMPLEMENTED ("MOCK IMPLEMENTATION: build calculation streams for background rendering"); + UNIMPLEMENTED ("represent *this as RenderEnvironmentClosure)"); + RenderEnvironmentClosure* todo_fake(0); ////KABOOOM + + return *todo_fake; } diff --git a/src/proc/engine/engine-service-mock.hpp b/src/proc/engine/engine-service-mock.hpp index 21c290043..16990cab9 100644 --- a/src/proc/engine/engine-service-mock.hpp +++ b/src/proc/engine/engine-service-mock.hpp @@ -76,15 +76,12 @@ namespace engine{ - /****************************************************** - * A service to schedule series of calculations, - * delivering the rendered data into an external output - * sink in a timely fashion. Actually the CalculationStream - * instances provided through this (facade) interface are - * backed by jobs executed through the scheduler in the - * backend layer. The implementation of this service - * cares to create the right job entries in the correct - * order and to enqueue these into the scheduler. + /**************************************************************** + * Variant of the render engine, reconfigured for mock operation. + * Especially, this setup leaves out most of the actual Lumiera + * engine's implementation facilities. There is no scheduler + * and no frame cache; rather we perform simple dependent + * calculations which might block. */ class EngineServiceMock : public EngineService @@ -95,21 +92,10 @@ namespace engine{ public: EngineServiceMock(); - ~EngineServiceMock() { } - - CalcStreams - calculate(ModelPort mPort, - Timings nominalTimings, - OutputConnection& output, - Quality serviceQuality = EngineService::QoS_DEFAULT); - - CalcStreams - calculateBackground(ModelPort mPort, - Timings nominalTimings, - Quality serviceQuality = EngineService::QoS_BACKGROUND); protected: + virtual RenderEnvironmentClosure& configureCalculation (); }; diff --git a/src/proc/engine/engine-service.cpp b/src/proc/engine/engine-service.cpp index 0c9cea551..bffada11e 100644 --- a/src/proc/engine/engine-service.cpp +++ b/src/proc/engine/engine-service.cpp @@ -112,13 +112,13 @@ namespace engine{ * such a specific configuration remains opaque for the user of the * created render activity */ - CalcStream + RenderEnvironmentClosure& EngineService::configureCalculation () { UNIMPLEMENTED ("represent *this as RenderEnvironmentClosure)"); RenderEnvironmentClosure* todo_fake(0); ////KABOOOM - return activateCalculation (*todo_fake); + return *todo_fake; } diff --git a/src/proc/engine/engine-service.hpp b/src/proc/engine/engine-service.hpp index f40ea489c..2de5ff56b 100644 --- a/src/proc/engine/engine-service.hpp +++ b/src/proc/engine/engine-service.hpp @@ -135,8 +135,9 @@ namespace engine{ static lib::Singleton instance; + virtual ~EngineService() { } + EngineService(); - ~EngineService() { } CalcStreams calculate(ModelPort mPort, @@ -154,7 +155,7 @@ namespace engine{ CalcStream activateCalculation (RenderEnvironmentClosure&); protected: - virtual CalcStream configureCalculation (); + virtual RenderEnvironmentClosure& configureCalculation (); void activateTracing(); void disableTracing(); ///< EX_FREE diff --git a/tests/47playout.tests b/tests/47playout.tests index 0bdc2a9ad..0a6aa7875 100644 --- a/tests/47playout.tests +++ b/tests/47playout.tests @@ -2,6 +2,11 @@ TESTING "Component Test Suite: Player and Output" ./test-components --group=play +PLANNED "Dummy Player setup" DummyPlayConnection_test < + + This program 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. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +* *****************************************************/ + + +#include "lib/test/run.hpp" + +#include "proc/play/dummy-play-connection.hpp" +//#include "proc/engine/buffhandle.hpp" +//#include "proc/engine/testframe.hpp" +#include "include/play-facade.h" +#include "lib/time/control.hpp" + + + +namespace proc { +namespace play { +namespace test { + + namespace time = lib::time; + + using proc::engine::BuffHandle; +//using proc::engine::test::testData; +//using proc::engine::test::TestFrame; + + using lumiera::Play; + typedef Play::Controller Controller; + + typedef time::Control DurationControl; + + + /******************************************************************* + * @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 DummyPlayConnection_test : public Test + { + virtual void + run (Arg) + { + verify_simulatedPlayback(); + } + + + void + verify_simulatedPlayback() + { + DummyPlayConnection dummy; //////////TODO: how to pre-configure the DummyPlayConnection +#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #805 + CHECK (!dummy.isWired()); + + Controller ctrl = Play::facade().connect(dummy.port(), dummy.output()); + CHECK ( dummy.isWired()); + + DurationControl playDuration; + ctrl.controlDuration (playDuration); + + // configure the controller to playback only for a fixed time duration + playDuration (dummy.getPlannedTestDuration()); + + CHECK (!ctrl.is_playing()); + + ctrl.play(true); // hit the start button + CHECK (ctrl.is_playing()); + + dummy.waitUntilDue(); // test helper: block waiting until planned test should be done + + CHECK (!ctrl.is_playing()); // should have returned to pause, since we've set a fixed playback duration + CHECK (dummy.isWired()); + + ctrl.close(); + CHECK (!dummy.isWired()); + CHECK (dummy.gotCorrectOutput()); +#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #805 + } + }; + + + /** Register this test class... */ + LAUNCHER (DummyPlayConnection_test, "unit player"); + + + +}}} // namespace proc::play::test