2012-02-04 22:20:21 +01:00
|
|
|
/*
|
|
|
|
|
DispatcherInterface(Test) - document and verify dispatcher for frame job creation
|
|
|
|
|
|
|
|
|
|
Copyright (C) Lumiera.org
|
|
|
|
|
2012, Hermann Vosseler <Ichthyostega@web.de>
|
|
|
|
|
|
|
|
|
|
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 "lib/error.hpp"
|
|
|
|
|
|
|
|
|
|
//#include "proc/engine/procnode.hpp"
|
2012-02-13 00:37:57 +01:00
|
|
|
#include "proc/play/dummy-play-connection.hpp"
|
|
|
|
|
#include "proc/mobject/model-port.hpp"
|
2012-02-04 22:20:21 +01:00
|
|
|
#include "proc/engine/dispatcher.hpp"
|
2012-02-05 00:25:22 +01:00
|
|
|
#include "proc/play/timings.hpp"
|
|
|
|
|
#include "lib/time/timevalue.hpp"
|
|
|
|
|
#include "lib/time/timequant.hpp"
|
|
|
|
|
#include "lib/singleton.hpp"
|
2012-02-04 22:20:21 +01:00
|
|
|
|
|
|
|
|
//#include <boost/scoped_ptr.hpp>
|
|
|
|
|
//#include <iostream>
|
|
|
|
|
|
|
|
|
|
using test::Test;
|
|
|
|
|
//using std::cout;
|
|
|
|
|
//using std::rand;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace proc {
|
|
|
|
|
namespace engine{
|
|
|
|
|
namespace test {
|
2012-02-05 00:25:22 +01:00
|
|
|
|
|
|
|
|
using lib::time::QuTime;
|
|
|
|
|
using lib::time::FrameRate;
|
2012-02-09 22:24:05 +01:00
|
|
|
using lib::time::Duration;
|
2012-02-13 00:37:57 +01:00
|
|
|
using mobject::ModelPort;
|
|
|
|
|
using play::Timings;
|
2012-02-05 00:25:22 +01:00
|
|
|
|
2012-02-04 22:20:21 +01:00
|
|
|
namespace { // used internally
|
|
|
|
|
|
2012-02-13 00:37:57 +01:00
|
|
|
using play::PlayTestFrames_Strategy;
|
|
|
|
|
using play::ModelPorts;
|
|
|
|
|
|
|
|
|
|
typedef play::DummyPlayConnection<play::PlayTestFrames_Strategy> DummyPlaybackSetup;
|
|
|
|
|
|
2012-02-04 22:20:21 +01:00
|
|
|
|
|
|
|
|
class MockDispatcherTable
|
|
|
|
|
: public Dispatcher
|
|
|
|
|
{
|
|
|
|
|
|
2012-02-13 00:37:57 +01:00
|
|
|
DummyPlaybackSetup dummySetup_;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* == mock Dispatcher implementation == */
|
|
|
|
|
|
2012-02-09 22:24:05 +01:00
|
|
|
FrameCoord
|
|
|
|
|
locateFrameNext (uint frameCountOffset)
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED ("dummy implementation of the core dispatch operation");
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-04 22:20:21 +01:00
|
|
|
public:
|
2012-02-13 00:37:57 +01:00
|
|
|
|
|
|
|
|
ModelPort
|
|
|
|
|
provideMockModelPort()
|
|
|
|
|
{
|
|
|
|
|
ModelPorts mockModelPorts = dummySetup_.provide_testModelPorts();
|
|
|
|
|
return *mockModelPorts; // using just the first dummy port
|
|
|
|
|
}
|
2012-02-04 22:20:21 +01:00
|
|
|
};
|
|
|
|
|
|
2012-02-05 00:25:22 +01:00
|
|
|
lib::Singleton<MockDispatcherTable> mockDispatcher;
|
|
|
|
|
|
2012-02-04 22:20:21 +01:00
|
|
|
#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #880
|
|
|
|
|
#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #890
|
2012-02-13 00:37:57 +01:00
|
|
|
ModelPort
|
|
|
|
|
getTestPort()
|
|
|
|
|
{
|
|
|
|
|
return mockDispatcher().provideMockModelPort();
|
|
|
|
|
}
|
2012-02-04 22:20:21 +01:00
|
|
|
|
2012-02-13 00:37:57 +01:00
|
|
|
|
2012-02-04 22:20:21 +01:00
|
|
|
} // (End) internal defs
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
|
* @test document and verify the engine::Dispatcher interface, used
|
|
|
|
|
* to translate a CalcStream into individual node jobs.
|
|
|
|
|
* This test covers the definition of the interface itself,
|
|
|
|
|
* together with the supporting types and the default
|
|
|
|
|
* implementation of the basic operations.
|
|
|
|
|
* It creates and uses a mock Dispatcher implementation.
|
|
|
|
|
*/
|
|
|
|
|
class DispatcherInterface_test : public Test
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
|
run (Arg)
|
|
|
|
|
{
|
|
|
|
|
verify_basicDispatch();
|
|
|
|
|
verify_standardDispatcherUsage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @test perform the basic dispatch step
|
2012-02-18 00:49:53 +01:00
|
|
|
* and verify the generated frame coordinates
|
2012-02-04 22:20:21 +01:00
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
verify_basicDispatch()
|
|
|
|
|
{
|
2012-02-05 00:25:22 +01:00
|
|
|
Dispatcher& dispatcher = mockDispatcher();
|
|
|
|
|
Timings timings (FrameRate::PAL);
|
2012-02-13 00:37:57 +01:00
|
|
|
ModelPort modelPort (getTestPort());
|
2012-02-05 00:25:22 +01:00
|
|
|
uint startFrame(10);
|
2012-02-13 00:37:57 +01:00
|
|
|
uint channel(0);
|
2012-02-05 00:25:22 +01:00
|
|
|
|
2012-02-18 00:49:53 +01:00
|
|
|
TimeAnchor refPoint = TimeAnchor::build (timings, startFrame, modelPort, channel);
|
2012-02-09 22:24:05 +01:00
|
|
|
CHECK (refPoint == Time::ZERO + Duration(10, FrameRate::PAL));
|
|
|
|
|
|
|
|
|
|
FrameCoord coordinates = dispatcher.locateFrameNext (15);
|
|
|
|
|
CHECK (coordinates.absoluteNominalTime == Time(0,1));
|
|
|
|
|
CHECK (coordinates.absoluteFrameNumber == 25);
|
|
|
|
|
CHECK (coordinates.remainingRealTime() >= Time(FSecs(24,25)));
|
2012-02-18 00:49:53 +01:00
|
|
|
CHECK (coordinates.modelPort == modelPort);
|
|
|
|
|
CHECK (coordinates.channelNr == channel);
|
2012-02-13 00:37:57 +01:00
|
|
|
|
2012-02-18 00:49:53 +01:00
|
|
|
JobTicket& executionPlan = dispatcher.accessJobTicket (coordinates);
|
2012-02-13 00:37:57 +01:00
|
|
|
CHECK (executionPlan.isValid());
|
2012-02-18 00:49:53 +01:00
|
|
|
|
|
|
|
|
JobTicket::JobsPlanning jobs = executionPlan.createJobsFor (coordinates);
|
|
|
|
|
CHECK (!isnil (jobs));
|
|
|
|
|
|
|
|
|
|
Job headJob = *jobs;
|
|
|
|
|
CHECK (headJob.getNominalTime() == coordinates.absoluteNominalTime);
|
|
|
|
|
CHECK (0 < headJob.getInvocationInstanceID());
|
2012-02-18 19:42:20 +01:00
|
|
|
#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #880
|
2012-02-05 00:25:22 +01:00
|
|
|
#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #880
|
2012-02-04 22:20:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @test the standard invocation sequence
|
|
|
|
|
* used within the engine for planning new jobs.
|
|
|
|
|
* The actual implementation is mocked.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
verify_standardDispatcherUsage()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #880
|
2012-02-05 00:25:22 +01:00
|
|
|
#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #880
|
2012-02-04 22:20:21 +01:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Register this test class... */
|
|
|
|
|
LAUNCHER (DispatcherInterface_test, "unit engine");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}}} // namespace proc::engine::test
|