1
1
mirror of https://github.com/profanity-im/profanity.git synced 2025-01-03 14:57:42 -05:00

Added common mock functions and fixed tests

This commit is contained in:
James Booth 2013-12-18 22:49:43 +00:00
parent 81909ef000
commit 00a475cf55
7 changed files with 284 additions and 125 deletions

View File

@ -60,6 +60,7 @@ test_sources = \
src/config/accounts.h \ src/config/accounts.h \
src/config/preferences.c src/config/preferences.h \ src/config/preferences.c src/config/preferences.h \
src/config/theme.c src/config/theme.h \ src/config/theme.c src/config/theme.h \
tests/common_mocks.c tests/common_mocks.h \
tests/ui/mock_ui.c \ tests/ui/mock_ui.c \
tests/xmpp/mock_xmpp.c \ tests/xmpp/mock_xmpp.c \
tests/log/mock_log.c \ tests/log/mock_log.c \

48
tests/common_mocks.c Normal file
View File

@ -0,0 +1,48 @@
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#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);
}

10
tests/common_mocks.h Normal file
View File

@ -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

View File

@ -9,6 +9,7 @@
#include "xmpp/xmpp.h" #include "xmpp/xmpp.h"
#include "ui/ui.h" #include "ui/ui.h"
#include "command/commands.h" #include "command/commands.h"
#include "common_mocks.h"
void cmd_account_shows_usage_when_not_connected_and_no_args(void **state) 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"; help->usage = "some usage";
gchar *args[] = { NULL }; gchar *args[] = { NULL };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED); mock_connection_status(JABBER_DISCONNECTED);
expect_string(cons_show, output, "Usage: some usage"); 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)); ProfAccount *account = malloc(sizeof(ProfAccount));
gchar *args[] = { NULL }; gchar *args[] = { NULL };
will_return(jabber_get_connection_status, JABBER_CONNECTED); mock_connection_status(JABBER_CONNECTED);
mock_connection_account_name("account_name");
will_return(jabber_get_account_name, "account_name");
expect_any(accounts_get_account, name); expect_any(accounts_get_account, name);
will_return(accounts_get_account, account); 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_string(accounts_set_priority_online, account_name, "a_account");
expect_value(accounts_set_priority_online, value, 10); 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); 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_string(accounts_set_priority_chat, account_name, "a_account");
expect_value(accounts_set_priority_chat, value, 10); 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); 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_string(accounts_set_priority_away, account_name, "a_account");
expect_value(accounts_set_priority_away, value, 10); 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); 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_string(accounts_set_priority_xa, account_name, "a_account");
expect_value(accounts_set_priority_xa, value, 10); 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); 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_string(accounts_set_priority_dnd, account_name, "a_account");
expect_value(accounts_set_priority_dnd, value, 10); 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); expect_any_count(cons_show, output, 2);

View File

