diff --git a/sflphone-common/test/sflphoned-sample.yml b/sflphone-common/test/sflphoned-sample.yml index 1ff29e0eab1037a4230955471570c8ed7fc29f45..bcd9d156cf05ea2063707e6e83bc6ae59329ef5c 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 99c390dea0189d20bba7d5276424beb4d2cd7f72..2a32a84c86ad867b7cc7f5003c172d2a50e8c6d0 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 d6b480151488000438138bb1fd65cc270f0ecb02..b1da9e762e5d0effab2b956448133f7a3348eb08 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: };