X-Git-Url: http://developer.intra2net.com/git/?p=libt2n;a=blobdiff_plain;f=test%2Ftest_fixtures.hxx;fp=test%2Ftest_fixtures.hxx;h=255202e8eb063e336ee98ce46ebbeb0c7ed6fb78;hp=882457c289e29ef3e9b0f491f774757faec2cd4d;hb=df94ded3d8958d9baff6baebc8e0ac85244da31d;hpb=307b5e74c506b609d5c407be0943f45255ab5122 diff --git a/test/test_fixtures.hxx b/test/test_fixtures.hxx index 882457c..255202e 100644 --- a/test/test_fixtures.hxx +++ b/test/test_fixtures.hxx @@ -26,11 +26,40 @@ on this file might be covered by the GNU General Public License. #include #include +#include +#include + class KillChildOnShutdownFixture { protected: pid_t child_pid; + // this is an evil hack to get access to real_write, don't ever do this in an app!!! + class real_write_connection: public libt2n::socket_server_connection + { + public: + void real_write(const std::string& data) + { socket_write(data); } + }; + + // + // common functions used by some tests + // + void send_hello(std::string hello_string, libt2n::socket_server* ss, int conn_id) + { + libt2n::server_connection *sc=ss->get_connection(conn_id); + sc->write(hello_string); + } + + void send_raw_socket(std::string hello_string, libt2n::socket_server* ss, int conn_id) + { + libt2n::socket_server_connection *ssc=dynamic_cast(ss->get_connection(conn_id)); + + // this is an evil hack to get access to real_write, don't ever do this in an app!!! + real_write_connection *rwc=(real_write_connection*)ssc; + rwc->real_write(hello_string); + } + public: KillChildOnShutdownFixture() : child_pid(0)