diff options
-rw-r--r-- | functionaltests/functionaltests.c | 6 | ||||
-rw-r--r-- | functionaltests/test_presence.c | 129 | ||||
-rw-r--r-- | functionaltests/test_presence.h | 2 |
3 files changed, 94 insertions, 43 deletions
diff --git a/functionaltests/functionaltests.c b/functionaltests/functionaltests.c index 1b84a73f..e0a4415a 100644 --- a/functionaltests/functionaltests.c +++ b/functionaltests/functionaltests.c @@ -79,6 +79,12 @@ int main(int argc, char* argv[]) { unit_test_setup_teardown(presence_chat_with_message, init_prof_test, close_prof_test), + unit_test_setup_teardown(presence_set_priority, + init_prof_test, + close_prof_test), + unit_test_setup_teardown(presence_includes_priority, + init_prof_test, + close_prof_test), }; return run_tests(all_tests); diff --git a/functionaltests/test_presence.c b/functionaltests/test_presence.c index 90ebff2b..210cdaaf 100644 --- a/functionaltests/test_presence.c +++ b/functionaltests/test_presence.c @@ -19,9 +19,9 @@ presence_online(void **state) prof_input("/online"); assert_true(stbbr_received( - "<presence id=\"*\">" - "<c hash=\"sha-1\" xmlns=\"http://jabber.org/protocol/caps\" ver=\"*\" node=\"http://www.profanity.im\"/>" - "</presence>" + "<presence id=\"*\">" + "<c hash=\"sha-1\" xmlns=\"http://jabber.org/protocol/caps\" ver=\"*\" node=\"http://www.profanity.im\"/>" + "</presence>" )); assert_true(prof_output_exact("Status set to online (priority 0)")); @@ -35,10 +35,10 @@ presence_online_with_message(void **state) prof_input("/online \"Hi there\""); assert_true(stbbr_received( - "<presence id=\"*\">" - "<status>Hi there</status>" - "<c hash=\"sha-1\" xmlns=\"http://jabber.org/protocol/caps\" ver=\"*\" node=\"http://www.profanity.im\"/>" - "</presence>" + "<presence id=\"*\">" + "<status>Hi there</status>" + "<c hash=\"sha-1\" xmlns=\"http://jabber.org/protocol/caps\" ver=\"*\" node=\"http://www.profanity.im\"/>" + "</presence>" )); assert_true(prof_output_exact("Status set to online (priority 0), \"Hi there\".")); @@ -52,10 +52,10 @@ presence_away(void **state) prof_input("/away"); assert_true(stbbr_received( - "<presence id=\"*\">" - "<show>away</show>" - "<c hash=\"sha-1\" xmlns=\"http://jabber.org/protocol/caps\" ver=\"*\" node=\"http://www.profanity.im\"/>" - "</presence>" + "<presence id=\"*\">" + "<show>away</show>" + "<c hash=\"sha-1\" xmlns=\"http://jabber.org/protocol/caps\" ver=\"*\" node=\"http://www.profanity.im\"/>" + "</presence>" )); assert_true(prof_output_exact("Status set to away (priority 0)")); @@ -69,11 +69,11 @@ presence_away_with_message(void **state) prof_input("/away \"I'm not here for a bit\""); assert_true(stbbr_received( - "<presence id=\"*\">" - "<show>away</show>" - "<status>I'm not here for a bit</status>" - "<c hash=\"sha-1\" xmlns=\"http://jabber.org/protocol/caps\" ver=\"*\" node=\"http://www.profanity.im\"/>" - "</presence>" + "<presence id=\"*\">" + "<show>away</show>" + "<status>I'm not here for a bit</status>" + "<c hash=\"sha-1\" xmlns=\"http://jabber.org/protocol/caps\" ver=\"*\" node=\"http://www.profanity.im\"/>" + "</presence>" )); assert_true(prof_output_exact("Status set to away (priority 0), \"I'm not here for a bit\".")); @@ -87,10 +87,10 @@ presence_xa(void **state) prof_input("/xa"); assert_true(stbbr_received( - "<presence id=\"*\">" - "<show>xa</show>" - "<c hash=\"sha-1\" xmlns=\"http://jabber.org/protocol/caps\" ver=\"*\" node=\"http://www.profanity.im\"/>" - "</presence>" + "<presence id=\"*\">" + "<show>xa</show>" + "<c hash=\"sha-1\" xmlns=\"http://jabber.org/protocol/caps\" ver=\"*\" node=\"http://www.profanity.im\"/>" + "</presence>" )); assert_true(prof_output_exact("Status set to xa (priority 0)")); @@ -104,11 +104,11 @@ presence_xa_with_message(void **state) prof_input("/xa \"Gone to the shops\""); assert_true(stbbr_received( - "<presence id=\"*\">" - "<show>xa</show>" - "<status>Gone to the shops</status>" - "<c hash=\"sha-1\" xmlns=\"http://jabber.org/protocol/caps\" ver=\"*\" node=\"http://www.profanity.im\"/>" - "</presence>" + "<presence id=\"*\">" + "<show>xa</show>" + "<status>Gone to the shops</status>" + "<c hash=\"sha-1\" xmlns=\"http://jabber.org/protocol/caps\" ver=\"*\" node=\"http://www.profanity.im\"/>" + "</presence>" )); assert_true(prof_output_exact("Status set to xa (priority 0), \"Gone to the shops\".")); @@ -122,10 +122,10 @@ presence_dnd(void **state) prof_input("/dnd"); assert_true(stbbr_received( - "<presence id=\"*\">" - "<show>dnd</show>" - "<c hash=\"sha-1\" xmlns=\"http://jabber.org/protocol/caps\" ver=\"*\" node=\"http://www.profanity.im\"/>" - "</presence>" + "<presence id=\"*\">" + "<show>dnd</show>" + "<c hash=\"sha-1\" xmlns=\"http://jabber.org/protocol/caps\" ver=\"*\" node=\"http://www.profanity.im\"/>" + "</presence>" )); assert_true(prof_output_exact("Status set to dnd (priority 0)")); @@ -139,11 +139,11 @@ presence_dnd_with_message(void **state) prof_input("/dnd \"Working\""); assert_true(stbbr_received( - "<presence id=\"*\">" - "<show>dnd</show>" - "<status>Working</status>" - "<c hash=\"sha-1\" xmlns=\"http://jabber.org/protocol/caps\" ver=\"*\" node=\"http://www.profanity.im\"/>" - "</presence>" + "<presence id=\"*\">" + "<show>dnd</show>" + "<status>Working</status>" + "<c hash=\"sha-1\" xmlns=\"http://jabber.org/protocol/caps\" ver=\"*\" node=\"http://www.profanity.im\"/>" + "</presence>" )); assert_true(prof_output_exact("Status set to dnd (priority 0), \"Working\".")); @@ -157,10 +157,10 @@ presence_chat(void **state) prof_input("/chat"); assert_true(stbbr_received( - "<presence id=\"*\">" - "<show>chat</show>" - "<c hash=\"sha-1\" xmlns=\"http://jabber.org/protocol/caps\" ver=\"*\" node=\"http://www.profanity.im\"/>" - "</presence>" + "<presence id=\"*\">" + "<show>chat</show>" + "<c hash=\"sha-1\" xmlns=\"http://jabber.org/protocol/caps\" ver=\"*\" node=\"http://www.profanity.im\"/>" + "</presence>" )); assert_true(prof_output_exact("Status set to chat (priority 0)")); @@ -174,12 +174,55 @@ presence_chat_with_message(void **state) prof_input("/chat \"Free to talk\""); assert_true(stbbr_received( - "<presence id=\"*\">" - "<show>chat</show>" - "<status>Free to talk</status>" - "<c hash=\"sha-1\" xmlns=\"http://jabber.org/protocol/caps\" ver=\"*\" node=\"http://www.profanity.im\"/>" - "</presence>" + "<presence id=\"*\">" + "<show>chat</show>" + "<status>Free to talk</status>" + "<c hash=\"sha-1\" xmlns=\"http://jabber.org/protocol/caps\" ver=\"*\" node=\"http://www.profanity.im\"/>" + "</presence>" )); assert_true(prof_output_exact("Status set to chat (priority 0), \"Free to talk\".")); } + +void +presence_set_priority(void **state) +{ + prof_connect("stabber@localhost", "password"); + + prof_input("/priority 25"); + + assert_true(stbbr_received( + "<presence id=\"*\">" + "<priority>25</priority>" + "<c hash=\"sha-1\" xmlns=\"http://jabber.org/protocol/caps\" ver=\"*\" node=\"http://www.profanity.im\"/>" + "</presence>" + )); + + assert_true(prof_output_exact("Priority set to 25.")); +} + +void +presence_includes_priority(void **state) +{ + prof_connect("stabber@localhost", "password"); + + prof_input("/priority 25"); + assert_true(stbbr_received( + "<presence id=\"*\">" + "<priority>25</priority>" + "<c hash=\"sha-1\" xmlns=\"http://jabber.org/protocol/caps\" ver=\"*\" node=\"http://www.profanity.im\"/>" + "</presence>" + )); + assert_true(prof_output_exact("Priority set to 25.")); + + prof_input("/chat \"Free to talk\""); + assert_true(stbbr_received( + "<presence id=\"*\">" + "<priority>25</priority>" + "<show>chat</show>" + "<status>Free to talk</status>" + "<c hash=\"sha-1\" xmlns=\"http://jabber.org/protocol/caps\" ver=\"*\" node=\"http://www.profanity.im\"/>" + "</presence>" + )); + assert_true(prof_output_exact("Status set to chat (priority 25), \"Free to talk\".")); +} diff --git a/functionaltests/test_presence.h b/functionaltests/test_presence.h index 2e57c107..23fd5d98 100644 --- a/functionaltests/test_presence.h +++ b/functionaltests/test_presence.h @@ -8,3 +8,5 @@ void presence_dnd(void **state); void presence_dnd_with_message(void **state); void presence_chat(void **state); void presence_chat_with_message(void **state); +void presence_set_priority(void **state); +void presence_includes_priority(void **state); |