about summary refs log tree commit diff stats
path: root/tests/ui
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-01-28 23:56:45 +0000
committerJames Booth <boothj5@gmail.com>2014-01-28 23:56:45 +0000
commit571665eeac0c357fb1b9482531dc62c10ccdb595 (patch)
treefb80aafaa790664764b2c2c01595427481fbc8c3 /tests/ui
parent96af960995a00b3c59cc9a4d82e8b1fff0c935fc (diff)
downloadprofani-tty-571665eeac0c357fb1b9482531dc62c10ccdb595.tar.gz
Added message stanza error tests
Diffstat (limited to 'tests/ui')
-rw-r--r--tests/ui/mock_ui.c49
-rw-r--r--tests/ui/mock_ui.h4
2 files changed, 49 insertions, 4 deletions
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, ...)
 {
@@ -99,10 +101,33 @@ void _mock_ui_handle_error(const char * const 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);