diff --git a/tests/test_cmd_otr.c b/tests/test_cmd_otr.c index 2d82163f..b926b391 100644 --- a/tests/test_cmd_otr.c +++ b/tests/test_cmd_otr.c @@ -280,6 +280,46 @@ void cmd_otr_gen_shows_message_when_not_connected(void **state) free(help); } +static void test_with_command_and_connection_status(char *command, jabber_conn_status_t status) +{ + mock_cons_show(); + CommandHelp *help = malloc(sizeof(CommandHelp)); + gchar *args[] = { command, NULL }; + + mock_connection_status(status); + expect_cons_show("You are not currently connected."); + + gboolean result = cmd_rooms(args, *help); + assert_true(result); + + free(help); +} + +void cmd_otr_gen_shows_message_when_disconnected(void **state) +{ + test_with_command_and_connection_status("gen", JABBER_DISCONNECTED); +} + +void cmd_otr_gen_shows_message_when_undefined(void **state) +{ + test_with_command_and_connection_status("gen", JABBER_UNDEFINED); +} + +void cmd_otr_gen_shows_message_when_started(void **state) +{ + test_with_command_and_connection_status("gen", JABBER_STARTED); +} + +void cmd_otr_gen_shows_message_when_connecting(void **state) +{ + test_with_command_and_connection_status("gen", JABBER_CONNECTING); +} + +void cmd_otr_gen_shows_message_when_disconnecting(void **state) +{ + test_with_command_and_connection_status("gen", JABBER_DISCONNECTING); +} + void cmd_otr_gen_generates_key_for_connected_account(void **state) { CommandHelp *help = malloc(sizeof(CommandHelp)); diff --git a/tests/test_cmd_otr.h b/tests/test_cmd_otr.h index c198a4f6..224b7bd6 100644 --- a/tests/test_cmd_otr.h +++ b/tests/test_cmd_otr.h @@ -17,6 +17,11 @@ void cmd_otr_warn_off_disables_unencrypted_warning(void **state); void cmd_otr_libver_shows_libotr_version(void **state); void cmd_otr_gen_shows_message_when_not_connected(void **state); void cmd_otr_gen_generates_key_for_connected_account(void **state); +void cmd_otr_gen_shows_message_when_disconnected(void **state); +void cmd_otr_gen_shows_message_when_undefined(void **state); +void cmd_otr_gen_shows_message_when_started(void **state); +void cmd_otr_gen_shows_message_when_connecting(void **state); +void cmd_otr_gen_shows_message_when_disconnecting(void **state); #else void cmd_otr_shows_message_when_otr_unsupported(void **state); #endif diff --git a/tests/testsuite.c b/tests/testsuite.c index 17ae3172..4c539d2c 100644 --- a/tests/testsuite.c +++ b/tests/testsuite.c @@ -458,6 +458,11 @@ int main(int argc, char* argv[]) { unit_test(cmd_otr_libver_shows_libotr_version), unit_test(cmd_otr_gen_shows_message_when_not_connected), unit_test(cmd_otr_gen_generates_key_for_connected_account), + unit_test(cmd_otr_gen_shows_message_when_disconnected), + unit_test(cmd_otr_gen_shows_message_when_undefined), + unit_test(cmd_otr_gen_shows_message_when_started), + unit_test(cmd_otr_gen_shows_message_when_connecting), + unit_test(cmd_otr_gen_shows_message_when_disconnecting), #else unit_test(cmd_otr_shows_message_when_otr_unsupported), #endif