Lumiera  0.pre.03
»edit your freedom«
builder-tool-test.cpp
Go to the documentation of this file.
1 /*
2  BuilderTool(Test) - specialised visitor used within the builder for processing Placements
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 "lib/test/run.hpp"
29 
32 #include "steam/asset/category.hpp"
33 #include "steam/asset/media.hpp"
37 #include "lib/depend-inject.hpp"
38 #include "lib/format-cout.hpp"
39 #include "lib/util.hpp"
40 
41 using std::string;
42 
43 
44 
45 namespace steam {
46 namespace mobject {
47 namespace builder {
48 namespace test {
49 
50  using session::Clip;
51  using session::AbstractMO;
52  using namespace mobject::test;
53 
54  using MediaAccessMock = lib::DependInject<vault::MediaAccessFacade>
55  ::Local<vault::test::MediaAccessMock>;
56 
57 
58 
70  class TestTool
71  : public Applicable<TestTool, Types<Clip, DummyMO>::List>
72  {
73  public:
74  string log_;
75 
76  void treat (Clip& c)
77  {
78  Placement<Clip>& pC = getPlacement<Clip>();
79  cout << "Clip on media : "<< pC->getMedia() <<"\n";
80  CHECK (pC->operator==(c));
81  log_ = string (pC);
82  }
83  void treat (AbstractMO&)
84  {
85  cout << "treat (AbstractMO&);\n";
86  log_ = string (getPlacement<MObject>());
87  }
88  void onUnknown (Buildable&)
89  {
90  cout << "catch-all-function called...\n";
91  log_ = string (getPlacement<MObject>());
92  }
93  };
94 
95 
96 
97 
98 
99 
100  /*********************************************************************************/
114  class BuilderTool_test : public Test
115  {
116  virtual void
117  run(Arg)
118  {
119  MediaAccessMock useMockMedia;
120 
121 
122  TestTool t1;
123  BuilderTool& tool = t1;
124 
125  Placement<Clip> clip = asset::Media::create("test-1", asset::VIDEO)->createClip();
126  TestPlacement<> test1(*new TestSubMO1);
127  TestPlacement<> test2(*new TestSubMO2);
128 
129 
130  cout << "apply (tool, clip);\n";
131  apply (tool, clip);
132  INFO (test, "got Wrapper = %s", t1.log_.c_str());
133  CHECK (t1.log_ == string(clip));
134 
135  cout << "apply (tool, test1);\n";
136  apply (tool, test1);
137  INFO (test, "got Wrapper = %s", t1.log_.c_str());
138  CHECK (t1.log_ == string(test1));
139 
140  cout << "apply (tool, test2);\n";
141  apply (tool, test2);
142  INFO (test, "got Wrapper = %s", t1.log_.c_str());
143  CHECK (t1.log_ == string(test2));
144  }
145  };
146 
147 
149  LAUNCHER (BuilderTool_test, "unit builder");
150 
151 
152 
153 }}}} // namespace steam::mobject::builder::test
Automatically use custom string conversion in C++ stream output.
Marker Interface for classes visitable by Builder tools.
Subclass-1 is not defined "processible", thus will always be handled as DummyMO...
Media data represented a specific kind of Asset.
Definition: run.hpp:49
Core abstraction: placement of a media object into session context.
Per type specific configuration of instances created as service dependencies.
MObject in the Session to represent a clip on the timeline.
declare the concrete types a BuilderTool may receive and treat.
Unit test helper to access an emulated media file.
Base class of all BuilderTools, used according to the visitor pattern: each Tool contains the concret...
A user visible/editable Clip is a reference to a contiguous sequence of media data loaded as Asset in...
static MediaFactory create
storage for the static MediaFactory instance
Definition: media.hpp:84
Steam-Layer implementation namespace root.
This framework allows to (re)configure the lib::Depend front-end for dependency-injection.
Visiting-tool mechanism configured specifically for the Builder.
Simple test class runner.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
A hierarchy of simple dummy-Media-Objects for easy unit testing.
abstract base class of all MObjects for providing common services.
Definition: abstractmo.hpp:48
BuilderTool implementation for checking the invocation of the correct treat() function and for access...
Subclass-2 is defined "processible", but we omit the necessary "applicable" definition in TestTool...
Definition of Asset categorisation.
Buildable::ReturnType apply(BuilderTool &tool, WRA &wrappedTargetObj)
to be picked up by ADL: redirect tool invocation for double dispatch.