diff options
-rw-r--r-- | Makefile.am | 1 | ||||
-rw-r--r-- | functionaltests/functionaltests.c | 8 | ||||
-rw-r--r-- | functionaltests/test_message.c | 52 | ||||
-rw-r--r-- | functionaltests/test_message.h | 2 |
4 files changed, 63 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am index a2b46a9c..5656ce24 100644 --- a/Makefile.am +++ b/Makefile.am @@ -100,6 +100,7 @@ functionaltest_sources = \ functionaltests/test_ping.c functionaltests/test_ping.h \ functionaltests/test_rooms.c functionaltests/test_rooms.h \ functionaltests/test_presence.c functionaltests/test_presence.h \ + functionaltests/test_message.c functionaltests/test_message.h \ functionaltests/functionaltests.c main_source = src/main.c diff --git a/functionaltests/functionaltests.c b/functionaltests/functionaltests.c index 27fa91c9..fa162a26 100644 --- a/functionaltests/functionaltests.c +++ b/functionaltests/functionaltests.c @@ -14,6 +14,7 @@ #include "test_ping.h" #include "test_rooms.h" #include "test_presence.h" +#include "test_message.h" int main(int argc, char* argv[]) { @@ -88,6 +89,13 @@ int main(int argc, char* argv[]) { unit_test_setup_teardown(presence_received, init_prof_test, close_prof_test), + + unit_test_setup_teardown(message_send, + init_prof_test, + close_prof_test), + unit_test_setup_teardown(message_receive, + init_prof_test, + close_prof_test), }; return run_tests(all_tests); diff --git a/functionaltests/test_message.c b/functionaltests/test_message.c new file mode 100644 index 00000000..98864233 --- /dev/null +++ b/functionaltests/test_message.c @@ -0,0 +1,52 @@ +#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 +message_send(void **state) +{ + prof_connect("stabber@localhost", "password"); + + prof_input("/msg somejid@someserver.com Hi there"); + + assert_true(stbbr_received( + "<message id=\"*\" to=\"somejid@someserver.com\" type=\"chat\">" + "<body>Hi there</body>" + "</message>" + )); + + assert_true(prof_output_regex("me: .+Hi there")); +} + +void +message_receive(void **state) +{ + stbbr_for("roster", + "<iq id=\"roster\" type=\"result\" to=\"stabber@localhost/profanity\">" + "<query xmlns=\"jabber:iq:roster\" ver=\"362\">" + "<item jid=\"buddy1@localhost\" subscription=\"both\" name=\"Buddy1\"/>" + "<item jid=\"buddy2@localhost\" subscription=\"both\" name=\"Buddy2\"/>" + "</query>" + "</iq>" + ); + + prof_connect("stabber@localhost", "password"); + stbbr_wait_for("prof_presence_1"); + + stbbr_send( + "<message id=\"*\" to=\"stabber@localhost\" from=\"someuser@chatserv.org/laptop\" type=\"chat\">" + "<body>How are you?</body>" + "</message>" + ); + + assert_true(prof_output_exact("<< incoming from someuser@chatserv.org/laptop (2)")); +} diff --git a/functionaltests/test_message.h b/functionaltests/test_message.h new file mode 100644 index 00000000..b8f03a7e --- /dev/null +++ b/functionaltests/test_message.h @@ -0,0 +1,2 @@ +void message_send(void **state); +void message_receive(void **state); |