static void devices_reload_test(void) { char *devid1; char *devid2; LinphoneCoreManager *mgr = linphone_core_manager_new2("empty_rc", FALSE); devid1 = ms_strdup(linphone_core_get_capture_device(mgr->lc)); linphone_core_reload_sound_devices(mgr->lc); devid2 = ms_strdup(linphone_core_get_capture_device(mgr->lc)); BC_ASSERT_STRING_EQUAL(devid1, devid2); ms_free(devid1); ms_free(devid2); devid1 = ms_strdup(linphone_core_get_video_device(mgr->lc)); linphone_core_reload_video_devices(mgr->lc); devid2 = ms_strdup(linphone_core_get_video_device(mgr->lc)); if (devid1 && devid2) { BC_ASSERT_STRING_EQUAL(devid1, devid2); } else { BC_ASSERT_PTR_NULL(devid1); BC_ASSERT_PTR_NULL(devid2); } ms_free(devid1); ms_free(devid2); linphone_core_manager_destroy(mgr); }
static void phone_normalization_with_proxy(void) { LinphoneProxyConfig *proxy = linphone_proxy_config_new(); linphone_proxy_config_set_dial_prefix(proxy, "33"); BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "012 3456 789"), "+33123456789"); BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "+33123456789"), "+33123456789"); BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "+33 0123456789"), "+330123456789"); BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "+330012345678"), "+330012345678"); BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "+3301 2345678"), "+33012345678"); BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "+3301234567891"), "+3301234567891"); BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "123456789"), "+33123456789"); BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, " 0123456789"), "+33123456789"); BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "0012345678"), "+12345678"); BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "01 2345678"), "+33012345678"); BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "01234567891"), "+33234567891"); // invalid phone number (too long) BC_ASSERT_PTR_NULL(phone_normalization(proxy, "I_AM_NOT_A_NUMBER")); // invalid phone number BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "+990012345678"), "+990012345678"); BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "0952636505"), "+33952636505"); BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "09 52 63 65 05"), "+33952636505"); BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "09-52-63-65-05"), "+33952636505"); BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "+31952636505"), "+31952636505"); BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "0033952636505"), "+33952636505"); BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "0033952636505"), "+33952636505"); BC_ASSERT_PTR_NULL(phone_normalization(proxy, "toto")); linphone_proxy_config_set_dial_prefix(proxy, "99"); BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "0012345678"), "+12345678"); linphone_proxy_config_destroy(proxy); }
static void test_file_path(void) { belle_generic_uri_t* source_uri = belle_generic_uri_parse("/index.html"); char* source_uri_raw = belle_sip_object_to_string(source_uri); belle_generic_uri_t* first_uri = belle_generic_uri_parse(source_uri_raw); belle_generic_uri_t* uri=BELLE_GENERIC_URI(belle_sip_object_clone(BELLE_SIP_OBJECT(first_uri))); belle_sip_free(source_uri_raw); belle_sip_object_unref(source_uri); belle_sip_object_unref(first_uri); BC_ASSERT_PTR_NULL(belle_generic_uri_get_scheme(uri)); BC_ASSERT_PTR_NULL(belle_generic_uri_get_host(uri)); BC_ASSERT_STRING_EQUAL(belle_generic_uri_get_path(uri),"/index.html"); belle_sip_object_unref(uri); source_uri = belle_generic_uri_parse("file:///tmp/absolute-file"); BC_ASSERT_PTR_NOT_NULL(source_uri); if (source_uri!=NULL){ BC_ASSERT_STRING_EQUAL(belle_generic_uri_get_scheme(source_uri),"file"); BC_ASSERT_PTR_NULL(belle_generic_uri_get_host(source_uri)); BC_ASSERT_STRING_EQUAL(belle_generic_uri_get_path(source_uri),"/tmp/absolute-file"); belle_sip_object_unref(source_uri); } /*this is INVALID*/ source_uri = belle_generic_uri_parse("file://./relative-file"); BC_ASSERT_PTR_NOT_NULL(source_uri); /* PATH segment always start by / */ source_uri = belle_generic_uri_parse("./relative-file"); BC_ASSERT_PTR_NULL(source_uri); if (source_uri!=NULL){ belle_sip_object_unref(source_uri); } }
void ms_tester_create_filters(unsigned int filter_mask, MSFactory * f) { MSSndCardManager *snd_manager; MSWebCamManager *cam_manager; MSSndCard *playcard; MSSndCard *captcard; MSWebCam *camera; CREATE_FILTER(FILTER_MASK_FILEPLAY, ms_tester_fileplay,f, MS_FILE_PLAYER_ID); CREATE_FILTER(FILTER_MASK_FILEREC, ms_tester_filerec,f, MS_FILE_REC_ID); CREATE_FILTER(FILTER_MASK_DTMFGEN, ms_tester_dtmfgen, f, MS_DTMF_GEN_ID); CREATE_FILTER(FILTER_MASK_TONEDET, ms_tester_tonedet, f, MS_TONE_DETECTOR_ID); CREATE_FILTER(FILTER_MASK_VOIDSOURCE, ms_tester_voidsource, f, MS_VOID_SOURCE_ID); CREATE_FILTER(FILTER_MASK_VOIDSINK, ms_tester_voidsink, f, MS_VOID_SINK_ID); if (filter_mask & FILTER_MASK_ENCODER) { BC_ASSERT_PTR_NULL(ms_tester_encoder); ms_tester_encoder = ms_factory_create_encoder(f, ms_tester_codec_mime); BC_ASSERT_PTR_NOT_NULL(ms_tester_encoder); } if (filter_mask & FILTER_MASK_DECODER) { BC_ASSERT_PTR_NULL(ms_tester_decoder); ms_tester_decoder = ms_factory_create_decoder(f, ms_tester_codec_mime); BC_ASSERT_PTR_NOT_NULL(ms_tester_decoder); } CREATE_FILTER(FILTER_MASK_RTPRECV, ms_tester_rtprecv, f, MS_RTP_RECV_ID); CREATE_FILTER(FILTER_MASK_RTPSEND, ms_tester_rtpsend, f ,MS_RTP_SEND_ID); CREATE_FILTER(FILTER_MASK_RESAMPLER, ms_tester_resampler, f, MS_RESAMPLE_ID); if (filter_mask & FILTER_MASK_SOUNDWRITE) { BC_ASSERT_PTR_NULL(ms_tester_soundwrite); snd_manager = ms_factory_get_snd_card_manager(f); playcard = ms_snd_card_manager_get_default_playback_card(snd_manager); BC_ASSERT_PTR_NOT_NULL(playcard); ms_tester_soundwrite = ms_snd_card_create_writer(playcard); BC_ASSERT_PTR_NOT_NULL(ms_tester_soundwrite); } if (filter_mask & FILTER_MASK_SOUNDREAD) { BC_ASSERT_PTR_NULL(ms_tester_soundread); snd_manager = ms_factory_get_snd_card_manager(f); captcard = ms_snd_card_manager_get_default_capture_card(snd_manager); BC_ASSERT_PTR_NOT_NULL(captcard); ms_tester_soundread = ms_snd_card_create_reader(captcard); BC_ASSERT_PTR_NOT_NULL(ms_tester_soundread); } if (filter_mask & FILTER_MASK_VIDEOCAPTURE) { BC_ASSERT_PTR_NULL(ms_tester_videocapture); cam_manager = ms_factory_get_web_cam_manager(f); camera = ms_web_cam_manager_get_default_cam(cam_manager); BC_ASSERT_PTR_NOT_NULL(camera); ms_tester_videocapture = ms_web_cam_create_reader(camera); BC_ASSERT_PTR_NOT_NULL(ms_tester_videocapture); } }
static void carddav_sync_4(void) { LinphoneCoreManager *manager = linphone_core_manager_new2("carddav_rc", FALSE); LinphoneCardDAVStats *stats = (LinphoneCardDAVStats *)ms_new0(LinphoneCardDAVStats, 1); LinphoneVcard *lvc = linphone_vcard_context_get_vcard_from_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Margaux Clerc\r\nIMPP;TYPE=work:sip:[email protected]\r\nEND:VCARD\r\n"); LinphoneFriend *lf = linphone_friend_new_from_vcard(lvc); LinphoneFriendList *lfl = linphone_core_create_friend_list(manager->lc); LinphoneCardDavContext *c = NULL; linphone_friend_list_set_uri(lfl, CARDDAV_SERVER); linphone_core_add_friend_list(manager->lc, lfl); linphone_friend_list_unref(lfl); c = linphone_carddav_context_new(lfl); BC_ASSERT_PTR_NOT_NULL(c); linphone_carddav_set_user_data(c, stats); linphone_carddav_set_synchronization_done_callback(c, carddav_sync_done); linphone_carddav_set_new_contact_callback(c, carddav_new_contact); linphone_carddav_set_removed_contact_callback(c, carddav_removed_contact); linphone_carddav_set_updated_contact_callback(c, carddav_updated_contact); BC_ASSERT_PTR_NULL(linphone_vcard_get_uid(lvc)); linphone_carddav_put_vcard(c, lf); BC_ASSERT_PTR_NOT_NULL(linphone_vcard_get_uid(lvc)); wait_for_until(manager->lc, NULL, &stats->sync_done_count, 1, 5000); BC_ASSERT_EQUAL(stats->sync_done_count, 1, int, "%i"); linphone_carddav_delete_vcard(c, lf); wait_for_until(manager->lc, NULL, &stats->sync_done_count, 2, 5000); BC_ASSERT_EQUAL(stats->sync_done_count, 2, int, "%i"); linphone_friend_unref(lf); ms_free(stats); linphone_carddav_context_destroy(c); linphone_core_manager_destroy(manager); }
static void test_filterdesc_enable_disable_base(const char* mime, const char* filtername,bool_t is_enc) { MSFilter *filter; MSFactory *factory = NULL; factory = ms_factory_new_with_voip(); if (is_enc) filter = ms_factory_create_encoder(factory,mime); else filter = ms_factory_create_decoder(factory,mime); BC_ASSERT_PTR_NOT_NULL(filter); ms_filter_destroy(filter); BC_ASSERT_FALSE(ms_factory_enable_filter_from_name(factory,filtername,FALSE)); BC_ASSERT_FALSE(ms_factory_filter_from_name_enabled(factory,filtername)); if (is_enc) filter = ms_factory_create_encoder(factory,mime); else filter = ms_factory_create_decoder(factory,mime); BC_ASSERT_PTR_NULL(filter); BC_ASSERT_FALSE(ms_factory_enable_filter_from_name(factory,filtername,TRUE)); BC_ASSERT_TRUE(ms_factory_filter_from_name_enabled(factory,filtername)); if (is_enc) filter = ms_factory_create_encoder(factory,mime); else filter = ms_factory_create_decoder(factory,mime); BC_ASSERT_PTR_NOT_NULL(filter); ms_filter_destroy(filter); ms_factory_destroy(factory); }
static void test_filterdesc_enable_disable_base(const char* mime, const char* filtername,bool_t is_enc) { MSFilter *filter; ms_init(); if (is_enc) filter = ms_filter_create_encoder(mime); else filter = ms_filter_create_decoder(mime); BC_ASSERT_PTR_NOT_NULL(filter); ms_filter_destroy(filter); BC_ASSERT_FALSE(ms_factory_enable_filter_from_name(ms_factory_get_fallback(),filtername,FALSE)); BC_ASSERT_FALSE(ms_factory_filter_from_name_enabled(ms_factory_get_fallback(),filtername)); if (is_enc) filter = ms_filter_create_encoder(mime); else filter = ms_filter_create_decoder(mime); BC_ASSERT_PTR_NULL(filter); BC_ASSERT_FALSE(ms_factory_enable_filter_from_name(ms_factory_get_fallback(),filtername,TRUE)); BC_ASSERT_TRUE(ms_factory_filter_from_name_enabled(ms_factory_get_fallback(),filtername)); if (is_enc) filter = ms_filter_create_encoder(mime); else filter = ms_filter_create_decoder(mime); BC_ASSERT_PTR_NOT_NULL(filter); ms_filter_destroy(filter); ms_exit(); }
static void sip_uri_normalization(void) { char* expected ="sip:%d9%[email protected]"; BC_ASSERT_PTR_NULL(linphone_proxy_config_normalize_sip_uri(NULL, "test")); SIP_URI_CHECK("*****@*****.**", "sip:[email protected]"); SIP_URI_CHECK("[email protected];transport=tls", "sip:[email protected];transport=tls"); SIP_URI_CHECK("١", expected); //test that no more invalid memory writes are made (valgrind only) }
static void phone_normalization_without_proxy(void) { BC_ASSERT_STRING_EQUAL(phone_normalization(NULL, "012 345 6789"), "0123456789"); BC_ASSERT_STRING_EQUAL(phone_normalization(NULL, "+33123456789"), "+33123456789"); BC_ASSERT_STRING_EQUAL(phone_normalization(NULL, "+33012345678"), "+33012345678"); BC_ASSERT_STRING_EQUAL(phone_normalization(NULL, "+33 0012345678"), "+330012345678"); BC_ASSERT_STRING_EQUAL(phone_normalization(NULL, "+33012345678"), "+33012345678"); BC_ASSERT_STRING_EQUAL(phone_normalization(NULL, "+3301234567891"), "+3301234567891"); BC_ASSERT_STRING_EQUAL(phone_normalization(NULL, "+33 01234567891"), "+3301234567891"); BC_ASSERT_PTR_NULL(phone_normalization(NULL, "I_AM_NOT_A_NUMBER")); // invalid phone number }
/* IPv4 A query send failure */ static void ipv4_a_query_send_failure(void) { endpoint_t *client = create_endpoint(); if (!BC_ASSERT_PTR_NOT_NULL(client)) return; belle_sip_stack_set_resolver_send_error(client->stack, -1); client->resolver_ctx = belle_sip_stack_resolve_a(client->stack, IPV4_SIP_DOMAIN, SIP_PORT, AF_INET, a_resolve_done, client); BC_ASSERT_PTR_NULL(client->resolver_ctx); belle_sip_stack_set_resolver_send_error(client->stack, 0); destroy_endpoint(client); }
static void linphone_vcard_update_existing_friends_test(void) { LinphoneFriend *lf = linphone_friend_new_with_addr("sip:[email protected]"); BC_ASSERT_PTR_NOT_NULL_FATAL(lf); BC_ASSERT_PTR_NULL(linphone_friend_get_vcard(lf)); linphone_friend_edit(lf); linphone_friend_set_name(lf, "Old Friend"); linphone_friend_done(lf); BC_ASSERT_PTR_NOT_NULL(linphone_friend_get_vcard(lf)); BC_ASSERT_STRING_EQUAL(linphone_vcard_get_full_name(linphone_friend_get_vcard(lf)), "Old Friend"); linphone_friend_unref(lf); lf = NULL; }
static void quality_reporting_not_used_without_config() { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_quality_reporting_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); LinphoneCall* call_marie = NULL; LinphoneCall* call_pauline = NULL; if (create_call_for_quality_reporting_tests(marie, pauline, &call_marie, &call_pauline, NULL, NULL)) { // marie has stats collection enabled but pauline has not BC_ASSERT_TRUE(linphone_proxy_config_quality_reporting_enabled(call_marie->dest_proxy)); BC_ASSERT_FALSE(linphone_proxy_config_quality_reporting_enabled(call_pauline->dest_proxy)); // this field should be already filled BC_ASSERT_PTR_NOT_NULL(call_marie->log->reporting.reports[0]->info.local_addr.ip); // but not this one since it is updated at the end of call BC_ASSERT_PTR_NULL(call_marie->log->reporting.reports[0]->dialog_id); } linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); }
static void filter_register_tester(void) { MSFilter* filter; ms_init(); ms_init(); BC_ASSERT_PTR_NOT_NULL(ms_filter_lookup_by_name("MSVoidSource")); filter= ms_filter_create_decoder("pcma"); BC_ASSERT_PTR_NOT_NULL(filter); ms_filter_destroy(filter); ms_exit(); BC_ASSERT_PTR_NOT_NULL(ms_filter_lookup_by_name("MSVoidSource")); filter= ms_filter_create_decoder("pcma"); BC_ASSERT_PTR_NOT_NULL(filter); ms_filter_destroy(filter); ms_exit(); BC_ASSERT_PTR_NULL(ms_factory_get_fallback()); }
static void subscribe_presence_expired(void){ LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline1 = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); LinphoneFriend *lf; bctbx_list_t *lcs = NULL; lcs = bctbx_list_append(lcs, marie->lc); lcs = bctbx_list_append(lcs, pauline1->lc); lp_config_set_int(marie->lc->config, "sip", "subscribe_expires", 10); lf = linphone_core_create_friend(marie->lc); linphone_friend_set_address(lf, pauline1->identity); linphone_friend_enable_subscribes(lf, TRUE); linphone_core_add_friend(marie->lc, lf); linphone_friend_unref(lf); BC_ASSERT_TRUE(wait_for_list(lcs,&pauline1->stat.number_of_NewSubscriptionRequest,1, 5000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphonePresenceActivityOnline,1, 2000)); lf = linphone_core_find_friend(pauline1->lc, marie->identity); BC_ASSERT_PTR_NOT_NULL(lf); if (lf) { BC_ASSERT_PTR_NOT_NULL(lf->insubs); /*marie comes offline suddenly*/ linphone_core_set_network_reachable(marie->lc, FALSE); /*after a certain time, pauline shall see the incoming SUBSCRIBE expired*/ wait_for_list(lcs,NULL, 0, 11000); BC_ASSERT_PTR_NULL(lf->insubs); /*just make network reachable so that marie can unregister properly*/ linphone_core_set_network_reachable(marie->lc, TRUE); BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneRegistrationOk,2, 10000)); } linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline1); bctbx_list_free(lcs); }
void ms_tester_create_ticker(void) { BC_ASSERT_PTR_NULL(ms_tester_ticker); ms_tester_ticker = create_ticker(); BC_ASSERT_PTR_NOT_NULL(ms_tester_ticker); }
static void sip_uri_normalization(void) { BC_ASSERT_PTR_NULL(linphone_proxy_config_normalize_sip_uri(NULL, "test")); SIP_URI_CHECK("*****@*****.**", "sip:[email protected]"); SIP_URI_CHECK("[email protected];transport=tls", "sip:[email protected];transport=tls"); }
void ms_tester_create_filter(MSFilter **filter, MSFilterId id, MSFactory *f) { BC_ASSERT_PTR_NOT_NULL(filter); BC_ASSERT_PTR_NULL(*filter); *filter = ms_factory_create_filter(f, id); BC_ASSERT_PTR_NOT_NULL(*filter); }
static void linphone_address_test(void) { linphone_address_destroy(create_linphone_address(NULL)); BC_ASSERT_PTR_NULL(linphone_address_new("sip:@sip.linphone.org")); }
static void presence_information(void) { const char *bike_description = "Riding my bike"; const char *vacation_note = "I'm on vacation until July 4th"; const char *vacation_lang = "en"; const char *contact = "sip:[email protected]"; LinphoneCoreManager *marie = presence_linphone_core_manager_new("marie"); LinphoneCoreManager *pauline = presence_linphone_core_manager_new("pauline"); LinphonePresenceModel *presence; LinphonePresenceActivity *activity = NULL; LinphonePresenceNote *note = NULL; const char *description = NULL; const char *note_content = NULL; char *contact2; time_t current_timestamp, presence_timestamp; BC_ASSERT_TRUE(subscribe_to_callee_presence(marie, pauline)); /* Presence activity without description. */ presence = linphone_presence_model_new_with_activity(LinphonePresenceActivityDinner, NULL); linphone_core_set_presence_model(pauline->lc, presence); wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePresenceActivityDinner,1); BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePresenceActivityDinner, 1, int, "%d"); activity = linphone_presence_model_get_activity(marie->stat.last_received_presence); BC_ASSERT_PTR_NOT_NULL(activity); BC_ASSERT_EQUAL(linphone_presence_activity_get_type(activity), LinphonePresenceActivityDinner, int, "%d"); description = linphone_presence_activity_get_description(activity); BC_ASSERT_PTR_NULL(description); /* Presence activity with description. */ presence = linphone_presence_model_new_with_activity(LinphonePresenceActivitySteering, bike_description); linphone_core_set_presence_model(pauline->lc, presence); wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePresenceActivitySteering,1); BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePresenceActivitySteering, 1, int, "%d"); activity = linphone_presence_model_get_activity(marie->stat.last_received_presence); BC_ASSERT_PTR_NOT_NULL(activity); BC_ASSERT_EQUAL(linphone_presence_activity_get_type(activity), LinphonePresenceActivitySteering, int, "%d"); description = linphone_presence_activity_get_description(activity); BC_ASSERT_PTR_NOT_NULL(description); if (description != NULL) BC_ASSERT_STRING_EQUAL(description, bike_description); /* Presence activity with description and note. */ presence = linphone_presence_model_new_with_activity_and_note(LinphonePresenceActivityVacation, NULL, vacation_note, vacation_lang); linphone_core_set_presence_model(pauline->lc, presence); wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePresenceActivityVacation,1); BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePresenceActivityVacation, 1, int, "%d"); activity = linphone_presence_model_get_activity(marie->stat.last_received_presence); BC_ASSERT_PTR_NOT_NULL(activity); BC_ASSERT_EQUAL(linphone_presence_activity_get_type(activity), LinphonePresenceActivityVacation, int, "%d"); description = linphone_presence_activity_get_description(activity); BC_ASSERT_PTR_NULL(description); note = linphone_presence_model_get_note(marie->stat.last_received_presence, NULL); BC_ASSERT_PTR_NOT_NULL(note); if (note != NULL) { note_content = linphone_presence_note_get_content(note); BC_ASSERT_PTR_NOT_NULL(note_content); if (note_content != NULL) { BC_ASSERT_STRING_EQUAL(note_content, vacation_note); } } /* Presence contact. */ presence = linphone_presence_model_new_with_activity(LinphonePresenceActivityOnThePhone, NULL); linphone_presence_model_set_contact(presence, contact); linphone_core_set_presence_model(pauline->lc, presence); wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePresenceActivityOnThePhone,1); BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePresenceActivityOnThePhone, 1, int, "%d"); contact2 = linphone_presence_model_get_contact(presence); BC_ASSERT_PTR_NOT_NULL(contact2); if (contact2 != NULL) { BC_ASSERT_STRING_EQUAL(contact, contact2); ms_free(contact2); } /* Presence timestamp. */ current_timestamp = ms_time(NULL); presence = linphone_presence_model_new_with_activity(LinphonePresenceActivityShopping, NULL); linphone_core_set_presence_model(pauline->lc, presence); wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePresenceActivityShopping,1); BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePresenceActivityShopping, 1, int, "%d"); presence_timestamp = linphone_presence_model_get_timestamp(presence); BC_ASSERT_GREATER((unsigned)presence_timestamp , (unsigned)current_timestamp, unsigned, "%u"); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); }
static void linphone_version_test(void){ const char *version=linphone_core_get_version(); /*make sure the git version is always included in the version number*/ BC_ASSERT_PTR_NULL(strstr(version,"unknown")); }
static void carddav_integration(void) { LinphoneCoreManager *manager = linphone_core_manager_new2("carddav_rc", FALSE); LinphoneFriendList *lfl = linphone_core_create_friend_list(manager->lc); LinphoneVcard *lvc = linphone_vcard_context_get_vcard_from_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Margaux Clerc\r\nIMPP;TYPE=work:sip:[email protected]\r\nEND:VCARD\r\n"); LinphoneFriend *lf = linphone_friend_new_from_vcard(lvc); LinphoneVcard *lvc2 = NULL; LinphoneFriend *lf2 = NULL; LinphoneFriendListCbs *cbs = NULL; LinphoneCardDAVStats *stats = (LinphoneCardDAVStats *)ms_new0(LinphoneCardDAVStats, 1); const char *refkey = "toto"; char *address = NULL; LinphoneAddress *addr; linphone_friend_list_set_uri(lfl, CARDDAV_SERVER); cbs = linphone_friend_list_get_callbacks(lfl); linphone_friend_list_cbs_set_user_data(cbs, stats); linphone_friend_list_cbs_set_contact_created(cbs, carddav_contact_created); linphone_friend_list_cbs_set_contact_deleted(cbs, carddav_contact_deleted); linphone_friend_list_cbs_set_contact_updated(cbs, carddav_contact_updated); linphone_friend_list_cbs_set_sync_status_changed(cbs, carddav_sync_status_changed); linphone_core_add_friend_list(manager->lc, lfl); BC_ASSERT_PTR_NULL(linphone_vcard_get_uid(lvc)); BC_ASSERT_EQUAL(bctbx_list_size(lfl->dirty_friends_to_update), 0, int, "%d"); BC_ASSERT_EQUAL(linphone_friend_list_add_friend(lfl, lf), LinphoneFriendListOK, int, "%d"); BC_ASSERT_EQUAL(bctbx_list_size(lfl->dirty_friends_to_update), 1, int, "%d"); wait_for_until(manager->lc, NULL, &stats->sync_done_count, 1, 5000); BC_ASSERT_EQUAL(stats->sync_done_count, 1, int, "%i"); BC_ASSERT_EQUAL(bctbx_list_size(lfl->dirty_friends_to_update), 0, int, "%d"); BC_ASSERT_PTR_NOT_NULL(linphone_vcard_get_uid(lvc)); linphone_friend_list_remove_friend(lfl, lf); BC_ASSERT_EQUAL(bctbx_list_size(lfl->friends), 0, int, "%d"); wait_for_until(manager->lc, NULL, &stats->sync_done_count, 2, 5000); BC_ASSERT_EQUAL(stats->sync_done_count, 2, int, "%i"); linphone_friend_unref(lf); lf = NULL; lvc = linphone_vcard_context_get_vcard_from_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Ghislain Mary\r\nIMPP;TYPE=work:sip:[email protected]\r\nEND:VCARD\r\n"); lf = linphone_friend_new_from_vcard(lvc); BC_ASSERT_EQUAL(linphone_friend_list_add_local_friend(lfl, lf), LinphoneFriendListOK, int, "%d"); linphone_friend_unref(lf); lvc2 = linphone_vcard_context_get_vcard_from_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nIMPP:sip:[email protected]\r\nUID:1f08dd48-29ac-4097-8e48-8596d7776283\r\nEND:VCARD\r\n"); linphone_vcard_set_url(lvc2, "/card.php/addressbooks/tester/default/me.vcf"); lf2 = linphone_friend_new_from_vcard(lvc2); linphone_friend_set_ref_key(lf2, refkey); BC_ASSERT_EQUAL(linphone_friend_list_add_local_friend(lfl, lf2), LinphoneFriendListOK, int, "%d"); BC_ASSERT_EQUAL(lfl->revision, 0, int, "%i"); linphone_friend_list_synchronize_friends_from_server(lfl); wait_for_until(manager->lc, NULL, &stats->new_contact_count, 0, 5000); BC_ASSERT_EQUAL(stats->new_contact_count, 0, int, "%i"); wait_for_until(manager->lc, NULL, &stats->removed_contact_count, 1, 5000); BC_ASSERT_EQUAL(stats->removed_contact_count, 1, int, "%i"); wait_for_until(manager->lc, NULL, &stats->updated_contact_count, 1, 5000); BC_ASSERT_EQUAL(stats->updated_contact_count, 1, int, "%i"); BC_ASSERT_NOT_EQUAL(lfl->revision, 0, int, "%i"); wait_for_until(manager->lc, NULL, &stats->sync_done_count, 3, 5000); BC_ASSERT_EQUAL(stats->sync_done_count, 3, int, "%i"); BC_ASSERT_EQUAL(bctbx_list_size(lfl->friends), 1, int, "%i"); lf = (LinphoneFriend *)lfl->friends->data; BC_ASSERT_STRING_EQUAL(lf->refkey, refkey); BC_ASSERT_EQUAL(lf->storage_id, lf2->storage_id, unsigned int, "%u"); linphone_friend_unref(lf2); addr = linphone_friend_get_address(lf); address = linphone_address_as_string_uri_only(addr); BC_ASSERT_STRING_EQUAL(address, "sip:[email protected]"); ms_free(address); linphone_address_unref(addr); linphone_friend_edit(lf); linphone_friend_done(lf); BC_ASSERT_EQUAL(bctbx_list_size(lf->friend_list->dirty_friends_to_update), 0, int, "%i"); linphone_core_set_network_reachable(manager->lc, FALSE); //To prevent the CardDAV update linphone_friend_edit(lf); linphone_friend_set_name(lf, "François Grisez"); linphone_friend_done(lf); BC_ASSERT_EQUAL(bctbx_list_size(lf->friend_list->dirty_friends_to_update), 1, int, "%i"); ms_free(stats); linphone_friend_list_unref(lfl); linphone_core_manager_destroy(manager); }
static void collect_files_disabled() { LinphoneCoreManager* marie = setup(FALSE); BC_ASSERT_PTR_NULL(linphone_core_compress_log_collection(marie->lc)); collect_cleanup(marie); }
static void test_object_data(void) { belle_sip_object_t* obj = belle_sip_object_new(belle_sip_object_t); belle_sip_object_t* cloned = belle_sip_object_new(belle_sip_object_t); int i = 123; const char* str = "toto", *str2 = "titi"; /* normal insertion with no destroy callback */ // should return 0 BC_ASSERT_EQUAL(belle_sip_object_data_set(obj, "test_i", INT_TO_VOIDPTR(i), NULL), 0, int, "%d"); // should return the value we put in it BC_ASSERT_EQUAL( VOIDPTR_TO_INT(belle_sip_object_data_get(obj, "test_i")), i, int, "%d"); /* * Overwriting insertion */ // overwrite data: should return 1 when set() i = 124; BC_ASSERT_EQUAL(belle_sip_object_data_set(obj, "test_i", INT_TO_VOIDPTR(i), NULL), 1 , int, "%d"); // should return the new value we put in it BC_ASSERT_EQUAL( VOIDPTR_TO_INT(belle_sip_object_data_get(obj, "test_i")), i, int, "%d"); /* * normal insertion with destroy callback */ BC_ASSERT_EQUAL(belle_sip_object_data_set(obj, "test_str", (void*)belle_sip_strdup(str), test_object_data_string_destroy), 0, int, "%d"); // we should get back the same string BC_ASSERT_STRING_EQUAL( (const char*)belle_sip_object_data_get(obj, "test_str"), str ); BC_ASSERT_EQUAL(belle_sip_object_data_remove(obj, "test_str"),0, int, "%d"); // we expect the destroy() function to be called on removal BC_ASSERT_EQUAL(destroy_called, 1, int, "%d"); destroy_called = 0; /* * string insertion and replace */ belle_sip_object_data_set(obj, "test_str", (void*)belle_sip_strdup(str), test_object_data_string_destroy); belle_sip_object_data_set(obj, "test_str", (void*)belle_sip_strdup(str2), test_object_data_string_destroy); BC_ASSERT_EQUAL(destroy_called, 1, int, "%d"); // we expect the dtor to have been called to free the first string /* * Get non-existent key */ BC_ASSERT_PTR_NULL(belle_sip_object_data_get(obj, "non-exist")); /* * test cloning the dictionary */ belle_sip_object_data_clone(obj, cloned, test_object_data_string_clone); BC_ASSERT_EQUAL(clone_called,2,int,"%d"); // we expect the clone function to be called for "test_i" and "test_st, int, "%d"r" // the values should be equal BC_ASSERT_EQUAL( VOIDPTR_TO_INT(belle_sip_object_data_get(obj, "test_i")), VOIDPTR_TO_INT(belle_sip_object_data_get(cloned, "test_i")) , int, "%d"); BC_ASSERT_STRING_EQUAL( (const char*)belle_sip_object_data_get(obj, "test_str"), (const char*)belle_sip_object_data_get(cloned, "test_str")); // but the pointers should be different BC_ASSERT_PTR_NOT_EQUAL( belle_sip_object_data_get(obj, "test_str"), belle_sip_object_data_get(cloned, "test_str")); /* * Foreach test */ belle_sip_object_data_foreach(obj, test_object_data_foreach_cb, NULL); BC_ASSERT_EQUAL( foreach_called, 2 , int, "%d"); belle_sip_object_unref(obj); belle_sip_object_unref(cloned); }