about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-12-30 00:32:52 +0000
committerJames Booth <boothj5@gmail.com>2015-12-30 00:32:52 +0000
commit69ac809776e3845ad0921053b26612077782466d (patch)
tree21b14017e072de094f456f8b626b6ac667df7561
parent7f98e013e1ba103f3c9b4606be369f49673a2711 (diff)
downloadprofani-tty-69ac809776e3845ad0921053b26612077782466d.tar.gz
Added functional tests for /console command
-rw-r--r--tests/functionaltests/functionaltests.c4
-rw-r--r--tests/functionaltests/proftest.c12
-rw-r--r--tests/functionaltests/proftest.h3
-rw-r--r--tests/functionaltests/test_muc.c91
-rw-r--r--tests/functionaltests/test_muc.h4
5 files changed, 111 insertions, 3 deletions
diff --git a/tests/functionaltests/functionaltests.c b/tests/functionaltests/functionaltests.c
index 3cdb60f0..751306c0 100644
--- a/tests/functionaltests/functionaltests.c
+++ b/tests/functionaltests/functionaltests.c
@@ -95,7 +95,9 @@ int main(int argc, char* argv[]) {
         PROF_FUNC_TEST(shows_history_message),
         PROF_FUNC_TEST(shows_occupant_join),
         PROF_FUNC_TEST(shows_message),
-        PROF_FUNC_TEST(shows_message_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_no_message_in_console_when_window_not_focussed),
     };
 
     return run_tests(all_tests);
diff --git a/tests/functionaltests/proftest.c b/tests/functionaltests/proftest.c
index 3b256f60..20e9da14 100644
--- a/tests/functionaltests/proftest.c
+++ b/tests/functionaltests/proftest.c
@@ -257,6 +257,18 @@ prof_connect_with_roster(char *roster)
 }
 
 void
+prof_timeout(int timeout)
+{
+    exp_timeout = timeout;
+}
+
+void
+prof_timeout_reset(void)
+{
+    exp_timeout = 10;
+}
+
+void
 prof_connect(void)
 {
     prof_connect_with_roster(
diff --git a/tests/functionaltests/proftest.h b/tests/functionaltests/proftest.h
index 547b2c11..5d06c74c 100644
--- a/tests/functionaltests/proftest.h
+++ b/tests/functionaltests/proftest.h
@@ -15,4 +15,7 @@ void prof_input(char *input);
 int prof_output_exact(char *text);
 int prof_output_regex(char *text);
 
+void prof_timeout(int timeout);
+void prof_timeout_reset(void);
+
 #endif
diff --git a/tests/functionaltests/test_muc.c b/tests/functionaltests/test_muc.c
index 57c06a33..002b052d 100644
--- a/tests/functionaltests/test_muc.c
+++ b/tests/functionaltests/test_muc.c
@@ -224,7 +224,7 @@ shows_message(void **state)
 }
 
 void
-shows_message_in_console_when_window_not_focussed(void **state)
+shows_all_messages_in_console_when_window_not_focussed(void **state)
 {
     prof_connect();
 
@@ -251,4 +251,93 @@ shows_message_in_console_when_window_not_focussed(void **state)
     );
 
     assert_true(prof_output_exact("<< room message: testoccupant in testroom@conference.localhost (win 2)"));
+
+    stbbr_send(
+        "<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/anotheroccupant'>"
+            "<body>some other message</body>"
+        "</message>"
+    );
+
+    assert_true(prof_output_exact("<< room message: anotheroccupant in testroom@conference.localhost (win 2)"));
+}
+
+void
+shows_first_message_in_console_when_window_not_focussed(void **state)
+{
+    prof_connect();
+
+    prof_input("/console muc first");
+    assert_true(prof_output_exact("Console MUC messages set: first"));
+
+    stbbr_for_id("prof_join_2",
+        "<presence id='prof_join_2' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
+            "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://www.profanity.im' ver='*'/>"
+            "<x xmlns='http://jabber.org/protocol/muc#user'>"
+                "<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
+            "</x>"
+            "<status code='110'/>"
+        "</presence>"
+    );
+
+    prof_input("/join testroom@conference.localhost");
+    assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));
+
+    prof_input("/win 1");
+    assert_true(prof_output_exact("Profanity. Type /help for help information."));
+
+    stbbr_send(
+        "<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
+            "<body>a new message</body>"
+        "</message>"
+    );
+
+    assert_true(prof_output_exact("<< room message: testroom@conference.localhost (win 2)"));
+    prof_input("/clear");
+    prof_input("/about");
+    assert_true(prof_output_exact("Type '/help' to show complete help."));
+
+    stbbr_send(
+        "<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/anotheroccupant'>"
+            "<body>some other message</body>"
+        "</message>"
+    );
+
+    prof_timeout(2);
+    assert_false(prof_output_exact("<< room message: testroom@conference.localhost (win 2)"));
+    prof_timeout_reset();
+}
+
+void
+shows_no_message_in_console_when_window_not_focussed(void **state)
+{
+    prof_connect();
+
+    prof_input("/console muc none");
+    assert_true(prof_output_exact("Console MUC messages set: none"));
+
+    stbbr_for_id("prof_join_2",
+        "<presence id='prof_join_2' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
+            "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://www.profanity.im' ver='*'/>"
+            "<x xmlns='http://jabber.org/protocol/muc#user'>"
+                "<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
+            "</x>"
+            "<status code='110'/>"
+        "</presence>"
+    );
+
+    prof_input("/join testroom@conference.localhost");
+    assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));
+
+    prof_input("/win 1");
+    assert_true(prof_output_exact("Profanity. Type /help for help information."));
+
+    stbbr_send(
+        "<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
+            "<body>a new message</body>"
+        "</message>"
+    );
+
+    prof_timeout(2);
+    assert_false(prof_output_exact("testroom@conference.localhost (win 2)"));
+    prof_timeout_reset();
 }
diff --git a/tests/functionaltests/test_muc.h b/tests/functionaltests/test_muc.h
index 5293e50c..30a6c2c8 100644
--- a/tests/functionaltests/test_muc.h
+++ b/tests/functionaltests/test_muc.h
@@ -8,4 +8,6 @@ void shows_subject_on_join(void **state);
 void shows_history_message(void **state);
 void shows_occupant_join(void **state);
 void shows_message(void **state);
-void shows_message_in_console_when_window_not_focussed(void **state);
+void shows_all_messages_in_console_when_window_not_focussed(void **state);
+void shows_first_message_in_console_when_window_not_focussed(void **state);
+void shows_no_message_in_console_when_window_not_focussed(void **state);