diff options
-rw-r--r-- | src/command/commands.c | 2 | ||||
-rw-r--r-- | src/ui/core.c | 7 | ||||
-rw-r--r-- | src/ui/ui.h | 1 | ||||
-rw-r--r-- | tests/test_cmd_connect.c | 4 | ||||
-rw-r--r-- | tests/ui/mock_ui.c | 11 | ||||
-rw-r--r-- | tests/ui/mock_ui.h | 4 |
6 files changed, 24 insertions, 5 deletions
diff --git a/src/command/commands.c b/src/command/commands.c index a7deb17a..2dcb4a0e 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -65,7 +65,7 @@ cmd_connect(gchar **args, struct cmd_help_t help) jabber_conn_status_t conn_status = jabber_get_connection_status(); if ((conn_status != JABBER_DISCONNECTED) && (conn_status != JABBER_STARTED)) { - cons_show("You are either connected already, or a login is in process."); + ui_already_connected(); result = TRUE; } else { char *user = args[0]; diff --git a/src/ui/core.c b/src/ui/core.c index 3cb05fe8..b3b4eadb 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -545,6 +545,12 @@ _ui_unknown_command(const char * const input) } static void +_ui_already_connected(void) +{ + cons_show("You are either connected already, or a login is in process."); +} + +static void _ui_disconnected(void) { wins_lost_connection(); @@ -1922,4 +1928,5 @@ ui_init_module(void) ui_replace_input = _ui_replace_input; ui_invalid_command_usage = _ui_invalid_command_usage; ui_unknown_command = _ui_unknown_command; + ui_already_connected = _ui_already_connected; } diff --git a/src/ui/ui.h b/src/ui/ui.h index fc689305..7543e6a8 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -161,6 +161,7 @@ void (*ui_replace_input)(char *input, const char * const new_input, int *size); void (*ui_invalid_command_usage)(const char * const usage, void (**setting_func)(void)); void (*ui_unknown_command)(const char * const input); +void (*ui_already_connected)(void); // console window actions void (*cons_show)(const char * const msg, ...); diff --git a/tests/test_cmd_connect.c b/tests/test_cmd_connect.c index 33f49164..76493115 100644 --- a/tests/test_cmd_connect.c +++ b/tests/test_cmd_connect.c @@ -19,13 +19,11 @@ static void test_with_connection_status(jabber_conn_status_t status) { - mock_cons_show(); + stub_ui_already_connected(); CommandHelp *help = malloc(sizeof(CommandHelp)); mock_connection_status(status); - expect_cons_show("You are either connected already, or a login is in process."); - gboolean result = cmd_connect(NULL, *help); assert_true(result); diff --git a/tests/ui/mock_ui.c b/tests/ui/mock_ui.c index 94f8e3c3..0e01be25 100644 --- a/tests/ui/mock_ui.c +++ b/tests/ui/mock_ui.c @@ -83,6 +83,11 @@ char * _stub_ui_ask_password(void) } static +void _stub_ui_already_connected(void) +{ +} + +static win_type_t _mock_ui_current_win_type(void) { return (win_type_t)mock(); @@ -259,6 +264,12 @@ stub_cons_show(void) } void +stub_ui_already_connected(void) +{ + ui_already_connected = _stub_ui_already_connected; +} + +void stub_ui_handle_recipient_not_found(void) { ui_handle_recipient_not_found = _stub_ui_handle_recipient_not_found; diff --git a/tests/ui/mock_ui.h b/tests/ui/mock_ui.h index 5b984615..70c9f3b3 100644 --- a/tests/ui/mock_ui.h +++ b/tests/ui/mock_ui.h @@ -66,4 +66,6 @@ void cons_show_roster_expect(GSList *list); void ui_switch_win_expect_and_return(int given_i, gboolean result); -#endif +void stub_ui_already_connected(void); + +#endif \ No newline at end of file |