2010-03-09 06:31:07 +01:00
|
|
|
|
/*
|
|
|
|
|
|
SessionElementTracker(Test) - check the facility to track and expose selected model elements
|
2010-12-17 23:28:49 +01:00
|
|
|
|
|
Copyright: clarify and simplify the file headers
* Lumiera source code always was copyrighted by individual contributors
* there is no entity "Lumiera.org" which holds any copyrights
* Lumiera source code is provided under the GPL Version 2+
== Explanations ==
Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above.
For this to become legally effective, the ''File COPYING in the root directory is sufficient.''
The licensing header in each file is not strictly necessary, yet considered good practice;
attaching a licence notice increases the likeliness that this information is retained
in case someone extracts individual code files. However, it is not by the presence of some
text, that legally binding licensing terms become effective; rather the fact matters that a
given piece of code was provably copyrighted and published under a license. Even reformatting
the code, renaming some variables or deleting parts of the code will not alter this legal
situation, but rather creates a derivative work, which is likewise covered by the GPL!
The most relevant information in the file header is the notice regarding the
time of the first individual copyright claim. By virtue of this initial copyright,
the first author is entitled to choose the terms of licensing. All further
modifications are permitted and covered by the License. The specific wording
or format of the copyright header is not legally relevant, as long as the
intention to publish under the GPL remains clear. The extended wording was
based on a recommendation by the FSF. It can be shortened, because the full terms
of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
|
|
|
|
Copyright (C)
|
|
|
|
|
|
2008, 2010, Hermann Vosseler <Ichthyostega@web.de>
|
2010-12-17 23:28:49 +01:00
|
|
|
|
|
Copyright: clarify and simplify the file headers
* Lumiera source code always was copyrighted by individual contributors
* there is no entity "Lumiera.org" which holds any copyrights
* Lumiera source code is provided under the GPL Version 2+
== Explanations ==
Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above.
For this to become legally effective, the ''File COPYING in the root directory is sufficient.''
The licensing header in each file is not strictly necessary, yet considered good practice;
attaching a licence notice increases the likeliness that this information is retained
in case someone extracts individual code files. However, it is not by the presence of some
text, that legally binding licensing terms become effective; rather the fact matters that a
given piece of code was provably copyrighted and published under a license. Even reformatting
the code, renaming some variables or deleting parts of the code will not alter this legal
situation, but rather creates a derivative work, which is likewise covered by the GPL!
The most relevant information in the file header is the notice regarding the
time of the first individual copyright claim. By virtue of this initial copyright,
the first author is entitled to choose the terms of licensing. All further
modifications are permitted and covered by the License. The specific wording
or format of the copyright header is not legally relevant, as long as the
intention to publish under the GPL remains clear. The extended wording was
based on a recommendation by the FSF. It can be shortened, because the full terms
of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
|
|
|
|
**Lumiera** 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. See the file COPYING for further details.
|
2010-12-17 23:28:49 +01:00
|
|
|
|
|
Copyright: clarify and simplify the file headers
* Lumiera source code always was copyrighted by individual contributors
* there is no entity "Lumiera.org" which holds any copyrights
* Lumiera source code is provided under the GPL Version 2+
== Explanations ==
Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above.
For this to become legally effective, the ''File COPYING in the root directory is sufficient.''
The licensing header in each file is not strictly necessary, yet considered good practice;
attaching a licence notice increases the likeliness that this information is retained
in case someone extracts individual code files. However, it is not by the presence of some
text, that legally binding licensing terms become effective; rather the fact matters that a
given piece of code was provably copyrighted and published under a license. Even reformatting
the code, renaming some variables or deleting parts of the code will not alter this legal
situation, but rather creates a derivative work, which is likewise covered by the GPL!
The most relevant information in the file header is the notice regarding the
time of the first individual copyright claim. By virtue of this initial copyright,
the first author is entitled to choose the terms of licensing. All further
modifications are permitted and covered by the License. The specific wording
or format of the copyright header is not legally relevant, as long as the
intention to publish under the GPL remains clear. The extended wording was
based on a recommendation by the FSF. It can be shortened, because the full terms
of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
|
|
|
|
* *****************************************************************/
|
2010-03-09 06:31:07 +01:00
|
|
|
|
|
2017-02-22 01:54:20 +01:00
|
|
|
|
/** @file session-element-tracker-test.cpp
|
2017-02-22 03:17:18 +01:00
|
|
|
|
** unit test \ref SessionElementTracker_test
|
2016-11-03 18:20:10 +01:00
|
|
|
|
*/
|
|
|
|
|
|
|
2010-03-09 06:31:07 +01:00
|
|
|
|
|
|
|
|
|
|
#include "lib/test/run.hpp"
|
2010-03-12 22:58:46 +01:00
|
|
|
|
|
|
|
|
|
|
#include "lib/element-tracker.hpp"
|
|
|
|
|
|
|
2018-11-15 23:42:43 +01:00
|
|
|
|
#include "steam/assetmanager.hpp"
|
|
|
|
|
|
#include "steam/mobject/session.hpp"
|
|
|
|
|
|
#include "steam/asset/timeline.hpp"
|
|
|
|
|
|
#include "steam/asset/sequence.hpp"
|
2012-12-01 08:44:07 +01:00
|
|
|
|
#include "common/query.hpp"
|
|
|
|
|
|
#include "lib/p.hpp"
|
2010-03-09 06:31:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-11-15 23:55:13 +01:00
|
|
|
|
namespace steam {
|
2010-03-09 06:31:07 +01:00
|
|
|
|
namespace mobject {
|
|
|
|
|
|
namespace session {
|
|
|
|
|
|
namespace test {
|
|
|
|
|
|
|
2010-03-10 05:44:57 +01:00
|
|
|
|
namespace { // yet another accounting dummy
|
|
|
|
|
|
|
2010-03-12 17:16:11 +01:00
|
|
|
|
uint instance = 0;
|
|
|
|
|
|
int checksum = 0;
|
2010-03-10 05:44:57 +01:00
|
|
|
|
|
2010-03-12 22:58:46 +01:00
|
|
|
|
using lib::AutoRegistered;
|
2010-03-11 18:27:52 +01:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Test Dummy: to be created through the inherited static #create(),
|
|
|
|
|
|
* managed by smart-ptr. Any Dummy instance gets automatically registered
|
|
|
|
|
|
* for tracking, and will be deregistered by invoking #unlink().
|
|
|
|
|
|
* The link to the actual registration service has to be established at
|
|
|
|
|
|
* runtime once, by calling #establishRegistryLink or #setRegistryInstance
|
|
|
|
|
|
*/
|
|
|
|
|
|
struct Dummy
|
|
|
|
|
|
: AutoRegistered<Dummy>
|
2010-03-10 05:44:57 +01:00
|
|
|
|
{
|
|
|
|
|
|
const uint id_;
|
|
|
|
|
|
|
2010-03-11 18:27:52 +01:00
|
|
|
|
Dummy()
|
2010-03-12 17:16:11 +01:00
|
|
|
|
: id_(++instance)
|
2010-03-10 05:44:57 +01:00
|
|
|
|
{
|
2010-03-12 17:16:11 +01:00
|
|
|
|
checksum += id_;
|
2010-03-10 05:44:57 +01:00
|
|
|
|
}
|
2010-03-12 17:16:11 +01:00
|
|
|
|
// to be created by factory...
|
|
|
|
|
|
friend class AutoRegistered<Dummy>;
|
2010-03-10 05:44:57 +01:00
|
|
|
|
|
2010-03-12 17:16:11 +01:00
|
|
|
|
public:
|
2010-03-10 05:44:57 +01:00
|
|
|
|
void
|
2010-03-12 22:02:27 +01:00
|
|
|
|
detach() // demonstrates how to hook into the cleanup-operation
|
2010-03-10 05:44:57 +01:00
|
|
|
|
{
|
2010-03-12 22:02:27 +01:00
|
|
|
|
AutoRegistered<Dummy>::detach();
|
2010-03-10 05:44:57 +01:00
|
|
|
|
checksum -= id_;
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
2010-03-12 17:16:11 +01:00
|
|
|
|
|
2010-03-12 01:50:33 +01:00
|
|
|
|
bool
|
|
|
|
|
|
operator== (Dummy const& d1, Dummy const& d2)
|
|
|
|
|
|
{
|
|
|
|
|
|
return util::isSameObject (d1, d2);
|
|
|
|
|
|
}
|
2010-03-11 18:27:52 +01:00
|
|
|
|
|
2010-03-12 22:58:46 +01:00
|
|
|
|
} // (End) test dummy and helper
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-03-09 06:31:07 +01:00
|
|
|
|
|
2012-12-01 08:44:07 +01:00
|
|
|
|
using lib::P;
|
|
|
|
|
|
using lumiera::Query;
|
2010-03-12 01:50:33 +01:00
|
|
|
|
using asset::Timeline;
|
2010-03-09 06:31:07 +01:00
|
|
|
|
using asset::PTimeline;
|
2010-03-12 01:50:33 +01:00
|
|
|
|
using asset::AssetManager;
|
2010-03-09 06:31:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
2013-10-24 23:06:36 +02:00
|
|
|
|
/****************************************************************************//**
|
2010-03-09 06:31:07 +01:00
|
|
|
|
* @test verify the tracking of special session/model elements, to be exposed
|
|
|
|
|
|
* through an self-contained interface module on the session API.
|
2010-03-12 22:58:46 +01:00
|
|
|
|
* The basic element-tracking mechanism uses a simple (vector based)
|
|
|
|
|
|
* registry, which stores a smart-ptr. Thus the elements need to be
|
|
|
|
|
|
* created by a factory. In case of Timeline / Sequence, the
|
|
|
|
|
|
* asset::StructFactory will take on this role. The integration test
|
|
|
|
|
|
* creates a Timeline (facade asset) and verifies proper registration
|
|
|
|
|
|
* and deregistration.
|
2010-03-09 06:31:07 +01:00
|
|
|
|
*
|
|
|
|
|
|
* @see timeline-sequence-handling-test.cpp
|
|
|
|
|
|
* @see session-interface-modules.hpp
|
|
|
|
|
|
* @see ref-array-test.cpp
|
|
|
|
|
|
*/
|
|
|
|
|
|
class SessionElementTracker_test : public Test
|
|
|
|
|
|
{
|
|
|
|
|
|
virtual void
|
|
|
|
|
|
run (Arg)
|
|
|
|
|
|
{
|
|
|
|
|
|
verify_trackingMechanism();
|
2010-10-20 05:12:13 +02:00
|
|
|
|
verify_integration();
|
2010-03-09 06:31:07 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
verify_trackingMechanism()
|
|
|
|
|
|
{
|
2010-03-12 17:16:11 +01:00
|
|
|
|
instance = 0;
|
2010-03-10 05:44:57 +01:00
|
|
|
|
checksum = 0;
|
|
|
|
|
|
{
|
2010-03-11 18:27:52 +01:00
|
|
|
|
typedef Dummy AutoRegisteringDummy;
|
2011-12-02 17:50:44 +01:00
|
|
|
|
typedef P<AutoRegisteringDummy> PDummy;
|
2010-03-11 18:27:52 +01:00
|
|
|
|
typedef lib::ElementTracker<Dummy> DummyRegistry;
|
|
|
|
|
|
|
|
|
|
|
|
DummyRegistry trackedDummies;
|
2010-03-10 05:44:57 +01:00
|
|
|
|
|
|
|
|
|
|
CHECK (0 == checksum);
|
|
|
|
|
|
CHECK (0 == trackedDummies.size());
|
|
|
|
|
|
|
2010-03-11 18:27:52 +01:00
|
|
|
|
AutoRegisteringDummy::setRegistryInstance (trackedDummies);
|
2010-03-10 05:44:57 +01:00
|
|
|
|
PDummy dummy1 = AutoRegisteringDummy::create();
|
|
|
|
|
|
PDummy dummy2 = AutoRegisteringDummy::create();
|
|
|
|
|
|
|
|
|
|
|
|
CHECK (2 == trackedDummies.size());
|
|
|
|
|
|
CHECK (dummy1 == trackedDummies[0]);
|
|
|
|
|
|
CHECK (dummy2 == trackedDummies[1]);
|
|
|
|
|
|
|
|
|
|
|
|
PDummy dummy3 = AutoRegisteringDummy::create();
|
|
|
|
|
|
CHECK (3 == trackedDummies.size());
|
|
|
|
|
|
CHECK (dummy3 == trackedDummies[2]);
|
|
|
|
|
|
|
|
|
|
|
|
CHECK (1+2+3 == checksum);
|
|
|
|
|
|
|
2010-03-12 17:16:11 +01:00
|
|
|
|
dummy2->detach();
|
2010-03-10 05:44:57 +01:00
|
|
|
|
CHECK (1 + 3 == checksum);
|
|
|
|
|
|
CHECK (2 == trackedDummies.size());
|
|
|
|
|
|
CHECK (dummy1 == trackedDummies[0]);
|
|
|
|
|
|
CHECK (dummy3 == trackedDummies[1]);
|
|
|
|
|
|
|
|
|
|
|
|
CHECK (1 == dummy2.use_count());
|
|
|
|
|
|
CHECK (2 == dummy1.use_count());
|
|
|
|
|
|
CHECK (2 == dummy3.use_count());
|
|
|
|
|
|
|
|
|
|
|
|
// deliberately discard our reference,
|
2010-03-11 18:27:52 +01:00
|
|
|
|
// so the only remaining ref is within the registry
|
2010-03-10 05:44:57 +01:00
|
|
|
|
dummy1.reset();
|
2010-03-12 17:16:11 +01:00
|
|
|
|
dummy3.reset();
|
|
|
|
|
|
CHECK (!dummy1);
|
|
|
|
|
|
CHECK ( dummy2);
|
|
|
|
|
|
CHECK (!dummy3);
|
2010-03-10 05:44:57 +01:00
|
|
|
|
CHECK (1 == trackedDummies[0].use_count());
|
|
|
|
|
|
CHECK (1 == trackedDummies[1].use_count());
|
|
|
|
|
|
CHECK (1 + 3 == checksum);
|
|
|
|
|
|
|
|
|
|
|
|
// now the tracker goes out of scope...
|
|
|
|
|
|
}
|
|
|
|
|
|
CHECK (0 == checksum); // ...remaining elements have been unlinked
|
2010-03-09 06:31:07 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
verify_integration()
|
|
|
|
|
|
{
|
|
|
|
|
|
Session::current.reset();
|
|
|
|
|
|
CHECK (Session::current.isUp());
|
|
|
|
|
|
|
|
|
|
|
|
PSess sess = Session::current;
|
|
|
|
|
|
CHECK (sess->isValid());
|
|
|
|
|
|
|
|
|
|
|
|
uint num_timelines = sess->timelines.size();
|
|
|
|
|
|
CHECK (0 < num_timelines);
|
|
|
|
|
|
|
2010-10-29 05:24:19 +02:00
|
|
|
|
PTimeline specialTimeline (asset::Struct::retrieve.newInstance<Timeline> ("testical"));
|
2010-03-09 06:31:07 +01:00
|
|
|
|
CHECK (specialTimeline);
|
|
|
|
|
|
CHECK (num_timelines + 1 == sess->timelines.size());
|
2010-10-18 05:33:46 +02:00
|
|
|
|
CHECK (specialTimeline == sess->timelines[num_timelines]); // got appended at the end of the tracking table
|
2010-10-29 05:24:19 +02:00
|
|
|
|
CHECK (specialTimeline.use_count() == 3); // we, the AssetManager and the session
|
2010-03-09 06:31:07 +01:00
|
|
|
|
|
2010-10-29 05:24:19 +02:00
|
|
|
|
PTimeline anotherTimeline (asset::Struct::retrieve.newInstance<Timeline>());
|
2010-03-09 06:31:07 +01:00
|
|
|
|
CHECK (num_timelines + 2 == sess->timelines.size());
|
2010-03-12 01:50:33 +01:00
|
|
|
|
CHECK (specialTimeline == sess->timelines[num_timelines]);
|
|
|
|
|
|
CHECK (anotherTimeline == sess->timelines[num_timelines+1]); // new one got appended at the end
|
2010-03-09 06:31:07 +01:00
|
|
|
|
|
|
|
|
|
|
AssetManager& assetM (AssetManager::instance());
|
|
|
|
|
|
CHECK (assetM.known (specialTimeline->getID()));
|
2010-10-18 05:33:46 +02:00
|
|
|
|
assetM.remove (specialTimeline->getID()); //////////////TICKET #550 modalities of Timeline/Sequence deletion
|
2010-03-09 06:31:07 +01:00
|
|
|
|
CHECK (!assetM.known (specialTimeline->getID()));
|
|
|
|
|
|
|
|
|
|
|
|
CHECK (num_timelines + 1 == sess->timelines.size());
|
2010-03-12 01:50:33 +01:00
|
|
|
|
CHECK (anotherTimeline == sess->timelines[num_timelines]); // moved to the previous slot
|
2010-03-12 22:58:46 +01:00
|
|
|
|
CHECK (specialTimeline.use_count() == 1); // we're holding the last reference
|
2010-10-20 04:42:22 +02:00
|
|
|
|
|
|
|
|
|
|
verify_cleanup (anotherTimeline);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @test ensure the asset cleanup doesn't interfere with session shutdown
|
|
|
|
|
|
*/
|
|
|
|
|
|
void
|
2012-12-27 03:31:09 +01:00
|
|
|
|
verify_cleanup (PTimeline const& aTimeline_in_session)
|
2010-10-20 04:42:22 +02:00
|
|
|
|
{
|
2010-12-10 03:00:17 +01:00
|
|
|
|
CHECK (1 < aTimeline_in_session.use_count(), "test object should still be attached to session");
|
2010-10-20 04:42:22 +02:00
|
|
|
|
Session::current.reset();
|
2012-12-27 03:31:09 +01:00
|
|
|
|
CHECK (1 == aTimeline_in_session.use_count(), "session reset should have de-registered the test object");
|
2010-03-09 06:31:07 +01:00
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Register this test class... */
|
|
|
|
|
|
LAUNCHER (SessionElementTracker_test, "unit session");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-11-15 23:55:13 +01:00
|
|
|
|
}}}} // namespace steam::mobject::session::test
|