Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
liblinphone
Commits
d8158669
Commit
d8158669
authored
Jun 09, 2016
by
jehan
Browse files
add tests for lime & file transfer
parent
00236d14
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
78 additions
and
23 deletions
+78
-23
coreapi/chat.c
coreapi/chat.c
+11
-1
coreapi/linphonecore.c
coreapi/linphonecore.c
+3
-0
coreapi/linphonecore.h
coreapi/linphonecore.h
+7
-1
tester/message_tester.c
tester/message_tester.c
+47
-17
tester/tester.c
tester/tester.c
+10
-4
No files found.
coreapi/chat.c
View file @
d8158669
...
...
@@ -385,7 +385,7 @@ void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatMessage
linphone_chat_room_upload_file
(
msg
);
}
else
{
SalOp
*
op
=
NULL
;
LinphoneCall
*
call
;
LinphoneCall
*
call
=
NULL
;
char
*
content_type
;
const
char
*
identity
=
NULL
;
msg
->
time
=
ms_time
(
0
);
...
...
@@ -460,6 +460,16 @@ void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatMessage
}
linphone_chat_room_delete_composing_idle_timer
(
cr
);
linphone_chat_room_delete_composing_refresh_timer
(
cr
);
if
(
call
&&
call
->
op
==
op
)
{
/*In this case, chat delivery status is not notified, so unrefing chat message right now*/
/*Might be better fixed by delivering status, but too costly for now*/
msg
->
chat_room
->
transient_messages
=
ms_list_remove
(
msg
->
chat_room
->
transient_messages
,
msg
);
linphone_chat_message_unref
(
msg
);
linphone_chat_message_unref
(
msg
);
return
;
}
}
// if operation failed, we should not change message state
...
...
coreapi/linphonecore.c
View file @
d8158669
...
...
@@ -7459,6 +7459,9 @@ void linphone_core_set_chat_database_path(LinphoneCore *lc, const char *path){
linphone_core_message_storage_init
(
lc
);
}
}
const
char
*
linphone_core_get_chat_database_path
(
const
LinphoneCore
*
lc
)
{
return
lc
->
chat_db_file
;
}
void
linphone_core_enable_sdp_200_ack
(
LinphoneCore
*
lc
,
bool_t
enable
)
{
lp_config_set_int
(
lc
->
config
,
"sip"
,
"sdp_200_ack"
,
lc
->
sip_conf
.
sdp_200_ack
=
enable
);
}
...
...
coreapi/linphonecore.h
View file @
d8158669
...
...
@@ -1299,7 +1299,13 @@ typedef void (*LinphoneChatMessageCbsFileTransferProgressIndicationCb)(LinphoneC
LINPHONE_PUBLIC
void
linphone_core_set_chat_database_path
(
LinphoneCore
*
lc
,
const
char
*
path
);
/**
* Get path to the database file used for storing chat messages.
* @param lc the linphone core
* @return file path or NULL if not exist
**/
LINPHONE_PUBLIC
const
char
*
linphone_core_get_chat_database_path
(
const
LinphoneCore
*
lc
);
/**
* Get a chat room whose peer is the supplied address. If it does not exist yet, it will be created.
* No reference is transfered to the application. The LinphoneCore keeps a reference on the chat room.
...
...
tester/message_tester.c
View file @
d8158669
...
...
@@ -774,6 +774,10 @@ static void lime_text_message(void) {
LinphoneCoreManager
*
marie
=
linphone_core_manager_new
(
"marie_rc"
);
LinphoneCoreManager
*
pauline
=
linphone_core_manager_new
(
"pauline_tcp_rc"
);
if
(
!
linphone_core_lime_available
(
marie
->
lc
))
{
ms_warning
(
"Lime not available, skiping"
);
goto
end
;
}
/* make sure lime is enabled */
linphone_core_enable_lime
(
marie
->
lc
,
1
);
linphone_core_enable_lime
(
pauline
->
lc
,
1
);
...
...
@@ -802,7 +806,7 @@ static void lime_text_message(void) {
BC_ASSERT_PTR_NOT_NULL
(
linphone_core_get_chat_room
(
marie
->
lc
,
pauline
->
identity
));
/* TODO : check the msg arrived correctly deciphered */
end:
linphone_core_manager_destroy
(
marie
);
linphone_core_manager_destroy
(
pauline
);
}
...
...
@@ -813,7 +817,11 @@ static void lime_text_message_to_non_lime(void) {
char
*
filepath
;
LinphoneCoreManager
*
marie
=
linphone_core_manager_new
(
"marie_rc"
);
LinphoneCoreManager
*
pauline
=
linphone_core_manager_new
(
"pauline_tcp_rc"
);
if
(
!
linphone_core_lime_available
(
marie
->
lc
))
{
ms_warning
(
"Lime not available, skiping"
);
goto
end
;
}
/* make sure lime is enabled */
linphone_core_enable_lime
(
marie
->
lc
,
0
);
linphone_core_enable_lime
(
pauline
->
lc
,
1
);
...
...
@@ -835,10 +843,11 @@ static void lime_text_message_to_non_lime(void) {
BC_ASSERT_EQUAL
(
marie
->
stat
.
number_of_LinphoneMessageReceivedLegacy
,
0
,
int
,
"%d"
);
BC_ASSERT_PTR_NOT_NULL
(
linphone_core_get_chat_room
(
marie
->
lc
,
pauline
->
identity
));
end:
linphone_core_manager_destroy
(
marie
);
linphone_core_manager_destroy
(
pauline
);
}
void
lime_transfer_message_base
(
bool_t
encrypt_file
)
{
void
lime_transfer_message_base
(
bool_t
encrypt_file
,
bool_t
download_file_from_stored_msg
)
{
FILE
*
ZIDCacheMarieFD
,
*
ZIDCachePaulineFD
;
LinphoneCoreManager
*
marie
,
*
pauline
;
LinphoneChatMessage
*
msg
;
...
...
@@ -848,7 +857,11 @@ void lime_transfer_message_base(bool_t encrypt_file) {
marie
=
linphone_core_manager_new
(
"marie_rc"
);
pauline
=
linphone_core_manager_new
(
"pauline_tcp_rc"
);
if
(
!
linphone_core_lime_available
(
marie
->
lc
))
{
ms_warning
(
"Lime not available, skiping"
);
goto
end
;
}
/* make sure lime is enabled */
linphone_core_enable_lime
(
marie
->
lc
,
1
);
linphone_core_enable_lime
(
pauline
->
lc
,
1
);
...
...
@@ -886,26 +899,49 @@ void lime_transfer_message_base(bool_t encrypt_file) {
linphone_chat_room_send_chat_message
(
msg
->
chat_room
,
msg
);
BC_ASSERT_TRUE
(
wait_for
(
pauline
->
lc
,
marie
->
lc
,
&
marie
->
stat
.
number_of_LinphoneMessageReceivedWithFile
,
1
));
if
(
marie
->
stat
.
last_received_chat_message
)
{
cbs
=
linphone_chat_message_get_callbacks
(
marie
->
stat
.
last_received_chat_message
);
LinphoneChatMessage
*
recv_msg
;
const
LinphoneContent
*
content
;
if
(
download_file_from_stored_msg
)
{
LinphoneChatRoom
*
marie_room
=
linphone_core_get_chat_room
(
marie
->
lc
,
pauline
->
identity
);
MSList
*
msgs
=
linphone_chat_room_get_history
(
marie_room
,
1
);
BC_ASSERT_PTR_NOT_NULL
(
msgs
);
if
(
!
msgs
)
goto
end
;
recv_msg
=
(
LinphoneChatMessage
*
)
msgs
->
data
;
ms_list_free
(
msgs
);
}
else
{
recv_msg
=
marie
->
stat
.
last_received_chat_message
;
}
cbs
=
linphone_chat_message_get_callbacks
(
recv_msg
);
linphone_chat_message_cbs_set_msg_state_changed
(
cbs
,
liblinphone_tester_chat_message_msg_state_changed
);
linphone_chat_message_cbs_set_file_transfer_recv
(
cbs
,
file_transfer_received
);
linphone_chat_message_download_file
(
marie
->
stat
.
last_received_chat_message
);
content
=
linphone_chat_message_get_file_transfer_information
(
recv_msg
);
if
(
!
content
)
goto
end
;
if
(
encrypt_file
)
BC_ASSERT_PTR_NOT_NULL
(
linphone_content_get_key
(
content
));
else
BC_ASSERT_PTR_NULL
(
linphone_content_get_key
(
content
));
linphone_chat_message_download_file
(
recv_msg
);
BC_ASSERT_TRUE
(
wait_for
(
pauline
->
lc
,
marie
->
lc
,
&
marie
->
stat
.
number_of_LinphoneFileTransferDownloadSuccessful
,
1
));
}
BC_ASSERT_TRUE
(
wait_for
(
pauline
->
lc
,
marie
->
lc
,
&
marie
->
stat
.
number_of_LinphoneFileTransferDownloadSuccessful
,
1
));
BC_ASSERT_EQUAL
(
pauline
->
stat
.
number_of_LinphoneMessageInProgress
,
2
,
int
,
"%d"
);
// file transfer
BC_ASSERT_EQUAL
(
pauline
->
stat
.
number_of_LinphoneMessageDelivered
,
1
,
int
,
"%d"
);
BC_ASSERT_EQUAL
(
marie
->
stat
.
number_of_LinphoneFileTransferDownloadSuccessful
,
1
,
int
,
"%d"
);
end:
linphone_core_manager_destroy
(
marie
);
linphone_core_manager_destroy
(
pauline
);
}
static
void
lime_transfer_message
(
void
)
{
lime_transfer_message_base
(
TRUE
);
lime_transfer_message_base
(
TRUE
,
FALSE
);
}
static
void
lime_transfer_message_from_history
(
void
)
{
lime_transfer_message_base
(
TRUE
,
TRUE
);
}
static
void
lime_transfer_message_without_encryption
(
void
)
{
lime_transfer_message_base
(
FALSE
);
lime_transfer_message_base
(
FALSE
,
FALSE
);
}
static
void
printHex
(
char
*
title
,
uint8_t
*
data
,
uint32_t
length
)
{
...
...
@@ -1092,8 +1128,6 @@ static void lime_unit(void) {
#endif
/* HAVE_LIME */
#ifdef MSG_STORAGE_ENABLED
/*
* Copy file "from" to file "to".
* Destination file is truncated if existing.
...
...
@@ -1285,7 +1319,6 @@ static void history_count(void) {
ms_free
(
src_db
);
bc_free
(
tmp_db
);
}
#endif
static
void
text_status_after_destroying_chat_room
(
void
)
{
LinphoneCoreManager
*
marie
=
linphone_core_manager_new
(
"marie_rc"
);
...
...
@@ -1759,7 +1792,7 @@ void file_transfer_with_http_proxy(void) {
test_t
message_tests
[]
=
{
TEST_NO_TAG
(
"Text message"
,
text_message
),
TEST_O
NE
_TAG
(
"Text message within call dialog"
,
text_message_within_call_dialog
,
"LeaksMemory"
),
TEST_
N
O_TAG
(
"Text message within call dialog"
,
text_message_within_call_dialog
),
TEST_NO_TAG
(
"Text message with credentials from auth callback"
,
text_message_with_credential_from_auth_callback
),
TEST_NO_TAG
(
"Text message with privacy"
,
text_message_with_privacy
),
TEST_NO_TAG
(
"Text message compatibility mode"
,
text_message_compatibility_mode
),
...
...
@@ -1778,18 +1811,15 @@ test_t message_tests[] = {
TEST_NO_TAG
(
"Info message"
,
info_message
),
TEST_NO_TAG
(
"Info message with body"
,
info_message_with_body
),
TEST_NO_TAG
(
"IsComposing notification"
,
is_composing_notification
),
#ifdef HAVE_LIME
TEST_NO_TAG
(
"Lime text message"
,
lime_text_message
),
TEST_NO_TAG
(
"Lime text message to non lime"
,
lime_text_message_to_non_lime
),
TEST_NO_TAG
(
"Lime transfer message"
,
lime_transfer_message
),
TEST_ONE_TAG
(
"Lime transfer message from history"
,
lime_transfer_message_from_history
,
"LeaksMemory"
),
TEST_NO_TAG
(
"Lime transfer message without encryption"
,
lime_transfer_message_without_encryption
),
TEST_NO_TAG
(
"Lime unitary"
,
lime_unit
),
#endif
/* HAVE_LIME */
#ifdef MSG_STORAGE_ENABLED
TEST_NO_TAG
(
"Database migration"
,
database_migration
),
TEST_NO_TAG
(
"History range"
,
history_range
),
TEST_NO_TAG
(
"History count"
,
history_count
),
#endif
TEST_NO_TAG
(
"Text status after destroying chat room"
,
text_status_after_destroying_chat_room
),
TEST_ONE_TAG
(
"Transfer not sent if invalid url"
,
file_transfer_not_sent_if_invalid_url
,
"LeaksMemory"
),
TEST_ONE_TAG
(
"Transfer not sent if host not found"
,
file_transfer_not_sent_if_host_not_found
,
"LeaksMemory"
),
...
...
tester/tester.c
View file @
d8158669
...
...
@@ -117,6 +117,7 @@ LinphoneCore* configure_lc_from(LinphoneCoreVTable* v_table, const char* path, c
char
*
rootcapath
=
NULL
;
char
*
dnsuserhostspath
=
NULL
;
char
*
nowebcampath
=
NULL
;
char
*
chatdb
=
NULL
;
if
(
path
==
NULL
)
path
=
"."
;
...
...
@@ -134,8 +135,8 @@ LinphoneCore* configure_lc_from(LinphoneCoreVTable* v_table, const char* path, c
ringbackpath
=
ms_strdup_printf
(
"%s/sounds/ringback.wav"
,
path
);
nowebcampath
=
ms_strdup_printf
(
"%s/images/nowebcamCIF.jpg"
,
path
);
rootcapath
=
ms_strdup_printf
(
"%s/certificates/cn/cafile.pem"
,
path
);
dnsuserhostspath
=
ms_strdup_printf
(
"%s/%s"
,
path
,
userhostsfile
);
dnsuserhostspath
=
ms_strdup_printf
(
"%s/%s"
,
path
,
userhostsfile
);
if
(
config
!=
NULL
)
{
lp_config_set_string
(
config
,
"sound"
,
"remote_ring"
,
ringbackpath
);
...
...
@@ -149,18 +150,22 @@ LinphoneCore* configure_lc_from(LinphoneCoreVTable* v_table, const char* path, c
linphone_core_set_ringback
(
lc
,
ringbackpath
);
linphone_core_set_root_ca
(
lc
,
rootcapath
);
}
chatdb
=
ms_strdup_printf
(
"%s/messages-%p.db"
,
bc_tester_get_writable_dir_prefix
(),
lc
);
linphone_core_enable_ipv6
(
lc
,
liblinphonetester_ipv6
);
sal_enable_test_features
(
lc
->
sal
,
TRUE
);
sal_set_dns_user_hosts_file
(
lc
->
sal
,
dnsuserhostspath
);
linphone_core_set_static_picture
(
lc
,
nowebcampath
);
linphone_core_set_chat_database_path
(
lc
,
chatdb
);
ms_free
(
ringpath
);
ms_free
(
ringbackpath
);
ms_free
(
nowebcampath
);
ms_free
(
rootcapath
);
ms_free
(
dnsuserhostspath
);
ms_free
(
chatdb
);
if
(
filepath
)
ms_free
(
filepath
);
...
...
@@ -415,7 +420,7 @@ void linphone_core_manager_uninit(LinphoneCoreManager *mgr) {
if
(
mgr
->
stat
.
last_received_info_message
)
linphone_info_message_destroy
(
mgr
->
stat
.
last_received_info_message
);
if
(
mgr
->
lc
){
const
char
*
record_file
=
linphone_core_get_record_file
(
mgr
->
lc
);
const
char
*
chatdb
=
linphone_core_get_chat_database_path
(
mgr
->
lc
);
if
(
!
liblinphone_tester_keep_record_files
&&
record_file
){
if
((
bc_get_number_of_failures
()
-
mgr
->
number_of_cunit_error_at_creation
)
>
0
)
{
ms_message
(
"Test has failed, keeping recorded file [%s]"
,
record_file
);
...
...
@@ -424,6 +429,7 @@ void linphone_core_manager_uninit(LinphoneCoreManager *mgr) {
}
}
linphone_core_destroy
(
mgr
->
lc
);
if
(
chatdb
)
unlink
(
chatdb
);
}
if
(
mgr
->
identity
)
{
linphone_address_destroy
(
mgr
->
identity
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment