mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-04-29 06:36:22 +00:00
tester: fix presence tests
This commit is contained in:
parent
32075b0318
commit
19384ed6de
2 changed files with 32 additions and 26 deletions
|
|
@ -26,6 +26,7 @@ struct _Account{
|
||||||
int registered;
|
int registered;
|
||||||
int done;
|
int done;
|
||||||
int created;
|
int created;
|
||||||
|
char *phone_alias;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _Account Account;
|
typedef struct _Account Account;
|
||||||
|
|
@ -38,6 +39,7 @@ static Account *account_new(LinphoneAddress *identity, const char *unique_id){
|
||||||
belle_sip_object_inhibit_leak_detector(TRUE);
|
belle_sip_object_inhibit_leak_detector(TRUE);
|
||||||
obj->identity=linphone_address_clone(identity);
|
obj->identity=linphone_address_clone(identity);
|
||||||
obj->password=sal_get_random_token(8);
|
obj->password=sal_get_random_token(8);
|
||||||
|
obj->phone_alias = NULL;
|
||||||
obj->modified_identity=linphone_address_clone(identity);
|
obj->modified_identity=linphone_address_clone(identity);
|
||||||
modified_username=ms_strdup_printf("%s_%s",linphone_address_get_username(identity), unique_id);
|
modified_username=ms_strdup_printf("%s_%s",linphone_address_get_username(identity), unique_id);
|
||||||
linphone_address_set_username(obj->modified_identity, modified_username);
|
linphone_address_set_username(obj->modified_identity, modified_username);
|
||||||
|
|
@ -205,8 +207,13 @@ static LinphoneAddress *account_manager_check_account(AccountManager *m, Linphon
|
||||||
, linphone_address_get_username(id_addr)
|
, linphone_address_get_username(id_addr)
|
||||||
, linphone_address_get_domain(id_addr));
|
, linphone_address_get_domain(id_addr));
|
||||||
|
|
||||||
if (!account){
|
if (!account||(phone_alias&&(!account->phone_alias||strcmp(phone_alias,account->phone_alias)!=0))){
|
||||||
|
if (account) {
|
||||||
|
m->accounts=bctbx_list_remove(m->accounts,account);
|
||||||
|
account_destroy(account);
|
||||||
|
}
|
||||||
account=account_new(id_addr,m->unique_id);
|
account=account_new(id_addr,m->unique_id);
|
||||||
|
account->phone_alias=ms_strdup(phone_alias);
|
||||||
ms_message("No account for %s exists, going to create one.",identity);
|
ms_message("No account for %s exists, going to create one.",identity);
|
||||||
create_account=TRUE;
|
create_account=TRUE;
|
||||||
m->accounts=bctbx_list_append(m->accounts,account);
|
m->accounts=bctbx_list_append(m->accounts,account);
|
||||||
|
|
|
||||||
|
|
@ -158,7 +158,7 @@ static void subscriber_no_longer_reachable(void){
|
||||||
previous_number_of_LinphonePresenceActivityOnline=marie->stat.number_of_LinphonePresenceActivityOnline;
|
previous_number_of_LinphonePresenceActivityOnline=marie->stat.number_of_LinphonePresenceActivityOnline;
|
||||||
|
|
||||||
/*don't schedule marie to simulate Notify timeout server side*/
|
/*don't schedule marie to simulate Notify timeout server side*/
|
||||||
wait_for_until(pauline1->lc, NULL, 0, 0, 35000);
|
wait_for_until(pauline1->lc, NULL, 0, 0, 40000);
|
||||||
|
|
||||||
//sal_set_send_error(marie->lc->sal,0);
|
//sal_set_send_error(marie->lc->sal,0);
|
||||||
|
|
||||||
|
|
@ -649,6 +649,7 @@ static void presence_list_subscribe_io_error(void) {
|
||||||
|
|
||||||
static void long_term_presence_base(const char* addr, bool_t exist, const char* contact) {
|
static void long_term_presence_base(const char* addr, bool_t exist, const char* contact) {
|
||||||
LinphoneFriend* friend2;
|
LinphoneFriend* friend2;
|
||||||
|
const LinphonePresenceModel* model;
|
||||||
char *presence_contact;
|
char *presence_contact;
|
||||||
LinphoneCoreManager *pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
|
LinphoneCoreManager *pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
|
||||||
linphone_core_set_user_agent(pauline->lc, "full-presence-support", NULL);
|
linphone_core_set_user_agent(pauline->lc, "full-presence-support", NULL);
|
||||||
|
|
@ -659,21 +660,20 @@ static void long_term_presence_base(const char* addr, bool_t exist, const char*
|
||||||
linphone_friend_done(friend2);
|
linphone_friend_done(friend2);
|
||||||
linphone_core_add_friend(pauline->lc,friend2);
|
linphone_core_add_friend(pauline->lc,friend2);
|
||||||
|
|
||||||
|
int *presence = exist ? &pauline->stat.number_of_LinphonePresenceActivityOnline : &pauline->stat.number_of_LinphonePresenceActivityOffline;
|
||||||
if (exist) {
|
BC_ASSERT_TRUE(wait_for(pauline->lc,NULL,presence,1));
|
||||||
BC_ASSERT_TRUE(wait_for(pauline->lc,NULL,&pauline->stat.number_of_LinphonePresenceActivityOnline,1));
|
BC_ASSERT_EQUAL(*presence, 1, int, "%d");
|
||||||
BC_ASSERT_EQUAL(pauline->stat.number_of_LinphonePresenceActivityOnline, 1, int, "%d");
|
model = linphone_friend_get_presence_model(friend2);
|
||||||
BC_ASSERT_EQUAL(linphone_presence_model_get_basic_status(linphone_friend_get_presence_model(friend2)), LinphonePresenceBasicStatusOpen, int, "%d");
|
if (BC_ASSERT_PTR_NOT_NULL(model)) {
|
||||||
presence_contact = linphone_presence_model_get_contact(linphone_friend_get_presence_model(friend2));
|
BC_ASSERT_EQUAL(linphone_presence_model_get_basic_status(model),
|
||||||
BC_ASSERT_STRING_EQUAL(presence_contact, contact);
|
exist ? LinphonePresenceBasicStatusOpen : LinphonePresenceBasicStatusClosed, int, "%d");
|
||||||
if (presence_contact) ms_free(presence_contact);
|
presence_contact = linphone_presence_model_get_contact(model);
|
||||||
} else {
|
if (exist && BC_ASSERT_PTR_NOT_NULL(presence_contact)) {
|
||||||
BC_ASSERT_TRUE(wait_for(pauline->lc,NULL,&pauline->stat.number_of_LinphonePresenceActivityOffline,1));
|
BC_ASSERT_STRING_EQUAL(presence_contact, contact);
|
||||||
BC_ASSERT_EQUAL(pauline->stat.number_of_LinphonePresenceActivityOffline, 1, int, "%d");
|
ms_free(presence_contact);
|
||||||
BC_ASSERT_EQUAL(linphone_presence_model_get_basic_status(linphone_friend_get_presence_model(friend2)), LinphonePresenceBasicStatusClosed, int, "%d");
|
} else if (!exist) {
|
||||||
presence_contact = linphone_presence_model_get_contact(linphone_friend_get_presence_model(friend2));
|
BC_ASSERT_PTR_NULL(presence_contact);
|
||||||
BC_ASSERT_PTR_NULL(presence_contact);
|
}
|
||||||
if (presence_contact) ms_free(presence_contact);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
linphone_friend_unref(friend2);
|
linphone_friend_unref(friend2);
|
||||||
|
|
@ -742,8 +742,7 @@ static void long_term_presence_list(void) {
|
||||||
f1 = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(pauline->lc), "sip:liblinphone_tester@sip.example.org");
|
f1 = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(pauline->lc), "sip:liblinphone_tester@sip.example.org");
|
||||||
BC_ASSERT_EQUAL(linphone_presence_model_get_basic_status(linphone_friend_get_presence_model(f1)), LinphonePresenceBasicStatusOpen, int, "%d");
|
BC_ASSERT_EQUAL(linphone_presence_model_get_basic_status(linphone_friend_get_presence_model(f1)), LinphonePresenceBasicStatusOpen, int, "%d");
|
||||||
presence = linphone_friend_get_presence_model_for_uri_or_tel(f1, phone_number);
|
presence = linphone_friend_get_presence_model_for_uri_or_tel(f1, phone_number);
|
||||||
BC_ASSERT_PTR_NOT_NULL(presence);
|
if (BC_ASSERT_PTR_NOT_NULL(presence)) {
|
||||||
if (presence) {
|
|
||||||
BC_ASSERT_STRING_EQUAL(linphone_presence_model_get_contact(presence), "sip:liblinphone_tester@sip.example.org");
|
BC_ASSERT_STRING_EQUAL(linphone_presence_model_get_contact(presence), "sip:liblinphone_tester@sip.example.org");
|
||||||
}
|
}
|
||||||
BC_ASSERT_TRUE(f1->presence_received);
|
BC_ASSERT_TRUE(f1->presence_received);
|
||||||
|
|
@ -758,19 +757,19 @@ static void long_term_presence_list(void) {
|
||||||
test_t presence_server_tests[] = {
|
test_t presence_server_tests[] = {
|
||||||
TEST_NO_TAG("Simple", simple),
|
TEST_NO_TAG("Simple", simple),
|
||||||
TEST_NO_TAG("Fast activity change", fast_activity_change),
|
TEST_NO_TAG("Fast activity change", fast_activity_change),
|
||||||
TEST_NO_TAG("Subscriber no longer reachable using server",subscriber_no_longer_reachable),
|
|
||||||
TEST_NO_TAG("Subscribe with late publish", subscribe_with_late_publish),
|
|
||||||
TEST_NO_TAG("Forked subscribe with late publish", test_forked_subscribe_notify_publish),
|
TEST_NO_TAG("Forked subscribe with late publish", test_forked_subscribe_notify_publish),
|
||||||
TEST_NO_TAG("Presence list", test_presence_list),
|
TEST_NO_TAG("Presence list", test_presence_list),
|
||||||
TEST_NO_TAG("Presence list without compression", test_presence_list_without_compression),
|
TEST_NO_TAG("Presence list without compression", test_presence_list_without_compression),
|
||||||
TEST_NO_TAG("Presence list, subscription expiration for unknown contact",test_presence_list_subscription_expire_for_unknown),
|
TEST_NO_TAG("Presence list, subscription expiration for unknown contact",test_presence_list_subscription_expire_for_unknown),
|
||||||
TEST_NO_TAG("Presence list, silent subscription expiration", presence_list_subscribe_dialog_expire),
|
TEST_NO_TAG("Presence list, silent subscription expiration", presence_list_subscribe_dialog_expire),
|
||||||
TEST_NO_TAG("Presence list, io error",presence_list_subscribe_io_error),
|
TEST_NO_TAG("Presence list, io error",presence_list_subscribe_io_error),
|
||||||
TEST_NO_TAG("Long term presence existing friend",long_term_presence_existing_friend),
|
TEST_ONE_TAG("Long term presence existing friend",long_term_presence_existing_friend, "longterm"),
|
||||||
TEST_NO_TAG("Long term presence inexistent friend",long_term_presence_inexistent_friend),
|
TEST_ONE_TAG("Long term presence inexistent friend",long_term_presence_inexistent_friend, "longterm"),
|
||||||
TEST_NO_TAG("Long term presence phone alias",long_term_presence_phone_alias),
|
TEST_ONE_TAG("Long term presence phone alias",long_term_presence_phone_alias, "longterm"),
|
||||||
TEST_NO_TAG("Long term presence phone alias 2",long_term_presence_phone_alias2),
|
TEST_ONE_TAG("Long term presence phone alias 2",long_term_presence_phone_alias2, "longterm"),
|
||||||
TEST_NO_TAG("Long term presence list",long_term_presence_list),
|
TEST_ONE_TAG("Long term presence list",long_term_presence_list, "longterm"),
|
||||||
|
TEST_NO_TAG("Subscriber no longer reachable using server",subscriber_no_longer_reachable),
|
||||||
|
TEST_NO_TAG("Subscribe with late publish", subscribe_with_late_publish),
|
||||||
};
|
};
|
||||||
|
|
||||||
test_suite_t presence_server_test_suite = {"Presence using server", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each,
|
test_suite_t presence_server_test_suite = {"Presence using server", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue