about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2016-01-05 01:38:31 +0000
committerJames Booth <boothj5@gmail.com>2016-01-05 01:38:31 +0000
commit393e69016575c0e0dc3669f43b916b3742866cf3 (patch)
treee29a9ee836c1f4ba88e129f3c31df60a8b78cb56
parent055a5f71ce38c87ea1c97d475fd870ee25148ea9 (diff)
parente1e0fda8b307270045a744f1325e8d88032f65b9 (diff)
downloadprofani-tty-393e69016575c0e0dc3669f43b916b3742866cf3.tar.gz
Merge branch 'master' into roster-struct
-rw-r--r--Makefile.am1
-rw-r--r--src/event/client_events.c4
-rw-r--r--tests/functionaltests/functionaltests.c3
-rw-r--r--tests/functionaltests/test_disconnect.c24
-rw-r--r--tests/functionaltests/test_disconnect.h1
5 files changed, 31 insertions, 2 deletions
diff --git a/Makefile.am b/Makefile.am
index 2452451c..c61315f8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -115,6 +115,7 @@ functionaltest_sources = \
 	tests/functionaltests/test_roster.c tests/functionaltests/test_roster.h \
 	tests/functionaltests/test_software.c tests/functionaltests/test_software.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
 
 main_source = src/main.c
diff --git a/src/event/client_events.c b/src/event/client_events.c
index ac4b82ed..2f227d9f 100644
--- a/src/event/client_events.c
+++ b/src/event/client_events.c
@@ -73,13 +73,13 @@ cl_ev_disconnect(void)
     const char *jid = jabber_get_fulljid();
     cons_show("%s logged out successfully.", jid);
 
+    ui_disconnected();
+    ui_close_all_wins();
     jabber_disconnect();
     roster_destroy();
     muc_invites_clear();
     chat_sessions_clear();
     tlscerts_clear_current();
-    ui_disconnected();
-    ui_close_all_wins();
 #ifdef HAVE_LIBGPGME
     p_gpg_on_disconnect();
 #endif
diff --git a/tests/functionaltests/functionaltests.c b/tests/functionaltests/functionaltests.c
index 751306c0..878561dc 100644
--- a/tests/functionaltests/functionaltests.c
+++ b/tests/functionaltests/functionaltests.c
@@ -21,6 +21,7 @@
 #include "test_roster.h"
 #include "test_software.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)
 
@@ -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_first_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);
diff --git a/tests/functionaltests/test_disconnect.c b/tests/functionaltests/test_disconnect.c
new file mode 100644
index 00000000..7529da18
--- /dev/null
+++ b/tests/functionaltests/test_disconnect.c
@@ -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."));
+}
diff --git a/tests/functionaltests/test_disconnect.h b/tests/functionaltests/test_disconnect.h
new file mode 100644
index 00000000..2024269a
--- /dev/null
+++ b/tests/functionaltests/test_disconnect.h
@@ -0,0 +1 @@
+void disconnect_ends_session(void **state);