From 373f47c711bafa4c1a08690f668b4953a914ee38 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 31 May 2015 00:12:13 +0100 Subject: [PATCH] Added simple message tests --- Makefile.am | 1 + functionaltests/functionaltests.c | 8 +++++ functionaltests/test_message.c | 52 +++++++++++++++++++++++++++++++ functionaltests/test_message.h | 2 ++ 4 files changed, 63 insertions(+) create mode 100644 functionaltests/test_message.c create mode 100644 functionaltests/test_message.h 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 +#include +#include +#include +#include +#include +#include + +#include +#include + +#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( + "" + "Hi there" + "" + )); + + assert_true(prof_output_regex("me: .+Hi there")); +} + +void +message_receive(void **state) +{ + stbbr_for("roster", + "" + "" + "" + "" + "" + "" + ); + + prof_connect("stabber@localhost", "password"); + stbbr_wait_for("prof_presence_1"); + + stbbr_send( + "" + "How are you?" + "" + ); + + 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);