1 /* $Id: test_pipe.cpp,v 1.6 2006-03-29 13:44:45 adam Exp $
2 Copyright (c) 2005-2006, Index Data.
9 #include <yazpp/socket-manager.h>
17 #define BOOST_AUTO_TEST_MAIN
18 #include <boost/test/auto_unit_test.hpp>
20 using namespace boost::unit_test;
21 namespace mp = metaproxy_1;
23 class Timer : public yazpp_1::ISocketObserver {
25 yazpp_1::ISocketObservable *m_obs;
29 Timer(yazpp_1::ISocketObservable *obs, int duration);
30 void socketNotify(int event);
31 bool timeout() { return m_timeout; };
35 Timer::Timer(yazpp_1::ISocketObservable *obs,
37 m_obs(obs), m_pipe(9122), m_timeout(false)
39 obs->addObserver(m_pipe.read_fd(), this);
40 obs->maskObserver(this, yazpp_1::SOCKET_OBSERVE_READ);
41 obs->timeoutObserver(this, duration);
44 void Timer::socketNotify(int event)
47 m_obs->deleteObserver(this);
50 BOOST_AUTO_UNIT_TEST( test_pipe_1 )
52 yazpp_1::SocketManager mySocketManager;
54 Timer t(&mySocketManager, 0);
56 while (mySocketManager.processEvent() > 0)
59 BOOST_CHECK(t.timeout());
65 * indent-tabs-mode: nil
66 * c-file-style: "stroustrup"
68 * vim: shiftwidth=4 tabstop=8 expandtab