52 using session::test::TestClip;
53 using LERR_(BOTTOM_PLACEMENTREF);
54 using LERR_(NONEMPTY_SCOPE);
55 using LERR_(INVALID_SCOPE);
57 typedef PlacementIndex& Idx;
77 checkSimpleInsertRemove (index);
80 PMO::ID elmID = checkSimpleAccess (index);
84 checkTypedAccess (index, elmID);
87 checkScopeHandling (index);
101 has_size(uint siz, Idx index)
103 CHECK (siz == index.size());
108 checkSimpleInsertRemove (Idx index)
110 PMO clip = TestClip::create();
113 CHECK (0 == index.size());
115 PMO::ID elmID = index.
insert (clip, root);
116 CHECK (1 == index.size());
117 CHECK ( index.contains (elmID));
118 CHECK (!index.contains (clip));
121 CHECK (1 == index.size());
123 CHECK (0 == index.size());
124 CHECK (!index.contains (elmID));
125 CHECK ( index.contains (root));
130 checkSimpleAccess (Idx index)
132 PMO testObj = TestClip::create();
134 PMO::ID elmID = index.
insert (testObj, root);
136 PMO& elm = index.find(elmID);
137 CHECK (elmID == elm.
getID());
138 CHECK (!isSameObject (elm,testObj));
140 CHECK (elmID != testObj.
getID());
142 PMO::ID elmID2 = index.
insert(testObj, root);
143 CHECK (elmID2 != elmID);
144 CHECK (testObj != index.find (elmID));
145 CHECK (testObj != index.find (elmID2));
146 CHECK (
isSameDef(testObj, index.find(elmID)));
147 CHECK (
isSameDef(testObj, index.find(elmID2)));
148 CHECK (!isSameObject (testObj, index.find(elmID2)));
149 CHECK (!isSameObject (elm, index.find(elmID2)));
152 CHECK ( isSameObject (elm, index.find(elmID )));
153 CHECK ( isSameObject (elm, index.find(elmID )));
156 CHECK ( isSameObject (elm, index.find(elm)));
163 checkTypedAccess (Idx index, PMO::ID elmID)
165 PMO& elm = index.find(elmID);
166 CHECK (elmID == elm.
getID());
169 PClip anotherTestClip = TestClip::create();
171 typedef PlacementMO::Id<Clip> IDClip;
172 IDClip clipID = index.
insert(anotherTestClip, elmID);
176 PMO::ID mID = clipID;
177 PMO& asMO = index.find(mID);
180 PClip& asClip = index.find(clipID);
181 CHECK (LENGTH_TestClip == asClip->getMedia()->getLength());
183 CHECK ( isSameObject(asMO,asClip));
184 CHECK (!isSameObject(asClip, anotherTestClip));
189 checkInvalidRef (Idx index)
192 PlacementMO::ID invalidID (invalid);
193 CHECK (!
bool(invalidID));
194 CHECK (!
bool(invalid));
196 VERIFY_ERROR(BOTTOM_PLACEMENTREF, index.find(invalid) );
197 VERIFY_ERROR(BOTTOM_PLACEMENTREF, index.find(invalidID) );
198 VERIFY_ERROR(BOTTOM_PLACEMENTREF, index.getScope(invalidID) );
200 CHECK (!index.contains(invalidID));
202 PMO testObj = TestClip::create();
205 CHECK (
false == index.remove(invalidID));
210 checkScopeHandling (Idx index)
212 PMO testObj = TestClip::create();
216 ID e1 = index.
insert (testObj, root);
217 ID e11 = index.
insert (testObj, e1);
218 ID e12 = index.
insert (testObj, e1);
219 ID e13 = index.
insert (testObj, e1);
220 ID e131 = index.
insert (testObj, e13);
221 ID e132 = index.
insert (testObj, e13);
222 ID e133 = index.
insert (testObj, e13);
223 ID e1331 = index.
insert (testObj, e133);
226 CHECK (root == index.getScope(e1));
227 CHECK (e1 == index.getScope(e11).
getID());
228 CHECK (e1 == index.getScope(e12).
getID());
229 CHECK (e1 == index.getScope(e13).
getID());
230 CHECK (e13 == index.getScope(e131).
getID());
231 CHECK (e13 == index.getScope(e132).
getID());
232 CHECK (e13 == index.getScope(e133).
getID());
233 CHECK (e133 == index.getScope(e1331).
getID());
237 CHECK (index.getScope(e11) == index.getScope(index.find(e11)));
238 CHECK (index.getScope(e131) == index.getScope(index.find(e131)));
243 CHECK (index.contains(e1331));
244 CHECK (index.remove(e1331));
245 CHECK (!index.contains(e1331));
246 CHECK (!index.remove(e1331));
248 CHECK (index.remove(e133));
249 CHECK (!index.contains(e133));
253 uint siz = index.size();
254 ID e1321 = index.
insert (testObj, e132);
255 ID e13211 = index.
insert (testObj, e1321);
256 ID e13212 = index.
insert (testObj, e1321);
257 ID e13213 = index.
insert (testObj, e1321);
258 ID e13214 = index.
insert (testObj, e1321);
259 ID e132131 = index.
insert (testObj, e13213);
260 ID e132132 = index.
insert (testObj, e13213);
261 ID e132133 = index.
insert (testObj, e13213);
262 ID e132134 = index.
insert (testObj, e13213);
263 ID e132141 = index.
insert (testObj, e13214);
264 ID e132142 = index.
insert (testObj, e13214);
265 ID e132143 = index.
insert (testObj, e13214);
266 ID e132144 = index.
insert (testObj, e13214);
270 CHECK (!index.contains (e1321));
271 CHECK (!index.contains (e13211));
272 CHECK (!index.contains (e13212));
273 CHECK (!index.contains (e13213));
274 CHECK (!index.contains (e132131));
275 CHECK (!index.contains (e132132));
276 CHECK (!index.contains (e132133));
277 CHECK (!index.contains (e132134));
278 CHECK (!index.contains (e132141));
279 CHECK (!index.contains (e132142));
280 CHECK (!index.contains (e132143));
281 CHECK (!index.contains (e132144));
282 CHECK (siz == index.size());
307 CHECK (rootContents);
309 discover (index, rootContents, 0);
314 discover (Idx index, Iter
iter, uint level)
317 for ( ; iter; ++iter )
319 cout << indent(level) <<
"::" << *iter << endl;
322 Iter scopeContents = index.
getReferrers (iter->getID());
324 discover (index, scopeContents, level+1);
327 static _Fmt summary{
"...%i elements at Level %i"};
328 cout << indent(level) << summary % count % level << endl;
337 return string (level,
' ');
Core abstraction: placement of a media object into session context.
void checkContentsEnumeration(Idx index)
#define VERIFY_ERROR(ERROR_ID, ERRONEOUS_STATEMENT)
Macro to verify that a statement indeed raises an exception.
PlacementMO & getRoot() const
retrieve the logical root scope
Steam-Layer implementation namespace root.
A front-end for using printf-style formatting.
Namespace of Session and user visible high-level objects.
Core of the session implementation datastructure.
Simple test class runner.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
bool isSameDef(PlacementMO const &pl1, PlacementMO const &pl2)
compare the properties of placement
A stub implementation of the Clip interface for unit testing.
bool isValid() const
validity self-check, used for sanity checks and the session self-check.
A collection of frequently used helper functions to support unit testing.
ID insert(PlacementMO const &newObj, ID targetScope)
Add a new Placement (Object "instance") into the index.
void clear(ID targetScope)
recursively kill a complete scope, including the given element and all children.
Structured compound of Placement instances with lookup capabilities.
iterator getReferrers(ID) const
Retrieve all the elements attached to the given entry (scope) Each element (Placement) can act as a s...
Setup of a faked session root for unit testing.
thin wrapper around a size_t hash ID used as primary key for all Asset objects.
bool isSameObject(A const &a, B const &b)
compare plain object identity, bypassing any custom comparison operators.