Lumiera  0.pre.03
»edit your freedom«
stream-type-basics-test.cpp
Go to the documentation of this file.
1 /*
2  StreamTypeBasics(Test) - check the fundamentals of stream type information
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 #include "lib/util.hpp"
30 
32 #include "teststreamtypes.hpp"
33 
34 using ::test::Test;
35 using util::isnil;
36 
37 
38 namespace steam {
39 namespace test_format {
40 
41  using control::STypeManager;
42  typedef StreamType const& SType;
43  typedef StreamType::ImplFacade const& ImplType;
44 
45 
46  /***************************************************************/
52  class StreamTypeBasics_test : public Test
53  {
54  virtual void
55  run (Arg)
56  {
57  ImplType iType = buildImplType ();
58  basicImplTypeProperties (iType);
59 
60  SType type = extend2fullType (iType);
61  basicStreamTypeProperties (type, iType);
62  }
63 
64  ImplType
65  buildImplType ()
66  {
67  STypeManager& typeManager = STypeManager::instance();
68 
69  gavl_video_format_t rawType = test_createRawType();
70  ImplType iTy (typeManager.getImpl (GAVL, rawType));
71 
72  UNIMPLEMENTED ("at least preliminary implementation of the MediaImplLib interface for lib GAVL");
73 
74  TODO ("how to do a simple consistency check on the returned ImplFacade? can we re-create the GAVL frame type?");
75  CHECK (GAVL==iTy.libraryID);
76  return iTy;
77  }
78 
79  void
80  basicImplTypeProperties (ImplType refType)
81  {
82  ImplType iTy2 = test_createImplType ();
83  CHECK (iTy2==refType);
84  CHECK (refType==iTy2);
85  TODO ("add equality comparable concept to the ImplType class");
86 
87  CHECK (StreamType::VIDEO==refType.getKind());
88  UNIMPLEMENTED ("get a lib descriptor");
89  UNIMPLEMENTED ("check the lib of the type");
90  UNIMPLEMENTED ("compare two types");
91  }
92 
93  SType
94  extend2fullType (ImplType iTy)
95  {
96  return STypeManager::instance().getType(iTy);
97  }
98 
99  void
100  basicStreamTypeProperties (SType type, ImplType iTy)
101  {
102  CHECK (type.implType);
103  CHECK (iTy==(*type.implType));
104  CHECK (&iTy==type.implType); // actually using the same object (in the registry)
105 
106  CHECK (!isnil (type.prototype.id));
107  CHECK (StreamType::VIDEO==type.prototype.kind);
108  CHECK (StreamType::VIDEO==type.implType->getKind());
109 
110  CHECK (type.implType->canConvert(iTy)); // of course... they are actually the same
111  CHECK (iTy.canConvert(type)); // because it's based on the same impl type
112 
113  CHECK (StreamType::RAW==type.intentionTag);
114  }
115  };
116 
117  LAUNCHER (StreamTypeBasics_test, "unit common");
118 
119 
120 }} // namespace steam::test_format
121 
ImplFacade const & getImpl(Symbol libID, StreamType::Prototype const &protoType)
build or retrieve an implementation (facade) utilizing a specific MediaImplLib and implementing the g...
Steam-Layer implementation namespace root.
Interface to the stream type system.
static lib::Depend< STypeManager > instance
access the system-wide stream type manager instance.
gavl_video_format_t test_createRawType()
Helper: create an raw GAVL type descriptor usable for generating a Lumiera StreamType.
Unit test helper to create fake streamtype information.
Simple test class runner.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
StreamType::ImplFacade const & test_createImplType()
Helper: create an implementation frame and build the corresponding streamtype.