2023-05-26 04:20:12 +02:00
/*
Timings ( Test ) - document and verify basic frame step timings
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 0213 9 , USA .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/** @file dispatcher-interface-test.cpp
* * unit test \ ref Timings_test
* *
* * @ warning as of 5 / 2023 planning - chunk generation is reworked ///////////////////////////////////////////TICKET #1301 : factor out RenderDrive
*/
# include "lib/test/run.hpp"
2023-05-31 03:27:13 +02:00
# include "lib/test/test-helper.hpp"
2023-05-26 04:20:12 +02:00
# include "steam/play/timings.hpp"
# include "lib/time/timevalue.hpp"
//#include "lib/time/timequant.hpp"
//#include "lib/format-cout.hpp"
2023-06-03 03:39:33 +02:00
//#include "lib/util-coll.hpp"
2023-05-26 04:20:12 +02:00
# include "lib/util.hpp"
2023-06-03 03:39:33 +02:00
//#include <functional>
//#include <vector>
2023-05-26 04:20:12 +02:00
using test : : Test ;
using util : : isnil ;
2023-06-03 03:39:33 +02:00
//using std::vector;
//using std::function;
using std : : rand ;
2023-05-26 04:20:12 +02:00
namespace steam {
namespace engine {
namespace test {
2023-06-03 03:39:33 +02:00
using lib : : time : : FSecs ;
using lib : : time : : FrameCnt ;
2023-05-26 04:20:12 +02:00
using lib : : time : : FrameRate ;
using lib : : time : : Duration ;
using lib : : time : : Offset ;
using lib : : time : : Time ;
using play : : Timings ;
namespace { // Test fixture...
/* == test parameters == */
const uint START_FRAME ( 10 ) ;
const uint DUMMY_CHANNEL ( 0 ) ; /////////////////////////////////////////////////////////////TICKET #1297 : get rid of the channels (use different ModelPort)
2023-05-31 03:27:13 +02:00
FSecs
randTicks ( )
2023-05-26 04:20:12 +02:00
{
2023-05-31 03:27:13 +02:00
return FSecs { 1 + rand ( ) % 600 , 1 + rand ( ) % 600 } ;
2023-05-26 04:20:12 +02:00
}
} // (End) Test fixture
# if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #1301
# endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #1301
/***************************************************************/ /**
2023-05-29 04:43:10 +02:00
* @ test document and verify frame timing calculations , which are
* used in the Player / engine : : Dispatcher , to translate a CalcStream
* into individual node jobs .
* @ see TimingConstraints_test
2023-05-26 04:20:12 +02:00
*/
class Timings_test : public Test
{
virtual void
run ( Arg )
{
verify_simpleFrameStep ( ) ;
verify_next_startPoint ( ) ;
}
/** @test perform the basic dispatch step
* and verify the generated frame coordinates
*/
void
verify_simpleFrameStep ( )
{
Timings timings ( FrameRate : : PAL ) ;
2023-05-31 03:27:13 +02:00
CHECK ( timings . getOrigin ( ) = = Time : : ZERO ) ;
2023-05-26 04:20:12 +02:00
2023-05-31 03:27:13 +02:00
ENSURE ( START_FRAME = = 10 ) ;
CHECK ( timings . getFrameStartAt ( START_FRAME ) = = Time : : ZERO + Duration ( 10 , FrameRate : : PAL ) ) ;
CHECK ( timings . getFrameStartAt ( START_FRAME + 1 ) = = Time : : ZERO + Duration ( 11 , FrameRate : : PAL ) ) ;
2023-05-26 04:20:12 +02:00
# if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #1301
# endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #1301
}
2023-05-31 03:27:13 +02:00
/** @test detect boundaries of frame planning chunks for arbitrary chunk duration.
2023-05-26 04:20:12 +02:00
*/
void
verify_next_startPoint ( )
{
Timings timings ( FrameRate : : PAL ) ;
2023-05-31 03:27:13 +02:00
Time refPoint { randTicks ( ) } ;
FrameCnt startFrame = timings . getBreakPointAfter ( refPoint ) ;
Time frameStart = timings . getFrameStartAt ( startFrame ) ;
2023-05-26 04:20:12 +02:00
Duration frameDuration ( 1 , FrameRate : : PAL ) ;
2023-05-31 03:27:13 +02:00
CHECK ( frameStart > = refPoint ) ;
CHECK ( frameStart < refPoint + frameDuration ) ;
2023-05-26 04:20:12 +02:00
}
} ;
/** Register this test class... */
LAUNCHER ( Timings_test , " unit engine " ) ;
} } } // namespace steam::engine::test