Lumiera  0.pre.03
»edityourfreedom«
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 "proc/asset/category.hpp"
33 #include "proc/asset/media.hpp"
37 #include "lib/depend-inject.hpp"
38 #include "lib/format-cout.hpp"
39 #include "lib/util.hpp"
40 
41 using util::cStr;
42 using std::string;
43 
44 
45 
46 namespace proc {
47 namespace mobject {
48 namespace builder {
49 namespace test {
50 
51  using session::Clip;
52  using session::AbstractMO;
53  using namespace mobject::test;
54 
56  ::Local<backend::test::MediaAccessMock>;
57 
58 
59 
71  class TestTool
72  : public Applicable<TestTool, Types<Clip, DummyMO>::List>
73  {
74  public:
75  string log_;
76 
77  void treat (Clip& c)
78  {
79  Placement<Clip>& pC = getPlacement<Clip>();
80  cout << "Clip on media : "<< pC->getMedia() <<"\n";
81  CHECK (pC->operator==(c));
82  log_ = string (pC);
83  }
84  void treat (AbstractMO&)
85  {
86  cout << "treat (AbstractMO&);\n";
87  log_ = string (getPlacement<MObject>());
88  }
89  void onUnknown (Buildable&)
90  {
91  cout << "catch-all-function called...\n";
92  log_ = string (getPlacement<MObject>());
93  }
94  };
95 
96 
97 
98 
99 
100 
101  /*********************************************************************************/
115  class BuilderTool_test : public Test
116  {
117  virtual void
119  {
120  MediaAccessMock useMockMedia;
121 
122 
123  TestTool t1;
124  BuilderTool& tool = t1;
125 
126  Placement<Clip> clip = asset::Media::create("test-1", asset::VIDEO)->createClip();
127  TestPlacement<> test1(*new TestSubMO1);
128  TestPlacement<> test2(*new TestSubMO2);
129 
130 
131  cout << "apply (tool, clip);\n";
132  apply (tool, clip);
133  INFO (test, "got Wrapper = %s", t1.log_.c_str());
134  CHECK (t1.log_ == string(clip));
135 
136  cout << "apply (tool, test1);\n";
137  apply (tool, test1);
138  INFO (test, "got Wrapper = %s", t1.log_.c_str());
139  CHECK (t1.log_ == string(test1));
140 
141  cout << "apply (tool, test2);\n";
142  apply (tool, test2);
143  INFO (test, "got Wrapper = %s", t1.log_.c_str());
144  CHECK (t1.log_ == string(test2));
145  }
146  };
147 
148 
150  LAUNCHER (BuilderTool_test, "unit builder");
151 
152 
153 
154 }}}} // namespace proc::mobject::builder::test
declare the concrete types a BuilderTool may receive and treat.
A user visible/editable Clip is a reference to a contiguous sequence of media data loaded as Asset in...
Automatically use custom string conversion in C++ stream output.
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.
BuilderTool implementation for checking the invocation of the correct treat() function and for access...
Unit test helper to access an emulated media file.
static MediaFactory create
storage for the static MediaFactory instance
Definition: media.hpp:84
const char * cStr(string const &org)
convenience shortcut: conversion to c-String via string.
Definition: util.hpp:380
MObject in the Session to represent a clip on the timeline.
This framework allows to (re)configure the lib::Depend front-end for dependency-injection.
lib::DependInject< backend::MediaAccessFacade >::Local< backend::test::MediaAccessMock > MediaAccessMock
Visiting-tool mechanism configured specifically for the Builder.
std::vector< string > & Arg
Definition: run.hpp:54
abstract base class of all MObjects for providing common services.
Definition: abstractmo.hpp:48
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.
LAUNCHER(BuildSegment_test,"function builder")
Register this test class...
Subclass-2 is defined "processible", but we omit the necessary "applicable" definition in TestTool...
Proc-Layer implementation namespace root.
Definition: id-scheme.hpp:63
Definition of Asset categorisation.
Configuration handle for temporarily shadowing a dependency by a test mock instance.
Subclass-1 is not defined "processible", thus will always be handled as DummyMO...
Buildable::ReturnType apply(BuilderTool &tool, WRA &wrappedTargetObj)
to be picked up by ADL: redirect tool invocation for double dispatch.