1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Added test for /otr theirfp when in console

This commit is contained in:
James Booth 2014-02-17 22:14:33 +00:00
parent 82ad0cd306
commit 4afec6ab5e
5 changed files with 43 additions and 0 deletions

View File

@ -387,6 +387,22 @@ void cmd_otr_myfp_shows_my_fingerprint(void **state)
free(help);
}
void cmd_otr_theirfp_shows_message_when_in_console(void **state)
{
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "theirfp", NULL };
mock_connection_status(JABBER_CONNECTED);
mock_current_win_type(WIN_CONSOLE);
mock_ui_current_print_line();
ui_current_print_line_expect("You must be in a regular chat window to view a recipient's fingerprint.");
gboolean result = cmd_otr(args, *help);
assert_true(result);
free(help);
}
#else
void cmd_otr_shows_message_when_otr_unsupported(void **state)
{

View File

@ -28,6 +28,7 @@ void cmd_otr_myfp_shows_message_when_started(void **state);
void cmd_otr_myfp_shows_message_when_connecting(void **state);
void cmd_otr_myfp_shows_message_when_disconnecting(void **state);
void cmd_otr_myfp_shows_my_fingerprint(void **state);
void cmd_otr_theirfp_shows_message_when_in_console(void **state);
#else
void cmd_otr_shows_message_when_otr_unsupported(void **state);
#endif

View File

@ -469,6 +469,7 @@ int main(int argc, char* argv[]) {
unit_test(cmd_otr_myfp_shows_message_when_connecting),
unit_test(cmd_otr_myfp_shows_message_when_disconnecting),
unit_test(cmd_otr_myfp_shows_my_fingerprint),
unit_test(cmd_otr_theirfp_shows_message_when_in_console),
#else
unit_test(cmd_otr_shows_message_when_otr_unsupported),
#endif

View File

@ -171,6 +171,16 @@ void _mock_ui_current_print_formatted_line(const char show_char, int attrs, cons
va_end(args);
}
static
void _mock_ui_current_print_line(const char * const msg, ...)
{
va_list args;
va_start(args, msg);
vsnprintf(output, sizeof(output), msg, args);
check_expected(output);
va_end(args);
}
// bind mocks and stubs
void
@ -270,6 +280,12 @@ mock_ui_current_print_formatted_line(void)
ui_current_print_formatted_line = _mock_ui_current_print_formatted_line;
}
void
mock_ui_current_print_line(void)
{
ui_current_print_line = _mock_ui_current_print_line;
}
// expectations
void
@ -394,3 +410,9 @@ ui_current_print_formatted_line_expect(char show_char, int attrs, char *message)
expect_value(_mock_ui_current_print_formatted_line, attrs, attrs);
expect_string(_mock_ui_current_print_formatted_line, output, message);
}
void
ui_current_print_line_expect(char *message)
{
expect_string(_mock_ui_current_print_line, output, message);
}

View File

@ -54,4 +54,7 @@ void stub_ui_current_refresh(void);
void mock_ui_current_print_formatted_line(void);
void ui_current_print_formatted_line_expect(char show_char, int attrs, char *message);
void mock_ui_current_print_line(void);
void ui_current_print_line_expect(char *message);
#endif