mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Test /otr start sends OTR query message to current recipient
This commit is contained in:
parent
da058359ac
commit
c00376087f
@ -40,6 +40,12 @@ _mock_otr_key_loaded(void)
|
||||
return (gboolean)mock();
|
||||
}
|
||||
|
||||
static char *
|
||||
_mock_otr_start_query(void)
|
||||
{
|
||||
return (char *)mock();
|
||||
}
|
||||
|
||||
void
|
||||
otr_keygen_expect(ProfAccount *account)
|
||||
{
|
||||
@ -75,3 +81,10 @@ otr_key_loaded_returns(gboolean loaded)
|
||||
otr_key_loaded = _mock_otr_key_loaded;
|
||||
will_return(_mock_otr_key_loaded, loaded);
|
||||
}
|
||||
|
||||
void
|
||||
otr_start_query_returns(char *query)
|
||||
{
|
||||
otr_start_query = _mock_otr_start_query;
|
||||
will_return(_mock_otr_start_query, query);
|
||||
}
|
||||
|
@ -11,4 +11,6 @@ void otr_libotr_version_returns(char *version);
|
||||
void otr_get_my_fingerprint_returns(char *fingerprint);
|
||||
void otr_get_their_fingerprint_expect_and_return(char *recipient, char *fingerprint);
|
||||
|
||||
void otr_start_query_returns(char *query);
|
||||
|
||||
#endif
|
||||
|
@ -557,6 +557,28 @@ void cmd_otr_start_shows_message_when_no_key(void **state)
|
||||
free(help);
|
||||
}
|
||||
|
||||
void
|
||||
cmd_otr_start_sends_otr_query_message_to_current_recipeint(void **state)
|
||||
{
|
||||
char *recipient = "buddy@chat.com";
|
||||
char *query_message = "?OTR?";
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
gchar *args[] = { "start", NULL };
|
||||
mock_connection_status(JABBER_CONNECTED);
|
||||
mock_current_win_type(WIN_CHAT);
|
||||
ui_current_win_is_otr_returns(FALSE);
|
||||
otr_key_loaded_returns(TRUE);
|
||||
ui_current_recipient_returns(recipient);
|
||||
otr_start_query_returns(query_message);
|
||||
|
||||
message_send_expect(query_message, recipient);
|
||||
|
||||
gboolean result = cmd_otr(args, *help);
|
||||
assert_true(result);
|
||||
|
||||
free(help);
|
||||
}
|
||||
|
||||
#else
|
||||
void cmd_otr_shows_message_when_otr_unsupported(void **state)
|
||||
{
|
||||
|
@ -41,6 +41,7 @@ void cmd_otr_start_shows_message_when_in_private(void **state);
|
||||
void cmd_otr_start_shows_message_when_in_duck(void **state);
|
||||
void cmd_otr_start_shows_message_when_already_started(void **state);
|
||||
void cmd_otr_start_shows_message_when_no_key(void **state);
|
||||
void cmd_otr_start_sends_otr_query_message_to_current_recipeint(void **state);
|
||||
#else
|
||||
void cmd_otr_shows_message_when_otr_unsupported(void **state);
|
||||
#endif
|
||||
|
@ -482,6 +482,7 @@ int main(int argc, char* argv[]) {
|
||||
unit_test(cmd_otr_start_shows_message_when_in_duck),
|
||||
unit_test(cmd_otr_start_shows_message_when_already_started),
|
||||
unit_test(cmd_otr_start_shows_message_when_no_key),
|
||||
unit_test(cmd_otr_start_sends_otr_query_message_to_current_recipeint),
|
||||
#else
|
||||
unit_test(cmd_otr_shows_message_when_otr_unsupported),
|
||||
#endif
|
||||
|
@ -81,6 +81,13 @@ _mock_bookmark_remove(const char *jid, gboolean autojoin)
|
||||
return (gboolean)mock();
|
||||
}
|
||||
|
||||
static void
|
||||
_mock_message_send(const char * const msg, const char * const recipient)
|
||||
{
|
||||
check_expected(msg);
|
||||
check_expected(recipient);
|
||||
}
|
||||
|
||||
void
|
||||
mock_jabber_connect_with_details(void)
|
||||
{
|
||||
@ -219,3 +226,11 @@ expect_and_return_bookmark_remove(char *expected_jid, gboolean expected_autojoin
|
||||
|
||||
will_return(_mock_bookmark_remove, removed);
|
||||
}
|
||||
|
||||
void
|
||||
message_send_expect(char *message, char *recipient)
|
||||
{
|
||||
message_send = _mock_message_send;
|
||||
expect_string(_mock_message_send, msg, message);
|
||||
expect_string(_mock_message_send, recipient, recipient);
|
||||
}
|
||||
|
@ -31,4 +31,6 @@ void mock_bookmark_remove(void);
|
||||
void expect_and_return_bookmark_remove(char *expected_jid, gboolean expected_autojoin,
|
||||
gboolean removed);
|
||||
|
||||
void message_send_expect(char *message, char *recipient);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user