📄 sipxtapitestcall.cpp
字号:
CPPUNIT_ASSERT_EQUAL(sipxEventListenerRemove(g_hInst, UniversalEventValidatorCallback, &validatorCalling), SIPX_RESULT_SUCCESS) ; CPPUNIT_ASSERT_EQUAL(sipxEventListenerRemove(g_hInst2, AutoAnswerCallback, NULL), SIPX_RESULT_SUCCESS) ; CPPUNIT_ASSERT_EQUAL(sipxEventListenerRemove(g_hInst2, UniversalEventValidatorCallback, &validatorCalled), SIPX_RESULT_SUCCESS) ; CPPUNIT_ASSERT_EQUAL(sipxLineRemove(hLine), SIPX_RESULT_SUCCESS); CPPUNIT_ASSERT_EQUAL(sipxLineRemove(hReceivingLine), SIPX_RESULT_SUCCESS); } OsTask::delay(TEST_DELAY) ; checkForLeaks();}// A calls B, B answers, A mutes and unmutes repeatedly, then hangs upvoid sipXtapiTestSuite::testCallMute() { bool bRC ; EventValidator validatorCalling("testCallMute.calling") ; EventValidator validatorCalled("testCallMute.called") ; for (int iStressFactor = 0; iStressFactor<STRESS_FACTOR; iStressFactor++) { printf("\ntestCallMute (%2d of %2d)", iStressFactor+1, STRESS_FACTOR); SIPX_CALL hCall ; SIPX_LINE hLine ; SIPX_LINE hReceivingLine; validatorCalling.reset() ; validatorCalled.reset() ; // Setup Auto-answer call back resetAutoAnswerCallback() ; sipxEventListenerAdd(g_hInst2, AutoAnswerCallback, NULL) ; sipxEventListenerAdd(g_hInst2, UniversalEventValidatorCallback, &validatorCalled) ; sipxEventListenerAdd(g_hInst, UniversalEventValidatorCallback, &validatorCalling) ; sipxLineAdd(g_hInst2, "sip:foo@127.0.0.1:9100", &hReceivingLine, CONTACT_LOCAL); bRC = validatorCalled.waitForLineEvent(hReceivingLine, LINESTATE_PROVISIONED, LINESTATE_PROVISIONED_NORMAL, true) ; CPPUNIT_ASSERT(bRC) ; createCall(&hLine, &hCall) ; bRC = validatorCalling.waitForLineEvent(hLine, LINESTATE_PROVISIONED, LINESTATE_PROVISIONED_NORMAL, true) ; CPPUNIT_ASSERT(bRC) ; sipxCallConnect(hCall, "sip:foo@127.0.0.1:9100") ; // Validate Calling Side bRC = validatorCalling.waitForCallEvent(hLine, hCall, CALLSTATE_DIALTONE, CALLSTATE_DIALTONE_UNKNOWN, true) ; CPPUNIT_ASSERT(bRC) ; bRC = validatorCalling.waitForCallEvent(hLine, hCall, CALLSTATE_REMOTE_OFFERING, CALLSTATE_REMOTE_OFFERING_NORMAL, true) ; CPPUNIT_ASSERT(bRC) ; bRC = validatorCalling.waitForCallEvent(hLine, hCall, CALLSTATE_REMOTE_ALERTING, CALLSTATE_REMOTE_ALERTING_NORMAL, true) ; CPPUNIT_ASSERT(bRC) ; bRC = validatorCalling.waitForCallEvent(hLine, hCall, CALLSTATE_CONNECTED, CALLSTATE_CONNECTED_ACTIVE, true) ; CPPUNIT_ASSERT(bRC) ; bRC = validatorCalling.waitForCallEvent(hLine, hCall, CALLSTATE_AUDIO_EVENT, CALLSTATE_AUDIO_START, true) ; CPPUNIT_ASSERT(bRC) ; // Validate Called Side bRC = validatorCalled.waitForCallEvent(g_hAutoAnswerCallbackLine, g_hAutoAnswerCallbackCall, CALLSTATE_NEWCALL, CALLSTATE_NEW_CALL_NORMAL, true) ; CPPUNIT_ASSERT(bRC) ; bRC = validatorCalled.waitForCallEvent(g_hAutoAnswerCallbackLine, g_hAutoAnswerCallbackCall, CALLSTATE_OFFERING, CALLSTATE_OFFERING_ACTIVE, true) ; CPPUNIT_ASSERT(bRC) ; bRC = validatorCalled.waitForCallEvent(g_hAutoAnswerCallbackLine, g_hAutoAnswerCallbackCall, CALLSTATE_ALERTING, CALLSTATE_ALERTING_NORMAL, true) ; CPPUNIT_ASSERT(bRC) ; bRC = validatorCalled.waitForCallEvent(g_hAutoAnswerCallbackLine, g_hAutoAnswerCallbackCall, CALLSTATE_CONNECTED, CALLSTATE_CONNECTED_ACTIVE, true) ; CPPUNIT_ASSERT(bRC) ; bRC = validatorCalled.waitForCallEvent(g_hAutoAnswerCallbackLine, g_hAutoAnswerCallbackCall, CALLSTATE_AUDIO_EVENT, CALLSTATE_AUDIO_START, true) ; CPPUNIT_ASSERT(bRC) ; int connectionId = -1; CPPUNIT_ASSERT_EQUAL(sipxCallGetConnectionId(hCall, connectionId), SIPX_RESULT_SUCCESS); CPPUNIT_ASSERT(connectionId != -1) ; // loop 10 times, muting and unmuting for (int i = 0; i < 50; i++) { sipxAudioMute(g_hInst, true); sipxAudioMute(g_hInst, false); } SIPX_CALL hDestroyedCall = hCall ; destroyCall(hCall) ; // Validate Calling Side bRC = validatorCalling.waitForCallEvent(hLine, hDestroyedCall, CALLSTATE_CONNECTED, CALLSTATE_CONNECTED_ACTIVE_HELD, true) ; CPPUNIT_ASSERT(bRC) ; bRC = validatorCalling.waitForCallEvent(hLine, hDestroyedCall, CALLSTATE_AUDIO_EVENT, CALLSTATE_AUDIO_STOP, true) ; CPPUNIT_ASSERT(bRC) ; bRC = validatorCalling.waitForCallEvent(hLine, hDestroyedCall, CALLSTATE_DISCONNECTED, CALLSTATE_DISCONNECTED_NORMAL, true) ; CPPUNIT_ASSERT(bRC) ; bRC = validatorCalling.waitForCallEvent(hLine, hDestroyedCall, CALLSTATE_DESTROYED, CALLSTATE_DESTROYED_NORMAL, true) ; CPPUNIT_ASSERT(bRC) ; // Validate Called Side bRC = validatorCalled.waitForCallEvent(g_hAutoAnswerCallbackLine, g_hAutoAnswerCallbackCall, CALLSTATE_AUDIO_EVENT, CALLSTATE_AUDIO_STOP, true) ; CPPUNIT_ASSERT(bRC) ; bRC = validatorCalled.waitForCallEvent(g_hAutoAnswerCallbackLine, g_hAutoAnswerCallbackCall, CALLSTATE_DISCONNECTED, CALLSTATE_DISCONNECTED_NORMAL, true) ; CPPUNIT_ASSERT(bRC) ; bRC = validatorCalled.waitForCallEvent(g_hAutoAnswerCallbackLine, g_hAutoAnswerCallbackCall, CALLSTATE_DESTROYED, CALLSTATE_DESTROYED_NORMAL, true) ; CPPUNIT_ASSERT(bRC) ; CPPUNIT_ASSERT_EQUAL(sipxEventListenerRemove(g_hInst, UniversalEventValidatorCallback, &validatorCalling), SIPX_RESULT_SUCCESS) ; CPPUNIT_ASSERT_EQUAL(sipxEventListenerRemove(g_hInst2, AutoAnswerCallback, NULL), SIPX_RESULT_SUCCESS) ; CPPUNIT_ASSERT_EQUAL(sipxEventListenerRemove(g_hInst2, UniversalEventValidatorCallback, &validatorCalled), SIPX_RESULT_SUCCESS) ; CPPUNIT_ASSERT_EQUAL(sipxLineRemove(hLine), SIPX_RESULT_SUCCESS); CPPUNIT_ASSERT_EQUAL(sipxLineRemove(hReceivingLine), SIPX_RESULT_SUCCESS); } OsTask::delay(TEST_DELAY) ; checkForLeaks();}// A calls B, B answers, B hangs upvoid sipXtapiTestSuite::testCallBasic2() { bool bRC ; EventValidator validatorCalling("testCallBasic2.calling") ; EventValidator validatorCalled("testCallBasic2.called") ; for (int iStressFactor = 0; iStressFactor<STRESS_FACTOR; iStressFactor++) { printf("\ntestCallBasic2 (%2d of %2d)", iStressFactor+1, STRESS_FACTOR); SIPX_CALL hCall ; SIPX_LINE hLine ; SIPX_LINE hReceivingLine; validatorCalling.reset() ; validatorCalled.reset() ; // Setup Auto-answer call back sipxEventListenerAdd(g_hInst2, AutoAnswerHangupCallback, NULL) ; sipxEventListenerAdd(g_hInst2, UniversalEventValidatorCallback, &validatorCalled) ; sipxEventListenerAdd(g_hInst, UniversalEventValidatorCallback, &validatorCalling) ; sipxLineAdd(g_hInst2, "sip:foo@127.0.0.1:9100", &hReceivingLine, CONTACT_LOCAL); bRC = validatorCalled.waitForLineEvent(hReceivingLine, LINESTATE_PROVISIONED, LINESTATE_PROVISIONED_NORMAL, true) ; CPPUNIT_ASSERT(bRC) ; createCall(&hLine, &hCall) ; bRC = validatorCalling.waitForLineEvent(hLine, LINESTATE_PROVISIONED, LINESTATE_PROVISIONED_NORMAL, true) ; CPPUNIT_ASSERT(bRC) ; sipxCallConnect(hCall, "sip:foo@127.0.0.1:9100") ; // Validate Calling Side bRC = validatorCalling.waitForCallEvent(hLine, hCall, CALLSTATE_DIALTONE, CALLSTATE_DIALTONE_UNKNOWN, true) ; CPPUNIT_ASSERT(bRC) ; bRC = validatorCalling.waitForCallEvent(hLine, hCall, CALLSTATE_REMOTE_OFFERING, CALLSTATE_REMOTE_OFFERING_NORMAL, true) ; CPPUNIT_ASSERT(bRC) ; bRC = validatorCalling.waitForCallEvent(hLine, hCall, CALLSTATE_REMOTE_ALERTING, CALLSTATE_REMOTE_ALERTING_NORMAL, true) ; CPPUNIT_ASSERT(bRC) ; bRC = validatorCalling.waitForCallEvent(hLine, hCall, CALLSTATE_CONNECTED, CALLSTATE_CONNECTED_ACTIVE, true) ; CPPUNIT_ASSERT(bRC) ; bRC = validatorCalling.waitForCallEvent(hLine, hCall, CALLSTATE_AUDIO_EVENT, CALLSTATE_AUDIO_START, true) ; CPPUNIT_ASSERT(bRC) ; // Validate Called Side bRC = validatorCalled.waitForCallEvent(g_hAutoAnswerHangupCallbackLine, g_hAutoAnswerHangupCallbackCall, CALLSTATE_NEWCALL, CALLSTATE_NEW_CALL_NORMAL, true) ; CPPUNIT_ASSERT(bRC) ; bRC = validatorCalled.waitForCallEvent(g_hAutoAnswerHangupCallbackLine, g_hAutoAnswerHangupCallbackCall, CALLSTATE_OFFERING, CALLSTATE_OFFERING_ACTIVE, true) ; CPPUNIT_ASSERT(bRC) ; bRC = validatorCalled.waitForCallEvent(g_hAutoAnswerHangupCallbackLine, g_hAutoAnswerHangupCallbackCall, CALLSTATE_ALERTING, CALLSTATE_ALERTING_NORMAL, true) ; CPPUNIT_ASSERT(bRC) ; bRC = validatorCalled.waitForCallEvent(g_hAutoAnswerHangupCallbackLine, g_hAutoAnswerHangupCallbackCall, CALLSTATE_CONNECTED, CALLSTATE_CONNECTED_ACTIVE, true) ; CPPUNIT_ASSERT(bRC) ; bRC = validatorCalled.waitForCallEvent(g_hAutoAnswerHangupCallbackLine, g_hAutoAnswerHangupCallbackCall, CALLSTATE_AUDIO_EVENT, CALLSTATE_AUDIO_START, true) ; CPPUNIT_ASSERT(bRC) ; // Called side with automatically hang up bRC = validatorCalled.waitForCallEvent(g_hAutoAnswerHangupCallbackLine, g_hAutoAnswerHangupCallbackCall, CALLSTATE_AUDIO_EVENT, CALLSTATE_AUDIO_STOP, true) ; CPPUNIT_ASSERT(bRC) ; bRC = validatorCalled.waitForCallEvent(g_hAutoAnswerHangupCallbackLine, g_hAutoAnswerHangupCallbackCall, CALLSTATE_DISCONNECTED, CALLSTATE_DISCONNECTED_NORMAL, true) ; CPPUNIT_ASSERT(bRC) ; bRC = validatorCalled.waitForCallEvent(g_hAutoAnswerHangupCallbackLine, g_hAutoAnswerHangupCallbackCall, CALLSTATE_DESTROYED, CALLSTATE_DESTROYED_NORMAL, true) ; CPPUNIT_ASSERT(bRC) ; // Calling side should disconnect bRC = validatorCalling.waitForCallEvent(hLine, hCall, CALLSTATE_AUDIO_EVENT, CALLSTATE_AUDIO_STOP, true) ; CPPUNIT_ASSERT(bRC) ; bRC = validatorCalling.waitForCallEvent(hLine, hCall, CALLSTATE_DISCONNECTED, CALLSTATE_DISCONNECTED_NORMAL, true) ; CPPUNIT_ASSERT(bRC) ; SIPX_CALL hDestroyedCall = hCall ; destroyCall(hCall) ; // Finally, calling side is cleaned up bRC = validatorCalling.waitForCallEvent(hLine, hDestroyedCall, CALLSTATE_DESTROYED, CALLSTATE_DESTROYED_NORMAL, true) ; CPPUNIT_ASSERT(bRC) ; CPPUNIT_ASSERT_EQUAL(sipxEventListenerRemove(g_hInst, UniversalEventValidatorCallback, &validatorCalling), SIPX_RESULT_SUCCESS) ; CPPUNIT_ASSERT_EQUAL(sipxEventListenerRemove(g_hInst2, AutoAnswerHangupCallback, NULL), SIPX_RESULT_SUCCESS) ; CPPUNIT_ASSERT_EQUAL(sipxEventListenerRemove(g_hInst2, UniversalEventValidatorCallback, &validatorCalled), SIPX_RESULT_SUCCESS) ; CPPUNIT_ASSERT_EQUAL(sipxLineRemove(hLine), SIPX_RESULT_SUCCESS); CPPUNIT_ASSERT_EQUAL(sipxLineRemove(hReceivingLine), SIPX_RESULT_SUCCESS); } OsTask::delay(TEST_DELAY) ; checkForLeaks() ;}// Send a message in the dialog of the existing call// This is not strictly a sipXtapi feature, but it is easiest to// test using sipXtapi to set up the call/dialog in which to send// the message.void sipXtapiTestSuite::testInDialogSipRequest() { bool bRC ; EventValidator validatorCalling("testInDialogSipRequest.calling") ; EventValidator validatorCalled("testInDialogSipRequest.called") ; // Use a different queue for each run to avoid interferance and to // avoid having to have a transaction delay for each run. This way // we just have one delay at the end when we clean up. OsMsgQ* responseReceiveQueue[STRESS_FACTOR]; int iStressFactor; for (iStressFactor = 0; iStressFactor<STRESS_FACTOR; iStressFactor++) { responseReceiveQueue[iStressFactor] = NULL; } for (iStressFactor = 0; iStressFactor<STRESS_FACTOR; iStressFactor++) { printf("\ntestInDialogSipRequest (%2d of %2d)", iStressFactor+1, STRESS_FACTOR); SIPX_CALL hCall ; SIPX_LINE hLine ; SIPX_LINE hReceivingLine; validatorCalling.reset() ; validatorCalled.reset() ; // Setup Auto-answer call back resetAutoAnswerCallback() ; sipxEventListenerAdd(g_hInst2, AutoAnswerCallback, NULL) ; sipxEventListenerAdd(g_hInst2, UniversalEventValidatorCallback, &validatorCalled) ; sipxEventListenerAdd(g_hInst, UniversalEventValidatorCallback, &validatorCalling) ; sipxLineAdd(g_hInst2, "sip:foo@127.0.0.1:9100", &hReceivingLine, CONTACT_LOCAL); bRC = validatorCalled.waitForLineEvent(hReceivingLine, LINESTATE_PROVISIONED, LINESTATE_PROVISIONED_NORMAL, true) ; CPPUNIT_ASSERT(bRC) ; createCall(&hLine, &hCall) ; bRC = validatorCalling.waitForLineEvent(hLine, LINESTATE_PROVISIONED, LINESTATE_PROVISIONED_NORMAL, true) ; CPPUNIT_ASSERT(bRC) ; sipxCallConnect(hCall, "sip:foo@127.0.0.1:9100") ; // Validate Calling Side
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -