diff --git a/sflphone-common/test/rtpTest.cpp b/sflphone-common/test/rtpTest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..335bb0a40bed53f92411265d2f66a9306bae03a1 --- /dev/null +++ b/sflphone-common/test/rtpTest.cpp @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2009 Savoir-Faire Linux inc. + * Author: Alexandre Savarda <emmanuel.milou@savoirfairelinux.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <stdio.h> +#include <sstream> +#include <ccrtp/rtp.h> + + +#include "rtpTest.h" + +#include <unistd.h> + + +using std::cout; +using std::endl; + + +void RtpTest::setUp(){ + + Manager::instance().initConfigFile(); + Manager::instance().init(); + + CallID cid = "123456"; + + audiortp = new AudioRtp(); + + sipcall = new SIPCall(cid, Call::Incoming, NULL); +} + +void RtpTest::testRtpInit() +{ + + _debug("------ void RtpTest::testRtpInit() ------\n"); + try { + + _debug("-------- Open Rtp Session ----------\n"); + CPPUNIT_ASSERT(audiortp->createNewSession(sipcall) == 0); + + } catch(...) { + + _debug("!!! Exception occured while Oppenning Rtp \n"); + + } + +} + + +void RtpTest::testRtpClose() +{ + + _debug("------ RtpTest::testRtpClose() ------"); + + try { + _debug("------ Close Rtp Session -------\n"); + CPPUNIT_ASSERT(audiortp->closeRtpSession()); + + } catch(...) { + + _debug("!!! Exception occured while closing Rtp \n"); + + } + +} + + +void RtpTest::tearDown(){ + + delete audiortp; audiortp = NULL; +} diff --git a/sflphone-common/test/rtpTest.h b/sflphone-common/test/rtpTest.h new file mode 100644 index 0000000000000000000000000000000000000000..b2d314a1c2968f2e1aa082bc3018ae7eb5158f09 --- /dev/null +++ b/sflphone-common/test/rtpTest.h @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2009 Savoir-Faire Linux inc. + * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +// Cppunit import +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/TestCaller.h> +#include <cppunit/TestCase.h> +#include <cppunit/TestSuite.h> + +#include <assert.h> + +// Application import +#include "manager.h" +#include "audio/audiortp.h" +#include "../src/call.h" +#include "../src/sipcall.h" + +#include "config/config.h" +#include "user_cfg.h" + + + +/* + * @file audiorecorderTest.cpp + * @brief Regroups unitary tests related to the plugin manager. + */ + +#ifndef _RTP_TEST_ +#define _RTP_TEST_ + + + +class RtpTest : public CppUnit::TestCase { + + /* + * Use cppunit library macros to add unit test the factory + */ + CPPUNIT_TEST_SUITE( RtpTest ); + CPPUNIT_TEST( testRtpInit ); + CPPUNIT_TEST( testRtpClose ); + CPPUNIT_TEST_SUITE_END(); + + public: + RtpTest() : CppUnit::TestCase("Audio Layer Tests") {} + + /* + * Code factoring - Common resources can be initialized here. + * This method is called by unitcpp before each test + */ + void setUp(); + + /* + * Code factoring - Common resources can be released here. + * This method is called by unitcpp after each test + */ + inline void tearDown(); + + void testRtpInit(); + + void testRtpClose(); + + private: + + enum CallType {Incoming, Outgoing}; + + ManagerImpl* manager; + + AudioRtp *audiortp; + + SIPCall *sipcall; + +}; + +/* Register our test module */ +CPPUNIT_TEST_SUITE_REGISTRATION( RtpTest ); + +#endif