1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Added simple message tests

This commit is contained in:
James Booth 2015-05-31 00:12:13 +01:00
parent a5cf83d259
commit 373f47c711
4 changed files with 63 additions and 0 deletions

View File

@ -100,6 +100,7 @@ functionaltest_sources = \
functionaltests/test_ping.c functionaltests/test_ping.h \ functionaltests/test_ping.c functionaltests/test_ping.h \
functionaltests/test_rooms.c functionaltests/test_rooms.h \ functionaltests/test_rooms.c functionaltests/test_rooms.h \
functionaltests/test_presence.c functionaltests/test_presence.h \ functionaltests/test_presence.c functionaltests/test_presence.h \
functionaltests/test_message.c functionaltests/test_message.h \
functionaltests/functionaltests.c functionaltests/functionaltests.c
main_source = src/main.c main_source = src/main.c

View File

@ -14,6 +14,7 @@
#include "test_ping.h" #include "test_ping.h"
#include "test_rooms.h" #include "test_rooms.h"
#include "test_presence.h" #include "test_presence.h"
#include "test_message.h"
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
@ -88,6 +89,13 @@ int main(int argc, char* argv[]) {
unit_test_setup_teardown(presence_received, unit_test_setup_teardown(presence_received,
init_prof_test, init_prof_test,
close_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); return run_tests(all_tests);

View File

@ -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)"));
}

View File

@ -0,0 +1,2 @@
void message_send(void **state);
void message_receive(void **state);