Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Mohammed Sadiq
chatty
Commits
809a3a9b
Commit
809a3a9b
authored
Sep 02, 2021
by
Mohammed Sadiq
Browse files
tests: Add draft message tests
parent
7370008a
Pipeline
#71902
passed with stages
in 12 minutes and 8 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
tests/history.c
View file @
809a3a9b
...
...
@@ -582,7 +582,9 @@ add_chatty_message (ChattyHistory *history,
message
=
chatty_message_new
(
CHATTY_ITEM
(
contact
),
what
,
uuid
,
when
,
type
,
direction
,
status
);
g_clear_pointer
(
&
uuid
,
g_free
);
g_assert
(
CHATTY_IS_MESSAGE
(
message
));
g_ptr_array_add
(
msg_array
,
message
);
if
(
status
!=
CHATTY_STATUS_DRAFT
)
g_ptr_array_add
(
msg_array
,
message
);
task
=
g_task_new
(
NULL
,
NULL
,
NULL
,
NULL
);
chatty_history_add_message_async
(
history
,
chat
,
message
,
finish_bool_cb
,
task
);
...
...
@@ -625,6 +627,20 @@ add_chatty_message (ChattyHistory *history,
g_assert_finalize_object
(
task
);
g_ptr_array_unref
(
old_msg_array
);
}
if
(
status
==
CHATTY_STATUS_DRAFT
)
{
g_autofree
char
*
draft
=
NULL
;
task
=
g_task_new
(
NULL
,
NULL
,
NULL
,
NULL
);
chatty_history_get_draft_async
(
history
,
chat
,
finish_pointer_cb
,
task
);
while
(
!
g_task_get_completed
(
task
))
g_main_context_iteration
(
NULL
,
TRUE
);
draft
=
g_task_propagate_pointer
(
task
,
NULL
);
g_assert_cmpstr
(
draft
,
==
,
what
);
g_clear_object
(
&
task
);
}
}
static
void
...
...
@@ -743,6 +759,13 @@ test_history_message (void)
/* FIXME */
/* g_assert_finalize_object (chat); */
add_chatty_message
(
history
,
chat
,
msg_array
,
"Draft message"
,
when
+
1
,
CHATTY_MESSAGE_HTML_ESCAPED
,
CHATTY_DIRECTION_OUT
,
CHATTY_STATUS_DRAFT
);
add_chatty_message
(
history
,
chat
,
msg_array
,
"changed draft message"
,
when
+
3
,
CHATTY_MESSAGE_HTML_ESCAPED
,
CHATTY_DIRECTION_OUT
,
CHATTY_STATUS_DRAFT
);
add_chatty_message
(
history
,
chat
,
msg_array
,
"yet another draft"
,
when
+
2
,
CHATTY_MESSAGE_HTML_ESCAPED
,
CHATTY_DIRECTION_OUT
,
CHATTY_STATUS_DRAFT
);
g_ptr_array_unref
(
msg_array
);
chatty_history_close
(
history
);
}
...
...
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