From 54187dd7ef51778089e85db28f6ff5627d95b3bf Mon Sep 17 00:00:00 2001 From: Alexandre Savard <alexandre.savard@savoirfairelinux.com> Date: Fri, 1 Oct 2010 15:36:42 -0400 Subject: [PATCH] [#4233] --- sflphone-common/test/sflphoned-sample.yml | 4 +- sflphone-common/test/siptest.cpp | 55 ++++++++++++++++------- sflphone-common/test/siptest.h | 9 ++-- 3 files changed, 48 insertions(+), 20 deletions(-) diff --git a/sflphone-common/test/sflphoned-sample.yml b/sflphone-common/test/sflphoned-sample.yml index 1ff29e0eab..bcd9d156cf 100644 --- a/sflphone-common/test/sflphoned-sample.yml +++ b/sflphone-common/test/sflphoned-sample.yml @@ -11,7 +11,7 @@ accounts: hostname: id: IP2IP interface: default - mailbox: 97 + mailbox: password: port: 5060 publishAddr: @@ -54,7 +54,7 @@ preferences: historyMaxCalls: 20 md5Hash: false notifyMails: false - order: Account:1285624877/Account:1285265589/Account:1285257971/Account:1285253592/Account:1285252571/Account:1285251984/Account:1285251811/Account:1285251597/Account:1285192081/Account:1285184087/Account:1285182355/ + order: portNum: 5060 registrationExpire: 180 searchBarDisplay: true diff --git a/sflphone-common/test/siptest.cpp b/sflphone-common/test/siptest.cpp index 99c390dea0..2a32a84c86 100644 --- a/sflphone-common/test/siptest.cpp +++ b/sflphone-common/test/siptest.cpp @@ -248,17 +248,19 @@ void SIPTest::testTwoOutgoingIpCall () std::cout << "SIPTest: completed join with thread" << std::endl; } -/* void SIPTest::testTwoIncomingIpCall () { - pthread_t thethread; + pthread_t firstCallThread, secondCallThread; void *status; + // the first call is supposed to be put on hold when answering teh second incoming call + std::string firstCallCommand("sipp -sf sippxml/test_2.xml 127.0.0.1 -i 127.0.0.1 -p 5064 -m 1"); + // command to be executed by the thread, user agent client which initiate a call and hangup - std::string command("sipp -sn uac 127.0.0.1 -i 127.0.0.1 -p 5062 -m 1"); + std::string secondCallCommand("sipp -sn uac 127.0.0.1 -i 127.0.0.1 -p 5062 -m 1 -d 1000"); - int rc = pthread_create(&thethread, NULL, sippThread, (void *)(&command)); + int rc = pthread_create(&firstCallThread, NULL, sippThread, (void *)(&firstCallCommand)); if (rc) { std::cout << "SIPTest: ERROR; return code from pthread_create()" << std::endl; } @@ -269,26 +271,49 @@ void SIPTest::testTwoIncomingIpCall () sleep(2); // gtrab call id from sipvoiplink - SIPVoIPLink *siplink = SIPVoIPLink::instance (""); - - CPPUNIT_ASSERT(siplink->_callMap.size() == 1); - CallMap::iterator iterCallId = siplink->_callMap.begin(); - std::string testcallid = iterCallId->first; + SIPVoIPLink *sipLink = SIPVoIPLink::instance (""); - // TODO: hmmm, should IP2IP call be stored in call list.... - CPPUNIT_ASSERT(Manager::instance().getCallList().size() == 0); + CPPUNIT_ASSERT(sipLink->_callMap.size() == 1); + CallMap::iterator iterCallId = sipLink->_callMap.begin(); + std::string firstCallID = iterCallId->first; // Answer this call - CPPUNIT_ASSERT(Manager::instance().answerCall(testcallid)); + CPPUNIT_ASSERT(Manager::instance().answerCall(firstCallID)); + sleep(1); + + rc = pthread_create(&secondCallThread, NULL, sippThread, (void *)(&secondCallCommand)); + if(rc) { + std::cout << "SIPTest: Error; return code from pthread_create()" << std::endl; + } sleep(1); - rc = pthread_join(thethread, &status); + CPPUNIT_ASSERT(sipLink->_callMap.size() == 2); + iterCallId = sipLink->_callMap.begin(); + if(iterCallId->first == firstCallID) + iterCallId++; + std::string secondCallID = iterCallId->first; + + CPPUNIT_ASSERT(Manager::instance().answerCall(secondCallID)); + + + rc = pthread_join(firstCallThread, &status); if (rc) { std::cout << "SIPTest: ERROR; return code from pthread_join(): " << rc << std::endl; } else - std::cout << "SIPTest: completed join with thread" << std::endl; + std::cout << "SIPTest: completed join with thread 1" << std::endl; + + rc = pthread_join(secondCallThread, &status); + if (rc) { + std::cout << "SIPTest: ERROR; return code from pthread_join(): " << rc << std::endl; + } + else + std::cout << "SIPTest: completed join with thread 2" << std::endl; + + + + std::cout << "---------------------------" << std::endl; } -*/ + diff --git a/sflphone-common/test/siptest.h b/sflphone-common/test/siptest.h index d6b4801514..b1da9e762e 100644 --- a/sflphone-common/test/siptest.h +++ b/sflphone-common/test/siptest.h @@ -53,9 +53,10 @@ class SIPTest : public CppUnit::TestCase { * Use cppunit library macros to add unit test the factory */ CPPUNIT_TEST_SUITE( SIPTest ); - CPPUNIT_TEST ( testSimpleOutgoingIpCall ); - CPPUNIT_TEST ( testSimpleIncomingIpCall ); - CPPUNIT_TEST( testTwoOutgoingIpCall ); + // CPPUNIT_TEST ( testSimpleOutgoingIpCall ); + // CPPUNIT_TEST ( testSimpleIncomingIpCall ); + // CPPUNIT_TEST ( testTwoOutgoingIpCall ); + CPPUNIT_TEST ( testTwoIncomingIpCall ); CPPUNIT_TEST_SUITE_END(); public: @@ -80,6 +81,8 @@ class SIPTest : public CppUnit::TestCase { void testTwoOutgoingIpCall(void); + void testTwoIncomingIpCall(void); + private: }; -- GitLab