PPI: Started real Connectors.test.cc implementation
[senf.git] / PPI / Connectors.test.cc
1 // $Id$
2 //
3 // Copyright (C) 2007 
4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 //     Stefan Bund <g0dil@berlios.de>
7 //
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
23 /** \file
24     \brief Connectors.test unit tests */
25
26 //#include "Connectors.test.hh"
27 //#include "Connectors.test.ih"
28
29 // Custom includes
30 #include "Connectors.hh"
31 #include "DebugModules.hh"
32 #include "Setup.hh"
33
34 #include <boost/test/auto_unit_test.hpp>
35 #include <boost/test/test_tools.hpp>
36
37 #define prefix_
38 ///////////////////////////////cc.p////////////////////////////////////////
39
40 namespace debug = senf::ppi::module::debug;
41 namespace ppi = senf::ppi;
42
43 // For each type of connector we use the corresponding debug module. Additionally, we always need
44 // the corresponding connected module since otherwise the connectors cannot be connected anywhere
45 // and will be unusable.
46
47 BOOST_AUTO_UNIT_TEST(connector)
48 {
49     // It doesn't matter, which type of connectors we use here since they are all based on
50     // Connector.
51
52     debug::ActivePacketSource source;
53     debug::PassivePacketSink target;
54
55     ppi::connect(source.output,target.input);
56
57     BOOST_CHECK_EQUAL( & source.output.module(), & source );
58     BOOST_CHECK_EQUAL( & target.input.module(), & target );
59     BOOST_CHECK_EQUAL( & source.output.peer(), & target.input );
60     BOOST_CHECK_EQUAL( & target.input.peer(), & source.output );
61 }
62
63 BOOST_AUTO_UNIT_TEST(passiveConnector)
64 {
65     debug::ActivePacketSource source;
66     debug::PassivePacketSink target;
67
68     ppi::connect(source.output,target.input);
69
70     // onRequest is implicitly tested within the PassivePacketSink implementation which is tested
71     // in DebugModules.test.cc
72
73 #if 0
74     target.input.throttle();
75     BOOST_CHECK( target.input.throttled() );
76     BOOST_CHECK( target.input.nativeThrottled() );
77     
78     target.input.unthrottle();
79     BOOST_CHECK( ! target.input.throttled() );
80     BOOST_CHECK( ! target.input.nativeThrottled() );
81 #endif
82 }
83
84 ///////////////////////////////cc.e////////////////////////////////////////
85 #undef prefix_
86
87 \f
88 // Local Variables:
89 // mode: c++
90 // fill-column: 100
91 // comment-column: 40
92 // c-file-style: "senf"
93 // indent-tabs-mode: nil
94 // ispell-local-dictionary: "american"
95 // compile-command: "scons -u test"
96 // End: