diff --git a/src/proc/asset/meta/time-grid.hpp b/src/proc/asset/meta/time-grid.hpp index a56380807..2de580655 100644 --- a/src/proc/asset/meta/time-grid.hpp +++ b/src/proc/asset/meta/time-grid.hpp @@ -120,7 +120,7 @@ namespace meta { */ Builder(string const& nameID ="") : id_(nameID) - , fps_(0) + , fps_(1) , origin_(TimeValue(0)) , predecessor_() { } diff --git a/tests/components/proc/asset/meta/time-grid-basics-test.cpp b/tests/components/proc/asset/meta/time-grid-basics-test.cpp index 2314927c2..ab7f03c91 100644 --- a/tests/components/proc/asset/meta/time-grid-basics-test.cpp +++ b/tests/components/proc/asset/meta/time-grid-basics-test.cpp @@ -26,6 +26,7 @@ #include "proc/asset/meta.hpp" #include "proc/asset/meta/time-grid.hpp" +#include "lib/time/timevalue.hpp" //#include "proc/asset/entry-id.hpp" //#include "lib/p.hpp" //#include "proc/assetmanager.hpp" @@ -37,6 +38,7 @@ //#include "lib/symbol.hpp" //#include +#include //#include //#include @@ -46,6 +48,7 @@ //using util::and_all; //using util::for_each; //using util::isnil; +using boost::rational_cast; using lib::test::randStr; //using lib::Literal; //using lib::Symbol; @@ -60,14 +63,18 @@ namespace asset { namespace meta { namespace test { + using namespace lib::time; + typedef Builder GridBuilder; typedef EntryID GridID; namespace { // Test definitions... - Time testOrigin (12,23); - FrameRate testFps (5,4); + const Time testOrigin (12,34); + const FrameRate testFps (5,6); + const uint MAX_FRAMES = 1000; + const uint DIRT_GRAIN = 50; } @@ -98,17 +105,28 @@ namespace test { GridID myGrID (randStr(8)); GridBuilder spec = asset::Meta::create (myGrID); - CHECK (!spec.fps_); - CHECK (spec.origin_ == Time(0)); + CHECK ( spec.fps_ == 1); + CHECK ( spec.origin_ == Time(0)); CHECK (!spec.predecessor_); - spec.fps_ = testFps; + spec.fps_ = testFps; spec.origin_ = testOrigin; PGrid myGrid = spec.commit(); CHECK (myGrid); - UNIMPLEMENTED ("the basic Grid API, so we can actually check anything"); + // now verify the grid + // by performing some conversions... + int randomFrame = (rand() % MAX_FRAMES); + + Time point (myGrid->timeOf (randomFrame)); + CHECK (point == testOrigin + randomFrame * testFps.duration()); + + uint fract = rand() % DIRT_GRAIN; + FSecs dirt = rational_cast (1 / testFps / fract); + + Time dirty(point + Time(dirt)); + CHECK (point == testOrigin + myGrid->gridAlign(dirty)); } diff --git a/tests/lib/time/quantiser-basics-test.cpp b/tests/lib/time/quantiser-basics-test.cpp index bd8c11c72..e790d5f8b 100644 --- a/tests/lib/time/quantiser-basics-test.cpp +++ b/tests/lib/time/quantiser-basics-test.cpp @@ -40,7 +40,7 @@ namespace test{ namespace { const uint MAX_FRAMES = 25*500; - const uint MAX_DIRT = 50; + const uint DIRT_GRAIN = 50; const FSecs F25(1,25); // duration of one PAL frame } @@ -82,7 +82,7 @@ namespace test{ FixedFrameQuantiser fixQ(25); uint frames = (rand() % MAX_FRAMES); - FSecs dirt = (F25 / (rand() % MAX_DIRT)); + FSecs dirt = (F25 / (rand() % DIRT_GRAIN)); Time rawTime = dirt + frames*F25; diff --git a/tests/lib/time/time-quantisation-test.cpp b/tests/lib/time/time-quantisation-test.cpp index 4f12fc64e..3fae0c0f9 100644 --- a/tests/lib/time/time-quantisation-test.cpp +++ b/tests/lib/time/time-quantisation-test.cpp @@ -82,7 +82,7 @@ namespace test{ FrameNr count(qVal); // materialise this quantised time into.. int n = count; // frame count, accessible as plain number - CHECK (Time(FSecs(n-1, 25)) < org); // verify quantisation: the original time + CHECK (Time(FSecs(n-1, 25)) <= org); // verify quantisation: the original time CHECK (org < Time(FSecs(n+1, 25))); // is properly bracketed by (n-1, n+2) }