WIP: draft test to cover object identity handling

This commit is contained in:
Fischlurch 2010-01-08 04:00:47 +01:00
parent 36cd34e9b1
commit e01b41cd1a
2 changed files with 163 additions and 0 deletions

View file

@ -37,6 +37,10 @@ PLANNED "basic placement properties" PlacementBasic_test <<END
END
PLANNED "object identity" PlacementObjectIdentity_test <<END
END
TEST "hierarchical placement types" PlacementHierarchy_test <<END
out: sizeof\( .+ \) = [0-9]{2}
out: Placement.+mobject.+test.+TestSubMO1.+. use-cnt=1 .*

View file

@ -0,0 +1,159 @@
/*
PlacementObjectIdentity(Test) - object identity for placements into the session
Copyright (C) Lumiera.org
2010, 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/lumitime.hpp"
#include "proc/asset/media.hpp"
#include "proc/mobject/mobject.hpp"
#include "proc/mobject/mobject-ref.hpp"
#include "proc/mobject/placement.hpp"
#include "proc/mobject/placement-ref.hpp"
#include "proc/mobject/session/placement-index.hpp"
#include "proc/mobject/session/session-service-mock-index.hpp"
#include "proc/mobject/session/clip.hpp"
#include "proc/mobject/explicitplacement.hpp"
//#include "proc/mobject/test-dummy-mobject.hpp"
//#include "lib/test/test-helper.hpp"
//#include <iostream>
//
//using std::string;
//using std::cout;
//using std::endl;
namespace mobject {
namespace test {
using lumiera::Time;
using session::Clip;
using session::SessionServiceMockIndex;
/***************************************************************************
* @test verify correct handling of object identity. Create test objects,
* add placements to a dummy index/session, then create PlacementRef
* and MObjectRef handles. Finally do cross comparisons.
*
* @todo WIP-WIP to be written... TICKET #517
*
* @see mobject::PlacementRef_test
* @see mobject::MObjectRef_test
*/
class PlacementObjectIdentity_test : public Test
{
typedef Placement<MObject> PMObj;
typedef Placement<Clip> PClip;
typedef PlacementMO::ID PMObjID;
typedef PlacementMO::Id<Clip> PClipID;
virtual void
run (Arg)
{
// create data simulating a "Session"
PMObj pClip1 = asset::Media::create("test-1", asset::VIDEO)->createClip();
PMObj pClip2 = asset::Media::create("test-2", asset::VIDEO)->createClip();
// set up a tie to fixed start positions
pClip1.chain(Time(10));
pClip2.chain(Time(20));
ASSERT (pClip1->isValid());
ASSERT (pClip2->isValid());
ASSERT (2 == pClip1.use_count()); // one by the placement and one by the clip-Asset
ASSERT (2 == pClip2.use_count());
////////////////TODO direct comparisons
////////////////TODO direct comparisons
UNIMPLEMENTED ("verify proper handling of object identity");
#if false //////////////////////////////////////////////////////////////////////////////////////////////////////////TICKET 517 !!!!!!!!!!!!!!
// Prepare an (test)Index
PPIdx index = SessionServiceMockIndex::install();
PMO& root = index->getRoot();
// Add the Clips to "session"
PMObjID clip1ID = index->insert (pClip1, root);
PMObjID clip2ID = index->insert (pClip2, root);
////////////////TODO compare ids
////////////////TODO compare ids
// extract various kinds of IDs and refs
PMObj & rP1 (pClip1);
PMObj const& rP2 (pClip2);
PMObj::ID id1 = pClip1.getID();
PMObj::Id<Clip> id2 = pClip2.getID();
LumieraUid luid = id1.get();
PlacementRef<Clip> ref1 (id1);
PlacementRef<MObject> ref2 (pClip2);
MORef<Clip> rMO;
ASSERT (!rMO); // still empty (not bound)
// activate by binding to provided ref
rMO.activate(refObj);
ASSERT (rMO); // now bound
///TODO access Placement, fetch ID
// re-link to the Placement (note we get the Clip API!)
Placement<Clip> & refP = rMO.getPlacement();
ASSERT (refP);
ASSERT (3 == refP.use_count());
ASSERT (&refP == placementAdr); // actually denotes the address of the original Placement in the "session"
ExplicitPlacement exPla = refP.resolve();
ASSERT (exPla.time == start); // recovered Placement resolves to the same time as provided by the proxied API
ASSERT (4 == refP.use_count()); // but now we've indeed created an additional owner (exPla)
ASSERT (4 == rMO.use_count());
////////////////TODO now do the cross comparisons
////////////////TODO now do the cross comparisons
///clean up...
index.reset();
#endif //////////////////////////////////////////////// ////////////////////////////////////////////////////TODO to be written........!!!!!
}
};
/** Register this test class... */
LAUNCHER (PlacementObjectIdentity_test, "function session");
}} // namespace mobject::test