Commit 6e9bfc27 authored by jehan's avatar jehan
Browse files

add more test for presence

parent 4e1e0df4
......@@ -347,6 +347,62 @@ static void presence_information(void) {
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
#define USE_PRESENCE_SERVER 0
#if USE_PRESENCE_SERVER
static void test_subscribe_notify_publish(void) {
LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc");
LinphoneProxyConfig* proxy;
LinphonePresenceModel* presence;
LpConfig *pauline_lp = linphone_core_get_config(pauline->lc);
char* lf_identity=linphone_address_as_string_uri_only(marie->identity);
LinphoneFriend *lf = linphone_core_create_friend_with_address(pauline->lc,lf_identity);
lp_config_set_int(pauline_lp,"sip","subscribe_expires",5);
linphone_core_add_friend(pauline->lc,lf);
/*wait for subscribe acknowledgment*/
wait_for_until(pauline->lc,marie->lc,&pauline->stat.number_of_NotifyReceived,1,2000);
CU_ASSERT_EQUAL(LinphoneStatusOffline,linphone_friend_get_status(lf));
/*enable publish*/
linphone_core_get_default_proxy(marie->lc,&proxy);
linphone_proxy_config_edit(proxy);
linphone_proxy_config_enable_publish(proxy,TRUE);
linphone_proxy_config_set_publish_expires(proxy,3);
linphone_proxy_config_done(proxy);
/*wait for marie status*/
wait_for_until(pauline->lc,marie->lc,&pauline->stat.number_of_NotifyReceived,2,2000);
CU_ASSERT_EQUAL(LinphoneStatusOnline,linphone_friend_get_status(lf));
presence =linphone_presence_model_new_with_activity(LinphonePresenceActivityOffline,NULL);
linphone_core_set_presence_model(marie->lc,presence);
/*wait for new status*/
wait_for_until(pauline->lc,marie->lc,&pauline->stat.number_of_NotifyReceived,3,2000);
CU_ASSERT_EQUAL(LinphonePresenceActivityOffline,linphone_friend_get_status(lf));
/*wait for refresh*/
wait_for_until(pauline->lc,marie->lc,&pauline->stat.number_of_NotifyReceived,4,5000);
CU_ASSERT_EQUAL(LinphonePresenceActivityOffline,linphone_friend_get_status(lf));
//linphone_core_remove_friend(pauline->lc,lf);
/*wait for final notify*/
//wait_for_until(pauline->lc,marie->lc,&pauline->stat.number_of_NotifyReceived,4,5000);
//CU_ASSERT_EQUAL(LinphonePresenceActivityOffline,linphone_friend_get_status(lf));
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
#endif
test_t presence_tests[] = {
{ "Simple Subscribe", simple_subscribe },
......@@ -356,6 +412,9 @@ test_t presence_tests[] = {
{ "Unsubscribe while subscribing", unsubscribe_while_subscribing },
{ "Presence information", presence_information },
{ "App managed presence failure", subscribe_failure_handle_by_app },
#if USE_PRESENCE_SERVER
{ "Subscribe with late publish", test_subscribe_notify_publish },
#endif
};
test_suite_t presence_test_suite = {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment