about summary refs log tree commit diff stats
path: root/tests/functionaltests
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-08-04 23:43:19 +0100
committerJames Booth <boothj5@gmail.com>2015-08-04 23:43:19 +0100
commitde747e3d46c1be9e3256716d8939148e0bc07a35 (patch)
tree85f213d0f00c2db06defa7257756a01d4e78a603 /tests/functionaltests
parent2cb2f83ce3519a40f752ca2be7a07669a125ed1b (diff)
downloadprofani-tty-de747e3d46c1be9e3256716d8939148e0bc07a35.tar.gz
Added software version request tests
Diffstat (limited to 'tests/functionaltests')
-rw-r--r--tests/functionaltests/functionaltests.c4
-rw-r--r--tests/functionaltests/test_software.c59
-rw-r--r--tests/functionaltests/test_software.h3
3 files changed, 66 insertions, 0 deletions
diff --git a/tests/functionaltests/functionaltests.c b/tests/functionaltests/functionaltests.c
index 4b2b76ee..a253fe63 100644
--- a/tests/functionaltests/functionaltests.c
+++ b/tests/functionaltests/functionaltests.c
@@ -19,6 +19,7 @@
 #include "test_chat_session.h"
 #include "test_receipts.h"
 #include "test_roster.h"
+#include "test_software.h"
 
 #define PROF_FUNC_TEST(test) unit_test_setup_teardown(test, init_prof_test, close_prof_test)
 
@@ -75,6 +76,9 @@ int main(int argc, char* argv[]) {
         PROF_FUNC_TEST(sends_new_item_nick),
         PROF_FUNC_TEST(sends_remove_item),
         PROF_FUNC_TEST(sends_nick_change),
+
+        PROF_FUNC_TEST(send_software_version_request),
+        PROF_FUNC_TEST(display_software_version_result),
     };
 
     return run_tests(all_tests);
diff --git a/tests/functionaltests/test_software.c b/tests/functionaltests/test_software.c
new file mode 100644
index 00000000..aeb3f8f5
--- /dev/null
+++ b/tests/functionaltests/test_software.c
@@ -0,0 +1,59 @@
+#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
+send_software_version_request(void **state)
+{
+    prof_connect();
+    stbbr_send(
+        "<presence to=\"stabber@localhost\" from=\"buddy1@localhost/mobile\">"
+            "<priority>10</priority>"
+            "<status>I'm here</status>"
+        "</presence>"
+    );
+    prof_output_exact("Buddy1 (mobile) is online, \"I'm here\"");
+    prof_input("/software buddy1@localhost/mobile");
+
+    stbbr_received(
+        "<iq id=\"*\" to=\"buddy1@localhost/mobile\" type=\"get\">"
+            "<query xmlns=\"jabber:iq:version\"/>"
+        "</iq>"
+    );
+}
+
+void
+display_software_version_result(void **state)
+{
+    prof_connect();
+    stbbr_send(
+        "<presence to=\"stabber@localhost\" from=\"buddy1@localhost/mobile\">"
+            "<priority>10</priority>"
+            "<status>I'm here</status>"
+        "</presence>"
+    );
+    prof_output_exact("Buddy1 (mobile) is online, \"I'm here\"");
+
+    stbbr_for_query("jabber:iq:version",
+        "<iq id=\"*\" type=\"result\" lang=\"en\" to=\"stabber@localhost/profanity\" from=\"buddy1@localhost/mobile\">"
+            "<query xmlns=\"jabber:iq:version\">"
+                "<name>Profanity</name>"
+                "<version>0.4.7dev.master.2cb2f83</version>"
+            "</query>"
+        "</iq>"
+    );
+    prof_input("/software buddy1@localhost/mobile");
+
+    prof_output_exact("buddy1@localhost/mobile:");
+    prof_output_exact("Name    : Profanity");
+    prof_output_exact("Version : 0.4.7dev.master.2cb2f83");
+}
diff --git a/tests/functionaltests/test_software.h b/tests/functionaltests/test_software.h
new file mode 100644
index 00000000..b031e264
--- /dev/null
+++ b/tests/functionaltests/test_software.h
@@ -0,0 +1,3 @@
+void send_software_version_request(void **state);
+void display_software_version_result(void **state);
+