diff options
author | James Booth <boothj5@gmail.com> | 2014-12-25 00:57:02 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2014-12-25 00:57:02 +0000 |
commit | 25a60c999745b1b5f9fb9372e7d22237e3a0aa0b (patch) | |
tree | 80c33a7a5cf1c945d9137b7928c88814042a8036 | |
parent | 7a104431645af3a37b3626748a0290dda3d0cee4 (diff) | |
download | profani-tty-25a60c999745b1b5f9fb9372e7d22237e3a0aa0b.tar.gz |
Removed old mocks
-rw-r--r-- | tests/config/mock_accounts.c | 564 | ||||
-rw-r--r-- | tests/config/mock_accounts.h | 70 | ||||
-rw-r--r-- | tests/otr/mock_otr.c | 97 | ||||
-rw-r--r-- | tests/otr/mock_otr.h | 16 | ||||
-rw-r--r-- | tests/test_form.c | 1 | ||||
-rw-r--r-- | tests/ui/mock_ui.c | 451 | ||||
-rw-r--r-- | tests/ui/mock_ui.h | 72 | ||||
-rw-r--r-- | tests/xmpp/mock_xmpp.c | 334 | ||||
-rw-r--r-- | tests/xmpp/mock_xmpp.h | 47 |
9 files changed, 0 insertions, 1652 deletions
diff --git a/tests/config/mock_accounts.c b/tests/config/mock_accounts.c deleted file mode 100644 index 6c555e0d..00000000 --- a/tests/config/mock_accounts.c +++ /dev/null @@ -1,564 +0,0 @@ -#include <glib.h> -#include <setjmp.h> -#include <cmocka.h> -#include <string.h> - -#include "config/accounts.h" - -// mocks and stubs - -static ProfAccount * -_mock_accounts_get_account(const char * const name) -{ - check_expected(name); - return mock_ptr_type(ProfAccount *); -} - -gchar ** -_mock_accounts_get_list(void) -{ - return mock_ptr_type(gchar **); -} - -void -_mock_accounts_add(const char *account_name, const char *altdomain, const int port) -{ - check_expected(account_name); - check_expected(altdomain); -} - -void -_stub_accounts_add(const char *account_name, const char *altdomain, const int port) -{ - // do nothing -} - -static gboolean -_mock_accounts_enable(const char * const name) -{ - check_expected(name); - return (gboolean)mock(); -} - -static gboolean -_mock_accounts_disable(const char * const name) -{ - check_expected(name); - return (gboolean)mock(); -} - -static gboolean -_mock_accounts_rename(const char * const account_name, const char * const new_name) -{ - check_expected(account_name); - check_expected(new_name); - return (gboolean)mock(); -} - -static gboolean -_mock_accounts_account_exists(const char * const account_name) -{ - check_expected(account_name); - return (gboolean)mock(); -} - -static void -_mock_accounts_set_jid(const char * const account_name, const char * const value) -{ - check_expected(account_name); - check_expected(value); -} - -static void -_stub_accounts_set_jid(const char * const account_name, const char * const value) -{ - // do nothing -} - -static void -_mock_accounts_set_resource(const char * const account_name, const char * const value) -{ - check_expected(account_name); - check_expected(value); -} - -static void -_stub_accounts_set_resource(const char * const account_name, const char * const value) -{ - // do nothing -} - -static void -_mock_accounts_set_server(const char * const account_name, const char * const value) -{ - check_expected(account_name); - check_expected(value); -} - -static void -_stub_accounts_set_server(const char * const account_name, const char * const value) -{ - // do nothing -} - -static void -_mock_accounts_set_password(const char * const account_name, const char * const value) -{ - check_expected(account_name); - check_expected(value); -} - -static void -_stub_accounts_set_password(const char * const account_name, const char * const value) -{ - // do nothing -} - -static void -_mock_accounts_set_muc_service(const char * const account_name, const char * const value) -{ - check_expected(account_name); - check_expected(value); -} - -static void -_stub_accounts_set_muc_service(const char * const account_name, const char * const value) -{ - // do nothing -} - -static void -_mock_accounts_set_muc_nick(const char * const account_name, const char * const value) -{ - check_expected(account_name); - check_expected(value); -} - -static void -_stub_accounts_set_muc_nick(const char * const account_name, const char * const value) -{ - // do nothing -} - -static void -_mock_accounts_set_priority_online(const char * const account_name, const gint value) -{ - check_expected(account_name); - check_expected(value); -} - -static void -_stub_accounts_set_priority_online(const char * const account_name, const gint value) -{ - // do nothing -} - -static void -_mock_accounts_set_priority_chat(const char * const account_name, const gint value) -{ - check_expected(account_name); - check_expected(value); -} - -static void -_stub_accounts_set_priority_chat(const char * const account_name, const gint value) -{ - // do nothing -} - -static void -_mock_accounts_set_priority_away(const char * const account_name, const gint value) -{ - check_expected(account_name); - check_expected(value); -} - -static void -_stub_accounts_set_priority_away(const char * const account_name, const gint value) -{ - // do nothing -} - -static void -_mock_accounts_set_priority_xa(const char * const account_name, const gint value) -{ - check_expected(account_name); - check_expected(value); -} - -static void -_stub_accounts_set_priority_xa(const char * const account_name, const gint value) -{ - // do nothing -} - -static void -_mock_accounts_set_priority_dnd(const char * const account_name, const gint value) -{ - check_expected(account_name); - check_expected(value); -} - -static void -_stub_accounts_set_priority_dnd(const char * const account_name, const gint value) -{ - // do nothing -} - -static void -_mock_accounts_set_login_presence(const char * const account_name, const char * const value) -{ - check_expected(account_name); - check_expected(value); -} - -static void -_stub_accounts_set_login_presence(const char * const account_name, const char * const value) -{ - // do nothing -} - -static resource_presence_t -_mock_accounts_get_last_presence(const char * const account_name) -{ - check_expected(account_name); - return (resource_presence_t)mock(); -} - -// set up functions - -void -mock_accounts_get_account(void) -{ - accounts_get_account = _mock_accounts_get_account; -} - -void -mock_accounts_get_list(void) -{ - accounts_get_list = _mock_accounts_get_list; -} - -void -mock_accounts_add(void) -{ - accounts_add = _mock_accounts_add; -} - -void -stub_accounts_add(void) -{ - accounts_add = _stub_accounts_add; -} - -void -mock_accounts_enable(void) -{ - accounts_enable = _mock_accounts_enable; -} - -void -mock_accounts_disable(void) -{ - accounts_disable = _mock_accounts_disable; -} - -void -mock_accounts_rename(void) -{ - accounts_rename = _mock_accounts_rename; -} - -void -mock_accounts_account_exists(void) -{ - accounts_account_exists = _mock_accounts_account_exists; -} - -void -mock_accounts_set_jid(void) -{ - accounts_set_jid = _mock_accounts_set_jid; -} - -void -stub_accounts_set_jid(void) -{ - accounts_set_jid = _stub_accounts_set_jid; -} - -void -mock_accounts_set_resource(void) -{ - accounts_set_resource = _mock_accounts_set_resource; -} - -void -stub_accounts_set_resource(void) -{ - accounts_set_resource = _stub_accounts_set_resource; -} - -void -mock_accounts_set_server(void) -{ - accounts_set_server = _mock_accounts_set_server; -} - -void -stub_accounts_set_server(void) -{ - accounts_set_server = _stub_accounts_set_server; -} - -void -mock_accounts_set_password(void) -{ - accounts_set_password = _mock_accounts_set_password; -} - -void -stub_accounts_set_password(void) -{ - accounts_set_password = _stub_accounts_set_password; -} - -void -mock_accounts_set_muc_service(void) -{ - accounts_set_muc_service = _mock_accounts_set_muc_service; -} - -void -stub_accounts_set_muc_service(void) -{ - accounts_set_muc_service = _stub_accounts_set_muc_service; -} - -void -mock_accounts_set_muc_nick(void) -{ - accounts_set_muc_nick = _mock_accounts_set_muc_nick; -} - -void -stub_accounts_set_muc_nick(void) -{ - accounts_set_muc_nick = _stub_accounts_set_muc_nick; -} - -void -mock_accounts_set_priorities(void) -{ - accounts_set_priority_online = _mock_accounts_set_priority_online; - accounts_set_priority_chat = _mock_accounts_set_priority_chat; - accounts_set_priority_away = _mock_accounts_set_priority_away; - accounts_set_priority_xa = _mock_accounts_set_priority_xa; - accounts_set_priority_dnd = _mock_accounts_set_priority_dnd; -} - -void -stub_accounts_set_priorities(void) -{ - accounts_set_priority_online = _stub_accounts_set_priority_online; - accounts_set_priority_chat = _stub_accounts_set_priority_chat; - accounts_set_priority_away = _stub_accounts_set_priority_away; - accounts_set_priority_xa = _stub_accounts_set_priority_xa; - accounts_set_priority_dnd = _stub_accounts_set_priority_dnd; -} - -void -mock_accounts_set_login_presence(void) -{ - accounts_set_login_presence = _mock_accounts_set_login_presence; -} - -void -stub_accounts_set_login_presence(void) -{ - accounts_set_login_presence = _stub_accounts_set_login_presence; -} - -void -mock_accounts_get_last_presence(void) -{ - accounts_get_last_presence = _mock_accounts_get_last_presence; -} - -// mock behaviours - -void -accounts_get_account_expect_and_return(const char * const name, ProfAccount *account) -{ - expect_string(_mock_accounts_get_account, name, name); - will_return(_mock_accounts_get_account, account); -} - -void -accounts_get_account_return(ProfAccount *account) -{ - expect_any(_mock_accounts_get_account, name); - will_return(_mock_accounts_get_account, account); -} - -void -accounts_get_list_return(gchar **accounts) -{ - will_return(_mock_accounts_get_list, accounts); -} - -void -accounts_add_expect_account_name(char *account_name) -{ - expect_any(_mock_accounts_add, altdomain); - expect_string(_mock_accounts_add, account_name, account_name); -} - -void -accounts_enable_expect(char *name) -{ - expect_string(_mock_accounts_enable, name, name); - will_return(_mock_accounts_enable, TRUE); -} - -void -accounts_enable_return(gboolean result) -{ - expect_any(_mock_accounts_enable, name); - will_return(_mock_accounts_enable, result); -} - -void -accounts_disable_expect(char *name) -{ - expect_string(_mock_accounts_disable, name, name); - will_return(_mock_accounts_disable, TRUE); -} - -void -accounts_disable_return(gboolean result) -{ - expect_any(_mock_accounts_disable, name); - will_return(_mock_accounts_disable, result); -} - -void -accounts_rename_expect(char *account_name, char *new_name) -{ - expect_string(_mock_accounts_rename, account_name, account_name); - expect_string(_mock_accounts_rename, new_name, new_name); - will_return(_mock_accounts_rename, TRUE); -} - -void -accounts_rename_return(gboolean result) -{ - expect_any(_mock_accounts_rename, account_name); - expect_any(_mock_accounts_rename, new_name); - will_return(_mock_accounts_rename, result); -} - -void -accounts_account_exists_expect(char *account_name) -{ - expect_string(_mock_accounts_account_exists, account_name, account_name); - will_return(_mock_accounts_account_exists, TRUE); -} - -void -accounts_account_exists_return(gboolean result) -{ - expect_any(_mock_accounts_account_exists, account_name); - will_return(_mock_accounts_account_exists, result); -} - -void -accounts_set_jid_expect(char *account_name, char *jid) -{ - expect_string(_mock_accounts_set_jid, account_name, account_name); - expect_string(_mock_accounts_set_jid, value, jid); -} - -void -accounts_set_resource_expect(char *account_name, char *resource) -{ - expect_string(_mock_accounts_set_resource, account_name, account_name); - expect_string(_mock_accounts_set_resource, value, resource); -} - -void -accounts_set_server_expect(char *account_name, char *server) -{ - expect_string(_mock_accounts_set_server, account_name, account_name); - expect_string(_mock_accounts_set_server, value, server); -} - -void -accounts_set_password_expect(char *account_name, char *password) -{ - expect_string(_mock_accounts_set_password, account_name, account_name); - expect_string(_mock_accounts_set_password, value, password); -} - -void -accounts_set_muc_service_expect(char *account_name, char *service) -{ - expect_string(_mock_accounts_set_muc_service, account_name, account_name); - expect_string(_mock_accounts_set_muc_service, value, service); -} - -void -accounts_set_muc_nick_expect(char *account_name, char *nick) -{ - expect_string(_mock_accounts_set_muc_nick, account_name, account_name); - expect_string(_mock_accounts_set_muc_nick, value, nick); -} - -void -accounts_set_priority_online_expect(char *account_name, gint priority) -{ - expect_string(_mock_accounts_set_priority_online, account_name, account_name); - expect_value(_mock_accounts_set_priority_online, value, priority); -} - -void -accounts_set_priority_chat_expect(char *account_name, gint priority) -{ - expect_string(_mock_accounts_set_priority_chat, account_name, account_name); - expect_value(_mock_accounts_set_priority_chat, value, priority); -} - -void -accounts_set_priority_away_expect(char *account_name, gint priority) -{ - expect_string(_mock_accounts_set_priority_away, account_name, account_name); - expect_value(_mock_accounts_set_priority_away, value, priority); -} - -void -accounts_set_priority_xa_expect(char *account_name, gint priority) -{ - expect_string(_mock_accounts_set_priority_xa, account_name, account_name); - expect_value(_mock_accounts_set_priority_xa, value, priority); -} - -void -accounts_set_priority_dnd_expect(char *account_name, gint priority) -{ - expect_string(_mock_accounts_set_priority_dnd, account_name, account_name); - expect_value(_mock_accounts_set_priority_dnd, value, priority); -} - -void -accounts_set_login_presence_expect(char *account_name, char *presence) -{ - expect_string(_mock_accounts_set_login_presence, account_name, account_name); - expect_string(_mock_accounts_set_login_presence, value, presence); -} - -void -accounts_get_last_presence_return(resource_presence_t presence) -{ - expect_any(_mock_accounts_get_last_presence, account_name); - will_return(_mock_accounts_get_last_presence, presence); -} diff --git a/tests/config/mock_accounts.h b/tests/config/mock_accounts.h deleted file mode 100644 index 32c715f1..00000000 --- a/tests/config/mock_accounts.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef MOCK_ACCOUNTS_H -#define MOCK_ACCOUNTS_H - -void mock_accounts_get_account(void); -void accounts_get_account_expect_and_return(const char * const name, ProfAccount *account); -void accounts_get_account_return(ProfAccount *account); - -void mock_accounts_get_list(void); -void accounts_get_list_return(gchar **accounts); - -void mock_accounts_add(void); -void stub_accounts_add(void); -void accounts_add_expect_account_name(char *account_name); - -void mock_accounts_enable(void); -void accounts_enable_expect(char *name); -void accounts_enable_return(gboolean result); - -void mock_accounts_disable(void); -void accounts_disable_expect(char *name); -void accounts_disable_return(gboolean result); - -void mock_accounts_rename(void); -void accounts_rename_expect(char *account_name, char *new_name); -void accounts_rename_return(gboolean result); - -void mock_accounts_account_exists(void); -void accounts_account_exists_expect(char *account_name); -void accounts_account_exists_return(gboolean result); - -void mock_accounts_set_jid(void); -void stub_accounts_set_jid(void); -void accounts_set_jid_expect(char *account_name, char *jid); - -void mock_accounts_set_resource(void); -void stub_accounts_set_resource(void); -void accounts_set_resource_expect(char *account_name, char *resource); - -void mock_accounts_set_server(void); -void stub_accounts_set_server(void); -void accounts_set_server_expect(char *account_name, char *server); - -void mock_accounts_set_password(void); -void stub_accounts_set_password(void); -void accounts_set_password_expect(char *account_name, char *password); - -void mock_accounts_set_muc_service(void); -void stub_accounts_set_muc_service(void); -void accounts_set_muc_service_expect(char *account_name, char *service); - -void mock_accounts_set_muc_nick(void); -void stub_accounts_set_muc_nick(void); -void accounts_set_muc_nick_expect(char *account_name, char *nick); - -void mock_accounts_set_priorities(void); -void stub_accounts_set_priorities(void); -void accounts_set_priority_online_expect(char *account_name, gint priority); -void accounts_set_priority_chat_expect(char *account_name, gint priority); -void accounts_set_priority_away_expect(char *account_name, gint priority); -void accounts_set_priority_xa_expect(char *account_name, gint priority); -void accounts_set_priority_dnd_expect(char *account_name, gint priority); - -void mock_accounts_set_login_presence(void); -void stub_accounts_set_login_presence(void); -void accounts_set_login_presence_expect(char *account_name, char *presence); - -void mock_accounts_get_last_presence(void); -void accounts_get_last_presence_return(resource_presence_t presence); - -#endif diff --git a/tests/otr/mock_otr.c b/tests/otr/mock_otr.c deleted file mode 100644 index 25409197..00000000 --- a/tests/otr/mock_otr.c +++ /dev/null @@ -1,97 +0,0 @@ -#include <stdarg.h> -#include <stddef.h> -#include <setjmp.h> -#include <cmocka.h> -#include <stdlib.h> -#include <string.h> -#include <glib.h> - - -#include "config.h" - -#ifdef HAVE_LIBOTR -#include "otr/otr.h" -#endif -#include "config/account.h" - -#ifdef HAVE_LIBOTR -static void -_mock_otr_keygen(ProfAccount *account) -{ - check_expected(account); -} - -static char * -_mock_otr_libotr_version(void) -{ - return mock_ptr_type(char *); -} - -static char * -_mock_otr_get_my_fingerprint(void) -{ - return mock_ptr_type(char *); -} - -static char * -_mock_otr_get_their_fingerprint(const char * const recipient) -{ - check_expected(recipient); - return mock_ptr_type(char *); -} - -static gboolean -_mock_otr_key_loaded(void) -{ - return (gboolean)mock(); -} - -static char * -_mock_otr_start_query(void) -{ - return mock_ptr_type(char *); -} - -void -otr_keygen_expect(ProfAccount *account) -{ - otr_keygen = _mock_otr_keygen; - expect_memory(_mock_otr_keygen, account, account, sizeof(ProfAccount)); -} - -void -otr_libotr_version_returns(char *version) -{ - otr_libotr_version = _mock_otr_libotr_version; - will_return(_mock_otr_libotr_version, version); -} - -void -otr_get_my_fingerprint_returns(char *fingerprint) -{ - otr_get_my_fingerprint = _mock_otr_get_my_fingerprint; - will_return(_mock_otr_get_my_fingerprint, fingerprint); -} - -void -otr_get_their_fingerprint_expect_and_return(char *recipient, char *fingerprint) -{ - otr_get_their_fingerprint = _mock_otr_get_their_fingerprint; - expect_string(_mock_otr_get_their_fingerprint, recipient, recipient); - will_return(_mock_otr_get_their_fingerprint, fingerprint); -} - -void -otr_key_loaded_returns(gboolean loaded) -{ - otr_key_loaded = _mock_otr_key_loaded; - will_return(_mock_otr_key_loaded, loaded); -} - -void -otr_start_query_returns(char *query) -{ - otr_start_query = _mock_otr_start_query; - will_return(_mock_otr_start_query, query); -} -#endif diff --git a/tests/otr/mock_otr.h b/tests/otr/mock_otr.h deleted file mode 100644 index ab28ed6c..00000000 --- a/tests/otr/mock_otr.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef MOCK_OTR_H -#define MOCK_OTR_H - -#include "config/account.h" - -void otr_keygen_expect(ProfAccount *account); -void otr_key_loaded_returns(gboolean loaded); - -void otr_libotr_version_returns(char *version); - -void otr_get_my_fingerprint_returns(char *fingerprint); -void otr_get_their_fingerprint_expect_and_return(char *recipient, char *fingerprint); - -void otr_start_query_returns(char *query); - -#endif diff --git a/tests/test_form.c b/tests/test_form.c index b2e769a0..b3158a83 100644 --- a/tests/test_form.c +++ b/tests/test_form.c @@ -6,7 +6,6 @@ #include <stdlib.h> #include "xmpp/form.h" -#include "xmpp/mock_xmpp.h" xmpp_ctx_t* connection_get_ctx(void) { diff --git a/tests/ui/mock_ui.c b/tests/ui/mock_ui.c deleted file mode 100644 index e2327388..00000000 --- a/tests/ui/mock_ui.c +++ /dev/null @@ -1,451 +0,0 @@ -#include <glib.h> -#include <setjmp.h> -#include <cmocka.h> -#include <string.h> - -#include "ui/ui.h" -#include "ui/window.h" -#include "tests/helpers.h" - -#include "xmpp/bookmark.h" - -char output[256]; - -// Mocks and stubs - -static -void _mock_cons_show(const char * const msg, ...) -{ - va_list args; - va_start(args, msg); - vsnprintf(output, sizeof(output), msg, args); - check_expected(output); - va_end(args); -} - -static -void _stub_cons_show(const char * const msg, ...) -{ -} - -static -void _stub_rosterwin_roster(void) -{ -} - -static -void _mock_cons_show_contact_online(PContact contact, Resource *resource, GDateTime *last_activity) -{ - check_expected(contact); - check_expected(resource); - check_expected(last_activity); -} - -static -void _mock_cons_show_error(const char * const msg, ...) -{ - va_list args; - va_start(args, msg); - vsnprintf(output, sizeof(output), msg, args); - check_expected(output); - va_end(args); -} - -static -void _mock_cons_show_account(ProfAccount *account) -{ - check_expected(account); -} - -static -void _mock_cons_show_bookmarks(const GList *list) -{ - check_expected(list); -} - -static -void _mock_cons_show_aliases(GList *aliases) -{ - check_expected(aliases); -} - -static -void _mock_cons_show_account_list(gchar **accounts) -{ - check_expected(accounts); -} - -static -char * _mock_ui_ask_password(void) -{ - return mock_ptr_type(char *); -} - -static -char * _stub_ui_ask_password(void) -{ - return NULL; -} - -static -win_type_t _mock_ui_current_win_type(void) -{ - return (win_type_t)mock(); -} - -static -ProfChatWin * _mock_ui_get_current_chat(void) -{ - return (ProfChatWin*)mock(); -} - -static -void _mock_ui_handle_error(const char * const err_msg) -{ - check_expected(err_msg); -} - -static -void _mock_ui_handle_recipient_error(const char * const recipient, - const char * const err_msg) -{ - check_expected(recipient); - check_expected(err_msg); -} - -static -void _stub_ui_handle_recipient_error(const char * const recipient, - const char * const err_msg) -{ -} - -static -void _mock_ui_handle_recipient_not_found(const char * const recipient, - const char * const err_msg) -{ - check_expected(recipient); - check_expected(err_msg); -} - -static -void _stub_ui_chat_win_contact_online(PContact contact, Resource *resource, GDateTime *last_activity) -{ -} - -static -void _stub_ui_handle_recipient_not_found(const char * const recipient, const char * const err_msg) -{ -} - -static -void _mock_ui_current_print_formatted_line(const char show_char, int attrs, const char * const msg, ...) -{ - check_expected(show_char); - check_expected(attrs); - va_list args; - va_start(args, msg); - vsnprintf(output, sizeof(output), msg, args); - check_expected(output); - va_end(args); -} - -static -void _mock_ui_current_print_line(const char * const msg, ...) -{ - va_list args; - va_start(args, msg); - vsnprintf(output, sizeof(output), msg, args); - check_expected(output); - va_end(args); -} - -static -gboolean _mock_ui_current_win_is_otr(void) -{ - return (gboolean)mock(); -} - -static -void _mock_ui_room_join(const char * const room, gboolean focus) -{ - check_expected(room); - check_expected(focus); -} - -static -void _mock_cons_show_roster(GSList *list) -{ - check_expected(list); -} - -static -gboolean _mock_ui_switch_win(const int i) -{ - check_expected(i); - return (gboolean)mock(); -} - -// bind mocks and stubs - -void -mock_cons_show(void) -{ - cons_show = _mock_cons_show; -} - -void -mock_cons_show_contact_online(void) -{ - cons_show_contact_online = _mock_cons_show_contact_online; -} - -void -stub_ui_chat_win_contact_online(void) -{ - ui_chat_win_contact_online = _stub_ui_chat_win_contact_online; -} - -void -stub_rosterwin_roster(void) -{ - rosterwin_roster = _stub_rosterwin_roster; -} - -void -mock_cons_show_error(void) -{ - cons_show_error = _mock_cons_show_error; -} - -void -mock_cons_show_account(void) -{ - cons_show_account = _mock_cons_show_account; -} - -void -mock_cons_show_bookmarks(void) -{ - cons_show_bookmarks = _mock_cons_show_bookmarks; -} - -void -mock_cons_show_aliases(void) -{ - cons_show_aliases = _mock_cons_show_aliases; -} - -void -mock_cons_show_account_list(void) -{ - cons_show_account_list = _mock_cons_show_account_list; -} - -void -mock_ui_ask_password(void) -{ - ui_ask_password = _mock_ui_ask_password; -} - -void -stub_ui_ask_password(void) -{ - ui_ask_password = _stub_ui_ask_password; -} - -void -stub_cons_show(void) -{ - cons_show = _stub_cons_show; -} - -void -stub_ui_handle_recipient_not_found(void) -{ - ui_handle_recipient_not_found = _stub_ui_handle_recipient_not_found; -} - -void -stub_ui_handle_recipient_error(void) -{ - ui_handle_recipient_error = _stub_ui_handle_recipient_error; -} - -void -mock_ui_current_print_formatted_line(void) -{ - ui_current_print_formatted_line = _mock_ui_current_print_formatted_line; -} - -void -mock_ui_current_print_line(void) -{ - ui_current_print_line = _mock_ui_current_print_line; -} - -void -mock_cons_show_roster(void) -{ - cons_show_roster = _mock_cons_show_roster; -} - -// expectations - -void -expect_cons_show(char *expected) -{ - expect_string(_mock_cons_show, output, expected); -} - -void -expect_cons_show_calls(int n) -{ - expect_any_count(_mock_cons_show, output, n); -} - -void -expect_cons_show_error(char *expected) -{ - expect_string(_mock_cons_show_error, output, expected); -} - -void -expect_cons_show_account(ProfAccount *account) -{ - expect_memory(_mock_cons_show_account, account, account, sizeof(ProfAccount)); -} - -static gboolean -_cmp_bookmark(Bookmark *bm1, Bookmark *bm2) -{ - if (strcmp(bm1->jid, bm2->jid) != 0) { - return FALSE; - } - if (strcmp(bm1->nick, bm2->nick) != 0) { - return FALSE; - } - if (bm1->autojoin != bm2->autojoin) { - return FALSE; - } - - return TRUE; -} - -void -expect_cons_show_bookmarks(GList *bookmarks) -{ - glist_set_cmp((GCompareFunc)_cmp_bookmark); - expect_any(_mock_cons_show_bookmarks, list); -// expect_check(_mock_cons_show_bookmarks, list, (CheckParameterValue)glist_contents_equal, bookmarks); -} - -void -expect_cons_show_account_list(gchar **accounts) -{ - expect_memory(_mock_cons_show_account_list, accounts, accounts, sizeof(accounts)); -} - -void -expect_cons_show_contact_online(PContact contact, Resource *resource, GDateTime *last_activity) -{ - expect_memory(_mock_cons_show_contact_online, contact, contact, sizeof(contact)); - expect_memory(_mock_cons_show_contact_online, resource, resource, sizeof(Resource)); - if (last_activity == NULL) { - expect_value(_mock_cons_show_contact_online, last_activity, NULL); - } else { - expect_memory(_mock_cons_show_contact_online, last_activity, last_activity, sizeof(last_activity)); - } -} - -void -expect_cons_show_aliases() -{ - // write a custom checker for the list - expect_any(_mock_cons_show_aliases, aliases); -} - -void -mock_ui_ask_password_returns(char *password) -{ - will_return(_mock_ui_ask_password, strdup(password)); -} - -void -expect_ui_handle_error(char *err_msg) -{ - ui_handle_error = _mock_ui_handle_error; - expect_string(_mock_ui_handle_error, err_msg, err_msg); -} - -void -expect_ui_handle_recipient_error(char *recipient, char *err_msg) -{ - ui_handle_recipient_error = _mock_ui_handle_recipient_error; - expect_string(_mock_ui_handle_recipient_error, recipient, recipient); - expect_string(_mock_ui_handle_recipient_error, err_msg, err_msg); -} - -void -expect_ui_handle_recipient_not_found(char *recipient, char *err_msg) -{ - ui_handle_recipient_not_found = _mock_ui_handle_recipient_not_found; - expect_string(_mock_ui_handle_recipient_not_found, recipient, recipient); - expect_string(_mock_ui_handle_recipient_not_found, err_msg, err_msg); -} - -void -mock_current_win_type(win_type_t type) -{ - ui_current_win_type = _mock_ui_current_win_type; - will_return(_mock_ui_current_win_type, type); -} - -void -mock_ui_get_current_chat(ProfChatWin *chatwin) -{ - ui_get_current_chat = _mock_ui_get_current_chat; - will_return(_mock_ui_get_current_chat, chatwin); -} - -void -ui_current_print_formatted_line_expect(char show_char, int attrs, char *message) -{ - expect_value(_mock_ui_current_print_formatted_line, show_char, show_char); - expect_value(_mock_ui_current_print_formatted_line, attrs, attrs); - expect_string(_mock_ui_current_print_formatted_line, output, message); -} - -void -ui_current_print_line_expect(char *message) -{ - expect_string(_mock_ui_current_print_line, output, message); -} - -void -ui_current_win_is_otr_returns(gboolean result) -{ - ui_current_win_is_otr = _mock_ui_current_win_is_otr; - will_return(_mock_ui_current_win_is_otr, result); -} - -void -ui_room_join_expect(char *room, gboolean focus) -{ - ui_room_join = _mock_ui_room_join; - expect_string(_mock_ui_room_join, room, room); - expect_value(_mock_ui_room_join, focus, focus); -} - -void -cons_show_roster_expect(GSList *list) -{ - expect_any(_mock_cons_show_roster, list); -} - -void -ui_switch_win_expect_and_return(int given_i, gboolean result) -{ - ui_switch_win = _mock_ui_switch_win; - expect_value(_mock_ui_switch_win, i, given_i); - will_return(_mock_ui_switch_win, result); -} diff --git a/tests/ui/mock_ui.h b/tests/ui/mock_ui.h deleted file mode 100644 index e68ba6dc..00000000 --- a/tests/ui/mock_ui.h +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef MOCK_UI_H -#define MICK_UI_H - -#include <glib.h> -#include <setjmp.h> -#include <cmocka.h> - -#include "config/account.h" -#include "contact.h" -#include "ui/window.h" - -void stub_cons_show(void); -void stub_rosterwin_roster(void); - -void mock_cons_show(void); -void expect_cons_show(char *output); -void expect_cons_show_calls(int n); - -void mock_cons_show_contact_online(void); -void expect_cons_show_contact_online(PContact contact, Resource *resource, GDateTime *last_activity); -void stub_ui_chat_win_contact_online(void); - -void mock_cons_show_error(void); -void expect_cons_show_error(char *output); - -void stub_ui_handle_recipient_not_found(void); -void stub_ui_handle_recipient_error(void); -void expect_ui_handle_error(char *err_msg); -void expect_ui_handle_recipient_error(char *recipient, char *err_msg); -void expect_ui_handle_recipient_not_found(char *recipient, char *err_msg); - -void mock_cons_show_account(void); -void expect_cons_show_account(ProfAccount *account); - -void mock_cons_show_bookmarks(void); -void expect_cons_show_bookmarks(GList *bookmarks); - -void mock_cons_show_aliases(void); -void expect_cons_show_aliases(void); - -void mock_cons_show_account_list(void); -void expect_cons_show_account_list(gchar **accounts); - -void stub_ui_ask_password(void); -void mock_ui_ask_password(void); -void mock_ui_ask_password_returns(char *password); - -void mock_current_win_type(win_type_t type); - -void mock_ui_get_current_chat(ProfChatWin *chatwin); - -void mock_ui_current_recipient(void); -void ui_current_recipient_returns(char *jid); - -void stub_ui_current_update_virtual(void); - -void mock_ui_current_print_formatted_line(void); -void ui_current_print_formatted_line_expect(char show_char, int attrs, char *message); - -void mock_ui_current_print_line(void); -void ui_current_print_line_expect(char *message); - -void ui_current_win_is_otr_returns(gboolean result); - -void ui_room_join_expect(char *room, gboolean focus); - -void mock_cons_show_roster(void); -void cons_show_roster_expect(GSList *list); - -void ui_switch_win_expect_and_return(int given_i, gboolean result); - -#endif diff --git a/tests/xmpp/mock_xmpp.c b/tests/xmpp/mock_xmpp.c deleted file mode 100644 index a9987b57..00000000 --- a/tests/xmpp/mock_xmpp.c +++ /dev/null @@ -1,334 +0,0 @@ -#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 mock_ptr_type(char *); -} - -static void -_mock_iq_room_list_request(gchar *conf_server) -{ - check_expected(conf_server); -} - -static jabber_conn_status_t -_mock_jabber_connect_with_details(const char * const jid, - const char * const passwd, const char * const altdomain, const int port) -{ - check_expected(jid); - check_expected(passwd); - check_expected(altdomain); - check_expected(port); - return (jabber_conn_status_t)mock(); -} - -static jabber_conn_status_t -_mock_jabber_connect_with_account(const ProfAccount * const account) -{ - check_expected(account); - return (jabber_conn_status_t)mock(); -} - -static char * -_mock_jabber_get_presence_message(void) -{ - return mock_ptr_type(char *); -} - -static void -_mock_presence_update(resource_presence_t status, const char * const msg, int idle) -{ - check_expected(status); - check_expected(msg); - check_expected(idle); -} - -static const GList * -_mock_bookmark_get_list(void) -{ - return mock_ptr_type(GList *); -} - -static gboolean -_mock_bookmark_add(const char *jid, const char *nick, const char *password, const char *autojoin_str) -{ - check_expected(jid); - check_expected(nick); - check_expected(password); - check_expected(autojoin_str); - return (gboolean)mock(); -} - -static gboolean -_mock_bookmark_remove(const char *jid) -{ - check_expected(jid); - return (gboolean)mock(); -} - -static void -_mock_message_send_chat(const char * const recipient, const char * const msg) -{ - check_expected(recipient); - check_expected(msg); -} - -static void -_mock_presence_join_room(char *room, char*nick, char *passwd) -{ - check_expected(room); - check_expected(nick); - check_expected(passwd); -} - -static void -_mock_roster_send_add_new(const char *const barejid, const char * const name) -{ - check_expected(barejid); - check_expected(name); -} - -static void -_mock_roster_send_remove(const char * const barejid) -{ - check_expected(barejid); -} - -static void -_mock_roster_send_name_change(const char * const barejid, const char * const new_name, - GSList *groups) -{ - check_expected(barejid); - check_expected(new_name); - check_expected(groups); -} - -void -mock_jabber_connect_with_details(void) -{ - jabber_connect_with_details = _mock_jabber_connect_with_details; -} - -void -mock_jabber_connect_with_account(void) -{ - jabber_connect_with_account = _mock_jabber_connect_with_account; -} - -void -mock_presence_update(void) -{ - presence_update = _mock_presence_update; -} - -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_bookmark_add(void) -{ - bookmark_add = _mock_bookmark_add; -} - -void -mock_bookmark_remove(void) -{ - bookmark_remove = _mock_bookmark_remove; -} - -void -mock_presence_join_room(void) -{ - presence_join_room = _mock_presence_join_room; -} - -void -mock_roster_send_add_new(void) -{ - roster_send_add_new = _mock_roster_send_add_new; -} - -void -mock_roster_send_remove(void) -{ - roster_send_remove = _mock_roster_send_remove; -} - -void -mock_roster_send_name_change(void) -{ - roster_send_name_change = _mock_roster_send_name_change; -} - -void -bookmark_get_list_returns(GList *bookmarks) -{ - bookmark_get_list = _mock_bookmark_get_list; - will_return(_mock_bookmark_get_list, bookmarks); -} - -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 -mock_connection_presence_message(char *message) -{ - jabber_get_presence_message = _mock_jabber_get_presence_message; - will_return(_mock_jabber_get_presence_message, message); -} - -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); -} - -void -jabber_connect_with_details_expect_and_return(char *jid, - char *password, char *altdomain, int port, jabber_conn_status_t result) -{ - expect_string(_mock_jabber_connect_with_details, jid, jid); - expect_string(_mock_jabber_connect_with_details, passwd, password); - if (altdomain == NULL) { - expect_value(_mock_jabber_connect_with_details, altdomain, NULL); - } else { - expect_string(_mock_jabber_connect_with_details, altdomain, altdomain); - } - expect_value(_mock_jabber_connect_with_details, port, port); - will_return(_mock_jabber_connect_with_details, result); -} - -void -jabber_connect_with_details_return(jabber_conn_status_t result) -{ - expect_any(_mock_jabber_connect_with_details, jid); - expect_any(_mock_jabber_connect_with_details, passwd); - expect_any(_mock_jabber_connect_with_details, altdomain); - expect_any(_mock_jabber_connect_with_details, port); - will_return(_mock_jabber_connect_with_details, result); -} - -void -jabber_connect_with_account_expect_and_return(ProfAccount *account, - jabber_conn_status_t result) -{ - expect_memory(_mock_jabber_connect_with_account, account, account, sizeof(ProfAccount)); - will_return(_mock_jabber_connect_with_account, result); -} - -void -jabber_connect_with_account_return(ProfAccount *account, - jabber_conn_status_t result) -{ - expect_any(_mock_jabber_connect_with_account, account); - will_return(_mock_jabber_connect_with_account, result); -} - -void -presence_update_expect(resource_presence_t presence, char *msg, int idle) -{ - expect_value(_mock_presence_update, status, presence); - expect_string(_mock_presence_update, msg, msg); - expect_value(_mock_presence_update, idle, idle); -} - -void -expect_and_return_bookmark_add(char *expected_jid, char *expected_nick, - const char *expected_password, const char *expected_autojoin_str, gboolean added) -{ - expect_string(_mock_bookmark_add, jid, expected_jid); - if (expected_nick != NULL) { - expect_string(_mock_bookmark_add, nick, expected_nick); - } else { - expect_value(_mock_bookmark_add, nick, NULL); - } - if (expected_password != NULL) { - expect_string(_mock_bookmark_add, password, expected_password); - } else { - expect_value(_mock_bookmark_add, password, NULL); - } - if (expected_autojoin_str != NULL) { - expect_string(_mock_bookmark_add, autojoin_str, expected_autojoin_str); - } else { - expect_value(_mock_bookmark_add, autojoin_str, NULL); - } - - will_return(_mock_bookmark_add, added); -} - -void -expect_and_return_bookmark_remove(char *expected_jid, gboolean removed) -{ - expect_string(_mock_bookmark_remove, jid, expected_jid); - - will_return(_mock_bookmark_remove, removed); -} - -void -message_send_chat_expect(char *recipient, char *message) -{ - message_send_chat = _mock_message_send_chat; - expect_string(_mock_message_send_chat, recipient, recipient); - expect_string(_mock_message_send_chat, msg, message); -} - -void -presence_join_room_expect(char *room, char *nick, char *passwd) -{ - expect_string(_mock_presence_join_room, room, room); - expect_string(_mock_presence_join_room, nick, nick); - if (passwd == NULL) { - expect_value(_mock_presence_join_room, passwd, NULL); - } else { - expect_string(_mock_presence_join_room, passwd, passwd); - } -} - -void -roster_send_add_new_expect(char *jid, char *nick) -{ - expect_string(_mock_roster_send_add_new, barejid, jid); - expect_string(_mock_roster_send_add_new, name, nick); -} - -void -roster_send_remove_expect(char *jid) -{ - expect_string(_mock_roster_send_remove, barejid, jid); -} - -void -roster_send_name_change_expect(char *jid, char *nick, GSList *groups) -{ - expect_string(_mock_roster_send_name_change, barejid, jid); - if (nick == NULL) { - expect_value(_mock_roster_send_name_change, new_name, NULL); - } else { - expect_string(_mock_roster_send_name_change, new_name, nick); - } - expect_memory(_mock_roster_send_name_change, groups, groups, sizeof(GSList)); -} diff --git a/tests/xmpp/mock_xmpp.h b/tests/xmpp/mock_xmpp.h deleted file mode 100644 index ebe1fd7d..00000000 --- a/tests/xmpp/mock_xmpp.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef MOCK_XMPP_H -#define MOCK_XMPP_H - -#include "xmpp/xmpp.h" - -void mock_connection_status(jabber_conn_status_t status); -void mock_connection_account_name(char *name); -void mock_connection_presence_message(char *message); -void expect_room_list_request(char *conf_server); - -void mock_jabber_connect_with_details(void); -void jabber_connect_with_details_expect_and_return(char *jid, - char *password, char *altdomain, int port, jabber_conn_status_t result); -void jabber_connect_with_details_return(jabber_conn_status_t result); - -void mock_jabber_connect_with_account(void); -void jabber_connect_with_account_expect_and_return(ProfAccount *account, - jabber_conn_status_t result); -void jabber_connect_with_account_return(jabber_conn_status_t result); - -void mock_presence_update(void); -void presence_update_expect(resource_presence_t presence, char *msg, int idle); - -void bookmark_get_list_returns(GList *bookmarks); - -void mock_bookmark_add(void); -void expect_and_return_bookmark_add(char *expected_jid, char *expected_nick, - char *expected_password, char *expected_autojoin_str, gboolean added); - -void mock_bookmark_remove(void); -void expect_and_return_bookmark_remove(char *expected_jid, gboolean removed); - -void message_send_chat_expect(char *message, char *recipient); - -void mock_presence_join_room(void); -void presence_join_room_expect(char *room, char *nick, char *passwd); - -void mock_roster_send_add_new(void); -void roster_send_add_new_expect(char *jid, char *nick); - -void mock_roster_send_remove(void); -void roster_send_remove_expect(char *jid); - -void mock_roster_send_name_change(void); -void roster_send_name_change_expect(char *jid, char *name, GSList *groups); - -#endif |