Lumiera  0.pre.03
»edit your freedom«
identity-of-assets-test.cpp
Go to the documentation of this file.
1 /*
2  IdentityOfAssets(Test) - Asset object identity and versioning
3 
4  Copyright (C) Lumiera.org
5  2008, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 * *****************************************************/
22 
28 #include "include/logging.h"
29 #include "lib/test/run.hpp"
30 #include "lib/util.hpp"
31 
32 #include "steam/assetmanager.hpp"
33 #include "steam/asset/media.hpp"
34 #include "steam/asset/proc.hpp"
35 
38 #include "lib/depend-inject.hpp"
39 
40 using util::isnil;
41 using std::string;
42 
43 
44 namespace steam {
45 namespace asset{
46 namespace test {
47 
48  using MediaAccessMock = lib::DependInject<vault::MediaAccessFacade>
49  ::Local<vault::test::MediaAccessMock>;
50 
51 
52 
53 
54  /*******************************************************************/
59  class IdentityOfAssets_test : public Test
60  {
61  virtual void run(Arg arg)
62  {
64 
65  if (!isnil (arg))
66  dumpAssetManager();
67  TRACE (asset_mem, "leaving IdentityOfAssets_test::run()");
68  }
69 
70 
71 
73 
80  {
81  MediaAccessMock useMockMedia;
82 
83  PM mm1 = asset::Media::create ("test-1.mov", VIDEO);
84 
85  Asset::Ident idi (mm1->ident); // duplicate Ident record
86  PM mm1X = asset::Media::create (idi); // note: we actually don't call any ctor
87  CHECK (mm1 == mm1X); // instead, we got mm1 back.
88 
89  PM mm2 = asset::Media::create (idi,"test-2.mov");
90 
91  CHECK (mm1->getID() == mm2->getID()); // different object, same hash
92 
94  CHECK (aMang.getAsset (mm1->getID()) == mm2); // record of mm1 was replaced by mm2
95  CHECK (aMang.getAsset (mm2->getID()) == mm2);
96 
97  CHECK (aMang.known (mm1->getID()));
98  CHECK (aMang.known (mm2->getID()));
99  CHECK (mm1->ident.name == "test-1");
100  CHECK (mm2->ident.name == "test-1");
101  CHECK (mm1->getFilename() == "test-1.mov");
102  CHECK (mm2->getFilename() == "test-2.mov");
103 
104 
105  TRACE (asset_mem, "leaving test method scope");
106  }
107 
108  };
109 
110 
112  LAUNCHER (IdentityOfAssets_test, "unit asset");
113 
114 
115 
116 }}} // namespace steam::asset::test
Steam-Layer Interface: Asset Lookup and Organisation.
Media data represented a specific kind of Asset.
Definition: run.hpp:49
Per type specific configuration of instances created as service dependencies.
Unit test helper to access an emulated media file.
Facade for the Asset subsystem.
This header is for including and configuring NoBug.
static MediaFactory create
storage for the static MediaFactory instance
Definition: media.hpp:84
Steam-Layer implementation namespace root.
static lib::Depend< AssetManager > instance
get at the system-wide asset manager instance.
This framework allows to (re)configure the lib::Depend front-end for dependency-injection.
Data processing Plugins and Codecs can be treated as a specific Kind of Asset.
a POD comprised of all the information sufficiently identifying any given Asset.
Definition: asset.hpp:158
Simple test class runner.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
Small helper and diagnostic functions related to Asset and AssetManager.
The asset subsystem of the Steam-Layer.
Definition: wrapperptr.hpp:44