Added message stanza error tests

This commit is contained in:
James Booth
2014-01-28 23:56:45 +00:00
parent 96af960995
commit 571665eeac
6 changed files with 102 additions and 8 deletions

View File

@@ -8,6 +8,7 @@
#include "server_events.h"
#include "roster_list.h"
#include "chat_session.h"
#include "config/preferences.h"
#include "ui/ui.h"
#include "ui/mock_ui.h"
@@ -108,8 +109,46 @@ void console_shows_dnd_presence_when_set_all(void **state)
void handle_message_stanza_error_when_no_from(void **state)
{
char *err_msg = "Some error.";
mock_ui_handle_error();
expect_ui_handle_error(err_msg);
handle_message_error(NULL, "cancel", err_msg);
}
void handle_message_stanza_error_from_cancel(void **state)
{
char *err_msg = "Some error.";
char *from = "bob@server.com";
prefs_set_boolean(PREF_STATES, FALSE);
chat_sessions_init();
expect_ui_handle_recipient_not_found(from, err_msg);
handle_message_error(from, "cancel", err_msg);
}
void handle_message_stanza_error_from_cancel_disables_chat_session(void **state)
{
char *err_msg = "Some error.";
char *from = "bob@server.com";
stub_ui_handle_recipient_not_found();
prefs_set_boolean(PREF_STATES, TRUE);
chat_sessions_init();
chat_session_start(from, TRUE);
handle_message_error(from, "cancel", err_msg);
gboolean chat_session_supported = chat_session_get_recipient_supports(from);
assert_false(chat_session_supported);
chat_sessions_clear();
}
void handle_message_stanza_error_from_no_type(void **state)
{
char *err_msg = "Some error.";
char *from = "bob@server.com";
expect_ui_handle_recipient_error(from, err_msg);
handle_message_error(from, NULL, err_msg);
}