Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
timings-test.cpp
Go to the documentation of this file.
1/*
2 Timings(Test) - document and verify basic frame step timings
3
4 Copyright (C)
5 2012, Hermann Vosseler <Ichthyostega@web.de>
6
7  **Lumiera** is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by the
9  Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version. See the file COPYING for further details.
11
12* *****************************************************************/
13
21#include "lib/test/run.hpp"
23
26//#include "lib/time/timequant.hpp"
27//#include "lib/format-cout.hpp"
28//#include "lib/util-coll.hpp"
29#include "lib/util.hpp"
30
31//#include <functional>
32//#include <vector>
33
34using test::Test;
35using util::isnil;
36//using std::vector;
37//using std::function;
38
39
40namespace steam {
41namespace engine{
42namespace test {
43
44 using lib::time::FSecs;
49 using lib::time::Time;
50 using play::Timings;
51
52 namespace { // Test fixture...
53
54 /* == test parameters == */
55
56 const uint START_FRAME(10);
57
58
59
60 FSecs
62 {
63 return FSecs{1 + rani(600), 1 + rani(600)};
64 }
65
66 } // (End) Test fixture
67
68
69
70
71 /***************************************************************/
77 class Timings_test : public Test
78 {
79
80 virtual void
81 run (Arg)
82 {
83 seedRand();
86 }
87
88
92 void
94 {
95 Timings timings (FrameRate::PAL);
96 CHECK (timings.getOrigin() == Time::ZERO);
97
98 ENSURE (START_FRAME == 10);
99 CHECK (timings.getFrameStartAt(START_FRAME) == Time::ZERO + Duration(10, FrameRate::PAL));
100 CHECK (timings.getFrameStartAt(START_FRAME+1) == Time::ZERO + Duration(11, FrameRate::PAL));
101 }
102
103
106 void
108 {
109 Timings timings (FrameRate::PAL);
110 Time refPoint{randTicks()};
111
112 FrameCnt startFrame = timings.getBreakPointAfter (refPoint);
113 Time frameStart = timings.getFrameStartAt(startFrame);
114
115 Duration frameDuration (1, FrameRate::PAL);
116
117 CHECK (frameStart >= refPoint);
118 CHECK (frameStart < refPoint + frameDuration);
119 }
120 };
121
122
124 LAUNCHER (Timings_test, "unit engine");
125
126
127
128}}} // namespace steam::engine::test
Duration is the internal Lumiera time metric.
Framerate specified as frames per second.
static const FrameRate PAL
predefined constant for PAL framerate
Offset measures a distance in time.
Lumiera's internal time value datatype.
static const Time ZERO
Generic frame timing specification.
Definition timings.hpp:87
FrameCnt getBreakPointAfter(TimeValue refPoint) const
the next grid point at or after the given reference time
Definition timings.cpp:143
Time getOrigin() const
Definition timings.cpp:114
Time getFrameStartAt(FrameCnt frameNr) const
Definition timings.cpp:121
Abstract Base Class for all testcases.
Definition run.hpp:54
void seedRand()
draw a new random seed from a common nucleus, and re-seed the default-Gen.
Definition suite.cpp:211
unsigned int uint
Definition integral.hpp:29
int64_t FrameCnt
relative framecount or frame number.
Definition digxel.hpp:310
boost::rational< int64_t > FSecs
rational representation of fractional seconds
Steam-Layer implementation namespace root.
Test runner and basic definitions for tests.
bool isnil(lib::time::Duration const &dur)
Simplistic test class runner.
#define LAUNCHER(_TEST_CLASS_, _GROUPS_)
Definition run.hpp:116
A collection of frequently used helper functions to support unit testing.
a family of time value like entities and their relationships.
How to define a timing specification or constraint.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...