2007-11-21 06:08:01 +01:00
|
|
|
/*
|
|
|
|
|
TESTASSET.hpp - test asset (stub) for checking internal asset functionality
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2008-03-10 04:25:03 +01:00
|
|
|
Copyright (C) Lumiera.org
|
|
|
|
|
2008, Hermann Vosseler <Ichthyostega@web.de>
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2007-11-21 06:08:01 +01:00
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License as
|
2010-12-17 23:28:49 +01:00
|
|
|
published by the Free Software Foundation; either version 2 of
|
|
|
|
|
the License, or (at your option) any later version.
|
|
|
|
|
|
2007-11-21 06:08:01 +01:00
|
|
|
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.
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2007-11-21 06:08:01 +01:00
|
|
|
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.
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2007-11-21 06:08:01 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef ASSET_TESTASSET_H
|
|
|
|
|
#define ASSET_TESTASSET_H
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "proc/asset.hpp"
|
2013-09-01 17:36:05 +02:00
|
|
|
#include "lib/format-string.hpp"
|
2007-11-21 06:08:01 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-12-02 17:50:44 +01:00
|
|
|
namespace proc {
|
|
|
|
|
namespace asset{
|
|
|
|
|
namespace test {
|
|
|
|
|
|
2013-09-01 17:36:05 +02:00
|
|
|
using util::_Fmt;
|
|
|
|
|
|
2007-11-21 06:08:01 +01:00
|
|
|
|
2011-12-02 17:50:44 +01:00
|
|
|
/**
|
|
|
|
|
* Test(mock) asset subclass usable for hijacking a given
|
|
|
|
|
* asset class (template parameter) and subsequently accessing
|
2013-09-01 17:36:05 +02:00
|
|
|
* internal facilities for writing unit tests. Prerequisite
|
2011-12-02 17:50:44 +01:00
|
|
|
* for using this template is that the used asset base class
|
|
|
|
|
* has a (protected) ctor taking an Asset::Ident....
|
|
|
|
|
*/
|
|
|
|
|
template<class A>
|
|
|
|
|
class TestAsset : public A
|
|
|
|
|
{
|
|
|
|
|
TestAsset () ;
|
2013-09-01 17:36:05 +02:00
|
|
|
TestAsset (PAsset&); ///< declared dependent on the given Asset
|
2011-12-02 17:50:44 +01:00
|
|
|
|
|
|
|
|
static void deleter (TestAsset<A>* aa) { delete aa; }
|
|
|
|
|
|
|
|
|
|
public:
|
2015-07-02 19:16:46 +02:00
|
|
|
typedef lib::P<TestAsset<A> > PA;
|
2011-12-02 17:50:44 +01:00
|
|
|
|
|
|
|
|
static PA create () { return (new TestAsset<A> )->ptrFromThis(); }
|
|
|
|
|
static PA create (PAsset& pRef) { return (new TestAsset<A> (pRef))->ptrFromThis(); }
|
|
|
|
|
|
|
|
|
|
/* === interesting asset features we want to access for tests === */
|
|
|
|
|
void call_unlink () { this->unlink (); }
|
|
|
|
|
void call_unlink (IDA target) { this->unlink (target); }
|
|
|
|
|
void set_depend (PAsset parent) { this->defineDependency (parent); }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
PA ptrFromThis ();
|
|
|
|
|
};
|
2007-11-21 06:08:01 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-12-02 17:50:44 +01:00
|
|
|
}}} // namespace proc::asset::test
|
2007-11-21 06:08:01 +01:00
|
|
|
#endif
|