1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Call UI disconnect functions before disconnecting with /disconnect

fixes #703
This commit is contained in:
James Booth 2016-01-05 01:30:32 +00:00
parent 8e9bf08389
commit e1e0fda8b3
5 changed files with 31 additions and 2 deletions

View File

@ -115,6 +115,7 @@ functionaltest_sources = \
tests/functionaltests/test_roster.c tests/functionaltests/test_roster.h \ tests/functionaltests/test_roster.c tests/functionaltests/test_roster.h \
tests/functionaltests/test_software.c tests/functionaltests/test_software.h \ tests/functionaltests/test_software.c tests/functionaltests/test_software.h \
tests/functionaltests/test_muc.c tests/functionaltests/test_muc.h \ tests/functionaltests/test_muc.c tests/functionaltests/test_muc.h \
tests/functionaltests/test_disconnect.c tests/functionaltests/test_disconnect.h \
tests/functionaltests/functionaltests.c tests/functionaltests/functionaltests.c
main_source = src/main.c main_source = src/main.c

View File

@ -73,13 +73,13 @@ cl_ev_disconnect(void)
const char *jid = jabber_get_fulljid(); const char *jid = jabber_get_fulljid();
cons_show("%s logged out successfully.", jid); cons_show("%s logged out successfully.", jid);
ui_disconnected();
ui_close_all_wins();
jabber_disconnect(); jabber_disconnect();
roster_clear(); roster_clear();
muc_invites_clear(); muc_invites_clear();
chat_sessions_clear(); chat_sessions_clear();
tlscerts_clear_current(); tlscerts_clear_current();
ui_disconnected();
ui_close_all_wins();
#ifdef HAVE_LIBGPGME #ifdef HAVE_LIBGPGME
p_gpg_on_disconnect(); p_gpg_on_disconnect();
#endif #endif

View File

@ -21,6 +21,7 @@
#include "test_roster.h" #include "test_roster.h"
#include "test_software.h" #include "test_software.h"
#include "test_muc.h" #include "test_muc.h"
#include "test_disconnect.h"
#define PROF_FUNC_TEST(test) unit_test_setup_teardown(test, init_prof_test, close_prof_test) #define PROF_FUNC_TEST(test) unit_test_setup_teardown(test, init_prof_test, close_prof_test)
@ -98,6 +99,8 @@ int main(int argc, char* argv[]) {
PROF_FUNC_TEST(shows_all_messages_in_console_when_window_not_focussed), PROF_FUNC_TEST(shows_all_messages_in_console_when_window_not_focussed),
PROF_FUNC_TEST(shows_first_message_in_console_when_window_not_focussed), PROF_FUNC_TEST(shows_first_message_in_console_when_window_not_focussed),
PROF_FUNC_TEST(shows_no_message_in_console_when_window_not_focussed), PROF_FUNC_TEST(shows_no_message_in_console_when_window_not_focussed),
PROF_FUNC_TEST(disconnect_ends_session),
}; };
return run_tests(all_tests); return run_tests(all_tests);

View File

@ -0,0 +1,24 @@
#include <glib.h>
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include <stdlib.h>
#include <string.h>
#include <stabber.h>
#include <expect.h>
#include "proftest.h"
void
disconnect_ends_session(void **state)
{
prof_connect();
prof_input("/disconnect");
assert_true(prof_output_exact("stabber@localhost/profanity logged out successfully."));
prof_input("/roster");
assert_true(prof_output_exact("You are not currently connected."));
}

View File

@ -0,0 +1 @@
void disconnect_ends_session(void **state);