From 69ac809776e3845ad0921053b26612077782466d Mon Sep 17 00:00:00 2001 From: James Booth Date: Wed, 30 Dec 2015 00:32:52 +0000 Subject: Added functional tests for /console command --- tests/functionaltests/functionaltests.c | 4 +- tests/functionaltests/proftest.c | 12 +++++ tests/functionaltests/proftest.h | 3 ++ tests/functionaltests/test_muc.c | 91 ++++++++++++++++++++++++++++++++- tests/functionaltests/test_muc.h | 4 +- 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 @@ -256,6 +256,18 @@ prof_connect_with_roster(char *roster) stbbr_wait_for("prof_presence_*"); } +void +prof_timeout(int timeout) +{ + exp_timeout = timeout; +} + +void +prof_timeout_reset(void) +{ + exp_timeout = 10; +} + void prof_connect(void) { 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( + "" + "some other 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", + "" + "" + "" + "" + "" + "" + "" + ); + + 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( + "" + "a new 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( + "" + "some other 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", + "" + "" + "" + "" + "" + "" + "" + ); + + 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( + "" + "a new 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); -- cgit 1.4.1-2-gfad0