diff options
author | James Booth <boothj5@gmail.com> | 2015-05-31 00:12:13 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2015-05-31 00:12:13 +0100 |
commit | 373f47c711bafa4c1a08690f668b4953a914ee38 (patch) | |
tree | 7cf5488d7c01fec75608603e3afec11522a30d6d /functionaltests | |
parent | a5cf83d2595c41fda72f67284b101f509524e659 (diff) | |
download | profani-tty-373f47c711bafa4c1a08690f668b4953a914ee38.tar.gz |
Added simple message tests
Diffstat (limited to 'functionaltests')
-rw-r--r-- | functionaltests/functionaltests.c | 8 | ||||
-rw-r--r-- | functionaltests/test_message.c | 52 | ||||
-rw-r--r-- | functionaltests/test_message.h | 2 |
3 files changed, 62 insertions, 0 deletions
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); |