about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-05-29 01:10:45 +0100
committerJames Booth <boothj5@gmail.com>2015-05-29 01:10:45 +0100
commit4ec78920919398bd2964c2eae680e1374714f419 (patch)
treeab6f3663134e74616cfefeecbceeddbc2e7400f1
parenta522d0225d7de9124ebbd18188ef9758c60cc8f5 (diff)
downloadprofani-tty-4ec78920919398bd2964c2eae680e1374714f419.tar.gz
Added remaining presence tests
-rw-r--r--functionaltests/functionaltests.c24
-rw-r--r--functionaltests/test_presence.c138
-rw-r--r--functionaltests/test_presence.h8
3 files changed, 170 insertions, 0 deletions
diff --git a/functionaltests/functionaltests.c b/functionaltests/functionaltests.c
index 668445cd..1b84a73f 100644
--- a/functionaltests/functionaltests.c
+++ b/functionaltests/functionaltests.c
@@ -55,6 +55,30 @@ int main(int argc, char* argv[]) {
         unit_test_setup_teardown(presence_away_with_message,
             init_prof_test,
             close_prof_test),
+        unit_test_setup_teardown(presence_online,
+            init_prof_test,
+            close_prof_test),
+        unit_test_setup_teardown(presence_online_with_message,
+            init_prof_test,
+            close_prof_test),
+        unit_test_setup_teardown(presence_xa,
+            init_prof_test,
+            close_prof_test),
+        unit_test_setup_teardown(presence_xa_with_message,
+            init_prof_test,
+            close_prof_test),
+        unit_test_setup_teardown(presence_dnd,
+            init_prof_test,
+            close_prof_test),
+        unit_test_setup_teardown(presence_dnd_with_message,
+            init_prof_test,
+            close_prof_test),
+        unit_test_setup_teardown(presence_chat,
+            init_prof_test,
+            close_prof_test),
+        unit_test_setup_teardown(presence_chat_with_message,
+            init_prof_test,
+            close_prof_test),
     };
 
     return run_tests(all_tests);
diff --git a/functionaltests/test_presence.c b/functionaltests/test_presence.c
index 1334fe91..90ebff2b 100644
--- a/functionaltests/test_presence.c
+++ b/functionaltests/test_presence.c
@@ -12,6 +12,39 @@
 #include "proftest.h"
 
 void
+presence_online(void **state)
+{
+    prof_connect("stabber@localhost", "password");
+
+    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>"
+    ));
+
+    assert_true(prof_output_exact("Status set to online (priority 0)"));
+}
+
+void
+presence_online_with_message(void **state)
+{
+    prof_connect("stabber@localhost", "password");
+
+    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>"
+    ));
+
+    assert_true(prof_output_exact("Status set to online (priority 0), \"Hi there\"."));
+}
+
+void
 presence_away(void **state)
 {
     prof_connect("stabber@localhost", "password");
@@ -45,3 +78,108 @@ presence_away_with_message(void **state)
 
     assert_true(prof_output_exact("Status set to away (priority 0), \"I'm not here for a bit\"."));
 }
+
+void
+presence_xa(void **state)
+{
+    prof_connect("stabber@localhost", "password");
+
+    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>"
+    ));
+
+    assert_true(prof_output_exact("Status set to xa (priority 0)"));
+}
+
+void
+presence_xa_with_message(void **state)
+{
+    prof_connect("stabber@localhost", "password");
+
+    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>"
+    ));
+
+    assert_true(prof_output_exact("Status set to xa (priority 0), \"Gone to the shops\"."));
+}
+
+void
+presence_dnd(void **state)
+{
+    prof_connect("stabber@localhost", "password");
+
+    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>"
+    ));
+
+    assert_true(prof_output_exact("Status set to dnd (priority 0)"));
+}
+
+void
+presence_dnd_with_message(void **state)
+{
+    prof_connect("stabber@localhost", "password");
+
+    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>"
+    ));
+
+    assert_true(prof_output_exact("Status set to dnd (priority 0), \"Working\"."));
+}
+
+void
+presence_chat(void **state)
+{
+    prof_connect("stabber@localhost", "password");
+
+    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>"
+    ));
+
+    assert_true(prof_output_exact("Status set to chat (priority 0)"));
+}
+
+void
+presence_chat_with_message(void **state)
+{
+    prof_connect("stabber@localhost", "password");
+
+    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>"
+    ));
+
+    assert_true(prof_output_exact("Status set to chat (priority 0), \"Free to talk\"."));
+}
diff --git a/functionaltests/test_presence.h b/functionaltests/test_presence.h
index f199ab41..2e57c107 100644
--- a/functionaltests/test_presence.h
+++ b/functionaltests/test_presence.h
@@ -1,2 +1,10 @@
 void presence_away(void **state);
 void presence_away_with_message(void **state);
+void presence_online(void **state);
+void presence_online_with_message(void **state);
+void presence_xa(void **state);
+void presence_xa_with_message(void **state);
+void presence_dnd(void **state);
+void presence_dnd_with_message(void **state);
+void presence_chat(void **state);
+void presence_chat_with_message(void **state);