From ba1318d8cb5506a848f18838d58b5f224e1666b1 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Mon, 11 Feb 2013 18:16:40 +0100 Subject: [PATCH] add conferencing test --- tester/call_tester.c | 98 +++++++++++++++++++++++++++++++++---- tester/laure_rc | 38 ++++++++++++++ tester/liblinphone_tester.c | 17 +++++-- tester/liblinphone_tester.h | 2 +- tester/userdb.conf | 1 + 5 files changed, 143 insertions(+), 13 deletions(-) create mode 100644 tester/laure_rc diff --git a/tester/call_tester.c b/tester/call_tester.c index bc9a75b98..3dd9cb0ca 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -75,6 +75,9 @@ static bool_t call(LinphoneCoreManager* caller_mgr,LinphoneCoreManager* callee_m LinphoneProxyConfig* proxy; linphone_core_get_default_proxy(callee_mgr->lc,&proxy); int retry=0; + stats initial_caller=caller_mgr->stat; + stats initial_callee=callee_mgr->stat; + CU_ASSERT_PTR_NOT_NULL_FATAL(proxy); @@ -82,19 +85,25 @@ static bool_t call(LinphoneCoreManager* caller_mgr,LinphoneCoreManager* callee_m /*linphone_core_invite(caller_mgr->lc,"pauline");*/ - CU_ASSERT_TRUE_FATAL(wait_for(callee_mgr->lc,caller_mgr->lc,&callee_mgr->stat.number_of_LinphoneCallIncomingReceived,1)); + CU_ASSERT_TRUE_FATAL(wait_for(callee_mgr->lc + ,caller_mgr->lc + ,&callee_mgr->stat.number_of_LinphoneCallIncomingReceived + ,initial_callee.number_of_LinphoneCallIncomingReceived+1)); CU_ASSERT_TRUE(linphone_core_inc_invite_pending(callee_mgr->lc)); - CU_ASSERT_EQUAL(caller_mgr->stat.number_of_LinphoneCallOutgoingProgress,1); + CU_ASSERT_EQUAL(caller_mgr->stat.number_of_LinphoneCallOutgoingProgress,initial_caller.number_of_LinphoneCallOutgoingProgress+1); - while ((caller_mgr->stat.number_of_LinphoneCallOutgoingRinging<1 - || caller_mgr->stat.number_of_LinphoneCallOutgoingEarlyMedia<1) && retry++ <20) { + + while (caller_mgr->stat.number_of_LinphoneCallOutgoingRinging!=(initial_caller.number_of_LinphoneCallOutgoingRinging + 1) + && caller_mgr->stat.number_of_LinphoneCallOutgoingEarlyMedia!=(initial_caller.number_of_LinphoneCallOutgoingEarlyMedia +1) + && retry++ <20) { linphone_core_iterate(caller_mgr->lc); linphone_core_iterate(callee_mgr->lc); ms_usleep(100000); } - CU_ASSERT_TRUE_FATAL(caller_mgr->stat.number_of_LinphoneCallOutgoingRinging|caller_mgr->stat.number_of_LinphoneCallOutgoingEarlyMedia); + CU_ASSERT_TRUE_FATAL((caller_mgr->stat.number_of_LinphoneCallOutgoingRinging==initial_caller.number_of_LinphoneCallOutgoingRinging+1) + |(caller_mgr->stat.number_of_LinphoneCallOutgoingEarlyMedia==initial_caller.number_of_LinphoneCallOutgoingEarlyMedia+1)); linphone_core_get_default_proxy(caller_mgr->lc,&proxy); CU_ASSERT_PTR_NOT_NULL_FATAL(proxy); @@ -104,12 +113,12 @@ static bool_t call(LinphoneCoreManager* caller_mgr,LinphoneCoreManager* callee_m linphone_core_accept_call(callee_mgr->lc,linphone_core_get_current_call(callee_mgr->lc)); - CU_ASSERT_TRUE_FATAL(wait_for(callee_mgr->lc,caller_mgr->lc,&callee_mgr->stat.number_of_LinphoneCallConnected,1)); - CU_ASSERT_TRUE_FATAL(wait_for(callee_mgr->lc,caller_mgr->lc,&caller_mgr->stat.number_of_LinphoneCallConnected,1)); + CU_ASSERT_TRUE_FATAL(wait_for(callee_mgr->lc,caller_mgr->lc,&callee_mgr->stat.number_of_LinphoneCallConnected,initial_callee.number_of_LinphoneCallConnected+1)); + CU_ASSERT_TRUE_FATAL(wait_for(callee_mgr->lc,caller_mgr->lc,&caller_mgr->stat.number_of_LinphoneCallConnected,initial_callee.number_of_LinphoneCallConnected+1)); /*just to sleep*/ - return wait_for(callee_mgr->lc,caller_mgr->lc,&caller_mgr->stat.number_of_LinphoneCallStreamsRunning,1) + return wait_for(callee_mgr->lc,caller_mgr->lc,&caller_mgr->stat.number_of_LinphoneCallStreamsRunning,initial_caller.number_of_LinphoneCallStreamsRunning+1) && - wait_for(callee_mgr->lc,caller_mgr->lc,&callee_mgr->stat.number_of_LinphoneCallStreamsRunning,1); + wait_for(callee_mgr->lc,caller_mgr->lc,&callee_mgr->stat.number_of_LinphoneCallStreamsRunning,initial_callee.number_of_LinphoneCallStreamsRunning+1); } static void simple_call() { @@ -247,6 +256,17 @@ static void call_paused_resumed() { linphone_core_manager_destroy(pauline); } +static bool_t pause_call_1(LinphoneCoreManager* mgr_1,LinphoneCall* call_1,LinphoneCoreManager* mgr_2,LinphoneCall* call_2) { + stats initial_call_stat_1=mgr_1->stat; + stats initial_call_stat_2=mgr_2->stat; + linphone_core_pause_call(mgr_1->lc,call_1); + CU_ASSERT_TRUE(wait_for(mgr_1->lc,mgr_2->lc,&mgr_1->stat.number_of_LinphoneCallPausing,initial_call_stat_1.number_of_LinphoneCallPausing+1)); + CU_ASSERT_TRUE(wait_for(mgr_1->lc,mgr_2->lc,&mgr_1->stat.number_of_LinphoneCallPaused,initial_call_stat_1.number_of_LinphoneCallPaused+1)); + CU_ASSERT_TRUE(wait_for(mgr_1->lc,mgr_2->lc,&mgr_2->stat.number_of_LinphoneCallPausedByRemote,initial_call_stat_2.number_of_LinphoneCallPausedByRemote+1)); + CU_ASSERT_EQUAL(linphone_call_get_state(call_1),LinphoneCallPaused); + CU_ASSERT_EQUAL(linphone_call_get_state(call_2),LinphoneCallPausedByRemote); + return linphone_call_get_state(call_1) == LinphoneCallPaused && linphone_call_get_state(call_2)==LinphoneCallPausedByRemote; +} static void call_paused_resumed_from_callee() { LinphoneCoreManager* marie = linphone_core_manager_new("./tester/marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new("./tester/pauline_rc"); @@ -314,6 +334,63 @@ static void call_with_video_added() { linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } +static void simple_conference() { + LinphoneCoreManager* marie = linphone_core_manager_new("./tester/marie_rc"); + stats initial_marie_stat; + stats initial_pauline_stat; + stats initial_laure_stat; + LinphoneCoreManager* pauline = linphone_core_manager_new("./tester/pauline_rc"); + LinphoneCoreManager* laure = linphone_core_manager_new("./tester/laure_rc"); + + MSList* lcs=ms_list_append(NULL,marie->lc); + lcs=ms_list_append(lcs,pauline->lc); + lcs=ms_list_append(lcs,laure->lc); + + LinphoneCall* marie_call_pauline; + LinphoneCall* pauline_called_by_marie; + LinphoneCall* marie_call_laure; + + CU_ASSERT_TRUE(call(marie,pauline)); + marie_call_pauline=linphone_core_get_current_call(marie->lc); + pauline_called_by_marie=linphone_core_get_current_call(pauline->lc); + CU_ASSERT_TRUE(pause_call_1(marie,marie_call_pauline,pauline,pauline_called_by_marie)); + + CU_ASSERT_TRUE(call(marie,laure)); + initial_marie_stat=marie->stat; + initial_pauline_stat=pauline->stat; + initial_laure_stat=laure->stat; + + marie_call_laure=linphone_core_get_current_call(marie->lc); + + linphone_core_add_to_conference(marie->lc,marie_call_laure); + CU_ASSERT_TRUE(wait_for(marie->lc,laure->lc,&marie->stat.number_of_LinphoneCallUpdating,initial_marie_stat.number_of_LinphoneCallUpdating+1)); + + + + linphone_core_add_to_conference(marie->lc,marie_call_pauline); + + CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallResuming,initial_marie_stat.number_of_LinphoneCallResuming+1,2000)); + + CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallStreamsRunning,initial_pauline_stat.number_of_LinphoneCallStreamsRunning+1,2000)); + CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallStreamsRunning,initial_marie_stat.number_of_LinphoneCallStreamsRunning+2,2000)); + CU_ASSERT_TRUE(wait_for_list(lcs,&laure->stat.number_of_LinphoneCallStreamsRunning,initial_laure_stat.number_of_LinphoneCallStreamsRunning+1,2000)); + + CU_ASSERT_TRUE(linphone_core_is_in_conference(marie->lc)); + CU_ASSERT_EQUAL(linphone_core_get_conference_size(marie->lc),3) + + linphone_core_terminate_conference(marie->lc); + + CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallEnd,1,2000)); + CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallEnd,1,2000)); + CU_ASSERT_TRUE(wait_for_list(lcs,&laure->stat.number_of_LinphoneCallEnd,1,2000)); + + + + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); + linphone_core_manager_destroy(laure); + ms_list_free(lcs); +} static void call_srtp() { @@ -387,6 +464,9 @@ int call_test_suite () { if (NULL == CU_add_test(pSuite, "call_with_video_added", call_with_video_added)) { return CU_get_error(); } + if (NULL == CU_add_test(pSuite, "simple_conference", simple_conference)) { + return CU_get_error(); + } return 0; } diff --git a/tester/laure_rc b/tester/laure_rc new file mode 100644 index 000000000..b4480494c --- /dev/null +++ b/tester/laure_rc @@ -0,0 +1,38 @@ +[sip] +sip_port=5092 +sip_tcp_port=5092 +sip_tls_port=5093 +default_proxy=0 +ping_with_options=0 +register_only_when_network_is_up=0 + +[auth_info_0] +username=laure +userid=laure +passwd=secret +realm="sip.example.org" + + +[proxy_0] +reg_proxy=sip.example.org +reg_identity=sip:laure@sip.example.org +reg_expires=3600 +reg_sendregister=1 +publish=0 +dial_escape_plus=0 + + +[rtp] +audio_rtp_port=9010 +video_rtp_port=9012 + +[video] +display=0 +capture=0 +show_local=0 +size=vga +enabled=0 +self_view=0 +automatically_initiate=0 +automatically_accept=0 +device=StaticImage: Static picture \ No newline at end of file diff --git a/tester/liblinphone_tester.c b/tester/liblinphone_tester.c index 8bfc5352b..a20d72581 100644 --- a/tester/liblinphone_tester.c +++ b/tester/liblinphone_tester.c @@ -113,10 +113,21 @@ LinphoneCore* configure_lc_from(LinphoneCoreVTable* v_table, const char* file,in bool_t wait_for(LinphoneCore* lc_1, LinphoneCore* lc_2,int* counter,int value) { + MSList* lcs=NULL; + lcs=ms_list_append(lcs,lc_1); + bool_t result; + lcs=ms_list_append(lcs,lc_2); + result=wait_for_list(lcs,counter,value,2000); + ms_list_free(lcs); + return result; +} +bool_t wait_for_list(MSList* lcs,int* counter,int value,int timeout_ms) { int retry=0; - while (*counternext) { + linphone_core_iterate((LinphoneCore*)(iterator->data)); + } ms_usleep(100000); } if(*counter