2009-10-16 03:13:57 +02:00
|
|
|
|
/*
|
|
|
|
|
|
TEST-SCOPES.cpp - builds a test PlacementIndex containing dummy Placements as nested scopes
|
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)
|
|
|
|
|
|
2009, 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
|
|
|
|
* *****************************************************************/
|
2009-10-16 03:13:57 +02:00
|
|
|
|
|
2017-02-22 01:58:49 +01:00
|
|
|
|
/** @file test-scopes.cpp
|
|
|
|
|
|
** Implementation of nested test scopes to cover the placement index.
|
|
|
|
|
|
** This translation unit builds mock "session content" with a fixed, known layout,
|
|
|
|
|
|
** which can be used to verify the behaviour of session query and content discovery
|
2016-11-03 18:20:10 +01:00
|
|
|
|
*/
|
|
|
|
|
|
|
2009-10-16 03:13:57 +02:00
|
|
|
|
|
2018-11-15 23:42:43 +01:00
|
|
|
|
#include "steam/mobject/session/test-scopes.hpp"
|
|
|
|
|
|
#include "steam/mobject/session/session-service-mock-index.hpp"
|
|
|
|
|
|
#include "steam/mobject/session/session-service-explore-scope.hpp"
|
|
|
|
|
|
#include "steam/mobject/session/scope-query.hpp"
|
2009-10-16 03:13:57 +02:00
|
|
|
|
|
|
|
|
|
|
|
2018-11-15 23:55:13 +01:00
|
|
|
|
namespace steam {
|
2009-10-16 03:13:57 +02:00
|
|
|
|
namespace mobject {
|
|
|
|
|
|
namespace session {
|
|
|
|
|
|
namespace test {
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-11 02:49:12 +01:00
|
|
|
|
/** @note this dummy index isn't actively connected to the session;
|
|
|
|
|
|
* the unit tests rely on this dummy index containing
|
|
|
|
|
|
* a specific tree structure of test-dummy MObjects.
|
2009-10-16 03:13:57 +02:00
|
|
|
|
*/
|
2009-10-17 21:29:16 +02:00
|
|
|
|
PPIdx
|
2009-10-16 03:13:57 +02:00
|
|
|
|
build_testScopes()
|
|
|
|
|
|
{
|
2009-10-17 21:29:16 +02:00
|
|
|
|
PDum p1(*new TestSubMO21);
|
|
|
|
|
|
PDum p2(*new TestSubMO21);
|
|
|
|
|
|
PDum p3(*new TestSubMO21);
|
|
|
|
|
|
PDum p4(*new TestSubMO21);
|
|
|
|
|
|
PDum p5(*new TestSubMO21);
|
|
|
|
|
|
|
|
|
|
|
|
PDum ps1(*new DummyMO);
|
|
|
|
|
|
PDum ps2(*new TestSubMO2);
|
2009-10-18 19:08:21 +02:00
|
|
|
|
PDum ps3(*new TestSubMO1);
|
2009-10-16 03:13:57 +02:00
|
|
|
|
|
|
|
|
|
|
// Prepare an (test)Index backing the PlacementRefs
|
2009-12-11 02:49:12 +01:00
|
|
|
|
PPIdx index (SessionServiceMockIndex::install());
|
|
|
|
|
|
|
2009-10-16 03:13:57 +02:00
|
|
|
|
PMO& root = index->getRoot();
|
2011-12-02 17:50:44 +01:00
|
|
|
|
|
2009-11-28 23:37:58 +01:00
|
|
|
|
typedef PMO::ID ID;
|
|
|
|
|
|
ID i1 = index->insert (p1, root);
|
|
|
|
|
|
ID i2 = index->insert (p2, i1 );
|
|
|
|
|
|
ID i3 = index->insert (p3, i2 );
|
|
|
|
|
|
ID i4 = index->insert (p4, i3 );
|
2015-08-15 18:24:35 +02:00
|
|
|
|
index->insert (p5, i4 );
|
2009-10-16 03:13:57 +02:00
|
|
|
|
|
2015-08-15 18:24:35 +02:00
|
|
|
|
index->insert (ps1,root);
|
|
|
|
|
|
ID is2 =index->insert (ps2,root);
|
|
|
|
|
|
index->insert (ps3, is2);
|
2009-10-17 21:29:16 +02:00
|
|
|
|
|
2009-10-16 03:13:57 +02:00
|
|
|
|
return index;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-05-11 02:08:53 +02:00
|
|
|
|
namespace {
|
|
|
|
|
|
template<class MO>
|
|
|
|
|
|
PlacementMO&
|
|
|
|
|
|
retrieve_firstElmOfType()
|
|
|
|
|
|
{
|
|
|
|
|
|
return *ContentsQuery<MO>(SessionServiceExploreScope::getScopeRoot())
|
|
|
|
|
|
.resolveBy(SessionServiceExploreScope::getResolver());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2009-10-16 03:13:57 +02:00
|
|
|
|
|
2009-11-21 01:07:56 +01:00
|
|
|
|
/** @note this test helper only works if build_testScopes is invoked
|
|
|
|
|
|
* beforehand, and the returned smart-ptr to the created test/dummy index
|
|
|
|
|
|
* is retained. Moreover, this function makes assumptions about the actual
|
|
|
|
|
|
* objects created by the former test function.
|
|
|
|
|
|
* @throw lumiera::error::Invalid if the intended start element doesn't exist (anymore)
|
|
|
|
|
|
*/
|
|
|
|
|
|
PlacementMO&
|
|
|
|
|
|
retrieve_startElm()
|
|
|
|
|
|
{
|
2014-05-11 02:08:53 +02:00
|
|
|
|
return retrieve_firstElmOfType<TestSubMO1>();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PlacementMO&
|
|
|
|
|
|
retrieve_firstTestSubMO21()
|
|
|
|
|
|
{
|
|
|
|
|
|
return retrieve_firstElmOfType<TestSubMO21>();
|
2009-11-21 01:07:56 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-11-21 20:55:14 +01:00
|
|
|
|
ScopeQuery<MObject>::iterator
|
|
|
|
|
|
explore_testScope (PlacementMO const& scopeTop)
|
|
|
|
|
|
{
|
2010-06-19 05:20:34 +02:00
|
|
|
|
return ScopeQuery<MObject>(scopeTop, CHILDREN)
|
|
|
|
|
|
.resolveBy(SessionServiceExploreScope::getResolver());
|
2009-11-21 20:55:14 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-11-15 23:55:13 +01:00
|
|
|
|
}}}} // namespace steam::mobject::session::test
|