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)
5  2008, Hermann Vosseler <Ichthyostega@web.de>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 * *****************************************************************/
13 
19 #include "lib/test/run.hpp"
20 
23 #include "steam/asset/category.hpp"
24 #include "steam/asset/media.hpp"
28 #include "lib/depend-inject.hpp"
29 #include "lib/format-cout.hpp"
30 #include "lib/util.hpp"
31 
32 using std::string;
33 
34 
35 
36 namespace steam {
37 namespace mobject {
38 namespace builder {
39 namespace test {
40 
41  using session::Clip;
42  using session::AbstractMO;
43  using namespace mobject::test;
44 
45  using MediaAccessMock = lib::DependInject<vault::MediaAccessFacade>
46  ::Local<vault::test::MediaAccessMock>;
47 
48 
49 
61  class TestTool
62  : public Applicable<TestTool, Types<Clip, DummyMO>::List>
63  {
64  public:
65  string log_;
66 
67  void treat (Clip& c)
68  {
69  Placement<Clip>& pC = getPlacement<Clip>();
70  cout << "Clip on media : "<< pC->getMedia() <<"\n";
71  CHECK (pC->operator==(c));
72  log_ = string (pC);
73  }
74  void treat (AbstractMO&)
75  {
76  cout << "treat (AbstractMO&);\n";
77  log_ = string (getPlacement<MObject>());
78  }
79  void onUnknown (Buildable&)
80  {
81  cout << "catch-all-function called...\n";
82  log_ = string (getPlacement<MObject>());
83  }
84  };
85 
86 
87 
88 
89 
90 
91  /*********************************************************************************/
105  class BuilderTool_test : public Test
106  {
107  virtual void
108  run(Arg)
109  {
110  MediaAccessMock useMockMedia;
111 
112 
113  TestTool t1;
114  BuilderTool& tool = t1;
115 
116  Placement<Clip> clip = asset::Media::create("test-1", asset::VIDEO)->createClip();
117  TestPlacement<> test1(*new TestSubMO1);
118  TestPlacement<> test2(*new TestSubMO2);
119 
120 
121  cout << "apply (tool, clip);\n";
122  apply (tool, clip);
123  INFO (test, "got Wrapper = %s", t1.log_.c_str());
124  CHECK (t1.log_ == string(clip));
125 
126  cout << "apply (tool, test1);\n";
127  apply (tool, test1);
128  INFO (test, "got Wrapper = %s", t1.log_.c_str());
129  CHECK (t1.log_ == string(test1));
130 
131  cout << "apply (tool, test2);\n";
132  apply (tool, test2);
133  INFO (test, "got Wrapper = %s", t1.log_.c_str());
134  CHECK (t1.log_ == string(test2));
135  }
136  };
137 
138 
140  LAUNCHER (BuilderTool_test, "unit builder");
141 
142 
143 
144 }}}} // 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:40
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...
Definition: buildertool.hpp:97
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:75
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.
Simplistic 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:39
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.