diff --git a/Makefile.am b/Makefile.am index 436d215c..dd4bf83c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -60,6 +60,7 @@ test_sources = \ src/config/accounts.h \ src/config/preferences.c src/config/preferences.h \ src/config/theme.c src/config/theme.h \ + tests/common_mocks.c tests/common_mocks.h \ tests/ui/mock_ui.c \ tests/xmpp/mock_xmpp.c \ tests/log/mock_log.c \ diff --git a/tests/common_mocks.c b/tests/common_mocks.c new file mode 100644 index 00000000..ab0f7856 --- /dev/null +++ b/tests/common_mocks.c @@ -0,0 +1,48 @@ +#include +#include +#include +#include +#include +#include +#include + +#include "xmpp/xmpp.h" + +static jabber_conn_status_t +_mock_jabber_get_connection_status(void) +{ + return (jabber_conn_status_t)mock(); +} + +static char * +_mock_jabber_get_account_name(void) +{ + return (char *)mock(); +} + +static void +_mock_iq_room_list_request(gchar *conf_server) +{ + check_expected(conf_server); +} + +void +mock_connection_status(jabber_conn_status_t status) +{ + jabber_get_connection_status = _mock_jabber_get_connection_status; + will_return(_mock_jabber_get_connection_status, status); +} + +void +mock_connection_account_name(char *name) +{ + jabber_get_account_name = _mock_jabber_get_account_name; + will_return(_mock_jabber_get_account_name, name); +} + +void +expect_room_list_request(char *conf_server) +{ + iq_room_list_request = _mock_iq_room_list_request; + expect_string(_mock_iq_room_list_request, conf_server, conf_server); +} diff --git a/tests/common_mocks.h b/tests/common_mocks.h new file mode 100644 index 00000000..89096836 --- /dev/null +++ b/tests/common_mocks.h @@ -0,0 +1,10 @@ +#ifndef COMMON_MOCKS_H +#define COMMON_MOCKS_H + +#include "xmpp/xmpp.h" + +void mock_connection_status(jabber_conn_status_t status); +void mock_connection_account_name(char *name); +void expect_room_list_request(char *conf_server); + +#endif diff --git a/tests/test_cmd_account.c b/tests/test_cmd_account.c index 6c3f34ff..87194620 100644 --- a/tests/test_cmd_account.c +++ b/tests/test_cmd_account.c @@ -9,6 +9,7 @@ #include "xmpp/xmpp.h" #include "ui/ui.h" #include "command/commands.h" +#include "common_mocks.h" void cmd_account_shows_usage_when_not_connected_and_no_args(void **state) { @@ -16,7 +17,7 @@ void cmd_account_shows_usage_when_not_connected_and_no_args(void **state) help->usage = "some usage"; gchar *args[] = { NULL }; - will_return(jabber_get_connection_status, JABBER_DISCONNECTED); + mock_connection_status(JABBER_DISCONNECTED); expect_string(cons_show, output, "Usage: some usage"); @@ -32,9 +33,8 @@ void cmd_account_shows_account_when_connected_and_no_args(void **state) ProfAccount *account = malloc(sizeof(ProfAccount)); gchar *args[] = { NULL }; - will_return(jabber_get_connection_status, JABBER_CONNECTED); - - will_return(jabber_get_account_name, "account_name"); + mock_connection_status(JABBER_CONNECTED); + mock_connection_account_name("account_name"); expect_any(accounts_get_account, name); will_return(accounts_get_account, account); @@ -851,7 +851,7 @@ void cmd_account_set_online_priority_sets_preference(void **state) expect_string(accounts_set_priority_online, account_name, "a_account"); expect_value(accounts_set_priority_online, value, 10); - will_return(jabber_get_connection_status, JABBER_DISCONNECTED); + mock_connection_status(JABBER_DISCONNECTED); expect_any_count(cons_show, output, 2); @@ -872,7 +872,7 @@ void cmd_account_set_chat_priority_sets_preference(void **state) expect_string(accounts_set_priority_chat, account_name, "a_account"); expect_value(accounts_set_priority_chat, value, 10); - will_return(jabber_get_connection_status, JABBER_DISCONNECTED); + mock_connection_status(JABBER_DISCONNECTED); expect_any_count(cons_show, output, 2); @@ -893,7 +893,7 @@ void cmd_account_set_away_priority_sets_preference(void **state) expect_string(accounts_set_priority_away, account_name, "a_account"); expect_value(accounts_set_priority_away, value, 10); - will_return(jabber_get_connection_status, JABBER_DISCONNECTED); + mock_connection_status(JABBER_DISCONNECTED); expect_any_count(cons_show, output, 2); @@ -914,7 +914,7 @@ void cmd_account_set_xa_priority_sets_preference(void **state) expect_string(accounts_set_priority_xa, account_name, "a_account"); expect_value(accounts_set_priority_xa, value, 10); - will_return(jabber_get_connection_status, JABBER_DISCONNECTED); + mock_connection_status(JABBER_DISCONNECTED); expect_any_count(cons_show, output, 2); @@ -935,7 +935,7 @@ void cmd_account_set_dnd_priority_sets_preference(void **state) expect_string(accounts_set_priority_dnd, account_name, "a_account"); expect_value(accounts_set_priority_dnd, value, 10); - will_return(jabber_get_connection_status, JABBER_DISCONNECTED); + mock_connection_status(JABBER_DISCONNECTED); expect_any_count(cons_show, output, 2); diff --git a/tests/test_cmd_connect.c b/tests/test_cmd_connect.c index 3625a521..ca1ead29 100644 --- a/tests/test_cmd_connect.c +++ b/tests/test_cmd_connect.c @@ -10,11 +10,46 @@ #include "ui/ui.h" #include "command/commands.h" +#include "common_mocks.h" + +static jabber_conn_status_t _mock_jabber_connect_with_details_no_altdomain(const char * const jid, + const char * const passwd, const char * const altdomain) +{ + check_expected(jid); + check_expected(passwd); + return (jabber_conn_status_t)mock(); +} + +static jabber_conn_status_t _mock_jabber_connect_with_details_altdomain(const char * const jid, + const char * const passwd, const char * const altdomain) +{ + check_expected(altdomain); + return (jabber_conn_status_t)mock(); +} + +static jabber_conn_status_t _mock_jabber_connect_with_details_result(const char * const jid, + const char * const passwd, const char * const altdomain) +{ + return (jabber_conn_status_t)mock(); +} + +static jabber_conn_status_t _mock_jabber_connect_with_account_result(const ProfAccount * const account) +{ + return (jabber_conn_status_t)mock(); +} + +static jabber_conn_status_t _mock_jabber_connect_with_account_result_check(const ProfAccount * const account) +{ + check_expected(account); + return (jabber_conn_status_t)mock(); +} + static void test_with_connection_status(jabber_conn_status_t status) { CommandHelp *help = malloc(sizeof(CommandHelp)); - will_return(jabber_get_connection_status, status); + mock_connection_status(status); + expect_string(cons_show, output, "You are either connected already, or a login is in process."); gboolean result = cmd_connect(NULL, *help); @@ -48,7 +83,7 @@ void cmd_connect_when_no_account(void **state) CommandHelp *help = malloc(sizeof(CommandHelp)); gchar *args[] = { "user@server.org", NULL }; - will_return(jabber_get_connection_status, JABBER_DISCONNECTED); + mock_connection_status(JABBER_DISCONNECTED); expect_string(accounts_get_account, name, "user@server.org"); will_return(accounts_get_account, NULL); @@ -57,10 +92,10 @@ void cmd_connect_when_no_account(void **state) expect_string(cons_show, output, "Connecting as user@server.org"); - expect_string(jabber_connect_with_details, jid, "user@server.org"); - expect_string(jabber_connect_with_details, passwd, "password"); - expect_any(jabber_connect_with_details, altdomain); - will_return(jabber_connect_with_details, JABBER_CONNECTING); + jabber_connect_with_details = _mock_jabber_connect_with_details_no_altdomain; + expect_string(_mock_jabber_connect_with_details_no_altdomain, jid, "user@server.org"); + expect_string(_mock_jabber_connect_with_details_no_altdomain, passwd, "password"); + will_return(_mock_jabber_connect_with_details_no_altdomain, JABBER_CONNECTING); gboolean result = cmd_connect(args, *help); assert_true(result); @@ -73,7 +108,7 @@ void cmd_connect_with_altdomain_when_provided(void **state) CommandHelp *help = malloc(sizeof(CommandHelp)); gchar *args[] = { "user@server.org", "altdomain" }; - will_return(jabber_get_connection_status, JABBER_DISCONNECTED); + mock_connection_status(JABBER_DISCONNECTED); expect_any(accounts_get_account, name); will_return(accounts_get_account, NULL); @@ -82,10 +117,9 @@ void cmd_connect_with_altdomain_when_provided(void **state) expect_any(cons_show, output); - expect_any(jabber_connect_with_details, jid); - expect_any(jabber_connect_with_details, passwd); - expect_string(jabber_connect_with_details, altdomain, "altdomain"); - will_return(jabber_connect_with_details, JABBER_CONNECTING); + jabber_connect_with_details = _mock_jabber_connect_with_details_altdomain; + expect_string(_mock_jabber_connect_with_details_altdomain, altdomain, "altdomain"); + will_return(_mock_jabber_connect_with_details_altdomain, JABBER_CONNECTING); gboolean result = cmd_connect(args, *help); assert_true(result); @@ -98,7 +132,7 @@ void cmd_connect_fail_message(void **state) CommandHelp *help = malloc(sizeof(CommandHelp)); gchar *args[] = { "user@server.org", NULL }; - will_return(jabber_get_connection_status, JABBER_DISCONNECTED); + mock_connection_status(JABBER_DISCONNECTED); expect_any(accounts_get_account, name); will_return(accounts_get_account, NULL); @@ -107,10 +141,8 @@ void cmd_connect_fail_message(void **state) expect_any(cons_show, output); - expect_any(jabber_connect_with_details, jid); - expect_any(jabber_connect_with_details, passwd); - expect_any(jabber_connect_with_details, altdomain); - will_return(jabber_connect_with_details, JABBER_DISCONNECTED); + jabber_connect_with_details = _mock_jabber_connect_with_details_result; + will_return(_mock_jabber_connect_with_details_result, JABBER_DISCONNECTED); expect_string(cons_show_error, output, "Connection attempt for user@server.org failed."); @@ -125,7 +157,7 @@ void cmd_connect_lowercases_argument(void **state) CommandHelp *help = malloc(sizeof(CommandHelp)); gchar *args[] = { "USER@server.ORG", NULL }; - will_return(jabber_get_connection_status, JABBER_DISCONNECTED); + mock_connection_status(JABBER_DISCONNECTED); expect_string(accounts_get_account, name, "user@server.org"); will_return(accounts_get_account, NULL); @@ -134,10 +166,8 @@ void cmd_connect_lowercases_argument(void **state) expect_any(cons_show, output); - expect_any(jabber_connect_with_details, jid); - expect_any(jabber_connect_with_details, passwd); - expect_any(jabber_connect_with_details, altdomain); - will_return(jabber_connect_with_details, JABBER_CONNECTING); + jabber_connect_with_details = _mock_jabber_connect_with_details_result; + will_return(_mock_jabber_connect_with_details_result, JABBER_CONNECTING); gboolean result = cmd_connect(args, *help); assert_true(result); @@ -152,7 +182,7 @@ void cmd_connect_asks_password_when_not_in_account(void **state) ProfAccount *account = malloc(sizeof(ProfAccount)); account->password = NULL; - will_return(jabber_get_connection_status, JABBER_DISCONNECTED); + mock_connection_status(JABBER_DISCONNECTED); expect_any(accounts_get_account, name); will_return(accounts_get_account, account); @@ -163,8 +193,8 @@ void cmd_connect_asks_password_when_not_in_account(void **state) expect_any(cons_show, output); - expect_any(jabber_connect_with_account, account); - will_return(jabber_connect_with_account, JABBER_CONNECTING); + jabber_connect_with_account = _mock_jabber_connect_with_account_result; + will_return(_mock_jabber_connect_with_account_result, JABBER_CONNECTING); expect_any(accounts_free_account, account); @@ -183,7 +213,7 @@ void cmd_connect_shows_message_when_connecting_with_account(void **state) account->password = "password"; account->name = "jabber_org"; - will_return(jabber_get_connection_status, JABBER_DISCONNECTED); + mock_connection_status(JABBER_DISCONNECTED); expect_any(accounts_get_account, name); will_return(accounts_get_account, account); @@ -192,8 +222,8 @@ void cmd_connect_shows_message_when_connecting_with_account(void **state) expect_string(cons_show, output, "Connecting with account jabber_org as user@jabber.org/laptop"); - expect_any(jabber_connect_with_account, account); - will_return(jabber_connect_with_account, JABBER_CONNECTING); + jabber_connect_with_account = _mock_jabber_connect_with_account_result; + will_return(_mock_jabber_connect_with_account_result, JABBER_CONNECTING); expect_any(accounts_free_account, account); @@ -212,7 +242,7 @@ void cmd_connect_connects_with_account(void **state) account->password = "password"; account->name = "jabber_org"; - will_return(jabber_get_connection_status, JABBER_DISCONNECTED); + mock_connection_status(JABBER_DISCONNECTED); expect_any(accounts_get_account, name); will_return(accounts_get_account, account); @@ -221,8 +251,9 @@ void cmd_connect_connects_with_account(void **state) expect_any(cons_show, output); - expect_memory(jabber_connect_with_account, account, account, sizeof(ProfAccount)); - will_return(jabber_connect_with_account, JABBER_CONNECTING); + jabber_connect_with_account = _mock_jabber_connect_with_account_result_check; + expect_memory(_mock_jabber_connect_with_account_result_check, account, account, sizeof(ProfAccount)); + will_return(_mock_jabber_connect_with_account_result_check, JABBER_CONNECTING); expect_any(accounts_free_account, account); @@ -239,7 +270,7 @@ void cmd_connect_frees_account_after_connecting(void **state) gchar *args[] = { "jabber_org", NULL }; ProfAccount *account = malloc(sizeof(ProfAccount)); - will_return(jabber_get_connection_status, JABBER_DISCONNECTED); + mock_connection_status(JABBER_DISCONNECTED); expect_any(accounts_get_account, name); will_return(accounts_get_account, account); @@ -248,8 +279,8 @@ void cmd_connect_frees_account_after_connecting(void **state) expect_any(cons_show, output); - expect_any(jabber_connect_with_account, account); - will_return(jabber_connect_with_account, JABBER_CONNECTING); + jabber_connect_with_account = _mock_jabber_connect_with_account_result; + will_return(_mock_jabber_connect_with_account_result, JABBER_CONNECTING); expect_memory(accounts_free_account, account, account, sizeof(ProfAccount)); diff --git a/tests/test_cmd_rooms.c b/tests/test_cmd_rooms.c index e39d9088..b1022a98 100644 --- a/tests/test_cmd_rooms.c +++ b/tests/test_cmd_rooms.c @@ -8,12 +8,13 @@ #include "xmpp/xmpp.h" #include "ui/ui.h" #include "command/commands.h" +#include "common_mocks.h" static void test_with_connection_status(jabber_conn_status_t status) { CommandHelp *help = malloc(sizeof(CommandHelp)); - will_return(jabber_get_connection_status, status); + mock_connection_status(status); expect_string(cons_show, output, "You are not currently connected."); gboolean result = cmd_rooms(NULL, *help); @@ -54,11 +55,13 @@ void cmd_rooms_uses_account_default_when_no_arg(void **state) account->muc_service = "default_conf_server"; gchar *args[] = { NULL }; - will_return(jabber_get_connection_status, JABBER_CONNECTED); - will_return(jabber_get_account_name, "account_name"); + mock_connection_status(JABBER_CONNECTED); + mock_connection_account_name("account_name"); + expect_string(accounts_get_account, name, "account_name"); will_return(accounts_get_account, account); - expect_string(iq_room_list_request, conferencejid, "default_conf_server"); + + expect_room_list_request("default_conf_server"); gboolean result = cmd_rooms(args, *help); @@ -73,8 +76,9 @@ void cmd_rooms_arg_used_when_passed(void **state) CommandHelp *help = malloc(sizeof(CommandHelp)); gchar *args[] = { "conf_server_arg" }; - will_return(jabber_get_connection_status, JABBER_CONNECTED); - expect_string(iq_room_list_request, conferencejid, "conf_server_arg"); + mock_connection_status(JABBER_CONNECTED); + + expect_room_list_request("conf_server_arg"); gboolean result = cmd_rooms(args, *help); diff --git a/tests/xmpp/mock_xmpp.c b/tests/xmpp/mock_xmpp.c index 8907c13e..7d3031c9 100644 --- a/tests/xmpp/mock_xmpp.c +++ b/tests/xmpp/mock_xmpp.c @@ -27,133 +27,198 @@ #include "xmpp/xmpp.h" // connection functions -void jabber_init(const int disable_tls) {} +static void _jabber_init(const int disable_tls) {} +void (*jabber_init)(const int disable_tls) = _jabber_init; -jabber_conn_status_t jabber_connect_with_details(const char * const jid, +static jabber_conn_status_t _jabber_connect_with_details(const char * const jid, const char * const passwd, const char * const altdomain) { - check_expected(jid); - check_expected(passwd); - check_expected(altdomain); - return (jabber_conn_status_t)mock(); + return JABBER_DISCONNECTED; } +jabber_conn_status_t (*jabber_connect_with_details)(const char * const, + const char * const, const char * const) = _jabber_connect_with_details; -jabber_conn_status_t jabber_connect_with_account(const ProfAccount * const account) +static jabber_conn_status_t _jabber_connect_with_account(const ProfAccount * const account) { - check_expected(account); - return (jabber_conn_status_t)mock(); + return JABBER_DISCONNECTED; } +jabber_conn_status_t (*jabber_connect_with_account)(const ProfAccount * const) = _jabber_connect_with_account; -void jabber_disconnect(void) {} -void jabber_shutdown(void) {} -void jabber_process_events(void) {} -const char * jabber_get_fulljid(void) -{ - return (const char *)mock(); -} -const char * jabber_get_domain(void) -{ - return (const char *)mock(); -} +static void _jabber_disconnect(void) {} +void (*jabber_disconnect)(void) = _jabber_disconnect; -jabber_conn_status_t jabber_get_connection_status(void) -{ - return (jabber_conn_status_t)mock(); -} +static void _jabber_shutdown(void) {} +void (*jabber_shutdown)(void) = _jabber_shutdown; -char * jabber_get_presence_message(void) -{ - return (char *)mock(); -} -void jabber_set_autoping(int seconds) {} +static void _jabber_process_events(void) {} +void (*jabber_process_events)(void) = _jabber_process_events; -char* jabber_get_account_name(void) +static const char * _jabber_get_fulljid(void) { - return (char *)mock(); + return NULL; } +const char * (*jabber_get_fulljid)(void) = _jabber_get_fulljid; -GList * jabber_get_available_resources(void) +static const char * _jabber_get_domain(void) { - return (GList *)mock(); + return NULL; } +const char * (*jabber_get_domain)(void) = _jabber_get_domain; + +static jabber_conn_status_t _jabber_get_connection_status(void) +{ + return JABBER_DISCONNECTED; +} +jabber_conn_status_t (*jabber_get_connection_status)(void) = _jabber_get_connection_status; + +static char * _jabber_get_presence_message(void) +{ + return NULL; +} +char * (*jabber_get_presence_message)(void) = _jabber_get_presence_message; + +static void _jabber_set_autoping(int seconds) {} +void (*jabber_set_autoping)(int) = _jabber_set_autoping; + +static char * _jabber_get_account_name(void) +{ + return NULL; +} +char * (*jabber_get_account_name)(void) = _jabber_get_account_name; + +static GList * _jabber_get_available_resources(void) +{ + return NULL; +} +GList * (*jabber_get_available_resources)(void) = _jabber_get_available_resources; // message functions -void message_send(const char * const msg, const char * const recipient) {} -void message_send_groupchat(const char * const msg, const char * const recipient) {} -void message_send_inactive(const char * const recipient) {} -void message_send_composing(const char * const recipient) {} -void message_send_paused(const char * const recipient) {} -void message_send_gone(const char * const recipient) {} -void message_send_invite(const char * const room, const char * const contact, +static void _message_send(const char * const msg, const char * const recipient) {} +void (*message_send)(const char * const, const char * const) = _message_send; + +static void _message_send_groupchat(const char * const msg, const char * const recipient) {} +void (*message_send_groupchat)(const char * const, const char * const) = _message_send_groupchat; + +static void _message_send_inactive(const char * const recipient) {} +void (*message_send_inactive)(const char * const) = _message_send_inactive; + +static void _message_send_composing(const char * const recipient) {} +void (*message_send_composing)(const char * const) = _message_send_composing; + +static void _message_send_paused(const char * const recipient) {} +void (*message_send_paused)(const char * const) = _message_send_paused; + +static void _message_send_gone(const char * const recipient) {} +void (*message_send_gone)(const char * const) = _message_send_gone; + +static void _message_send_invite(const char * const room, const char * const contact, const char * const reason) {} -void message_send_duck(const char * const query) {} +void (*message_send_invite)(const char * const, const char * const, + const char * const) = _message_send_invite; + +static void _message_send_duck(const char * const query) {} +void (*message_send_duck)(const char * const) = _message_send_duck; // presence functions -void presence_subscription(const char * const jid, const jabber_subscr_t action) {} +static void _presence_subscription(const char * const jid, const jabber_subscr_t action) {} +void (*presence_subscription)(const char * const, const jabber_subscr_t) = _presence_subscription; -GSList* presence_get_subscription_requests(void) +static GSList* _presence_get_subscription_requests(void) { - return (GSList *)mock(); + return NULL; } +GSList* (*presence_get_subscription_requests)(void) = _presence_get_subscription_requests; -gint presence_sub_request_count(void) +static gint _presence_sub_request_count(void) { - return (gint)mock(); + return 0; } +gint (*presence_sub_request_count)(void) = _presence_sub_request_count; -void presence_reset_sub_request_search(void) {} +static void _presence_reset_sub_request_search(void) {} +void (*presence_reset_sub_request_search)(void) = _presence_reset_sub_request_search; -char * presence_sub_request_find(char * search_str) +static char * _presence_sub_request_find(char * search_str) { - return (char *)mock(); + return NULL; } +char * (*presence_sub_request_find)(char *) = _presence_sub_request_find; -void presence_join_room(Jid *jid) {} -void presence_change_room_nick(const char * const room, const char * const nick) {} -void presence_leave_chat_room(const char * const room_jid) {} -void presence_update(resource_presence_t status, const char * const msg, +static void _presence_join_room(Jid *jid) {} +void (*presence_join_room)(Jid *) = _presence_join_room; + +static void _presence_change_room_nick(const char * const room, const char * const nick) {} +void (*presence_change_room_nick)(const char * const, const char * const) = _presence_change_room_nick; + +static void _presence_leave_chat_room(const char * const room_jid) {} +void (*presence_leave_chat_room)(const char * const) = _presence_leave_chat_room; + +static void _presence_update(resource_presence_t status, const char * const msg, int idle) {} -gboolean presence_sub_request_exists(const char * const bare_jid) +void (*presence_update)(resource_presence_t, const char * const, + int) = _presence_update; + +static gboolean _presence_sub_request_exists(const char * const bare_jid) { - return (gboolean)mock(); + return FALSE; } +gboolean (*presence_sub_request_exists)(const char * const bare_jid) = _presence_sub_request_exists; // iq functions -void iq_send_software_version(const char * const fulljid) {} +static void _iq_send_software_version(const char * const fulljid) {} +void (*iq_send_software_version)(const char * const) = _iq_send_software_version; -void iq_room_list_request(gchar *conferencejid) -{ - check_expected(conferencejid); -} +static void _iq_room_list_request(gchar *conferencejid) {} +void (*iq_room_list_request)(gchar *) = _iq_room_list_request; -void iq_disco_info_request(gchar *jid) {} -void iq_disco_items_request(gchar *jid) {} +static void _iq_disco_info_request(gchar *jid) {} +void (*iq_disco_info_request)(gchar *) = _iq_disco_info_request; + +static void _iq_disco_items_request(gchar *jid) {} +void (*iq_disco_items_request)(gchar *) = _iq_disco_items_request; // caps functions -Capabilities* caps_get(const char * const caps_str) +static Capabilities* _caps_get(const char * const caps_str) { - return (Capabilities *)mock(); + return NULL; } +Capabilities* (*caps_get)(const char * const) = _caps_get; -void caps_close(void) {} +static void _caps_close(void) {} +void (*caps_close)(void) = _caps_close; -void bookmark_add(const char *jid, const char *nick, gboolean autojoin) {} -void bookmark_remove(const char *jid, gboolean autojoin) {} +static void _bookmark_add(const char *jid, const char *nick, gboolean autojoin) {} +void (*bookmark_add)(const char *, const char *, gboolean) = _bookmark_add; -const GList *bookmark_get_list(void) +static void _bookmark_remove(const char *jid, gboolean autojoin) {} +void (*bookmark_remove)(const char *, gboolean) = _bookmark_remove; + +static const GList* _bookmark_get_list(void) { - return (const GList *)mock(); + return NULL; } +const GList* (*bookmark_get_list)(void) = _bookmark_get_list; -char *bookmark_find(char *search_str) +static char* _bookmark_find(char *search_str) { - return (char *)mock(); + return NULL; } +char* (*bookmark_find)(char *) = _bookmark_find; -void bookmark_autocomplete_reset(void) {} +static void _bookmark_autocomplete_reset(void) {} +void (*bookmark_autocomplete_reset)(void) = _bookmark_autocomplete_reset; -void roster_send_name_change(const char * const barejid, const char * const new_name, GSList *groups) {} -void roster_send_add_to_group(const char * const group, PContact contact) {} -void roster_send_remove_from_group(const char * const group, PContact contact) {} -void roster_add_new(const char * const barejid, const char * const name) {} -void roster_send_remove(const char * const barejid) {} +static void _roster_send_name_change(const char * const barejid, const char * const new_name, GSList *groups) {} +void (*roster_send_name_change)(const char * const, const char * const, GSList *) = _roster_send_name_change; + +static void _roster_send_add_to_group(const char * const group, PContact contact) {} +void (*roster_send_add_to_group)(const char * const, PContact) = _roster_send_add_to_group; + +static void _roster_send_remove_from_group(const char * const group, PContact contact) {} +void (*roster_send_remove_from_group)(const char * const, PContact) = _roster_send_remove_from_group; + +static void _roster_add_new(const char * const barejid, const char * const name) {} +void (*roster_add_new)(const char * const, const char * const) = _roster_add_new; + +static void _roster_send_remove(const char * const barejid) {} +void (*roster_send_remove)(const char * const) = _roster_send_remove;