From 571665eeac0c357fb1b9482531dc62c10ccdb595 Mon Sep 17 00:00:00 2001 From: James Booth Date: Tue, 28 Jan 2014 23:56:45 +0000 Subject: Added message stanza error tests --- tests/ui/mock_ui.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- tests/ui/mock_ui.h | 4 +++- 2 files changed, 49 insertions(+), 4 deletions(-) (limited to 'tests/ui') diff --git a/tests/ui/mock_ui.c b/tests/ui/mock_ui.c index 5e2be5f6..feeed9db 100644 --- a/tests/ui/mock_ui.c +++ b/tests/ui/mock_ui.c @@ -29,6 +29,8 @@ char output[256]; +// Mocks and stubs + static void _mock_cons_show(const char * const msg, ...) { @@ -98,11 +100,34 @@ 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 _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) +{ +} + +// bind mocks and stubs + void mock_cons_show(void) { @@ -146,7 +171,6 @@ mock_cons_show_account_list(void) cons_show_account_list = _mock_cons_show_account_list; } - void mock_ui_ask_password(void) { @@ -166,11 +190,13 @@ stub_cons_show(void) } void -mock_ui_handle_error(void) +stub_ui_handle_recipient_not_found(void) { - ui_handle_error = _mock_ui_handle_error; + ui_handle_recipient_not_found = _stub_ui_handle_recipient_not_found; } +// expectations + void expect_cons_show(char *output) { @@ -229,5 +255,22 @@ mock_ui_ask_password_returns(char *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); +} diff --git a/tests/ui/mock_ui.h b/tests/ui/mock_ui.h index a7a53e53..258cb10c 100644 --- a/tests/ui/mock_ui.h +++ b/tests/ui/mock_ui.h @@ -18,8 +18,10 @@ void stub_ui_chat_win_contact_online(void); void mock_cons_show_error(void); void expect_cons_show_error(char *output); -void mock_ui_handle_error(void); +void stub_ui_handle_recipient_not_found(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); -- cgit 1.4.1-2-gfad0