4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Jens Moedeker <jmo@berlios.de>
29 \brief TimerEventProxy.test non-inline non-template implementation */
31 //#include "TimerEventProxy.test.hh"
32 //#include "TimerEventProxy.test.ih"
35 #include "TimerEventProxy.hh"
36 #include "Scheduler.hh"
38 #include <senf/Utils/auto_unit_test.hh>
39 #include <boost/test/test_tools.hpp>
40 #include <boost/random.hpp>
43 //-/////////////////////////////////////////////////////////////////////////////////////////////////
50 void handler(ClockService::clock_type time, int const &id)
55 void run(ClockService::clock_type t) {
56 scheduler::TimerEvent timeout(
57 "test-timeout", &scheduler::terminate, scheduler::now() + t);
63 SENF_AUTO_UNIT_TEST(timerEventProxy)
65 // // abort on watchdog timeout
66 // scheduler::watchdogAbort( true);
67 // scheduler::watchdogTimeout(5000);
69 ClockService::clock_type now (ClockService::now());
71 scheduler::TimerEventProxy<int> timers ("unit-test");
73 // timers.add( t + ClockService::milliseconds(10000), 0 , &handler);
74 timers.add( now + ClockService::milliseconds(800), 4, &handler);
75 timers.add( now + ClockService::milliseconds(200), 1, &handler);
76 BOOST_CHECK( timers.remove( 4));
77 BOOST_CHECK(! timers.remove( 4));
78 BOOST_CHECK_EQUAL( timers.timeout(4), ClockService::clock_type(0));
79 timers.add( now + ClockService::milliseconds(700), 2, &handler);
81 BOOST_CHECK_EQUAL( timers.timeout(1), now + ClockService::milliseconds(200));
82 BOOST_CHECK_EQUAL( timers.timeout(2), now + ClockService::milliseconds(700));
84 timers.add( now + ClockService::milliseconds(800), 2, &handler);
85 BOOST_CHECK_EQUAL( timers.timeout(2), now + ClockService::milliseconds(800));
86 timers.add( now, 4, &handler);
88 run( ClockService::milliseconds( 2000));
90 BOOST_CHECK( mask == 7);
95 //-/////////////////////////////////////////////////////////////////////////////////////////////////
102 // comment-column: 40
103 // c-file-style: "senf"
104 // indent-tabs-mode: nil
105 // ispell-local-dictionary: "american"
106 // compile-command: "scons -u test"