diff options
author | James Booth <boothj5@gmail.com> | 2015-06-15 23:17:11 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2015-06-15 23:17:11 +0100 |
commit | 637b8bee9fcaeedbb09636b76e34270abbfcab47 (patch) | |
tree | 1de8a0181678fa44f1018a1fe86c6ca0a413942d /tests/unittests | |
parent | de4745059465f0baa21b4c3e721971cf40cd0d87 (diff) | |
parent | fb0e0659023e6483418de2a06626d640644e94d9 (diff) | |
download | profani-tty-637b8bee9fcaeedbb09636b76e34270abbfcab47.tar.gz |
Merge branch 'master' into openpgp
Diffstat (limited to 'tests/unittests')
-rw-r--r-- | tests/unittests/test_cmd_otr.c | 41 | ||||
-rw-r--r-- | tests/unittests/ui/stub_ui.c | 5 |
2 files changed, 36 insertions, 10 deletions
diff --git a/tests/unittests/test_cmd_otr.c b/tests/unittests/test_cmd_otr.c index 4039fe6a..a2985375 100644 --- a/tests/unittests/test_cmd_otr.c +++ b/tests/unittests/test_cmd_otr.c @@ -422,12 +422,21 @@ void cmd_otr_theirfp_shows_message_when_in_private(void **state) void cmd_otr_theirfp_shows_message_when_non_otr_chat_window(void **state) { + char *recipient = "someuser@someserver.com"; CommandHelp *help = malloc(sizeof(CommandHelp)); gchar *args[] = { "theirfp", NULL }; will_return(jabber_get_connection_status, JABBER_CONNECTED); will_return(ui_current_win_type, WIN_CHAT); - will_return(ui_current_win_is_otr, FALSE); + + ProfChatWin *chatwin = malloc(sizeof(ProfChatWin)); + chatwin->barejid = strdup(recipient); + chatwin->memcheck = PROFCHATWIN_MEMCHECK; + will_return(win_create_chat, &chatwin->window); + + wins_init(); + wins_new_chat(recipient); + wins_set_current_by_num(2); expect_ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session."); @@ -435,6 +444,7 @@ void cmd_otr_theirfp_shows_message_when_non_otr_chat_window(void **state) assert_true(result); free(help); + wins_close_current(); } void cmd_otr_theirfp_shows_fingerprint(void **state) @@ -450,6 +460,7 @@ void cmd_otr_theirfp_shows_fingerprint(void **state) ProfChatWin *chatwin = malloc(sizeof(ProfChatWin)); chatwin->barejid = strdup(recipient); chatwin->memcheck = PROFCHATWIN_MEMCHECK; + chatwin->enc_mode = PROF_ENC_OTR; will_return(win_create_chat, &chatwin->window); wins_init(); @@ -458,7 +469,6 @@ void cmd_otr_theirfp_shows_fingerprint(void **state) will_return(jabber_get_connection_status, JABBER_CONNECTED); will_return(ui_current_win_type, WIN_CHAT); - will_return(ui_current_win_is_otr, TRUE); expect_string(otr_get_their_fingerprint, recipient, chatwin->barejid); will_return(otr_get_their_fingerprint, strdup(fingerprint)); @@ -507,12 +517,22 @@ void cmd_otr_start_shows_message_when_in_private(void **state) void cmd_otr_start_shows_message_when_already_started(void **state) { + char *recipient = "someone@server.org"; CommandHelp *help = malloc(sizeof(CommandHelp)); gchar *args[] = { "start", NULL }; will_return(jabber_get_connection_status, JABBER_CONNECTED); will_return(ui_current_win_type, WIN_CHAT); - will_return(ui_current_win_is_otr, TRUE); + + ProfChatWin *chatwin = malloc(sizeof(ProfChatWin)); + chatwin->barejid = strdup(recipient); + chatwin->memcheck = PROFCHATWIN_MEMCHECK; + chatwin->enc_mode = PROF_ENC_OTR; + will_return(win_create_chat, &chatwin->window); + + wins_init(); + wins_new_chat(recipient); + wins_set_current_by_num(2); expect_ui_current_print_formatted_line('!', 0, "You are already in an OTR session."); @@ -520,24 +540,36 @@ void cmd_otr_start_shows_message_when_already_started(void **state) assert_true(result); free(help); + wins_close_current(); } void cmd_otr_start_shows_message_when_no_key(void **state) { + char *recipient = "someone@server.org"; CommandHelp *help = malloc(sizeof(CommandHelp)); gchar *args[] = { "start", NULL }; will_return(jabber_get_connection_status, JABBER_CONNECTED); will_return(ui_current_win_type, WIN_CHAT); - will_return(ui_current_win_is_otr, FALSE); will_return(otr_key_loaded, FALSE); + ProfChatWin *chatwin = malloc(sizeof(ProfChatWin)); + chatwin->barejid = strdup(recipient); + chatwin->memcheck = PROFCHATWIN_MEMCHECK; + chatwin->enc_mode = PROF_ENC_NONE; + will_return(win_create_chat, &chatwin->window); + + wins_init(); + wins_new_chat(recipient); + wins_set_current_by_num(2); + expect_ui_current_print_formatted_line('!', 0, "You have not generated or loaded a private key, use '/otr gen'"); gboolean result = cmd_otr(args, *help); assert_true(result); free(help); + wins_close_current(); } void @@ -559,7 +591,6 @@ cmd_otr_start_sends_otr_query_message_to_current_recipeint(void **state) will_return(jabber_get_connection_status, JABBER_CONNECTED); will_return(ui_current_win_type, WIN_CHAT); - will_return(ui_current_win_is_otr, FALSE); will_return(otr_key_loaded, TRUE); will_return(otr_start_query, query_message); diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index ac1ad1b8..c2626158 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -126,11 +126,6 @@ win_type_t ui_current_win_type(void) return (win_type_t)mock(); } -gboolean ui_current_win_is_otr(void) -{ - return (gboolean)mock(); -} - void ui_current_print_line(const char * const msg, ...) { va_list args; |