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
0e61ad55
Commit
0e61ad55
authored
Feb 14, 2018
by
Sylvain Berfini
🐮
Browse files
Added tests for unread count on ChatRoom
parent
7be8d6aa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
0 deletions
+48
-0
tester/message_tester.c
tester/message_tester.c
+48
-0
No files found.
tester/message_tester.c
View file @
0e61ad55
...
...
@@ -2282,6 +2282,52 @@ void im_encryption_engine_b64_async(void) {
im_encryption_engine_b64_base
(
TRUE
);
}
void
unread_message_count
(
void
)
{
LinphoneCoreManager
*
marie
=
linphone_core_manager_new
(
"marie_rc"
);
LinphoneCoreManager
*
pauline
=
linphone_core_manager_new
(
"pauline_tcp_rc"
);
text_message_base
(
marie
,
pauline
);
BC_ASSERT_PTR_NOT_NULL
(
marie
->
stat
.
last_received_chat_message
);
if
(
marie
->
stat
.
last_received_chat_message
!=
NULL
)
{
LinphoneChatRoom
*
marie_room
=
linphone_chat_message_get_chat_room
(
marie
->
stat
.
last_received_chat_message
);
BC_ASSERT_EQUAL
(
1
,
linphone_chat_room_get_unread_messages_count
(
marie_room
),
int
,
"%d"
);
linphone_chat_room_mark_as_read
(
marie_room
);
BC_ASSERT_EQUAL
(
0
,
linphone_chat_room_get_unread_messages_count
(
marie_room
),
int
,
"%d"
);
}
linphone_core_manager_destroy
(
marie
);
linphone_core_manager_destroy
(
pauline
);
}
static
void
message_received_callback
(
LinphoneCore
*
lc
,
LinphoneChatRoom
*
room
,
LinphoneChatMessage
*
msg
)
{
BC_ASSERT_PTR_NOT_NULL
(
room
);
BC_ASSERT_EQUAL
(
1
,
linphone_chat_room_get_unread_messages_count
(
room
),
int
,
"%d"
);
BC_ASSERT_PTR_NOT_NULL
(
msg
);
if
(
room
!=
NULL
)
{
linphone_chat_room_mark_as_read
(
room
);
}
BC_ASSERT_EQUAL
(
0
,
linphone_chat_room_get_unread_messages_count
(
room
),
int
,
"%d"
);
}
void
unread_message_count_callback
(
void
)
{
LinphoneCoreManager
*
marie
=
linphone_core_manager_new
(
"marie_rc"
);
LinphoneCoreManager
*
pauline
=
linphone_core_manager_new
(
"pauline_tcp_rc"
);
int
dummy
=
0
;
LinphoneCoreCbs
*
cbs
=
linphone_factory_create_core_cbs
(
linphone_factory_get
());
linphone_core_cbs_set_message_received
(
cbs
,
message_received_callback
);
linphone_core_add_callbacks
(
marie
->
lc
,
cbs
);
text_message_base
(
marie
,
pauline
);
wait_for_until
(
pauline
->
lc
,
marie
->
lc
,
&
dummy
,
1
,
5000
);
linphone_core_cbs_unref
(
cbs
);
linphone_core_manager_destroy
(
marie
);
linphone_core_manager_destroy
(
pauline
);
}
test_t
message_tests
[]
=
{
TEST_NO_TAG
(
"Text message"
,
text_message
),
TEST_NO_TAG
(
"Text message with credentials from auth callback"
,
text_message_with_credential_from_auth_callback
),
...
...
@@ -2305,6 +2351,8 @@ test_t message_tests[] = {
TEST_NO_TAG
(
"IMDN notifications"
,
imdn_notifications
),
TEST_NO_TAG
(
"IM notification policy"
,
im_notification_policy
),
#ifdef SQLITE_STORAGE_ENABLED
TEST_NO_TAG
(
"Unread message count"
,
unread_message_count
),
TEST_NO_TAG
(
"Unread message count in callback"
,
unread_message_count_callback
),
TEST_ONE_TAG
(
"IsComposing notification lime"
,
is_composing_notification_with_lime
,
"LIME"
),
TEST_ONE_TAG
(
"IMDN notifications with lime"
,
imdn_notifications_with_lime
,
"LIME"
),
TEST_ONE_TAG
(
"IM notification policy with lime"
,
im_notification_policy_with_lime
,
"LIME"
),
...
...
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