43 using session::test::TestClip;
44 using LERR_(BOTTOM_PLACEMENTREF);
45 using LERR_(NONEMPTY_SCOPE);
46 using LERR_(INVALID_SCOPE);
48 typedef PlacementIndex& Idx;
68 checkSimpleInsertRemove (index);
71 PMO::ID elmID = checkSimpleAccess (index);
75 checkTypedAccess (index, elmID);
78 checkScopeHandling (index);
92 has_size(uint siz, Idx index)
94 CHECK (siz == index.size());
99 checkSimpleInsertRemove (Idx index)
101 PMO clip = TestClip::create();
104 CHECK (0 == index.size());
106 PMO::ID elmID = index.
insert (clip, root);
107 CHECK (1 == index.size());
108 CHECK ( index.contains (elmID));
109 CHECK (!index.contains (clip));
112 CHECK (1 == index.size());
114 CHECK (0 == index.size());
115 CHECK (!index.contains (elmID));
116 CHECK ( index.contains (root));
121 checkSimpleAccess (Idx index)
123 PMO testObj = TestClip::create();
125 PMO::ID elmID = index.
insert (testObj, root);
127 PMO& elm = index.find(elmID);
128 CHECK (elmID == elm.
getID());
129 CHECK (!isSameObject (elm,testObj));
131 CHECK (elmID != testObj.
getID());
133 PMO::ID elmID2 = index.
insert(testObj, root);
134 CHECK (elmID2 != elmID);
135 CHECK (testObj != index.find (elmID));
136 CHECK (testObj != index.find (elmID2));
137 CHECK (
isSameDef(testObj, index.find(elmID)));
138 CHECK (
isSameDef(testObj, index.find(elmID2)));
139 CHECK (!isSameObject (testObj, index.find(elmID2)));
140 CHECK (!isSameObject (elm, index.find(elmID2)));
143 CHECK ( isSameObject (elm, index.find(elmID )));
144 CHECK ( isSameObject (elm, index.find(elmID )));
147 CHECK ( isSameObject (elm, index.find(elm)));
154 checkTypedAccess (Idx index, PMO::ID elmID)
156 PMO& elm = index.find(elmID);
157 CHECK (elmID == elm.
getID());
160 PClip anotherTestClip = TestClip::create();
162 typedef PlacementMO::Id<Clip> IDClip;
163 IDClip clipID = index.
insert(anotherTestClip, elmID);
167 PMO::ID mID = clipID;
168 PMO& asMO = index.find(mID);
171 PClip& asClip = index.find(clipID);
172 CHECK (LENGTH_TestClip == asClip->getMedia()->getLength());
174 CHECK ( isSameObject(asMO,asClip));
175 CHECK (!isSameObject(asClip, anotherTestClip));
180 checkInvalidRef (Idx index)
183 PlacementMO::ID invalidID (invalid);
184 CHECK (!
bool(invalidID));
185 CHECK (!
bool(invalid));
187 VERIFY_ERROR(BOTTOM_PLACEMENTREF, index.find(invalid) );
188 VERIFY_ERROR(BOTTOM_PLACEMENTREF, index.find(invalidID) );
189 VERIFY_ERROR(BOTTOM_PLACEMENTREF, index.getScope(invalidID) );
191 CHECK (!index.contains(invalidID));
193 PMO testObj = TestClip::create();
196 CHECK (
false == index.remove(invalidID));
201 checkScopeHandling (Idx index)
203 PMO testObj = TestClip::create();
207 ID e1 = index.
insert (testObj, root);
208 ID e11 = index.
insert (testObj, e1);
209 ID e12 = index.
insert (testObj, e1);
210 ID e13 = index.
insert (testObj, e1);
211 ID e131 = index.
insert (testObj, e13);
212 ID e132 = index.
insert (testObj, e13);
213 ID e133 = index.
insert (testObj, e13);
214 ID e1331 = index.
insert (testObj, e133);
217 CHECK (root == index.getScope(e1));
218 CHECK (e1 == index.getScope(e11).
getID());
219 CHECK (e1 == index.getScope(e12).
getID());
220 CHECK (e1 == index.getScope(e13).
getID());
221 CHECK (e13 == index.getScope(e131).
getID());
222 CHECK (e13 == index.getScope(e132).
getID());
223 CHECK (e13 == index.getScope(e133).
getID());
224 CHECK (e133 == index.getScope(e1331).
getID());
228 CHECK (index.getScope(e11) == index.getScope(index.find(e11)));
229 CHECK (index.getScope(e131) == index.getScope(index.find(e131)));
234 CHECK (index.contains(e1331));
235 CHECK (index.remove(e1331));
236 CHECK (!index.contains(e1331));
237 CHECK (!index.remove(e1331));
239 CHECK (index.remove(e133));
240 CHECK (!index.contains(e133));
244 uint siz = index.size();
245 ID e1321 = index.
insert (testObj, e132);
246 ID e13211 = index.
insert (testObj, e1321);
247 ID e13212 = index.
insert (testObj, e1321);
248 ID e13213 = index.
insert (testObj, e1321);
249 ID e13214 = index.
insert (testObj, e1321);
250 ID e132131 = index.
insert (testObj, e13213);
251 ID e132132 = index.
insert (testObj, e13213);
252 ID e132133 = index.
insert (testObj, e13213);
253 ID e132134 = index.
insert (testObj, e13213);
254 ID e132141 = index.
insert (testObj, e13214);
255 ID e132142 = index.
insert (testObj, e13214);
256 ID e132143 = index.
insert (testObj, e13214);
257 ID e132144 = index.
insert (testObj, e13214);
261 CHECK (!index.contains (e1321));
262 CHECK (!index.contains (e13211));
263 CHECK (!index.contains (e13212));
264 CHECK (!index.contains (e13213));
265 CHECK (!index.contains (e132131));
266 CHECK (!index.contains (e132132));
267 CHECK (!index.contains (e132133));
268 CHECK (!index.contains (e132134));
269 CHECK (!index.contains (e132141));
270 CHECK (!index.contains (e132142));
271 CHECK (!index.contains (e132143));
272 CHECK (!index.contains (e132144));
273 CHECK (siz == index.size());
298 CHECK (rootContents);
300 discover (index, rootContents, 0);
305 discover (Idx index, Iter
iter, uint level)
308 for ( ; iter; ++iter )
310 cout << indent(level) <<
"::" << *iter << endl;
313 Iter scopeContents = index.
getReferrers (iter->getID());
315 discover (index, scopeContents, level+1);
318 static _Fmt summary{
"...%i elements at Level %i"};
319 cout << indent(level) << summary % count % level << endl;
328 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.
Simplistic 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, based directly on the referee's memory identities. ...