mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
Fixed tests
This commit is contained in:
parent
ea267e2017
commit
6800bf1cad
@ -3887,7 +3887,7 @@ cmd_otr(gchar **args, struct cmd_help_t help)
|
|||||||
} else if (!ui_current_win_is_otr()) {
|
} else if (!ui_current_win_is_otr()) {
|
||||||
ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session.");
|
ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session.");
|
||||||
} else {
|
} else {
|
||||||
ProfChatWin *chatwin = wins_get_current_chat();
|
ProfChatWin *chatwin = ui_get_current_chat();
|
||||||
char *fingerprint = otr_get_their_fingerprint(chatwin->barejid);
|
char *fingerprint = otr_get_their_fingerprint(chatwin->barejid);
|
||||||
ui_current_print_formatted_line('!', 0, "%s's OTR fingerprint: %s", chatwin->barejid, fingerprint);
|
ui_current_print_formatted_line('!', 0, "%s's OTR fingerprint: %s", chatwin->barejid, fingerprint);
|
||||||
free(fingerprint);
|
free(fingerprint);
|
||||||
@ -3933,7 +3933,7 @@ cmd_otr(gchar **args, struct cmd_help_t help)
|
|||||||
if (!otr_key_loaded()) {
|
if (!otr_key_loaded()) {
|
||||||
ui_current_print_formatted_line('!', 0, "You have not generated or loaded a private key, use '/otr gen'");
|
ui_current_print_formatted_line('!', 0, "You have not generated or loaded a private key, use '/otr gen'");
|
||||||
} else {
|
} else {
|
||||||
ProfChatWin *chatwin = wins_get_current_chat();
|
ProfChatWin *chatwin = ui_get_current_chat();
|
||||||
char *otr_query_message = otr_start_query();
|
char *otr_query_message = otr_start_query();
|
||||||
message_send_chat(chatwin->barejid, otr_query_message);
|
message_send_chat(chatwin->barejid, otr_query_message);
|
||||||
}
|
}
|
||||||
|
@ -314,6 +314,12 @@ _ui_get_recipients(void)
|
|||||||
return recipients;
|
return recipients;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ProfChatWin *
|
||||||
|
_ui_get_current_chat(void)
|
||||||
|
{
|
||||||
|
return wins_get_current_chat();
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ui_incoming_msg(const char * const barejid, const char * const message, GTimeVal *tv_stamp)
|
_ui_incoming_msg(const char * const barejid, const char * const message, GTimeVal *tv_stamp)
|
||||||
{
|
{
|
||||||
@ -3208,5 +3214,6 @@ ui_init_module(void)
|
|||||||
ui_redraw = _ui_redraw;
|
ui_redraw = _ui_redraw;
|
||||||
ui_show_all_room_rosters = _ui_show_all_room_rosters;
|
ui_show_all_room_rosters = _ui_show_all_room_rosters;
|
||||||
ui_hide_all_room_rosters = _ui_hide_all_room_rosters;
|
ui_hide_all_room_rosters = _ui_hide_all_room_rosters;
|
||||||
|
ui_get_current_chat = _ui_get_current_chat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,6 +109,8 @@ int (*ui_current_win_index)(void);
|
|||||||
gboolean (*ui_current_win_is_otr)(void);
|
gboolean (*ui_current_win_is_otr)(void);
|
||||||
void (*ui_current_set_otr)(gboolean value);
|
void (*ui_current_set_otr)(gboolean value);
|
||||||
|
|
||||||
|
ProfChatWin *(*ui_get_current_chat)(void);
|
||||||
|
|
||||||
void (*ui_current_print_line)(const char * const msg, ...);
|
void (*ui_current_print_line)(const char * const msg, ...);
|
||||||
void (*ui_current_print_formatted_line)(const char show_char, int attrs, const char * const msg, ...);
|
void (*ui_current_print_formatted_line)(const char show_char, int attrs, const char * const msg, ...);
|
||||||
void (*ui_current_error_line)(const char * const msg);
|
void (*ui_current_error_line)(const char * const msg);
|
||||||
|
@ -457,14 +457,18 @@ void cmd_otr_theirfp_shows_fingerprint(void **state)
|
|||||||
gchar *args[] = { "theirfp", NULL };
|
gchar *args[] = { "theirfp", NULL };
|
||||||
mock_connection_status(JABBER_CONNECTED);
|
mock_connection_status(JABBER_CONNECTED);
|
||||||
mock_current_win_type(WIN_CHAT);
|
mock_current_win_type(WIN_CHAT);
|
||||||
|
ProfChatWin *chatwin = malloc(sizeof(ProfChatWin));
|
||||||
|
chatwin->barejid = strdup(recipient);
|
||||||
|
mock_ui_get_current_chat(chatwin);
|
||||||
|
|
||||||
ui_current_win_is_otr_returns(TRUE);
|
ui_current_win_is_otr_returns(TRUE);
|
||||||
mock_ui_current_print_formatted_line();
|
mock_ui_current_print_formatted_line();
|
||||||
|
|
||||||
GString *message = g_string_new(recipient);
|
GString *message = g_string_new(chatwin->barejid);
|
||||||
g_string_append(message, "'s OTR fingerprint: ");
|
g_string_append(message, "'s OTR fingerprint: ");
|
||||||
g_string_append(message, fingerprint);
|
g_string_append(message, fingerprint);
|
||||||
|
|
||||||
otr_get_their_fingerprint_expect_and_return(recipient, strdup(fingerprint));
|
otr_get_their_fingerprint_expect_and_return(chatwin->barejid, strdup(fingerprint));
|
||||||
ui_current_print_formatted_line_expect('!', 0, message->str);
|
ui_current_print_formatted_line_expect('!', 0, message->str);
|
||||||
|
|
||||||
gboolean result = cmd_otr(args, *help);
|
gboolean result = cmd_otr(args, *help);
|
||||||
@ -472,6 +476,8 @@ void cmd_otr_theirfp_shows_fingerprint(void **state)
|
|||||||
|
|
||||||
g_string_free(message, TRUE);
|
g_string_free(message, TRUE);
|
||||||
free(help);
|
free(help);
|
||||||
|
free(chatwin->barejid);
|
||||||
|
free(chatwin);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -550,16 +556,22 @@ cmd_otr_start_sends_otr_query_message_to_current_recipeint(void **state)
|
|||||||
gchar *args[] = { "start", NULL };
|
gchar *args[] = { "start", NULL };
|
||||||
mock_connection_status(JABBER_CONNECTED);
|
mock_connection_status(JABBER_CONNECTED);
|
||||||
mock_current_win_type(WIN_CHAT);
|
mock_current_win_type(WIN_CHAT);
|
||||||
|
ProfChatWin *chatwin = malloc(sizeof(ProfChatWin));
|
||||||
|
chatwin->barejid = strdup(recipient);
|
||||||
|
mock_ui_get_current_chat(chatwin);
|
||||||
|
|
||||||
ui_current_win_is_otr_returns(FALSE);
|
ui_current_win_is_otr_returns(FALSE);
|
||||||
otr_key_loaded_returns(TRUE);
|
otr_key_loaded_returns(TRUE);
|
||||||
otr_start_query_returns(query_message);
|
otr_start_query_returns(query_message);
|
||||||
|
|
||||||
message_send_chat_expect(query_message, recipient);
|
message_send_chat_expect(chatwin->barejid, query_message);
|
||||||
|
|
||||||
gboolean result = cmd_otr(args, *help);
|
gboolean result = cmd_otr(args, *help);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
free(help);
|
||||||
|
free(chatwin->barejid);
|
||||||
|
free(chatwin);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
@ -93,6 +93,12 @@ win_type_t _mock_ui_current_win_type(void)
|
|||||||
return (win_type_t)mock();
|
return (win_type_t)mock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
ProfChatWin * _mock_ui_get_current_chat(void)
|
||||||
|
{
|
||||||
|
return (ProfChatWin*)mock();
|
||||||
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
void _mock_ui_handle_error(const char * const err_msg)
|
void _mock_ui_handle_error(const char * const err_msg)
|
||||||
{
|
{
|
||||||
@ -394,6 +400,13 @@ mock_current_win_type(win_type_t type)
|
|||||||
will_return(_mock_ui_current_win_type, type);
|
will_return(_mock_ui_current_win_type, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
mock_ui_get_current_chat(ProfChatWin *chatwin)
|
||||||
|
{
|
||||||
|
ui_get_current_chat = _mock_ui_get_current_chat;
|
||||||
|
will_return(_mock_ui_get_current_chat, chatwin);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ui_current_print_formatted_line_expect(char show_char, int attrs, char *message)
|
ui_current_print_formatted_line_expect(char show_char, int attrs, char *message)
|
||||||
{
|
{
|
||||||
|
@ -47,6 +47,8 @@ void mock_ui_ask_password_returns(char *password);
|
|||||||
|
|
||||||
void mock_current_win_type(win_type_t type);
|
void mock_current_win_type(win_type_t type);
|
||||||
|
|
||||||
|
void mock_ui_get_current_chat(ProfChatWin *chatwin);
|
||||||
|
|
||||||
void mock_ui_current_recipient(void);
|
void mock_ui_current_recipient(void);
|
||||||
void ui_current_recipient_returns(char *jid);
|
void ui_current_recipient_returns(char *jid);
|
||||||
|
|
||||||
|
@ -292,8 +292,8 @@ void
|
|||||||
message_send_chat_expect(char *recipient, char *message)
|
message_send_chat_expect(char *recipient, char *message)
|
||||||
{
|
{
|
||||||
message_send_chat = _mock_message_send_chat;
|
message_send_chat = _mock_message_send_chat;
|
||||||
expect_string(_mock_message_send, recipient, recipient);
|
expect_string(_mock_message_send_chat, recipient, recipient);
|
||||||
expect_string(_mock_message_send, msg, message);
|
expect_string(_mock_message_send_chat, msg, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user