@ -10,11 +10,46 @@
#include "ui/ui.h" #include "ui/ui.h"
#include "command/commands.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) static void test_with_connection_status(jabber_conn_status_t status)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp)); 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."); expect_string(cons_show, output, "You are either connected already, or a login is in process.");
gboolean result = cmd_connect(NULL, *help); gboolean result = cmd_connect(NULL, *help);
@ -48,7 +83,7 @@ void cmd_connect_when_no_account(void **state)
CommandHelp *help = malloc(sizeof(CommandHelp)); CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "user@server.org", NULL }; 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"); expect_string(accounts_get_account, name, "user@server.org");
will_return(accounts_get_account, NULL); 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(cons_show, output, "Connecting as user@server.org");
expect_string(jabber_connect_with_details, jid, "user@server.org"); jabber_connect_with_details = _mock_jabber_connect_with_details_no_altdomain;
expect_string(jabber_connect_with_details, passwd, "password"); expect_string(_mock_jabber_connect_with_details_no_altdomain, jid, "user@server.org");
expect_any(jabber_connect_with_details, altdomain); expect_string(_mock_jabber_connect_with_details_no_altdomain, passwd, "password");
will_return(jabber_connect_with_details, JABBER_CONNECTING); will_return(_mock_jabber_connect_with_details_no_altdomain, JABBER_CONNECTING);
gboolean result = cmd_connect(args, *help); gboolean result = cmd_connect(args, *help);
assert_true(result); assert_true(result);
@ -73,7 +108,7 @@ void cmd_connect_with_altdomain_when_provided(void **state)
CommandHelp *help = malloc(sizeof(CommandHelp)); CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "user@server.org", "altdomain" }; 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); expect_any(accounts_get_account, name);
will_return(accounts_get_account, NULL); 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(cons_show, output);
expect_any(jabber_connect_with_details, jid); jabber_connect_with_details = _mock_jabber_connect_with_details_altdomain;
expect_any(jabber_connect_with_details, passwd); expect_string(_mock_jabber_connect_with_details_altdomain, altdomain, "altdomain");
expect_string(jabber_connect_with_details, altdomain, "altdomain"); will_return(_mock_jabber_connect_with_details_altdomain, JABBER_CONNECTING);
will_return(jabber_connect_with_details, JABBER_CONNECTING);
gboolean result = cmd_connect(args, *help); gboolean result = cmd_connect(args, *help);
assert_true(result); assert_true(result);
@ -98,7 +132,7 @@ void cmd_connect_fail_message(void **state)
CommandHelp *help = malloc(sizeof(CommandHelp)); CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "user@server.org", NULL }; 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); expect_any(accounts_get_account, name);
will_return(accounts_get_account, NULL); will_return(accounts_get_account, NULL);
@ -107,10 +141,8 @@ void cmd_connect_fail_message(void **state)
expect_any(cons_show, output); expect_any(cons_show, output);
expect_any(jabber_connect_with_details, jid); jabber_connect_with_details = _mock_jabber_connect_with_details_result;
expect_any(jabber_connect_with_details, passwd); will_return(_mock_jabber_connect_with_details_result, JABBER_DISCONNECTED);
expect_any(jabber_connect_with_details, altdomain);
will_return(jabber_connect_with_details, JABBER_DISCONNECTED);
expect_string(cons_show_error, output, "Connection attempt for user@server.org failed."); 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)); CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "USER@server.ORG", NULL }; 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"); expect_string(accounts_get_account, name, "user@server.org");
will_return(accounts_get_account, NULL); will_return(accounts_get_account, NULL);
@ -134,10 +166,8 @@ void cmd_connect_lowercases_argument(void **state)
expect_any(cons_show, output); expect_any(cons_show, output);
expect_any(jabber_connect_with_details, jid); jabber_connect_with_details = _mock_jabber_connect_with_details_result;
expect_any(jabber_connect_with_details, passwd); will_return(_mock_jabber_connect_with_details_result, JABBER_CONNECTING);
expect_any(jabber_connect_with_details, altdomain);
will_return(jabber_connect_with_details, JABBER_CONNECTING);
gboolean result = cmd_connect(args, *help); gboolean result = cmd_connect(args, *help);
assert_true(result); assert_true(result);
@ -152,7 +182,7 @@ void cmd_connect_asks_password_when_not_in_account(void **state)
ProfAccount *account = malloc(sizeof(ProfAccount)); ProfAccount *account = malloc(sizeof(ProfAccount));
account->password = NULL; account->password = NULL;
will_return(jabber_get_connection_status, JABBER_DISCONNECTED); mock_connection_status(JABBER_DISCONNECTED);
expect_any(accounts_get_account, name); expect_any(accounts_get_account, name);
will_return(accounts_get_account, account); 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(cons_show, output);
expect_any(jabber_connect_with_account, account); jabber_connect_with_account = _mock_jabber_connect_with_account_result;
will_return(jabber_connect_with_account, JABBER_CONNECTING); will_return(_mock_jabber_connect_with_account_result, JABBER_CONNECTING);
expect_any(accounts_free_account, account); 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->password = "password";
account->name = "jabber_org"; account->name = "jabber_org";
will_return(jabber_get_connection_status, JABBER_DISCONNECTED); mock_connection_status(JABBER_DISCONNECTED);
expect_any(accounts_get_account, name); expect_any(accounts_get_account, name);
will_return(accounts_get_account, account); 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_string(cons_show, output, "Connecting with account jabber_org as user@jabber.org/laptop");
expect_any(jabber_connect_with_account, account); jabber_connect_with_account = _mock_jabber_connect_with_account_result;
will_return(jabber_connect_with_account, JABBER_CONNECTING); will_return(_mock_jabber_connect_with_account_result, JABBER_CONNECTING);
expect_any(accounts_free_account, account); expect_any(accounts_free_account, account);
@ -212,7 +242,7 @@ void cmd_connect_connects_with_account(void **state)
account->password = "password"; account->password = "password";
account->name = "jabber_org"; account->name = "jabber_org";
will_return(jabber_get_connection_status, JABBER_DISCONNECTED); mock_connection_status(JABBER_DISCONNECTED);
expect_any(accounts_get_account, name); expect_any(accounts_get_account, name);
will_return(accounts_get_account, account); will_return(accounts_get_account, account);
@ -221,8 +251,9 @@ void cmd_connect_connects_with_account(void **state)
expect_any(cons_show, output); expect_any(cons_show, output);
expect_memory(jabber_connect_with_account, account, account, sizeof(ProfAccount)); jabber_connect_with_account = _mock_jabber_connect_with_account_result_check;
will_return(jabber_connect_with_account, JABBER_CONNECTING); 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); expect_any(accounts_free_account, account);
@ -239,7 +270,7 @@ void cmd_connect_frees_account_after_connecting(void **state)
gchar *args[] = { "jabber_org", NULL }; gchar *args[] = { "jabber_org", NULL };
ProfAccount *account = malloc(sizeof(ProfAccount)); ProfAccount *account = malloc(sizeof(ProfAccount));
will_return(jabber_get_connection_status, JABBER_DISCONNECTED); mock_connection_status(JABBER_DISCONNECTED);
expect_any(accounts_get_account, name); expect_any(accounts_get_account, name);
will_return(accounts_get_account, account); 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(cons_show, output);
expect_any(jabber_connect_with_account, account); jabber_connect_with_account = _mock_jabber_connect_with_account_result;
will_return(jabber_connect_with_account, JABBER_CONNECTING); will_return(_mock_jabber_connect_with_account_result, JABBER_CONNECTING);
expect_memory(accounts_free_account, account, account, sizeof(ProfAccount)); expect_memory(accounts_free_account, account, account, sizeof(ProfAccount));

