mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Test /otr theirfp
This commit is contained in:
parent
b4b463998b
commit
037ca81821
@ -27,6 +27,13 @@ _mock_otr_get_my_fingerprint(void)
|
|||||||
return (char *)mock();
|
return (char *)mock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *
|
||||||
|
_mock_otr_get_their_fingerprint(const char * const recipient)
|
||||||
|
{
|
||||||
|
check_expected(recipient);
|
||||||
|
return (char *)mock();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
otr_keygen_expect(ProfAccount *account)
|
otr_keygen_expect(ProfAccount *account)
|
||||||
{
|
{
|
||||||
@ -47,3 +54,11 @@ otr_get_my_fingerprint_returns(char *fingerprint)
|
|||||||
otr_get_my_fingerprint = _mock_otr_get_my_fingerprint;
|
otr_get_my_fingerprint = _mock_otr_get_my_fingerprint;
|
||||||
will_return(_mock_otr_get_my_fingerprint, fingerprint);
|
will_return(_mock_otr_get_my_fingerprint, fingerprint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
otr_get_their_fingerprint_expect_and_return(char *recipient, char *fingerprint)
|
||||||
|
{
|
||||||
|
otr_get_their_fingerprint = _mock_otr_get_their_fingerprint;
|
||||||
|
expect_string(_mock_otr_get_their_fingerprint, recipient, recipient);
|
||||||
|
will_return(_mock_otr_get_their_fingerprint, fingerprint);
|
||||||
|
}
|
||||||
|
@ -8,5 +8,6 @@ void otr_keygen_expect(ProfAccount *account);
|
|||||||
void otr_libotr_version_returns(char *version);
|
void otr_libotr_version_returns(char *version);
|
||||||
|
|
||||||
void otr_get_my_fingerprint_returns(char *fingerprint);
|
void otr_get_my_fingerprint_returns(char *fingerprint);
|
||||||
|
void otr_get_their_fingerprint_expect_and_return(char *recipient, char *fingerprint);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -441,6 +441,33 @@ void cmd_otr_theirfp_shows_message_when_non_otr_chat_window(void **state)
|
|||||||
free(help);
|
free(help);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cmd_otr_theirfp_shows_fingerprint(void **state)
|
||||||
|
{
|
||||||
|
char *recipient = "someone@chat.com";
|
||||||
|
char *fingerprint = "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD EEEEEEEE";
|
||||||
|
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||||
|
gchar *args[] = { "theirfp", NULL };
|
||||||
|
mock_connection_status(JABBER_CONNECTED);
|
||||||
|
mock_current_win_type(WIN_CHAT);
|
||||||
|
ui_current_win_is_otr_returns(TRUE);
|
||||||
|
mock_ui_current_recipient();
|
||||||
|
ui_current_recipient_returns(recipient);
|
||||||
|
mock_ui_current_print_formatted_line();
|
||||||
|
|
||||||
|
GString *message = g_string_new(recipient);
|
||||||
|
g_string_append(message, "'s OTR fingerprint: ");
|
||||||
|
g_string_append(message, fingerprint);
|
||||||
|
|
||||||
|
otr_get_their_fingerprint_expect_and_return(recipient, strdup(fingerprint));
|
||||||
|
ui_current_print_formatted_line_expect('!', 0, message->str);
|
||||||
|
|
||||||
|
gboolean result = cmd_otr(args, *help);
|
||||||
|
assert_true(result);
|
||||||
|
|
||||||
|
g_string_free(message, TRUE);
|
||||||
|
free(help);
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
void cmd_otr_shows_message_when_otr_unsupported(void **state)
|
void cmd_otr_shows_message_when_otr_unsupported(void **state)
|
||||||
{
|
{
|
||||||
|
@ -33,6 +33,7 @@ void cmd_otr_theirfp_shows_message_when_in_muc(void **state);
|
|||||||
void cmd_otr_theirfp_shows_message_when_in_private(void **state);
|
void cmd_otr_theirfp_shows_message_when_in_private(void **state);
|
||||||
void cmd_otr_theirfp_shows_message_when_in_duck(void **state);
|
void cmd_otr_theirfp_shows_message_when_in_duck(void **state);
|
||||||
void cmd_otr_theirfp_shows_message_when_non_otr_chat_window(void **state);
|
void cmd_otr_theirfp_shows_message_when_non_otr_chat_window(void **state);
|
||||||
|
void cmd_otr_theirfp_shows_fingerprint(void **state);
|
||||||
#else
|
#else
|
||||||
void cmd_otr_shows_message_when_otr_unsupported(void **state);
|
void cmd_otr_shows_message_when_otr_unsupported(void **state);
|
||||||
#endif
|
#endif
|
||||||
|
@ -474,6 +474,7 @@ int main(int argc, char* argv[]) {
|
|||||||
unit_test(cmd_otr_theirfp_shows_message_when_in_private),
|
unit_test(cmd_otr_theirfp_shows_message_when_in_private),
|
||||||
unit_test(cmd_otr_theirfp_shows_message_when_in_duck),
|
unit_test(cmd_otr_theirfp_shows_message_when_in_duck),
|
||||||
unit_test(cmd_otr_theirfp_shows_message_when_non_otr_chat_window),
|
unit_test(cmd_otr_theirfp_shows_message_when_non_otr_chat_window),
|
||||||
|
unit_test(cmd_otr_theirfp_shows_fingerprint),
|
||||||
#else
|
#else
|
||||||
unit_test(cmd_otr_shows_message_when_otr_unsupported),
|
unit_test(cmd_otr_shows_message_when_otr_unsupported),
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user