Skip to content
Snippets Groups Projects
Commit 54e6b0da authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#4123] Add single outgoing call unit test

parent ac4a8a89
No related branches found
No related tags found
No related merge requests found
...@@ -3687,6 +3687,8 @@ CallID ManagerImpl::getNewCallID () ...@@ -3687,6 +3687,8 @@ CallID ManagerImpl::getNewCallID ()
random_id << (unsigned) rand(); random_id << (unsigned) rand();
} }
_lastCallID = random_id.str();
return random_id.str(); return random_id.str();
} }
......
...@@ -1426,11 +1426,13 @@ class ManagerImpl ...@@ -1426,11 +1426,13 @@ class ManagerImpl
Conf::YamlParser *parser; Conf::YamlParser *parser;
Conf::YamlEmitter *emitter; Conf::YamlEmitter *emitter;
std::string _lastCallID;
#ifdef TEST #ifdef TEST
bool testCallAccountMap(); bool testCallAccountMap();
bool testAccountMap(); bool testAccountMap();
#endif #endif
friend class SipTest; friend class SIPTest;
friend class ConfigurationTest; friend class ConfigurationTest;
friend class HistoryTest; friend class HistoryTest;
}; };
......
...@@ -85,6 +85,7 @@ void SIPTest::testSimpleOutgoingIpCall () ...@@ -85,6 +85,7 @@ void SIPTest::testSimpleOutgoingIpCall ()
pthread_t thethread; pthread_t thethread;
void *status; void *status;
// command to be executed by the thread
std::string command("sipp -sn uas -i 127.0.0.1 -p 5062 -m 1"); std::string command("sipp -sn uas -i 127.0.0.1 -p 5062 -m 1");
int rc = pthread_create(&thethread, NULL, sippThread, (void *)(&command)); int rc = pthread_create(&thethread, NULL, sippThread, (void *)(&command));
...@@ -137,3 +138,45 @@ void SIPTest::testSimpleOutgoingIpCall () ...@@ -137,3 +138,45 @@ void SIPTest::testSimpleOutgoingIpCall ()
} }
void SIPTest::testSimpleIncomingIpCall ()
{
pthread_t thethread;
void *status;
// command to be executed by the thread
std::string command("sipp -sn uac 127.0.0.1 -i 127.0.0.1 -p 5062 -m 1");
int rc = pthread_create(&thethread, NULL, sippThread, (void *)(&command));
if (rc) {
std::cout << "SIPTest: ERROR; return code from pthread_create()" << std::endl;
}
// sleep a while to make sure that sipp insdtance is initialized and sflphoned received
// the incoming invite.
sleep(2);
// CallList should not be used if receiving only one call
CPPUNIT_ASSERT(Manager::instance().getCallList().size() == 0);
// CPPUNIT_ASSERT(Manager::instance()._callAccountMap.size() == 1);
// TODO: hmmm, need to find a better way to retreive the call id
// std::map<std::string, std::string>::iterator iterCallId = Manager::instance()._callAccountMap.begin();
// CPPUNIT_ASSERT(iterCallId != Manager::instance()._callAccountMap.end());
std::string testcallid = Manager::instance()._lastCallID;
CPPUNIT_ASSERT(Manager::instance().answerCall(testcallid));
sleep(2);
rc = pthread_join(thethread, &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;
}
...@@ -54,6 +54,7 @@ class SIPTest : public CppUnit::TestCase { ...@@ -54,6 +54,7 @@ class SIPTest : public CppUnit::TestCase {
*/ */
CPPUNIT_TEST_SUITE( SIPTest ); CPPUNIT_TEST_SUITE( SIPTest );
CPPUNIT_TEST ( testSimpleOutgoingIpCall ); CPPUNIT_TEST ( testSimpleOutgoingIpCall );
CPPUNIT_TEST ( testSimpleIncomingIpCall );
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
public: public:
...@@ -74,6 +75,8 @@ class SIPTest : public CppUnit::TestCase { ...@@ -74,6 +75,8 @@ class SIPTest : public CppUnit::TestCase {
void testSimpleOutgoingIpCall(void); void testSimpleOutgoingIpCall(void);
void testSimpleIncomingIpCall(void);
private: private:
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment