X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=PPI%2FModule.test.cc;h=2f6df29839a26bdbaae6475e4c39b52920f8b25d;hb=fd3a0e8ac95d1158e9ea661ddf9187b67c70169f;hp=ca678443d48da2073151d34f9fd63d3bdb791421;hpb=92f8630b75f3ef50e73c48cde58645dcd1534e27;p=senf.git diff --git a/PPI/Module.test.cc b/PPI/Module.test.cc index ca67844..2f6df29 100644 --- a/PPI/Module.test.cc +++ b/PPI/Module.test.cc @@ -27,6 +27,8 @@ //#include "Module.test.ih" // Custom includes +#include +#include "../Utils/membind.hh" #include "DebugEvent.hh" #include "DebugModules.hh" #include "Setup.hh" @@ -80,6 +82,57 @@ BOOST_AUTO_UNIT_TEST(module) BOOST_CHECK( senf::ClockService::now() - tester.time() < senf::ClockService::seconds(1) ); } +namespace { + + void timeout() { + senf::scheduler::terminate(); + } + + class InitTest : public ppi::module::Module + { + SENF_PPI_MODULE(InitTest); + public: + InitTest() : init (false) {} + void v_init() { init = true; } + + bool init; + }; + + struct MakeInit { + boost::scoped_ptr tester; + void make() { + tester.reset(new InitTest()); + } + void test() { + BOOST_REQUIRE( tester ); + BOOST_CHECK( tester->init ); + } + }; + +} + +BOOST_AUTO_UNIT_TEST(delayedInit) +{ + MakeInit maker; + senf::scheduler::TimerEvent timer ( + "delayedInit timer", + senf::membind(&MakeInit::make, &maker), + senf::ClockService::now() + senf::ClockService::milliseconds(250) ); + senf::scheduler::TimerEvent testTimer ( + "delayedInit test", + senf::membind(&MakeInit::test, &maker), + senf::ClockService::now() + senf::ClockService::milliseconds(500) ); + senf::scheduler::TimerEvent timeoutTimer ( + "delayedInit timeout", + &timeout, + senf::ClockService::now() + senf::ClockService::milliseconds(750) ); + + senf::ppi::run(); + + BOOST_REQUIRE( maker.tester ); + BOOST_CHECK( maker.tester->init ); +} + ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_