mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
Added server_event tests
This commit is contained in:
parent
d0a0e5e74f
commit
7a10443164
@ -86,6 +86,7 @@ tests_sources = \
|
||||
tests/test_parser.c tests/test_parser.h \
|
||||
tests/test_preferences.c tests/test_preferences.h \
|
||||
tests/test_roster_list.c tests/test_roster_list.h \
|
||||
tests/test_server_events.c tests/test_server_events.h \
|
||||
tests/test_autocomplete.c tests/test_autocomplete.h \
|
||||
tests/testsuite.c
|
||||
|
||||
|
@ -11,14 +11,10 @@
|
||||
#include "chat_session.h"
|
||||
#include "config/preferences.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ui/mock_ui.h"
|
||||
#include "muc.h"
|
||||
|
||||
void console_doesnt_show_online_presence_when_set_none(void **state)
|
||||
{
|
||||
mock_cons_show_contact_online();
|
||||
stub_ui_chat_win_contact_online();
|
||||
stub_rosterwin_roster();
|
||||
prefs_set_string(PREF_STATUSES_CONSOLE, "none");
|
||||
roster_init();
|
||||
roster_add("test1@server", "bob", NULL, "both", FALSE);
|
||||
@ -31,15 +27,15 @@ void console_doesnt_show_online_presence_when_set_none(void **state)
|
||||
|
||||
void console_shows_online_presence_when_set_online(void **state)
|
||||
{
|
||||
mock_cons_show_contact_online();
|
||||
stub_ui_chat_win_contact_online();
|
||||
prefs_set_string(PREF_STATUSES_CONSOLE, "online");
|
||||
roster_init();
|
||||
roster_add("test1@server", "bob", NULL, "both", FALSE);
|
||||
Resource *resource = resource_new("resource", RESOURCE_ONLINE, NULL, 10);
|
||||
PContact contact = roster_get_contact("test1@server");
|
||||
|
||||
expect_cons_show_contact_online(contact, resource, NULL);
|
||||
expect_memory(cons_show_contact_online, contact, contact, sizeof(contact));
|
||||
expect_memory(cons_show_contact_online, resource, resource, sizeof(resource));
|
||||
expect_value(cons_show_contact_online, last_activity, NULL);
|
||||
|
||||
handle_contact_online("test1@server", resource, NULL);
|
||||
|
||||
@ -48,15 +44,15 @@ void console_shows_online_presence_when_set_online(void **state)
|
||||
|
||||
void console_shows_online_presence_when_set_all(void **state)
|
||||
{
|
||||
mock_cons_show_contact_online();
|
||||
stub_ui_chat_win_contact_online();
|
||||
prefs_set_string(PREF_STATUSES_CONSOLE, "all");
|
||||
roster_init();
|
||||
roster_add("test1@server", "bob", NULL, "both", FALSE);
|
||||
Resource *resource = resource_new("resource", RESOURCE_ONLINE, NULL, 10);
|
||||
PContact contact = roster_get_contact("test1@server");
|
||||
|
||||
expect_cons_show_contact_online(contact, resource, NULL);
|
||||
expect_memory(cons_show_contact_online, contact, contact, sizeof(contact));
|
||||
expect_memory(cons_show_contact_online, resource, resource, sizeof(resource));
|
||||
expect_value(cons_show_contact_online, last_activity, NULL);
|
||||
|
||||
handle_contact_online("test1@server", resource, NULL);
|
||||
|
||||
@ -65,8 +61,6 @@ void console_shows_online_presence_when_set_all(void **state)
|
||||
|
||||
void console_doesnt_show_dnd_presence_when_set_none(void **state)
|
||||
{
|
||||
mock_cons_show_contact_online();
|
||||
stub_ui_chat_win_contact_online();
|
||||
prefs_set_string(PREF_STATUSES_CONSOLE, "none");
|
||||
roster_init();
|
||||
roster_add("test1@server", "bob", NULL, "both", FALSE);
|
||||
@ -79,8 +73,6 @@ void console_doesnt_show_dnd_presence_when_set_none(void **state)
|
||||
|
||||
void console_doesnt_show_dnd_presence_when_set_online(void **state)
|
||||
{
|
||||
mock_cons_show_contact_online();
|
||||
stub_ui_chat_win_contact_online();
|
||||
prefs_set_string(PREF_STATUSES_CONSOLE, "online");
|
||||
roster_init();
|
||||
roster_add("test1@server", "bob", NULL, "both", FALSE);
|
||||
@ -93,15 +85,15 @@ void console_doesnt_show_dnd_presence_when_set_online(void **state)
|
||||
|
||||
void console_shows_dnd_presence_when_set_all(void **state)
|
||||
{
|
||||
mock_cons_show_contact_online();
|
||||
stub_ui_chat_win_contact_online();
|
||||
prefs_set_string(PREF_STATUSES_CONSOLE, "all");
|
||||
roster_init();
|
||||
roster_add("test1@server", "bob", NULL, "both", FALSE);
|
||||
Resource *resource = resource_new("resource", RESOURCE_ONLINE, NULL, 10);
|
||||
PContact contact = roster_get_contact("test1@server");
|
||||
|
||||
expect_cons_show_contact_online(contact, resource, NULL);
|
||||
expect_memory(cons_show_contact_online, contact, contact, sizeof(contact));
|
||||
expect_memory(cons_show_contact_online, resource, resource, sizeof(resource));
|
||||
expect_value(cons_show_contact_online, last_activity, NULL);
|
||||
|
||||
handle_contact_online("test1@server", resource, NULL);
|
||||
|
||||
@ -114,7 +106,7 @@ void handle_message_error_when_no_recipient(void **state)
|
||||
char *from = NULL;
|
||||
char *type = "cancel";
|
||||
|
||||
expect_ui_handle_error(err_msg);
|
||||
expect_string(ui_handle_error, err_msg, err_msg);
|
||||
|
||||
handle_message_error(from, type, err_msg);
|
||||
}
|
||||
@ -128,7 +120,8 @@ void handle_message_error_when_recipient_cancel(void **state)
|
||||
prefs_set_boolean(PREF_STATES, FALSE);
|
||||
chat_sessions_init();
|
||||
|
||||
expect_ui_handle_recipient_not_found(from, err_msg);
|
||||
expect_string(ui_handle_recipient_not_found, recipient, from);
|
||||
expect_string(ui_handle_recipient_not_found, err_msg, err_msg);
|
||||
|
||||
handle_message_error(from, type, err_msg);
|
||||
}
|
||||
@ -139,11 +132,13 @@ void handle_message_error_when_recipient_cancel_disables_chat_session(void **sta
|
||||
char *from = "bob@server.com";
|
||||
char *type = "cancel";
|
||||
|
||||
stub_ui_handle_recipient_not_found();
|
||||
prefs_set_boolean(PREF_STATES, TRUE);
|
||||
chat_sessions_init();
|
||||
chat_session_start(from, TRUE);
|
||||
|
||||
expect_any(ui_handle_recipient_not_found, recipient);
|
||||
expect_any(ui_handle_recipient_not_found, err_msg);
|
||||
|
||||
handle_message_error(from, type, err_msg);
|
||||
gboolean chat_session_supported = chat_session_get_recipient_supports(from);
|
||||
|
||||
@ -157,7 +152,8 @@ void handle_message_error_when_recipient_and_no_type(void **state)
|
||||
char *from = "bob@server.com";
|
||||
char *type = NULL;
|
||||
|
||||
expect_ui_handle_recipient_error(from, err_msg);
|
||||
expect_string(ui_handle_recipient_error, recipient, from);
|
||||
expect_string(ui_handle_recipient_error, err_msg, err_msg);
|
||||
|
||||
handle_message_error(from, type, err_msg);
|
||||
}
|
||||
@ -168,7 +164,7 @@ void handle_presence_error_when_no_recipient(void **state)
|
||||
char *from = NULL;
|
||||
char *type = NULL;
|
||||
|
||||
expect_ui_handle_error(err_msg);
|
||||
expect_string(ui_handle_error, err_msg, err_msg);
|
||||
|
||||
handle_presence_error(from, type, err_msg);
|
||||
}
|
||||
@ -179,7 +175,8 @@ void handle_presence_error_when_from_recipient(void **state)
|
||||
char *from = "bob@server.com";
|
||||
char *type = NULL;
|
||||
|
||||
expect_ui_handle_recipient_error(from, err_msg);
|
||||
expect_string(ui_handle_recipient_error, recipient, from);
|
||||
expect_string(ui_handle_recipient_error, err_msg, err_msg);
|
||||
|
||||
handle_presence_error(from, type, err_msg);
|
||||
}
|
||||
|
@ -361,7 +361,6 @@ int main(int argc, char* argv[]) {
|
||||
load_preferences,
|
||||
close_preferences),
|
||||
|
||||
/*
|
||||
unit_test_setup_teardown(console_doesnt_show_online_presence_when_set_none,
|
||||
load_preferences,
|
||||
close_preferences),
|
||||
@ -390,7 +389,7 @@ int main(int argc, char* argv[]) {
|
||||
unit_test(handle_message_error_when_recipient_and_no_type),
|
||||
unit_test(handle_presence_error_when_no_recipient),
|
||||
unit_test(handle_presence_error_when_from_recipient),
|
||||
*/
|
||||
|
||||
unit_test(cmd_alias_add_shows_usage_when_no_args),
|
||||
unit_test(cmd_alias_add_shows_usage_when_no_value),
|
||||
unit_test(cmd_alias_remove_shows_usage_when_no_args),
|
||||
|
@ -247,9 +247,24 @@ void ui_group_added(const char * const contact, const char * const group) {}
|
||||
void ui_group_removed(const char * const contact, const char * const group) {}
|
||||
void ui_chat_win_contact_online(PContact contact, Resource *resource, GDateTime *last_activity) {}
|
||||
void ui_chat_win_contact_offline(PContact contact, char *resource, char *status) {}
|
||||
void ui_handle_recipient_not_found(const char * const recipient, const char * const err_msg) {}
|
||||
void ui_handle_recipient_error(const char * const recipient, const char * const err_msg) {}
|
||||
void ui_handle_error(const char * const err_msg) {}
|
||||
|
||||
void ui_handle_recipient_not_found(const char * const recipient, const char * const err_msg)
|
||||
{
|
||||
check_expected(recipient);
|
||||
check_expected(err_msg);
|
||||
}
|
||||
|
||||
void ui_handle_recipient_error(const char * const recipient, const char * const err_msg)
|
||||
{
|
||||
check_expected(recipient);
|
||||
check_expected(err_msg);
|
||||
}
|
||||
|
||||
void ui_handle_error(const char * const err_msg)
|
||||
{
|
||||
check_expected(err_msg);
|
||||
}
|
||||
|
||||
void ui_clear_win_title(void) {}
|
||||
void ui_handle_room_join_error(const char * const roomjid, const char * const err) {}
|
||||
void ui_handle_room_configuration(const char * const roomjid, DataForm *form) {}
|
||||
@ -432,7 +447,14 @@ void cons_autoping_setting(void) {}
|
||||
void cons_priority_setting(void) {}
|
||||
void cons_autoconnect_setting(void) {}
|
||||
void cons_inpblock_setting(void) {}
|
||||
void cons_show_contact_online(PContact contact, Resource *resource, GDateTime *last_activity) {}
|
||||
|
||||
void cons_show_contact_online(PContact contact, Resource *resource, GDateTime *last_activity)
|
||||
{
|
||||
check_expected(contact);
|
||||
check_expected(resource);
|
||||
check_expected(last_activity);
|
||||
}
|
||||
|
||||
void cons_show_contact_offline(PContact contact, char *resource, char *status) {}
|
||||
void cons_theme_colours(void) {}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user