View File

@ -8,12 +8,13 @@
#include "xmpp/xmpp.h" #include "xmpp/xmpp.h"
#include "ui/ui.h" #include "ui/ui.h"
#include "command/commands.h" #include "command/commands.h"
#include "common_mocks.h"
static void test_with_connection_status(jabber_conn_status_t status) static void test_with_connection_status(jabber_conn_status_t status)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp)); 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."); expect_string(cons_show, output, "You are not currently connected.");
gboolean result = cmd_rooms(NULL, *help); 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"; account->muc_service = "default_conf_server";
gchar *args[] = { NULL }; gchar *args[] = { NULL };
will_return(jabber_get_connection_status, JABBER_CONNECTED); mock_connection_status(JABBER_CONNECTED);
will_return(jabber_get_account_name, "account_name"); mock_connection_account_name("account_name");
expect_string(accounts_get_account, name, "account_name"); expect_string(accounts_get_account, name, "account_name");
will_return(accounts_get_account, account); 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); gboolean result = cmd_rooms(args, *help);
@ -73,8 +76,9 @@ void cmd_rooms_arg_used_when_passed(void **state)
CommandHelp *help = malloc(sizeof(CommandHelp)); CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "conf_server_arg" }; gchar *args[] = { "conf_server_arg" };
will_return(jabber_get_connection_status, JABBER_CONNECTED); mock_connection_status(JABBER_CONNECTED);
expect_string(iq_room_list_request, conferencejid, "conf_server_arg");
expect_room_list_request("conf_server_arg");
gboolean result = cmd_rooms(args, *help); gboolean result = cmd_rooms(args, *help);

View File

@ -27,133 +27,198 @@
#include "xmpp/xmpp.h" #include "xmpp/xmpp.h"
// connection functions // 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) const char * const passwd, const char * const altdomain)
{ {
check_expected(jid); return JABBER_DISCONNECTED;
check_expected(passwd);
check_expected(altdomain);
return (jabber_conn_status_t)mock();
} }
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_DISCONNECTED;
return (jabber_conn_status_t)mock();
} }
jabber_conn_status_t (*jabber_connect_with_account)(const ProfAccount * const) = _jabber_connect_with_account;
void jabber_disconnect(void) {} static void _jabber_disconnect(void) {}
void jabber_shutdown(void) {} void (*jabber_disconnect)(void) = _jabber_disconnect;
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();
}
jabber_conn_status_t jabber_get_connection_status(void) static void _jabber_shutdown(void) {}
{ void (*jabber_shutdown)(void) = _jabber_shutdown;
return (jabber_conn_status_t)mock();
}
char * jabber_get_presence_message(void) static void _jabber_process_events(void) {}
{ void (*jabber_process_events)(void) = _jabber_process_events;
return (char *)mock();
}
void jabber_set_autoping(int seconds) {}
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 // message functions
void message_send(const char * const msg, const char * const recipient) {} static 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)(const char * const, const char * const) = _message_send;
void message_send_inactive(const char * const recipient) {}
void message_send_composing(const char * const recipient) {} static void _message_send_groupchat(const char * const msg, const char * const recipient) {}
void message_send_paused(const char * const recipient) {} void (*message_send_groupchat)(const char * const, const char * const) = _message_send_groupchat;
void message_send_gone(const char * const recipient) {}
void message_send_invite(const char * const room, const char * const contact, 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) {} 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 // 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) {} static void _presence_join_room(Jid *jid) {}
void presence_change_room_nick(const char * const room, const char * const nick) {} void (*presence_join_room)(Jid *) = _presence_join_room;
void presence_leave_chat_room(const char * const room_jid) {}
void presence_update(resource_presence_t status, const char * const msg, 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) {} 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 // 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) static void _iq_room_list_request(gchar *conferencejid) {}
{ void (*iq_room_list_request)(gchar *) = _iq_room_list_request;
check_expected(conferencejid);
}
void iq_disco_info_request(gchar *jid) {} static void _iq_disco_info_request(gchar *jid) {}
void iq_disco_items_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 // 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) {} static void _bookmark_add(const char *jid, const char *nick, gboolean autojoin) {}
void bookmark_remove(const char *jid, 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) {} static 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_name_change)(const char * const, const char * const, GSList *) = _roster_send_name_change;
void roster_send_remove_from_group(const char * const group, PContact contact) {}
void roster_add_new(const char * const barejid, const char * const name) {} static void _roster_send_add_to_group(const char * const group, PContact contact) {}
void roster_send_remove(const char * const barejid) {} 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;